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

Examples of org.waveprotocol.wave.model.document.operation.Attributes


      @Override
      public <N, E extends N, T extends N> void exec(ObservableMutableDocument<N, E, T> doc) {
        E container = doc.getDocumentElement();

        // Insert entries
        Attributes attrs =
            state != null ? new AttributesImpl(VALUE_ATTR, state.toString()) : Attributes.EMPTY_MAP;
        doc.createChildElement(container, ENTRY_TAG, attrs);
      }
    });
  }
View Full Code Here


          entry = DocHelper.getNextSiblingElement(doc, entry);
        }

        for (Boolean b : state) {
          assertNotNull(entry);
          Attributes attrs =
              b != null ? new AttributesImpl(VALUE_ATTR, b.toString()) : Attributes.EMPTY_MAP;
          assertEquals(attrs, doc.getAttributes(entry));

          entry = DocHelper.getNextSiblingElement(doc, entry);
          // Skip over anything we don't care about
View Full Code Here

    }

    void addEntry(K key, C value) {
      String keyString = keySerializer.toString(key);
      String valueString = valueSerializer.toString(value);
      Attributes attrs = new AttributesImpl(KEY_ATTR, keyString, VALUE_ATTR, valueString);
      E child = context.doc.createChildElement(context.container, ENTRY_TAG, attrs);
    }
View Full Code Here

      int ... values) {
    // Insert container element
    E container = doc.createChildElement(doc.getDocumentElement(), CONTAINER_TAG,
        Collections.<String,String>emptyMap());
    for (int value : values) {
      Attributes attrs = new AttributesImpl(VALUE_ATTR, Serializer.INTEGER.toString(value));
      doc.createChildElement(container, ENTRY_TAG, attrs);
    }
    return new ValueContext<N, E>(doc, container);
  }
View Full Code Here

    assertFalse(new AttributesImpl("a", "1").updateWith(
        new AttributesUpdateImpl("a", "1", null)).containsKey("a"));
  }

  public void testVarargsConstructor() {
    Attributes a = new AttributesImpl("c", "0", "a", "1", "b", "2");
    Map<String, String> m = new HashMap<String, String>();
    m.put("a", "1");
    m.put("b", "2");
    m.put("c", "0");
    assertEquals(new AttributesImpl(m), a);
View Full Code Here

   *
   * @param location The location at which the insert the fragment.
   * @return The operation.
   */
  private static Nindo structuralSample5(int location) {
    Attributes attributes = new AttributesImpl(
        Collections.singletonMap("href", "http://www.google.com/"));
    Nindo.Builder builder = new Nindo.Builder();
    builder.skip(location);
    builder.elementStart("a", new AttributesImpl(attributes));
    builder.characters("google");
View Full Code Here

    String a = "<p>abc<b>def</b></p>";

    create(a);
    Element elem = (Element) doc.getDocumentElement().getFirstChild();

    Attributes attrs = attrs("x", "1", "y", "2", "z", "3");
    doc.setElementAttributes(elem, attrs);
    checkEvents(am(elem, pairs("x", null, "y", null, "z", null), attrs));

    Attributes updates = attrs("w", "4", "x", "1", "y", "5");
    doc.updateElementAttributes(elem, updates);
    // x omitted because no change.
    checkEvents(am(elem, pairs("w", null, "y", "2"), attrs("w", "4", "y", "5")));

    Map<String, String> updates2 = pairs("w", null);
    doc.updateElementAttributes(elem, updates2);
    // x omitted because no change.
    checkEvents(am(elem, pairs("w", "4"), pairs("w", null)));

    Attributes sets = attrs("x", "1", "y", "6", "v", "7");
    doc.setElementAttributes(elem, sets);
    // x omitted because no change.
    checkEvents(am(elem,
        pairs("y", "5", "z", "3", "v", null),
        pairs("y", "6", "z", null, "v", "7")));

    // tests lack of concurrent modification exception:
    Attributes sets2 = attrs("x", "1", "y", "6", "v", "7");
    doc.setElementAttributes(elem, sets2);
    checkEvents(am(elem, pairs(), pairs()));
  }
View Full Code Here

    create(a);

    Element firstEl = (Element) doc.getFirstChild(doc.getDocumentElement());

    Builder b = at(0);
    Attributes attrs = attrs("x", "1", "y", "2");
    b.replaceAttributes(attrs);
    b.elementStart("x", attrs("a", "1"));
    b.characters("hello");
    b.elementStart("y", attrs("b", "2", "c", "3"));
    b.characters("yeah");
View Full Code Here

    Node n2 = doc.getLastChild(top);
    List<Element> all = elementsInner(doc, top);
    List<Element> els = Arrays.asList(all.get(0), all.get(1));

    Builder b = at(0);
    Attributes attrs = attrs("x", "1", "y", "2");
    b.replaceAttributes(attrs);
    b.elementStart("x", attrs("a", "1"));
    b.characters("hello");
    b.elementStart("y", attrs("b", "2", "c", "3"));
    b.characters("yeah");
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

TOP

Related Classes of org.waveprotocol.wave.model.document.operation.Attributes

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.