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

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


   * Tests a schema featuring various regular expressions for attribute values.
   */
  public void testGoodSchema16() throws InvalidSchemaException, IOException, ParseException {
    SchemaPattern test = readSchema("good16.schema");
    SchemaPattern pattern = test.child("element1");
    checkValidation_V(pattern.validateAttributes(new AttributesImpl(
        "attribute1", "hello")));
    checkValidation_V(pattern.validateAttributes(new AttributesImpl(
        "attribute1", "world")));
    checkValidation_IAV(pattern.validateAttributes(new AttributesImpl(
        "attribute1", "bad")),
        "attribute1", "bad");
    checkValidation_V(pattern.validateAttributes(new AttributesImpl(
        "attribute2", "abcdgh")));
    checkValidation_V(pattern.validateAttributes(new AttributesImpl(
        "attribute2", "abefgh")));
    checkValidation_IAV(pattern.validateAttributes(new AttributesImpl(
        "attribute2", "bad")),
        "attribute2", "bad");
    checkValidation_V(pattern.validateAttributes(new AttributesImpl(
        "attribute3", "abccccccccccef")));
    checkValidation_V(pattern.validateAttributes(new AttributesImpl(
        "attribute3", "abcdef")));
    checkValidation_IAV(pattern.validateAttributes(new AttributesImpl(
        "attribute3", "abccdef")),
        "attribute3", "abccdef");
  }
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

    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

              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

    }

    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

   * @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 E createEntry(K key, V value) {
    Map<String, String> attrs = new HashMap<String, String>();
    attrs.put(keyAttrName, keySerializer.toString(key));
    attrs.put(valueAttrName, valueSerializer.toString(value));
    // Always insert the new element at the start of the parent container.
    return prependChild(getDocument(), container, entryTagName, new AttributesImpl(attrs));

    // The document should fire an onEntryAdded event, which will cause the value to show up in
    // the entries map.
  }
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

            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

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.