@Override public ObservableManifestThread adapt(DocumentEventRouter<? super E, E, ?> router, E element) { return DocumentBasedManifestThread.create(router, element); }
/** * Creates a document-based manifest backed by an empty document. * * @param doc the document on which to base the manifest * @precondition {@code !documentHasManifest(doc)} */ @VisibleForTesting public static <E> DocumentBasedManifest createNew( ObservableMutableDocument<? super E, E, ?> doc) { // If the precondition holds then the document must be empty. E top = DocHelper.createFirstTopLevelElement(doc, MANIFEST_TOP_TAG); DocumentEventRouter<? super E, E, ?> router = DefaultDocumentEventRouter.create(doc); return new DocumentBasedManifest( DocumentBasedManifestThread.create(router, top), DocumentBasedStructuredValue.create(router, top, Serializer.STRING, AnchorKey.class)); }
/** * Creates a document-based manifest backed by a document with existing * conversation structure. * * @param router event router for the document on which to base the manifest * @precondition {@code documentHasManifest(doc)} */ static <E> DocumentBasedManifest createOnExisting( DocumentEventRouter<? super E, E, ?> router, E top) { Preconditions.checkArgument(router.getDocument().getTagName(top).equals(MANIFEST_TOP_TAG), "Invalid manifest top tag %s", router.getDocument().getTagName(top)); return new DocumentBasedManifest( DocumentBasedManifestThread.create(router, top), DocumentBasedStructuredValue.create(router, top, Serializer.STRING, AnchorKey.class)); }
private <E> ObservableManifestThread buildThreadElement2( ObservableMutableDocument<? super E, E, ?> document, String id) { E root = DocHelper.getOrCreateFirstTopLevelElement(document, "conversation"); E blip = document.createChildElement(root, "blip", CollectionUtils.immutableMap("id", "b+top")); E container = document.createChildElement(blip, "thread", CollectionUtils.immutableMap("id", id)); return DocumentBasedManifestThread.create(DefaultDocumentEventRouter.create(document), container); } }
private <E> ObservableManifestThread buildThreadElement2( ObservableMutableDocument<? super E, E, ?> document, String id) { E root = DocHelper.getOrCreateFirstTopLevelElement(document, "conversation"); E blip = document.createChildElement(root, "blip", CollectionUtils.immutableMap("id", "b+top")); E container = document.createChildElement(blip, "thread", CollectionUtils.immutableMap("id", id)); return DocumentBasedManifestThread.create(DefaultDocumentEventRouter.create(document), container); } }