Package nux.xom.binary

Examples of nux.xom.binary.NodeBuilder


   * @return a shallow XOM Node corresponding to the current StAX event.
   * @throws ParsingException
   *             if there is an error processing the underlying XML source
   */
  public Node buildNode() throws ParsingException {
    if (nodeBuilder == null) nodeBuilder = new NodeBuilder();
   
    switch (reader.getEventType()) {
      case XMLStreamConstants.START_ELEMENT: {
        Element elem = readStartTag();
        addAttributes(elem);
View Full Code Here


        case XMLStreamConstants.START_ELEMENT: {
          if (hasRootElement) throw new IllegalAddException(
            "StAX reader must not return multiple root elements");

          if (factory.getClass() == NodeFactory.class) { // fast path
            if (nodeBuilder == null) nodeBuilder = new NodeBuilder();
            Element root = readStartTag();
            addAttributes(root);
            addNamespaceDeclarations(root);
            readElement(root); // reads entire subtree
            nodes = new Nodes(root);
View Full Code Here

     */
    return new NodeFactory() {
     
      private Element buffer = null;
      private final Nodes NONE = new Nodes();
      private final NodeBuilder nodeBuilder = new NodeBuilder();
           
      public Nodes makeAttribute(String name, String namespace,
          String value, Attribute.Type type) {
       
        buffer.addAttribute(
          nodeBuilder.createAttribute(name, namespace, value, type));
//        buffer.addAttribute(
//          new Attribute(name, namespace, value, type));
        return NONE;
      }
 
      public Nodes makeComment(String data) {
        flush();
        try {
          serializer.write(new Comment(data));
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
        return NONE;
      }
 
      public Nodes makeDocType(String rootElementName, String publicID, String systemID) {
        flush();
        try {
          serializer.write(new DocType(rootElementName, publicID, systemID));
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
        return NONE;
      }
 
      public Nodes makeProcessingInstruction(String target, String data) {
        flush();
        try {
          serializer.write(new ProcessingInstruction(target, data));
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
        return NONE;
      }
     
      public Nodes makeText(String text) {
        flush();
        try {
          serializer.write(new Text(text));
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
        return NONE;
      }
     
      public Element startMakingElement(String name, String namespace) {
        flush();
//        buffer = new Element(name, namespace);
        buffer = nodeBuilder.createElement(name, namespace);
        return buffer;
      }
     
      public Nodes finishMakingElement(Element element) {
        flush();
View Full Code Here

TOP

Related Classes of nux.xom.binary.NodeBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.