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

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


      if (indent > 0) {
        attrList.add(new Attribute(INDENT_ATTR, "" + indent));
      }
    }

    AttributesImpl attributes = AttributesImpl.fromUnsortedAttributes(attrList);

    return attributes;
  }
View Full Code Here


        Map<String, String> attributesMap = Maps.newHashMap();
        for (ProtocolDocumentOperation.Component.KeyValuePair pair :
            c.getElementStart().getAttributeList()) {
          attributesMap.put(pair.getKey(), pair.getValue());
        }
        output.elementStart(c.getElementStart().getType(), new AttributesImpl(attributesMap));
      } 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()) {
        Map<String, String> attributesMap = Maps.newHashMap();
        for (ProtocolDocumentOperation.Component.KeyValuePair pair :
            c.getDeleteElementStart().getAttributeList()) {
          attributesMap.put(pair.getKey(), pair.getValue());
        }
        output.deleteElementStart(c.getDeleteElementStart().getType(),
            new AttributesImpl(attributesMap));
      } else if (c.hasDeleteElementEnd()) {
        output.deleteElementEnd();
      } else if (c.hasReplaceAttributes()) {
        if (c.getReplaceAttributes().getEmpty()) {
          output.replaceAttributes(AttributesImpl.EMPTY_MAP, AttributesImpl.EMPTY_MAP);
        } else {
          Map<String, String> oldAttributesMap = Maps.newHashMap();
          Map<String, String> newAttributesMap = Maps.newHashMap();
          for (ProtocolDocumentOperation.Component.KeyValuePair pair :
              c.getReplaceAttributes().getOldAttributeList()) {
            oldAttributesMap.put(pair.getKey(), pair.getValue());
          }
          for (ProtocolDocumentOperation.Component.KeyValuePair pair :
              c.getReplaceAttributes().getNewAttributeList()) {
            newAttributesMap.put(pair.getKey(), pair.getValue());
          }
          output.replaceAttributes(new AttributesImpl(oldAttributesMap),
              new AttributesImpl(newAttributesMap));
        }
      } else if (c.hasUpdateAttributes()) {
        if (c.getUpdateAttributes().getEmpty()) {
          output.updateAttributes(AttributesUpdateImpl.EMPTY_MAP);
        } else {
View Full Code Here

        switch (parser.getCurrentType()) {
          case TEXT:
            builder.characters(parser.getText());
            break;
          case START_ELEMENT:
            builder.elementStart(parser.getTagName(), new AttributesImpl(CollectionUtils
                .newJavaMap(parser.getAttributes())));
            break;
          case END_ELEMENT:
            builder.elementEnd();
            break;
View Full Code Here

    Point.checkPoint(this, point, "MutableDocumentImpl.createElement");
    try {
      begin();

      int location = doc.getLocation(point);
      consume(createElement(tagName, new AttributesImpl(attributes), at(location)));

      Point<N> result = doc.locate(location);

      return doc.asElement(result.isInTextNode()
          ? doc.getNextSibling(result.getContainer()) : result.getNodeAfter());
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

  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

        if (textNode != null) {
          b.characters(substrate.getData(textNode));
        } else {
          E elementNode = substrate.asElement(node);
          b.elementStart(substrate.getTagName(elementNode),
              new AttributesImpl(substrate.getAttributes(elementNode)));
          depth++;
        }
      } else {
        // To avoid the sentinel
        depth--;
View Full Code Here

      }

      @Override
      public Attributes attributesAt(int pos) {
        E el = Point.elementAfter(doc, doc.locate(pos));
        return isUsableElement(el) ? new AttributesImpl(doc.getAttributes(el)) : null;
      }

      @Override
      public int charAt(int pos) {
        String str = DocHelper.getText(doc, pos, pos + 1);
View Full Code Here

      didSomethingOtherThanDeletionSinceAnnotationBoundary = true;

      beginUpdate();

      E node = substrate.asElement(currentContainer.getValue());
      Attributes oldAttributes = new AttributesImpl(substrate.getAttributes(node));
      // Iterate over oldAttributes here, not attributeMap, since we are modifying
      // the map underlying the latter.
      for (Map.Entry<String, String> attribute : oldAttributes.entrySet()) {
        String key = attribute.getKey();
        if (!newAttrs.containsKey(key)) {
          substrate.removeAttribute(node, attribute.getKey());
        }
      }
View Full Code Here

      E nodeToDelete = substrate.asElement(currentContainer.getValue());
      if (nodeToDelete == null) {
        throw new OpCursorException("No element to delete at the current location.");
      }
      String tagName = substrate.getTagName(nodeToDelete);
      Attributes attributes = new AttributesImpl(substrate.getAttributes(nodeToDelete));
      if (deletionDepth == 0) {
        substrate.removeChild(currentParent, nodeToDelete);
      }

      doSingleDelete(tagName, attributes);
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.