protected JavaSource getObjectFactory(SchemaSG pController, String pPackageName,
List pContextList)
throws SAXException {
JavaQName qName = JavaQNameImpl.getInstance(pPackageName, "ObjectFactory");
JavaSource js = pController.getJavaSourceFactory().newJavaSource(qName, "public");
JavaField jf = js.newJavaField("jaxbContext", JAXBContextImpl.class, "private");
JavaField properties = js.newJavaField("properties", Map.class, "private");
JavaConstructor jcon = js.newJavaConstructor("public");
jcon.addThrows(JAXBException.class);
jcon.addLine(jf, " = (", JAXBContextImpl.class, ") ",
JAXBContext.class, ".newInstance(",
JavaSource.getQuoted(pPackageName), ");");
JavaMethod newInstanceMethod = js.newJavaMethod("newInstance", Object.class, "public");
newInstanceMethod.addThrows(JAXBException.class);
Parameter pElementInterface = newInstanceMethod.addParam(Class.class, "pElementInterface");
newInstanceMethod.addLine("return ", jf, ".getManager(", pElementInterface, ").getElementJ();");
{
JavaMethod getPropertyMethod = js.newJavaMethod("getProperty", Object.class, "public");
Parameter pName = getPropertyMethod.addParam(String.class, "pName");
getPropertyMethod.addIf(properties, " == null");
getPropertyMethod.addLine("return null;");
getPropertyMethod.addEndIf();
getPropertyMethod.addLine("return ", properties, ".get(", pName, ");");
}
{
JavaMethod setPropertyMethod = js.newJavaMethod("setProperty", void.class, "public");
Parameter pName = setPropertyMethod.addParam(String.class, "pName");
Parameter pValue = setPropertyMethod.addParam(Object.class, "pValue");
setPropertyMethod.addIf(properties, " == null");
setPropertyMethod.addLine(properties, " = new ", HashMap.class, "();");
setPropertyMethod.addEndIf();