IndexedDocument<Node, Element, Text> createDocument() throws OperationException { return DocProviders.POJO.build(content, schema, handlerManager); } }
private static IndexedDocument<Node, Element, Text> getEmptyDocument() { return DocProviders.POJO.build(EmptyDocument.EMPTY_DOCUMENT, NO_SCHEMA_CONSTRAINTS); }
@Override public IndexedDocument<N, E, T> parse(String text) { DocInitialization docInitialization; try { docInitialization = DocOpUtil.docInitializationFromXml(text); } catch (XmlParseException e) { throw new IllegalArgumentException(e); } return build(docInitialization, NO_SCHEMA_CONSTRAINTS); }
private final DocumentSchema schema = schemas.getSchemaForId(waveletId, docId); private final IndexedDocument<Node, Element, Text> document = DocProviders.POJO.build(content, schema);
/** * Creates a document which applies generated operations to a copy of * itself, thus ensuring those ops are valid when received remotely. */ public static Document createValidatingDocument(DocumentSchema schema) { IndexedDocument<Node, Element, Text> indexedDoc = POJO.build(new DocInitializationBuilder().build(), schema); return new DocumentImpl(createCopyingSequencer(indexedDoc), indexedDoc); }
/** * Creates a sequencer that applies outgoing operations to a copy of the given * document, ensuring that both incoming and outgoing ops are valid. * * This is not implemented efficiently, intended for use in unit tests only. * * @param doc document to copy */ public final static <N, E extends N> OperationSequencer<Nindo> createCopyingSequencer( IndexedDocument<N, E, ? extends N> doc) { final IndexedDocument<Node, Element, Text> copy = POJO.build( doc.asOperation(), doc.getSchema()); return createTrivialSequencer(doc, new OperationSink<DocOp>() { @Override public void consume(DocOp op) throws OperationException { // Should throw exceptions if the op is invalid. copy.consume(op); } }); }
/** * Returns the position of the body element in an initial, empty, blip. */ public static int getInitialBlipBodyPosition() { IndexedDocument<Node, Element, Text> d = DocProviders.POJO.build( TitleHelper.emptyDocumentWithTitle(), DocumentSchema.NO_SCHEMA_CONSTRAINTS); return getBodyPosition(d); }
private DocOp getDocOpFromNindo(Nindo nindo) { try { return DocProviders.POJO.build(editor.getDocumentInitialization(), DocumentSchema.NO_SCHEMA_CONSTRAINTS).consumeAndReturnInvertible(nindo); } catch (OperationException e) { throw new OperationRuntimeException("initialization failed", e); } }
/** * Test that the head of the document built by emptyDocumentWithTitle matches * the initial head in ConversationConstants.BLIP_INITIAL_HEAD. **/ public void testEmptyDocumentWithTitle() { IndexedDocument<Node, Element, Text> d = DocProviders.POJO.build( TitleHelper.emptyDocumentWithTitle(), DocumentSchema.NO_SCHEMA_CONSTRAINTS); String message = Blips.INITIAL_CONTENT.toString() + " expected, found " + XmlStringBuilder.innerXml(d).toString(); assertTrue(message, DocCompare.equivalent(DocCompare.STRUCTURE, Blips.INITIAL_CONTENT.toString(), d)); }
private DocOp getDocOpFromNindo(Nindo nindo) { try { return DocProviders.POJO.build(editor.getDocumentInitialization(), DocumentSchema.NO_SCHEMA_CONSTRAINTS).consumeAndReturnInvertible(nindo); } catch (OperationException e) { throw new OperationRuntimeException("initialization failed", e); } }
/** * Test that the head of the document built by emptyDocumentWithTitle matches * the initial head in ConversationConstants.BLIP_INITIAL_HEAD. **/ public void testEmptyDocumentWithTitle() { IndexedDocument<Node, Element, Text> d = DocProviders.POJO.build( TitleHelper.emptyDocumentWithTitle(), DocumentSchema.NO_SCHEMA_CONSTRAINTS); String message = Blips.INITIAL_CONTENT.toString() + " expected, found " + XmlStringBuilder.innerXml(d).toString(); assertTrue(message, DocCompare.equivalent(DocCompare.STRUCTURE, Blips.INITIAL_CONTENT.toString(), d)); }
Nindo nindo = RandomNindoGenerator.generate(random, params, constraints, doc); DocOp docOp = doc.consumeAndReturnInvertible(nindo); docs[i] = DocProviders.POJO.build(doc.asOperation(), constraints); } else if (testNindos) { Nindo nindo = RandomNindoGenerator.generate(random, params, constraints, doc);
IndexedDocument<Node, Element, Text> copy = DocProviders.POJO.build(docAsOp, DocumentSchema.NO_SCHEMA_CONSTRAINTS); System.out.println(doc);
IndexedDocument<Node, Element, Text> copy = DocProviders.POJO.build(docAsOp, DocumentSchema.NO_SCHEMA_CONSTRAINTS); System.out.println(doc);
IndexedDocument<Node, Element, Text> copy = DocProviders.POJO.build(indexedDoc.asOperation(), DocumentSchema.NO_SCHEMA_CONSTRAINTS); copy.consume(indexedDoc.asOperation());
IndexedDocument<Node, Element, Text> copy = DocProviders.POJO.build(indexedDoc.asOperation(), DocumentSchema.NO_SCHEMA_CONSTRAINTS); copy.consume(indexedDoc.asOperation());
public void XtestAnchorRemovalIsUnworthy2() throws OperationException { IndexedDocument<Node, Element, Text> d = DocProviders.POJO.build( new DocInitializationBuilder() .annotationBoundary(new AnnotationBoundaryMapBuilder().change("a", null, "b").build()) .elementStart(WorthyChangeChecker.THREAD_INLINE_ANCHOR_TAGNAME, Attributes.EMPTY_MAP) .elementEnd() .annotationBoundary(new AnnotationBoundaryMapBuilder().end("a").build()) .build(), DocumentSchema.NO_SCHEMA_CONSTRAINTS); DocOp op = d.consumeAndReturnInvertible(new Nindo.Builder() { { deleteElementStart(); deleteElementEnd(); } }.build()); assertFalse(WorthyChangeChecker.isWorthy(op)); }
public void XtestAnchorRemovalIsUnworthy2() throws OperationException { IndexedDocument<Node, Element, Text> d = DocProviders.POJO.build( new DocInitializationBuilder() .annotationBoundary(new AnnotationBoundaryMapBuilder().change("a", null, "b").build()) .elementStart(WorthyChangeChecker.THREAD_INLINE_ANCHOR_TAGNAME, Attributes.EMPTY_MAP) .elementEnd() .annotationBoundary(new AnnotationBoundaryMapBuilder().end("a").build()) .build(), DocumentSchema.NO_SCHEMA_CONSTRAINTS); DocOp op = d.consumeAndReturnInvertible(new Nindo.Builder() { { deleteElementStart(); deleteElementEnd(); } }.build()); assertFalse(WorthyChangeChecker.isWorthy(op)); }
public void testAnchorRemovalIsUnworthy1() throws OperationException { IndexedDocument<Node, Element, Text> d = DocProviders.POJO.build( new DocInitializationBuilder() .annotationBoundary(new AnnotationBoundaryMapBuilder().change("a", null, "b").build()) .characters("a") .annotationBoundary(new AnnotationBoundaryMapBuilder().end("a").build()) .characters("a") .elementStart(WorthyChangeChecker.THREAD_INLINE_ANCHOR_TAGNAME, Attributes.EMPTY_MAP) .elementEnd() .build(), DocumentSchema.NO_SCHEMA_CONSTRAINTS); DocOp op = d.consumeAndReturnInvertible(new Nindo.Builder() { { skip(2); deleteElementStart(); deleteElementEnd(); } }.build()); assertFalse(WorthyChangeChecker.isWorthy(op)); }
public void testAnchorRemovalIsUnworthy1() throws OperationException { IndexedDocument<Node, Element, Text> d = DocProviders.POJO.build( new DocInitializationBuilder() .annotationBoundary(new AnnotationBoundaryMapBuilder().change("a", null, "b").build()) .characters("a") .annotationBoundary(new AnnotationBoundaryMapBuilder().end("a").build()) .characters("a") .elementStart(WorthyChangeChecker.THREAD_INLINE_ANCHOR_TAGNAME, Attributes.EMPTY_MAP) .elementEnd() .build(), DocumentSchema.NO_SCHEMA_CONSTRAINTS); DocOp op = d.consumeAndReturnInvertible(new Nindo.Builder() { { skip(2); deleteElementStart(); deleteElementEnd(); } }.build()); assertFalse(WorthyChangeChecker.isWorthy(op)); }