Esempio n. 1
0
 private void addSetRootMethod() {
   Method m = SourceFactory.newMethod("setRoot", TypeFactory.newVoidType(pack));
   m.setAccessLevel(AccessLevel.PUBLIC);
   Type t =
       TypeFactory.newReferenceType(
           pack, "de.realityinabox.databinding.libs.XMLElement", "XMLElement");
   m.addArgument(SourceFactory.newVariable("root", t));
   m.addSourceLine("this._root = root;");
   addMethod(m);
 }
Esempio n. 2
0
 public void addKeyLookup(KeyType keyType, ReferenceType valueType) {
   String mapName = Tools.toJavaName(keyType.getKeyName(), true);
   GenericType mapType = TypeFactory.newGenericType(pack, "java.util.Map", "Map");
   mapType.addTypeArgument(
       TypeFactory.newTypeArgument(TypeFactory.newReferenceType(pack, keyType.getJavaName(), "")));
   mapType.addTypeArgument(TypeFactory.newTypeArgument(valueType));
   Field mapField = SourceFactory.newField("map" + mapName + "Keys", mapType);
   mapField.setDefaultExpression(
       "new java.util.HashMap<" + keyType.getJavaName() + "," + valueType.getJavaName() + ">()");
   addField(mapField);
 }
Esempio n. 3
0
 private void addStartElementMethod() {
   Method m = SourceFactory.newMethod("startElement", TypeFactory.newVoidType(pack));
   m.setAccessLevel(AccessLevel.PUBLIC);
   Type t = TypeFactory.newReferenceType(pack, "java.lang.String", "String");
   m.addArgument(SourceFactory.newVariable("namespaceURI", t));
   m.addArgument(SourceFactory.newVariable("localName", t));
   m.addArgument(SourceFactory.newVariable("qName", t));
   t = TypeFactory.newReferenceType(pack, "org.xml.sax.Attributes", "Attributes");
   m.addArgument(SourceFactory.newVariable("atts", t));
   m.addException(
       TypeFactory.newReferenceType(pack, "org.xml.sax.SAXException", "SAXException"));
   m.addSourceLine("super.startElement(namespaceURI, localName, qName, atts);");
   m.addSourceLine("if (_root != null) return;");
   // ...
   MyHandlerClass.defaultStartElementCode(m, "_root");
   m.addSourceLine("_parseStack.push(_root);");
   addMethod(m);
 }
Esempio n. 4
0
 ContentInterceptorClass() {
   super(pack, null, "ContentInterceptor");
   setSuperClass(
       TypeFactory.newReferenceType(
           pack, "de.realityinabox.databinding.libs.DelegateHandler", "DelegateHandler"));
   setAccessLevel(AccessLevel.PRIVATE);
   addStartDocumentMethod();
   addStartElementMethod();
 }
Esempio n. 5
0
 private void addGetRootMethod() {
   Method m =
       SourceFactory.newMethod(
           "getRoot",
           TypeFactory.newReferenceType(
               pack, "de.realityinabox.databinding.libs.XMLElement", "XMLElement"));
   m.setAccessLevel(AccessLevel.PUBLIC);
   m.addSourceLine("return _root;");
   addMethod(m);
 }
Esempio n. 6
0
 private void addGetParseStackMethod() {
   Method m =
       SourceFactory.newMethod(
           "getParseStack",
           TypeFactory.newReferenceType(
               pack, "de.realityinabox.databinding.libs.ParseStack", "ParseStack"));
   m.setAccessLevel(AccessLevel.PUBLIC);
   m.addSourceLine("return _parseStack;");
   addMethod(m);
 }
Esempio n. 7
0
 public DocumentClass(XMLPackage pack) {
   super(pack, null, "XMLDocument");
   this.pack = pack;
   addSuperInterface(
       TypeFactory.newReferenceType(
           pack, "de.realityinabox.databinding.libs.Document", "Document"));
   addField(
       SourceFactory.newField(
           "_root",
           TypeFactory.newReferenceType(
               pack, "de.realityinabox.databinding.libs.XMLElement", "XMLElement")));
   addField(
       SourceFactory.newField(
           "_parseStack",
           TypeFactory.newReferenceType(
               pack, "de.realityinabox.databinding.libs.ParseStack", "ParseStack")));
   addConstructor();
   addGetParseStackMethod();
   addGetElementFactoryMethod();
   addGetRootMethod();
   addSetRootMethod();
   addNestedClass(new ContentInterceptorClass());
 }
Esempio n. 8
0
 private void addStartDocumentMethod() {
   Method m = SourceFactory.newMethod("startDocument", TypeFactory.newVoidType(pack));
   m.setAccessLevel(AccessLevel.PUBLIC);
   m.addSourceLine("_root = null;");
   addMethod(m);
 }