Package org.waveprotocol.wave.model.document.operation.impl

Examples of org.waveprotocol.wave.model.document.operation.impl.AttributesImpl


    b.characters("world");
    b.retain(2);
    b.deleteCharacters("cd");
    b.elementStart("a", Attributes.EMPTY_MAP);
    b.characters("hEllo");
    b.elementStart("b", new AttributesImpl("a", "1"));
    b.characters("world");
    b.elementStart("B", new AttributesImpl("A", "1", "b", "abc12"));
    b.elementEnd();
    // A non-ASCII Unicode character.
    b.characters("\u2603");
    b.elementEnd();
    b.elementEnd();
    b.deleteElementStart("a", new AttributesImpl("a", "2", "c", ""));
    b.deleteCharacters("asdf");
    b.deleteElementEnd();

    // Now some replaceAttributes with different size and case.
    b.replaceAttributes(new AttributesImpl("a", "b"), new AttributesImpl("b", "c", "c", "d"));
    b.replaceAttributes(Attributes.EMPTY_MAP, new AttributesImpl("Aa", "aA"));
    b.replaceAttributes(new AttributesImpl("B", "A"), new AttributesImpl());
    // Try both a fresh empty AttributesImpl() instance and the preallocated
    // EMPTY_MAP.
    b.replaceAttributes(new AttributesImpl(), Attributes.EMPTY_MAP);
    // Now we add similar cases for annotation boundaries.  Since consecutive annotation
    // boundaries would make the operation ill-formed, we interleave them with further
    // updateAttributes tests.
    b.annotationBoundary(AnnotationBoundaryMapImpl.builder().build());
    b.updateAttributes(new AttributesUpdateImpl());
View Full Code Here


   * @return The document with the given content.
   */
  public static DocInitialization createContent(String contentText) {
    if (contentText.isEmpty()) {
      return (new DocInitializationBuilder())
          .elementStart("body", new AttributesImpl())
          .elementStart("line", new AttributesImpl())
          .elementEnd()
          .elementEnd()
          .build();
    } else {
      return new DocInitializationBuilder()
          .elementStart("body", new AttributesImpl())
          .elementStart("line", new AttributesImpl())
          .elementEnd()
          .characters(contentText)
          .elementEnd()
          .build();
    }
View Full Code Here

  private void createEntry(WaveletId waveletId) {
    String waveletIdStr = WaveletBasedConversation.idFor(waveletId);
    E container =
        getDocument().createChildElement(getDocument().getDocumentElement(),
          WaveletBasedSupplement.WAVELET_TAG,
          new AttributesImpl(WaveletBasedSupplement.ID_ATTR, waveletIdStr));
  }
View Full Code Here

            public Attributes map(final String name) {
              return pickRandomNonNullMappedElement(r, p.getAttributeValues(),
                  new Mapper<String, Attributes> () {
                @Override
                public Attributes map(String value) {
                  Attributes b = new AttributesImpl(name, value);
                  switch (checker.check(b)) {
                    case ILL_FORMED:
                      return null;
                    case INVALID_DOCUMENT:
                    case INVALID_SCHEMA:
View Full Code Here

    }

    if (newValue != null) {
      // Add an element to reflect new value.
      getDocument().createChildElement(container, tag,
          new AttributesImpl(valueAttr, Serializer.BOOLEAN.toString(newValue)));
      cleanup();
    } else {
      // Erase all elements. Cleanup first, so that removal of real element
      // does not promote a redundant element temporarily.
      cleanup();
View Full Code Here

  @Override
  public void add(T value) {
    Preconditions.checkNotNull(value, "value must not be null");
    // Add an element to represent the value
    if (!valueElements.containsKey(value)) {
      Attributes attrs = new AttributesImpl(valueAttrName, serializer.toString(value));
      getDocument().createChildElement(container, entryTagName, attrs);
      deleteObsoleteElements();
    }
  }
View Full Code Here

   * @param cursor Cursor to write results out to.
   * @param recurse Whether or not to write children to the operation.
   */
  public static <N, E extends N, T extends N> void buildDomInitializationFromElement(
      ReadableDocument<N, E, T> doc, E element, DocInitializationCursor cursor, boolean recurse) {
    cursor.elementStart(doc.getTagName(element), new AttributesImpl(doc.getAttributes(element)));
    if (recurse) {
      for (N child = doc.getFirstChild(element); child != null; child = doc.getNextSibling(child)) {
        buildDomInitializationFromSubtree(doc, child, cursor);
      }
    }
View Full Code Here

  public static Attributes maybeCreateSuggestions(Map<String, Object> before) {
    StringMap<String> attributes = CollectionUtils.createStringMap();
    for (Plugin plugin : plugins) {
      plugin.maybeFillAttributes(before, attributes);
    }
    return new AttributesImpl(CollectionUtils.newJavaMap(attributes));
  }
View Full Code Here

      ContentElement prevLineElement = previousLine.getLineElement();
      ContentElement prevParagraph = previousLine.getParagraph();
      if (doc.getNextSibling(prevLineElement) == lineElement) {
        // If the previous line is empty
        Map<String, String> attrs = doc.getAttributes(lineElement);
        doc.setElementAttributes(prevLineElement, new AttributesImpl(attrs));
      }

      int at = doc.getLocation(Point.<ContentNode>end(prevParagraph));
      boolean needsAdjusting = prevParagraph.getFirstChild() == null;
      doc.deleteNode(lineElement);
View Full Code Here

              newValues));
        }
      } else if (c.hasCharacters()) {
        output.characters(c.getCharacters());
      } else if (c.hasElementStart()) {
        output.elementStart(c.getElementStart().getType(), new AttributesImpl(deserialize(c
            .getElementStart().getAttribute())));
      } else if (c.hasElementEnd()) {
        output.elementEnd();
      } else if (c.hasRetainItemCount()) {
        output.retain(c.getRetainItemCount());
      } else if (c.hasDeleteCharacters()) {
        output.deleteCharacters(c.getDeleteCharacters());
      } else if (c.hasDeleteElementStart()) {
        output.deleteElementStart(c.getDeleteElementStart().getType(), new AttributesImpl(
            deserialize(c.getDeleteElementStart().getAttribute())));
      } else if (c.hasDeleteElementEnd()) {
        output.deleteElementEnd();
      } else if (c.hasReplaceAttributes()) {
        ReplaceAttributes r = c.getReplaceAttributes();
        if (r.getEmpty()) {
          output.replaceAttributes(AttributesImpl.EMPTY_MAP, AttributesImpl.EMPTY_MAP);
        } else {
          output.replaceAttributes(new AttributesImpl(deserialize(r.getOldAttribute())),
              new AttributesImpl(deserialize(r.getNewAttribute())));
        }
      } else if (c.hasUpdateAttributes()) {
        UpdateAttributes u = c.getUpdateAttributes();
        if (u.getEmpty()) {
          output.updateAttributes(AttributesUpdateImpl.EMPTY_MAP);
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.model.document.operation.impl.AttributesImpl

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.