Package org.gjt.xpp

Examples of org.gjt.xpp.XmlPullParser


  protected Document parseDocument() throws DocumentException, IOException,
      XmlPullParserException {
    Document document = getDocumentFactory().createDocument();
    Element parent = null;
    XmlPullParser parser = getXPPParser();
    parser.setNamespaceAware(true);

    ProxyXmlStartTag startTag = new ProxyXmlStartTag();
    XmlEndTag endTag = xppFactory.newEndTag();

    while (true) {
      int type = parser.next();

      switch (type) {
        case XmlPullParser.END_DOCUMENT:
          return document;

        case XmlPullParser.START_TAG: {
          parser.readStartTag(startTag);

          Element newElement = startTag.getElement();

          if (parent != null) {
            parent.add(newElement);
          } else {
            document.add(newElement);
          }

          parent = newElement;

          break;
        }

        case XmlPullParser.END_TAG: {
          parser.readEndTag(endTag);

          if (parent != null) {
            parent = parent.getParent();
          }

          break;
        }

        case XmlPullParser.CONTENT: {
          String text = parser.readContent();

          if (parent != null) {
            parent.addText(text);
          } else {
            String msg = "Cannot have text content outside of the "
View Full Code Here


    // -------------------------------------------------------------------------
    protected Document parseDocument() throws DocumentException, IOException,
            XmlPullParserException {
        Document document = getDocumentFactory().createDocument();
        Element parent = null;
        XmlPullParser parser = getXPPParser();
        parser.setNamespaceAware(true);

        ProxyXmlStartTag startTag = new ProxyXmlStartTag();
        XmlEndTag endTag = xppFactory.newEndTag();

        while (true) {
            int type = parser.next();

            switch (type) {
                case XmlPullParser.END_DOCUMENT:
                    return document;

                case XmlPullParser.START_TAG: {
                    parser.readStartTag(startTag);

                    Element newElement = startTag.getElement();

                    if (parent != null) {
                        parent.add(newElement);
                    } else {
                        document.add(newElement);
                    }

                    parent = newElement;

                    break;
                }

                case XmlPullParser.END_TAG: {
                    parser.readEndTag(endTag);

                    if (parent != null) {
                        parent = parent.getParent();
                    }

                    break;
                }

                case XmlPullParser.CONTENT: {
                    String text = parser.readContent();

                    if (parent != null) {
                        parent.addText(text);
                    } else {
                        String msg = "Cannot have text content outside of the "
View Full Code Here

    throws gov.cca.CCAException {
    logger.finest("called");

    try {
      XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
      XmlPullParser pp = factory.newPullParser();
      pp.setInput(new StringReader(xmlState));
      pp.next();
      XmlPullNode stateTree = factory.newPullNode(pp);

      while(true) {
  // get the next child and check if we are done
  XmlPullNode nextChild = (XmlPullNode) stateTree.readNextChild();
View Full Code Here

    throws gov.cca.CCAException {
    logger.finest("called");

    try {
      XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
      XmlPullParser pp = factory.newPullParser();
      pp.setInput(new StringReader(sInfo));
      pp.next();
      XmlPullNode stateTree = factory.newPullNode(pp);

      while(true) {
  // get the next child and check if we are done
  XmlPullNode nextChild = (XmlPullNode) stateTree.readNextChild();
View Full Code Here

  public static void fromXML(String properties, TypeMap tMap)
    throws gov.cca.CCAException {
    try {
      // convert the properties object to an XmlPullNode
      XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
      XmlPullParser pp = factory.newPullParser();
      pp.setInput(new StringReader(properties));
      pp.next();
      XmlPullNode propertiesNode = factory.newPullNode(pp);
      while (true) {
  // read the next <propertiesEntry/>
  XmlPullNode entryNode = (XmlPullNode) propertiesNode.readNextChild();
  if (entryNode == null)
View Full Code Here

/*     */   protected Document parseDocument()
/*     */     throws DocumentException, IOException, XmlPullParserException
/*     */   {
/* 360 */     Document document = getDocumentFactory().createDocument();
/* 361 */     Element parent = null;
/* 362 */     XmlPullParser parser = getXPPParser();
/* 363 */     parser.setNamespaceAware(true);
/*     */
/* 365 */     ProxyXmlStartTag startTag = new ProxyXmlStartTag();
/* 366 */     XmlEndTag endTag = this.xppFactory.newEndTag();
/*     */     while (true)
/*     */     {
/* 369 */       int type = parser.next();
/*     */
/* 371 */       switch (type) {
/*     */       case 1:
/* 373 */         return document;
/*     */       case 2:
/* 376 */         parser.readStartTag(startTag);
/*     */
/* 378 */         Element newElement = startTag.getElement();
/*     */
/* 380 */         if (parent != null)
/* 381 */           parent.add(newElement);
/*     */         else {
/* 383 */           document.add(newElement);
/*     */         }
/*     */
/* 386 */         parent = newElement;
/*     */
/* 388 */         break;
/*     */       case 3:
/* 392 */         parser.readEndTag(endTag);
/*     */
/* 394 */         if (parent == null) break;
/* 395 */         parent = parent.getParent(); break;
/*     */       case 4:
/* 402 */         String text = parser.readContent();
/*     */
/* 404 */         if (parent != null) {
/* 405 */           parent.addText(text);
/*     */         } else {
/* 407 */           String msg = "Cannot have text content outside of the root document";
View Full Code Here

TOP

Related Classes of org.gjt.xpp.XmlPullParser

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.