当前位置: 首页>>代码示例>>Java>>正文


Java Attributes类代码示例

本文整理汇总了Java中org.waveprotocol.wave.model.document.operation.Attributes的典型用法代码示例。如果您正苦于以下问题:Java Attributes类的具体用法?Java Attributes怎么用?Java Attributes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Attributes类属于org.waveprotocol.wave.model.document.operation包,在下文中一共展示了Attributes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: containsAnnotationKey

import org.waveprotocol.wave.model.document.operation.Attributes; //导入依赖的package包/类
private boolean containsAnnotationKey(DocInitialization content, final String key) {
  final boolean[] found = { false };
  content.apply(new DocInitializationCursor() {
      @Override public void characters(String chars) {}
      @Override public void elementStart(String type, Attributes attrs) {}
      @Override public void elementEnd() {}
      @Override public void annotationBoundary(AnnotationBoundaryMap map) {
        for (int i = 0; i < map.changeSize(); i++) {
          if (key.equals(map.getChangeKey(i))) {
            found[0] = true;
          }
        }
      }
    });
  return found[0];
}
 
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:17,代码来源:HistorySynthesizer.java

示例2: testOperationFromElementNotRecursive

import org.waveprotocol.wave.model.document.operation.Attributes; //导入依赖的package包/类
/** Check that generating an op from just an element calls element start & end. */
public void testOperationFromElementNotRecursive() {
  Bundle data = new Bundle();
  DocOpBuffer cursorA = new DocOpBuffer(), cursorB = new DocOpBuffer();
  DomOperationUtil.buildDomInitializationFromElement(data.D, data.A.asElement(), cursorA, false);
  cursorB.elementStart("a", Attributes.EMPTY_MAP);
  cursorB.elementEnd();

  checkCursors(cursorA, cursorB);

  // do likewise with B
  cursorA = new DocOpBuffer();
  cursorB = new DocOpBuffer();
  DomOperationUtil.buildDomInitializationFromElement(data.D, data.B.asElement(), cursorA, false);
  cursorB.elementStart("b", new AttributesImpl(Collections.singletonMap("x", "y")));
  cursorB.elementEnd();

  checkCursors(cursorA, cursorB);
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:20,代码来源:DomOperationUtilTest.java

示例3: doTestInserts

import org.waveprotocol.wave.model.document.operation.Attributes; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void doTestInserts() throws OperationException {
  String a = "<p>abc<b>def</b></p>";

  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");
  b.elementEnd();
  b.elementEnd();
  String moreText = "more text";
  b.characters(moreText);
  consumeNindo(b.build());

  checkEvents(
      am(firstEl, pairs("x", null, "y", null), attrs),
      ci(doc.asElement(firstEl.getFirstChild())),
      ti(14, moreText));
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:27,代码来源:ObservableIndexedDocumentTest.java

示例4: testOpenDuringInsertionThenUpdate

import org.waveprotocol.wave.model.document.operation.Attributes; //导入依赖的package包/类
public void testOpenDuringInsertionThenUpdate() throws OperationException {
   IndexedDocument<Node, Element, Text> doc =
DocProviders.POJO.parse("<q><r/></q>abcdefghijkl");

   Nindo.Builder b;

   b = new Nindo.Builder();
   b.startAnnotation("a", "1");
   b.skip(7);
   b.endAnnotation("a");
   checkApply(doc, b.build());

   b = new Nindo.Builder();
   b.elementStart("p", Attributes.EMPTY_MAP);
   b.startAnnotation("a", null);
   b.elementEnd();
   b.updateAttributes(Collections.singletonMap("u", "v"));
   b.replaceAttributes(new AttributesImpl("v", "u"));
   b.skip(1);
   b.endAnnotation("a");
   checkApply(doc, b.build());
 }
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:23,代码来源:IndexedDocumentImplTest.java

示例5: pushHandler

import org.waveprotocol.wave.model.document.operation.Attributes; //导入依赖的package包/类
@Override
final Handler pushHandler(String type, Attributes attrs) throws InvalidSchemaException {
  // NOTE: Is it worth using a map here?
  if (type.equals(PROLOGUE_TYPE_NAME)) {
    return new PrologueHandler(this);
  } else if (type.equals(ATTRIBUTE_TYPE_NAME)) {
    handleAttribute(attrs);
    return new EmptyHandler(this);
  } else if (type.equals(ELEMENT_TYPE_NAME)) {
    String name = extractName(ELEMENT_TYPE_NAME, attrs);
    if (freeElements.containsKey(name)) {
      throw new InvalidSchemaException("Element pattern defined more than once: " + name);
    }
    return new ElementHandler(name, this);
  } else if (type.equals(TEXT_TYPE_NAME)) {
    handleText(attrs);
    return new EmptyHandler(this);
  } else if (type.equals(REFERENCE_TYPE_NAME)) {
    handleReference(attrs);
    return new EmptyHandler(this);
  }
  throw new InvalidSchemaException("Unrecognized element type: " + type);
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:24,代码来源:SchemaFactory.java

示例6: createAlignTestCxt

import org.waveprotocol.wave.model.document.operation.Attributes; //导入依赖的package包/类
private TestDocumentContext<Node, Element, Text> createAlignTestCxt() {
  // creates the following, where '<t>' are soft nodes
  // <div>
  //   <p>A</p>
  //   <p> <t>Z</t> </p>
  //   <p> <t><t/></t> </p>
  // </div>
  String initialContent = "<p>A</p><p>Z</p><p></p>";
  TestDocumentContext<Node, Element, Text> cxt = ContextProviders.createTestPojoContext(
      DocProviders.POJO.parse(initialContent).asOperation(), null, null, null,
        DocumentSchema.NO_SCHEMA_CONSTRAINTS);

  LocalDocument<Node, Element, Text> doc = cxt.annotatableContent();
  Text zText = doc.getDocumentElement().getFirstChild().getNextSibling().getFirstChild().asText();

  // First transparent part, moving the Z inside
  Element trans = doc.transparentCreate("S", Attributes.EMPTY_MAP,
      zText.getParentElement(), zText);
  cxt.annotatableContent().transparentMove(trans, zText, null, null);

  // Second transparent part, deep transparent (contains another transparent element)
  Element lastP = doc.getDocumentElement().getLastChild().asElement();
  trans = cxt.annotatableContent().transparentCreate("T", Attributes.EMPTY_MAP, lastP, null);
  cxt.annotatableContent().transparentCreate("U", Attributes.EMPTY_MAP, trans, null);
  return cxt;
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:27,代码来源:DocHelperTest.java

示例7: toConciseString

import org.waveprotocol.wave.model.document.operation.Attributes; //导入依赖的package包/类
public static String toConciseString(Attributes attributes) {
  if (attributes.isEmpty()) {
    return "{}";
  }
  StringBuilder b = new StringBuilder();
  b.append("{ ");
  boolean first = true;
  for (Map.Entry<String, String> entry : attributes.entrySet()) {
    if (first) {
      first = false;
    } else {
      b.append(", ");
    }
    b.append(entry.getKey());
    b.append("=");
    b.append(literalString(entry.getValue()));
  }
  b.append(" }");
  return b.toString();
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:21,代码来源:DocOpUtil.java

示例8: testAnnotationBoundary

import org.waveprotocol.wave.model.document.operation.Attributes; //导入依赖的package包/类
public void testAnnotationBoundary() {
  DocOpBuilder m = new DocOpBuilder();

  Attributes a = new AttributesImpl(ImmutableMap.of("a1", "1", "a2", "2"));
  AnnotationBoundaryMap mapA = new AnnotationBoundaryMapImpl(
      new String[]{},new String[]{"a"},new String[]{null},new String[]{"b"});
  AnnotationBoundaryMap mapB = new AnnotationBoundaryMapImpl(
      new String[]{},new String[]{"a"},new String[]{"b"},new String[]{null});
  AnnotationBoundaryMap mapC = new AnnotationBoundaryMapImpl(
      new String[]{"a"},new String[]{},new String[]{},new String[]{});
  m.elementStart("a", a);
  m.annotationBoundary(mapA);
  m.characters("test");
  m.annotationBoundary(mapB);
  m.characters("text");
  m.annotationBoundary(mapC);
  m.elementEnd();

  assertReversible(makeBlipOp("annotationBoundary", m.build()));
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:21,代码来源:WaveletOperationSerializerTest.java

示例9: attributeString

import org.waveprotocol.wave.model.document.operation.Attributes; //导入依赖的package包/类
public static String attributeString(Attributes attributes) {
  StringBuilder b = new StringBuilder();
  boolean first = true;
  for (Map.Entry<String, String> e : attributes.entrySet()) {
    if (first) {
      first = false;
    } else {
      b.append(" ");
    }
    // We're just writing null with no quotes if the value is null.
    // This is acceptable since it only occurs in updateAttributes,
    // which is a processing instruction, so we define the format of it.
    //
    // TODO: We should escape ' and " and < and & etc. in the value.
    b.append(e.getKey()).append("=")
        .append(e.getValue() == null ? "null"
        : ("\"" + xmlAttrEscape(e.getValue()) + "\""));
  }
  return b.toString();
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:21,代码来源:DocOpUtil.java

示例10: structuralDeletionSample3

import org.waveprotocol.wave.model.document.operation.Attributes; //导入依赖的package包/类
/**
 * Creates an operation to delete the XML fragment "12<u>3<i/><b/>4</u>56".
 *
 * @param size The size of the document on which this operation should apply.
 * @param location The start of the range where the fragment to be deleted
 *        resides.
 * @return The operation.
 */
private static DocOp structuralDeletionSample3(int size, int location) {
  return new DocOpBuilder()
      .retain(location)
      .deleteCharacters("12")
      .deleteElementStart("u", Attributes.EMPTY_MAP)
      .deleteCharacters("3")
      .deleteElementStart("i", Attributes.EMPTY_MAP)
      .deleteElementEnd()
      .deleteElementStart("b", Attributes.EMPTY_MAP)
      .deleteElementEnd()
      .deleteCharacters("4")
      .deleteElementEnd()
      .deleteCharacters("56")
      .retain(size - location - 12)
      .build();
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:25,代码来源:DocumentTestCases.java

示例11: testDeleteCharactersAndElements

import org.waveprotocol.wave.model.document.operation.Attributes; //导入依赖的package包/类
public void testDeleteCharactersAndElements() {
  DocOpBuilder m = new DocOpBuilder();

  Attributes a = new AttributesImpl(ImmutableMap.of("a1", "1", "a2", "2"));
  Attributes b = new AttributesImpl();
  Attributes c = new AttributesImpl(ImmutableMap.of("c1", "1", "c2", "2", "c3", "3"));

  m.deleteElementStart("a", a);
  m.deleteCharacters("hello");
  m.deleteElementStart("b", b);
  m.deleteCharacters("world");
  m.deleteElementStart("c", c);
  m.deleteElementEnd();
  m.deleteCharacters("blah");
  m.deleteElementEnd();
  m.deleteElementEnd();

  assertReversible(makeBlipOp("deleteCharactersAndElements", m.build()));
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:20,代码来源:WaveletOperationSerializerTest.java

示例12: createElementStart

import org.waveprotocol.wave.model.document.operation.Attributes; //导入依赖的package包/类
private static ElementStart createElementStart(String type, Attributes attrs) {
  ElementStart elementStart = MessageFactoryHelper.createDocumentElementStart();
  elementStart.setType(type);
  for (Map.Entry<String, String> attribute : attrs.entrySet()) {
    elementStart.addAttribute(
        createKeyValuePair(attribute.getKey(), attribute.getValue()));
  }
  return elementStart;
}
 
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:10,代码来源:OperationSerializer.java

示例13: newAttributesFrom

import org.waveprotocol.wave.model.document.operation.Attributes; //导入依赖的package包/类
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);
}
 
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:9,代码来源:MessageWrapperDocOp.java

示例14: setElementAttributes

import org.waveprotocol.wave.model.document.operation.Attributes; //导入依赖的package包/类
@Override
public void setElementAttributes(E element, Attributes attrs) {
  Preconditions.checkArgument(element != getDocumentElement(), "Cannot touch root element");
  try {
    begin();
    consume(setAttributes(attrs, at(Locator.before(doc, element))));
  } finally {
    end();
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:11,代码来源:MutableDocumentImpl.java

示例15: render

import org.waveprotocol.wave.model.document.operation.Attributes; //导入依赖的package包/类
/**
 * Renders a document as a paragraph of plain text.
 */
public static void render(DocInitialization doc, final StringBuilder out) {
  checkNotNull(doc, "Null doc");
  checkNotNull(out, "Null out");
  doc.apply(new DocInitializationCursor() {
    @Override
    public void characters(String chars) {
      out.append(chars);
    }

    @Override
    public void elementStart(String type, Attributes attrs) {
      out.append(' ');
    }

    @Override
    public void elementEnd() {
      out.append(' ');
    }

    @Override
    public void annotationBoundary(AnnotationBoundaryMap map) {
      // Ignore
    }
  });
  out.append("\n");
}
 
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:30,代码来源:TextRenderer.java


注:本文中的org.waveprotocol.wave.model.document.operation.Attributes类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。