Examples of XmlStringBuilder


Examples of org.waveprotocol.wave.model.document.util.XmlStringBuilder

   * Tests the construct XML function which is used to insert gadgets into wave
   * XML representation.
   */
  public void testConstructXml() {
    String xmlSource = "http://test.com/gadget.xml";
    XmlStringBuilder builder = GadgetXmlUtil.constructXml(xmlSource, "", LOGIN_NAME);
    String xml = builder.toString();
    String expectedValue = "<" + TAGNAME +
        " " + URL_ATTRIBUTE + "=\"" + xmlSource + "\"" +
        " " + TITLE_ATTRIBUTE + "=\"\"" +
        " " + PREFS_ATTRIBUTE + "=\"\"" +
        " " + STATE_ATTRIBUTE + "=\"\"" +
        " " + AUTHOR_ATTRIBUTE + "=\"johnny_addgadget@rentacoder.com\">" +
        "</" + TAGNAME + ">";
    assertEquals(expectedValue, xml);
    String[] categories = {"chess", "game"};
    builder = GadgetXmlUtil.constructXml(xmlSource, "my pref", categories, LOGIN_NAME);
    xml = builder.toString();
    expectedValue = "<" + TAGNAME +
        " " + URL_ATTRIBUTE + "=\"" + xmlSource + "\"" +
        " " + TITLE_ATTRIBUTE + "=\"\"" +
        " " + PREFS_ATTRIBUTE + "=\"my pref\"" +
        " " + STATE_ATTRIBUTE + "=\"\"" +
View Full Code Here

Examples of org.waveprotocol.wave.model.document.util.XmlStringBuilder

    IndexedDocument<Node, Element, Text> parse = DocProviders.POJO.parse(initialContent);
    SubTreeXmlRenderer<Node, Element, Text> renderer =
      new SubTreeXmlRenderer<Node, Element, Text>(parse);

    Element nearestCommonAncestor = parse.getDocumentElement();
    XmlStringBuilder rendered = renderer.renderRange(parse.locate(start), parse.locate(end));

    assertEquals(expectedContent, rendered.toString());
  }
View Full Code Here

Examples of org.waveprotocol.wave.model.document.util.XmlStringBuilder

    String content = OperationUtil.getRequiredParameter(operation, ParamsProperty.CONTENT);
    String blipId = OperationUtil.getRequiredParameter(operation, ParamsProperty.BLIP_ID);
    ConversationBlip convBlip = context.getBlip(conversation, blipId);

    // Create builder from xml content.
    XmlStringBuilder markupBuilder = XmlStringBuilder.createFromXmlString(content);

    // Append the new markup to the blip doc.
    Document doc = convBlip.getContent();
    LineContainers.appendLine(doc, markupBuilder);
View Full Code Here

Examples of org.waveprotocol.wave.model.document.util.XmlStringBuilder

      // While the client libraries force a newline to be sent as the first
      // character we'll remove it here since the new blip we created already
      // contains a newline.
      content = content.substring(1);
    }
    XmlStringBuilder builder = XmlStringBuilder.createText(content);
    LineContainers.appendToLastLine(newBlip.getContent(), builder);
  }
View Full Code Here

Examples of org.waveprotocol.wave.model.document.util.XmlStringBuilder

   */
  private void assertManifestXml(final String expected) {
    manifestDoc.with(new Action() {
      @Override
      public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) {
        XmlStringBuilder exp = XmlStringBuilder.createFromXmlString(expected);
        assertStructureEquivalent(exp.wrap("conversation"), doc);
      }
    });
  }
View Full Code Here

Examples of org.waveprotocol.wave.model.document.util.XmlStringBuilder

   * @param i The index at which to insert the tag.
   */
  public void addTag(String tagName, int i) {
    E node = getNthTagNode(i);
    El<N> point = Point.<N>inElement(doc.getDocumentElement(), node);
    XmlStringBuilder xml = getXmlFor(tagName);
    doc.insertXml(point, xml);
  }
View Full Code Here

Examples of org.waveprotocol.wave.model.document.util.XmlStringBuilder

    } else {
      Element element = modifyAction.getElement(valueIndex);
      if (element != null) {
        if (element.isGadget()) {
          Gadget gadget = (Gadget) element;
          XmlStringBuilder xml =
              GadgetXmlUtil.constructXml(gadget.getUrl(), "", gadget.getAuthor(), null,
                  gadget.getProperties());
          // TODO (Yuri Z.) Make it possible to specify a location to insert the
          // gadget and implement insertion at the specified location.
          LineContainers.appendLine(doc, xml);
View Full Code Here

Examples of org.waveprotocol.wave.model.document.util.XmlStringBuilder

            doc.emptyElement(child);
            Point<Doc.N> point = Point.<Doc.N> inElement(child, null);
            doc.insertText(point, val);
          }
        } else {
          XmlStringBuilder xml = GadgetXmlUtil.constructStateXml(property.getKey(), val);
          doc.insertXml(Point.<Doc.N> inElement(existingElement, null), xml);
        }
      }
    }
  }
View Full Code Here

Examples of org.waveprotocol.wave.model.document.util.XmlStringBuilder

        CollectionUtils.newArrayList(topBlip.getReplyThreads()));
  }

  public void testDeleteInlineReplyDeletesAnchor() {
    ConversationBlip blip = target.getRootThread().appendBlip();
    XmlStringBuilder xmlBefore = XmlStringBuilder.innerXml(blip.getContent());
    ConversationThread inlineReply = blip.addReplyThread(locateAfterLineElement(
        blip.getContent()));
    ConversationBlip inlineReplyBlip = inlineReply.appendBlip();

    inlineReplyBlip.delete();
View Full Code Here

Examples of org.waveprotocol.wave.model.document.util.XmlStringBuilder

   * @param state the initial gadget state.
   * @return content XML string for the gadget.
   */
  public static XmlStringBuilder constructXml(String url, String prefs, String author,
      @Nullable String[] categories, @Nullable Map<String, String> state) {
    final XmlStringBuilder builder = XmlStringBuilder.createEmpty();
    if (categories != null) {
      for (int i = 0; i < categories.length; ++i) {
        builder.append(
            XmlStringBuilder.createText("").wrap(
                CATEGORY_TAGNAME, KEY_ATTRIBUTE, categories[i]));
      }
    }
    if (state != null) {
      for (Map.Entry<String, String> entry : state.entrySet()) {
        builder.append(
            GadgetXmlUtil.constructStateXml(entry.getKey(), entry.getValue()));
      }
    }
    builder.wrap(
        TAGNAME,
        URL_ATTRIBUTE, url,
        TITLE_ATTRIBUTE, "",
        PREFS_ATTRIBUTE, prefs != null ? prefs : "",
        STATE_ATTRIBUTE, "",
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.