Package juzu

Examples of juzu.Response$Content


      Format format, CDATA cdata) {
    final List<CDATA> list = Collections.singletonList(cdata);
    final FormatStack fstack = new FormatStack(format);
    final Walker walker = buildWalker(fstack, list, false);
    if (walker.hasNext()) {
      final Content c = walker.next();
      if (c == null) {
        return printCDATA(fstack, basedoc, new CDATA(walker.text()));
      }
      if (c.getCType() == CType.CDATA) {
        return printCDATA(fstack, basedoc, (CDATA)c);
      }
    }
    // return an empty string if nothing happened.
    return null;
View Full Code Here


      Format format, Text text) {
    final List<Text> list = Collections.singletonList(text);
    final FormatStack fstack = new FormatStack(format);
    final Walker walker = buildWalker(fstack, list, false);
    if (walker.hasNext()) {
      final Content c = walker.next();
      if (c == null) {
        return printText(fstack, basedoc, new Text(walker.text()));
      }
      if (c.getCType() == CType.Text) {
        return printText(fstack, basedoc, (Text)c);
      }
    }
    // return an empty string if nothing happened.
    return null;
View Full Code Here

    final int sz = doc.getContentSize();
   
    if (sz > 0) {
      for (int i = 0; i < sz; i++) {
        final Content c = doc.getContent(i);
        org.w3c.dom.Node n = null;
        switch (c.getCType()) {
          case Comment :
            n = printComment(fstack, basedoc, (Comment)c);
            break;
          case DocType :
            // cannot simply add a DocType to a DOM object
View Full Code Here

  protected void printContent(final FormatStack fstack,
      final NamespaceStack nstack, final org.w3c.dom.Document basedoc,
      final org.w3c.dom.Node target, final Walker walker) {

    while (walker.hasNext()) {
      final Content c = walker.next();
      org.w3c.dom.Node n = null;
      if (c == null) {
        // Formatted Text or CDATA
        final String text = walker.text();
        if (walker.isCDATA()) {
View Full Code Here

      final CDATA cdata) throws XMLStreamException {
    final List<CDATA> list = Collections.singletonList(cdata);
    final FormatStack fstack = new FormatStack(format);
    final Walker walker = buildWalker(fstack, list, false);
    if (walker.hasNext()) {
      final Content c = walker.next();
      if (c == null) {
        printCDATA(out, fstack, new CDATA(walker.text()));
      } else if (c.getCType() == CType.CDATA) {
        printCDATA(out, fstack, (CDATA)c);
      }
    }
    out.flush();
  }
View Full Code Here

      final Text text) throws XMLStreamException {
    final List<Text> list = Collections.singletonList(text);
    final FormatStack fstack = new FormatStack(format);
    final Walker walker = buildWalker(fstack, list, false);
    if (walker.hasNext()) {
      final Content c = walker.next();
      if (c == null) {
        printText(out, fstack, new Text(walker.text()));
      } else if (c.getCType() == CType.Text) {
        printText(out, fstack, (Text)c);
      }
    }
    out.flush();
  }
View Full Code Here

    }
    Walker walker = buildWalker(fstack, list, false);
    if (walker.hasNext()) {
      while (walker.hasNext()) {
       
        final Content c = walker.next();
        // we do not ignore Text-like things in the Document.
        // the walker creates the indenting for us.
        if (c == null) {
          // but, what we do is ensure it is all whitespace, and not CDATA
          final String padding = walker.text();
          if (padding != null && Verifier.isAllXMLWhitespace(padding) &&
              !walker.isCDATA()) {
            // we do not use the escaping or text* method because this
            // content is outside of the root element, and thus is not
            // strict text.
            out.writeCharacters(padding);
          }
        } else {
          switch (c.getCType()) {
            case Comment :
              printComment(out, fstack, (Comment)c);
              break;
            case DocType :
              printDocType(out, fstack, (DocType)c);
View Full Code Here

  protected void printContent(final XMLStreamWriter out,
      final FormatStack fstack, final NamespaceStack nstack,
      final Walker walker) throws XMLStreamException {

    while (walker.hasNext()) {
      final Content content = walker.next();
     
      if (content == null) {
        if (walker.isCDATA()) {
          printCDATA(out, fstack, new CDATA(walker.text()));
        } else {
          printText(out, fstack, new Text(walker.text()));
        }
      } else {
        switch (content.getCType()) {
          case CDATA:
            printCDATA(out, fstack, (CDATA) content);
            break;
          case Comment:
            printComment(out, fstack, (Comment) content);
            break;
          case Element:
            printElement(out, fstack, nstack, (Element) content);
            break;
          case EntityRef:
            printEntityRef(out, fstack, (EntityRef) content);
            break;
          case ProcessingInstruction:
            printProcessingInstruction(out, fstack,
                (ProcessingInstruction) content);
            break;
          case Text:
            printText(out, fstack, (Text) content);
            break;
          case DocType:
            printDocType(out, fstack, (DocType) content);
            break;
          default:
            throw new IllegalStateException(
                "Unexpected Content " + content.getCType());
   
        }
      }
    }
View Full Code Here

      assertNotNull(ap);
      assertNotNull(bp);
      assertEquals(ap.getClass(), bp.getClass());
      assertTrue(ap != bp);
      if (ap instanceof Content) {
        final Content a = (Content)ap;
        final Content b = (Content)bp;
        if (a.getParent() != null) {
          assertTrue(a.getParent() != b.getParent());
        }
       
        switch (a.getCType()) {
          case Text:
            assertEquals(a.getValue(), b.getValue());
            break;
          case CDATA:
            assertEquals(a.getValue(), b.getValue());
            break;
          case Comment:
            assertEquals(((Comment)a).getText(), ((Comment)b).getText());
            break;
          case DocType:
            DocType da = (DocType)a;
            DocType db = (DocType)b;
            assertEquals(da.getElementName(), db.getElementName());
            assertEquals(da.getPublicID(), db.getPublicID());
            assertEquals(da.getSystemID(), db.getSystemID());
            assertEquals(da.getInternalSubset(), db.getInternalSubset());
            break;
          case Element:
            Element ea = (Element)a;
            Element eb = (Element)b;
            assertEquals(ea.getName(), eb.getName());
            compare(ea.getAttributes(), eb.getAttributes());
            assertEquals(ea.getNamespacesInScope(), eb.getNamespacesInScope());
              final int sz = ea.getContentSize();
              assertTrue(sz == eb.getContentSize());
              for (int i = 0; i < sz; i++) {
                compare(ea.getContent(i), eb.getContent(i));
              }
            break;
          case EntityRef:
            assertEquals(((EntityRef)a).getName(), ((EntityRef)b).getName());
            break;
          case ProcessingInstruction:
            ProcessingInstruction pa = (ProcessingInstruction)a;
            ProcessingInstruction pb = (ProcessingInstruction)b;
            assertEquals(pa.getTarget(), pb.getTarget());
            assertEquals(pa.getData(), pb.getData());
            break;
        }
      } else if (ap instanceof Attribute) {
        compare ((Attribute)ap, (Attribute)bp);
      } else if (ap instanceof Document) {
        Document a = (Document)ap;
        Document b = (Document)bp;
        assertEquals(a.getBaseURI(), b.getBaseURI());
        final int sz = a.getContentSize();
        assertTrue(sz == b.getContentSize());
        for (int i = 0; i < sz; i++) {
          compare(a.getContent(i), b.getContent(i));
        }
      }
    }
View Full Code Here

          Element emt = processElementFragment(factory, stream);
          stream.next();
          return emt;

        case DTD:
          Content dt = DTDParser.parse(stream.getText(), factory);
          stream.next();
          return dt;

        case CDATA:
          Content cd = factory.cdata(stream.getText());
          stream.next();
          return cd;

        case SPACE:
        case CHARACTERS:
          Content txt = factory.text(stream.getText());
          stream.next();
          return txt;

        case COMMENT:
          Content comment = factory.comment(stream.getText());
          stream.next();
          return comment;

        case ENTITY_REFERENCE:
          Content er = factory.entityRef(stream.getLocalName());
          stream.next();
          return er;

        case PROCESSING_INSTRUCTION:
          Content pi = factory.processingInstruction(
              stream.getPITarget(), stream.getPIData());
          stream.next();
          return pi;

        default:
View Full Code Here

TOP

Related Classes of juzu.Response$Content

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.