format = new Object[]{"((", JMUnmarshallerImpl.class, ") ", pData,
".getJMUnmarshaller()).get" + getDatatypeName(), "Format()"};
mayBeDate = true;
}
if (!(pValue instanceof DirectAccessible)) {
LocalJavaField v = pMethod.newJavaField(String.class);
v.addLine(pValue);
pValue = v;
}
LocalJavaField pos = pMethod.newJavaField(ParsePosition.class);
pos.addLine("new ", ParsePosition.class, "(0)");
LocalJavaField cal = pMethod.newJavaField(mayBeDate ? OBJECT_TYPE : pController.getRuntimeType());
cal.addLine(format, ".parseObject(", pValue, ", ", pos, ");");
pMethod.addIf(cal, " == null");
pMethod.addThrowNew(IllegalArgumentException.class,
JavaSource.getQuoted("Failed to parse dateTime "),
" + ", pValue, " + ", JavaSource.getQuoted(" at: "),
" + ", pValue, ".substring(", pos, ".getErrorIndex())");
pMethod.addEndIf();
if (mayBeDate) {
LocalJavaField result = pMethod.newJavaField(pController.getRuntimeType());
pMethod.addIf(cal, " instanceof ", Calendar.class);
pMethod.addLine(result, " = (", Calendar.class, ") ", cal, ";");
pMethod.addElse();
pMethod.addLine(result, " = ", Calendar.class, ".getInstance();");
pMethod.addLine(result, ".setTime((", Date.class, ") ", cal, ");");