Ejemplo n.º 1
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);
 }
Ejemplo n.º 2
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);
 }