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

Examples of org.waveprotocol.wave.model.document.operation.util.ImmutableStateMap.Attribute


  }

  public static Attributes scrubAttributes(Attributes unscrubbed, ScrubCache nameScrubber) {
    List<Attribute> list = new ArrayList<Attribute>();
    for (Map.Entry<String, String> entry : unscrubbed.entrySet()) {
      list.add(new Attribute(
          nameScrubber.scrubUniquely(entry.getKey()),
          scrubMostString(entry.getValue())));
    }
    return AttributesImpl.fromUnsortedAttributesUnchecked(list);
  }
View Full Code Here


  }

  public void testCheckAttributesSorted() {
    // see also the corresponding tests in ImmutableUpdateMapTest.
    ImmutableStateMap.checkAttributesSorted(Arrays.asList(new Attribute[] {}));
    ImmutableStateMap.checkAttributesSorted(Arrays.asList(new Attribute("a", "1")));
    ImmutableStateMap.checkAttributesSorted(Arrays.asList(
        new Attribute("aa", "1"), new Attribute("ab", "1")));
    ImmutableStateMap.checkAttributesSorted(Arrays.asList(
        new Attribute("a", "1"), new Attribute("b", "2"), new Attribute("c", "1")));
    try {
      ImmutableStateMap.checkAttributesSorted(Arrays.asList(
          new Attribute("asdfa", "1"), new Attribute("asdfb", "2"), new Attribute("asdfb", "2")));
      fail();
    } catch (IllegalArgumentException e) {
      // ok
    }
    try {
      ImmutableStateMap.checkAttributesSorted(Arrays.asList(
          new Attribute("rar", "1"), new Attribute("rar", "2"), new Attribute("rbr", "1")));
      fail();
    } catch (IllegalArgumentException e) {
      // ok
    }
    try {
      ImmutableStateMap.checkAttributesSorted(Arrays.asList(
          null, new Attribute("a", "2")));
      fail();
    } catch (NullPointerException e) {
      // ok
    }
    try {
      ImmutableStateMap.checkAttributesSorted(Arrays.asList(
          new Attribute("a", "2"), null));
      fail();
    } catch (NullPointerException e) {
      // ok
    }
    try {
      ImmutableStateMap.checkAttributesSorted(Arrays.asList(
          new Attribute("a", "1"), new Attribute("a", "1")));
      fail();
    } catch (IllegalArgumentException e) {
      // ok
    }
    try {
      ImmutableStateMap.checkAttributesSorted(Arrays.asList(
          new Attribute("a", "1"), null, new Attribute("c", "1")));
      fail();
    } catch (NullPointerException e) {
      // ok
    }
    try {
      ImmutableStateMap.checkAttributesSorted(Arrays.asList(
          null, new Attribute("a", "1"), new Attribute("c", "1")));
      fail();
    } catch (NullPointerException e) {
      // ok
    }
    try {
      ImmutableStateMap.checkAttributesSorted(Arrays.asList(
          new Attribute("a", "1"), new Attribute("c", "1"), null));
      fail();
    } catch (NullPointerException e) {
      // ok
    }
    try {
      ImmutableStateMap.checkAttributesSorted(Arrays.asList(
          new Attribute("a", "1"), new Attribute("a", "1"), null));
      fail();
    } catch (IllegalArgumentException e) {
      // ok
    }
    try {
      ImmutableStateMap.checkAttributesSorted(Arrays.asList(
          new Attribute("a", "1"), new Attribute("c", "2"), new Attribute("b", "3")));
      fail();
    } catch (IllegalArgumentException e) {
      // ok
    }
  }
View Full Code Here

      @Override
      public boolean build(DocInitializationCursor d, DocOpCursor m) {
        m.elementStart("blip",
            AttributesImpl.fromSortedAttributesUnchecked(
                Arrays.asList(new Attribute[] {
                    new Attribute("a", "1"),
                    new Attribute("b", "1")
                })));
        m.elementEnd();
        return true;
      }
    });
    doTest(new TestData() {
      @Override
      public boolean build(DocInitializationCursor d, DocOpCursor m) {
        m.elementStart("blip",
            AttributesImpl.fromSortedAttributesUnchecked(
                Arrays.asList(new Attribute[] {
                    new Attribute("b", "1"),
                    new Attribute("a", "1")
                })));
        m.elementEnd();
        return false;
      }
    });
View Full Code Here

    }

    private static Attributes convertAttributes(org.xml.sax.Attributes attributes) {
      List<Attribute> attributeList = new ArrayList<Attribute>();
      for (int i = 0; i < attributes.getLength(); ++i) {
        attributeList.add(new Attribute(attributes.getQName(i), attributes.getValue(i)));
      }
      return AttributesImpl.fromUnsortedAttributes(attributeList);
    }
View Full Code Here

    }

    private static Attributes convertAttributes(org.xml.sax.Attributes attributes) {
      List<Attribute> attributeList = new ArrayList<Attribute>();
      for (int i = 0; i < attributes.getLength(); ++i) {
        attributeList.add(new Attribute(attributes.getQName(i), attributes.getValue(i)));
      }
      return AttributesImpl.fromUnsortedAttributes(attributeList);
    }
View Full Code Here

      if (tokenizer.getCurrentType() == Type.LIST_ITEM) {
        switch (currentStructureType) {
        case UNORDERED_LIST_START:
          indent--;
          attrList.add(new Attribute(TYPE_ATTR, "li"));
          break;
        case ORDERED_LIST_START:
          indent--;
          attrList.add(new Attribute(TYPE_ATTR, "li"));
          attrList.add(new Attribute(LI_STYLE_ATTR, "decimal"));
          break;
        }
      } else if (tokenizer.getData() != null) {
        attrList.add(new Attribute(TYPE_ATTR, tokenizer.getData()));
      }

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

    AttributesImpl attributes = AttributesImpl.fromUnsortedAttributes(attrList);
View Full Code Here

  private GoogleDeserializer() {}

  private static Attributes attributesFrom(ElementStart in) {
    List<Attribute> attributes = new ArrayList<Attribute>();
    for (KeyValuePair p : in.getAttributeList()) {
      attributes.add(new Attribute(p.getKey(), p.getValue()));
    }
    try {
      return AttributesImpl.fromSortedAttributes(attributes);
    } catch (IllegalArgumentException e) {
      throw new InvalidInputException("Invalid attributes: " + e, e);
View Full Code Here

  private Attributes attributesFrom(ElementStart message) {
    List<Attribute> attributes = new ArrayList<Attribute>();
    for (int i = 0; i < message.getAttributeSize(); i++) {
      KeyValuePair p = message.getAttribute(i);
      attributes.add(new Attribute(p.getKey(), p.getValue()));
    }
    return createAttributesImpl(attributes);
  }
View Full Code Here

  private Attributes oldAttributesFrom(ReplaceAttributes message) {
    List<Attribute> attributes = new ArrayList<Attribute>();
    for (int i = 0; i < message.getOldAttributeSize(); i++) {
      KeyValuePair p = message.getOldAttribute(i);
      attributes.add(new Attribute(p.getKey(), p.getValue()));
    }
    return createAttributesImpl(attributes);
  }
View Full Code Here

  private Attributes newAttributesFrom(ReplaceAttributes message) {
    List<Attribute> attributes = new ArrayList<Attribute>();
    for (int i = 0; i < message.getNewAttributeSize(); i++) {
      KeyValuePair p = message.getNewAttribute(i);
      attributes.add(new Attribute(p.getKey(), p.getValue()));
    }
    return createAttributesImpl(attributes);
  }
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.model.document.operation.util.ImmutableStateMap.Attribute

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.