本文整理汇总了Java中org.waveprotocol.wave.model.wave.Wavelet.getDocument方法的典型用法代码示例。如果您正苦于以下问题:Java Wavelet.getDocument方法的具体用法?Java Wavelet.getDocument怎么用?Java Wavelet.getDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.waveprotocol.wave.model.wave.Wavelet
的用法示例。
在下文中一共展示了Wavelet.getDocument方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: WaveletBasedSupplement
import org.waveprotocol.wave.model.wave.Wavelet; //导入方法依赖的package包/类
/**
* Creates a supplement.
*
* @param userData wavelet to hold the supplement state
*/
private WaveletBasedSupplement(Wavelet userData) {
folders = fungeCreateFolders(userData.getDocument(FOLDERS_DOCUMENT));
muted = fungeCreateMuted(userData.getDocument(MUTED_DOCUMENT));
waveletArchiveVersions = fungeCreateWaveletArchiveState(
userData.getDocument(ARCHIVING_DOCUMENT));
archiveCleared = fungeCreateCleared(userData.getDocument(CLEARED_DOCUMENT));
ObservableDocument readState = userData.getDocument(READSTATE_DOCUMENT);
read = fungeCreateReadState(readState, forwardingListener);
ObservableDocument lookState = userData.getDocument(LOOKSTATE_DOCUMENT);
look = fungeCreateLookState(lookState, forwardingListener);
collapsed = fungeCreateCollapsedState(
userData.getDocument(PRESENTATION_DOCUMENT), forwardingListener);
abuseStore = fungeCreateAbuseStore(userData.getDocument(ABUSE_DOCUMENT));
seenVersion = fungeCreateSeenVersion(userData.getDocument(SEEN_DOCUMENT));
notifiedVersion = fungeCreateNotifiedVersion(userData.getDocument(SEEN_DOCUMENT));
pendingNotification = fungeCreatePendingNotification(userData.getDocument(SEEN_DOCUMENT));
gadgetStates =
fungeCreateGadgetStates(userData.getDocument(GADGETS_DOCUMENT), forwardingListener);
blipStates = fungeCreateBlipStates(userData.getDocument(BLIPS_DOCUMENT), forwardingListener);
hackCleanup(); // Cleanup before installing listeners, so we start from
// clean state.
installListeners();
}
示例2: WaveletBasedSupplement
import org.waveprotocol.wave.model.wave.Wavelet; //导入方法依赖的package包/类
/**
* Creates a supplement.
*
* @param userData wavelet to hold the supplement state
*/
private WaveletBasedSupplement(Wavelet userData) {
folders = fungeCreateFolders(userData.getDocument(FOLDERS_DOCUMENT));
muted = fungeCreateMuted(userData.getDocument(MUTED_DOCUMENT));
waveletArchiveVersions = fungeCreateWaveletArchiveState(
userData.getDocument(ARCHIVING_DOCUMENT));
archiveCleared = fungeCreateCleared(userData.getDocument(CLEARED_DOCUMENT));
ObservableDocument readState = userData.getDocument(READSTATE_DOCUMENT);
read = fungeCreateReadState(readState, forwardingListener);
collapsed = fungeCreateCollapsedState(
userData.getDocument(PRESENTATION_DOCUMENT), forwardingListener);
abuseStore = fungeCreateAbuseStore(userData.getDocument(ABUSE_DOCUMENT));
seenVersion = fungeCreateSeenVersion(userData.getDocument(SEEN_DOCUMENT));
notifiedVersion = fungeCreateNotifiedVersion(userData.getDocument(SEEN_DOCUMENT));
pendingNotification = fungeCreatePendingNotification(
userData.getDocument(SEEN_DOCUMENT));
gadgetStates =
fungeCreateGadgetStates(userData.getDocument(GADGETS_DOCUMENT), forwardingListener);
hackCleanup(); // Cleanup before installing listeners, so we start from
// clean state.
installListeners();
}
示例3: copyDocument
import org.waveprotocol.wave.model.wave.Wavelet; //导入方法依赖的package包/类
/**
* Copies a document from one wavelet to another, appending the contents if the
* destination document already exists.
*
* @param sourceWavelet the source wavelet
* @param destWavelet the destination wavelet
* @param docId the id of the document to copy
*/
public static void copyDocument(Wavelet sourceWavelet, Wavelet destWavelet, String docId) {
Document document = sourceWavelet.getDocument(docId);
DocInitialization docInit = document.toInitialization();
// TODO(user): add a createDocument method to Wavelet so that we can push this ugliness
// down the stack.
ObservableDocument destDoc = destWavelet.getDocument(docId);
destDoc.hackConsume(Nindo.fromDocOp(docInit, false /* don't remove skip */));
}
示例4: clearDocument
import org.waveprotocol.wave.model.wave.Wavelet; //导入方法依赖的package包/类
/**
* Erases the content of the provided document.
*
* @param wavelet the wavelet containing the document to erase
* @param documentId the id of the document to erase
*/
public static void clearDocument(Wavelet wavelet, String documentId) {
Document document = wavelet.getDocument(documentId);
if (document.size() != 0) {
document.emptyElement(document.getDocumentElement());
}
}
示例5: fromXml
import org.waveprotocol.wave.model.wave.Wavelet; //导入方法依赖的package包/类
@Override
public Element fromXml(Document doc, E element, Wavelet wavelet) {
Map<String, String> properties = Maps.newHashMap();
String attachmentId = doc.getAttribute(element, ATTACHMENT_STR);
if (attachmentId != null) {
properties.put(Attachment.ATTACHMENT_ID, attachmentId);
}
String caption = getCaption(doc, element);
if (caption != null) {
properties.put(Attachment.CAPTION, caption);
}
if (wavelet != null && attachmentId != null) {
Document attachmentDataDoc =
wavelet.getDocument(IdConstants.ATTACHMENT_METADATA_PREFIX + "+" + attachmentId);
if (attachmentDataDoc != null) {
String dataDocument = attachmentDataDoc.toXmlString();
if (dataDocument != null) {
properties.put(Attachment.MIME_TYPE, extractValue(dataDocument, MIME_TYPE_PATTERN));
properties.put(Attachment.ATTACHMENT_URL,
ElementSerializer.attachmentDownloadHostUrl
+ getAttachmentUrl(dataDocument));
}
}
}
return new Attachment(properties, null);
}
示例6: getManifestDocument
import org.waveprotocol.wave.model.wave.Wavelet; //导入方法依赖的package包/类
/**
* Gets the document on which the conversation manifest is constructed.
*/
@VisibleForTesting
static ObservableDocument getManifestDocument(Wavelet wavelet) {
return wavelet.getDocument(IdConstants.MANIFEST_DOCUMENT_ID);
}
示例7: getAttachmentDataDoc
import org.waveprotocol.wave.model.wave.Wavelet; //导入方法依赖的package包/类
/**
* Locates an attachment data doc for a given attachment id within a wavelet.
* First, it looks for an attachment data doc that matches the fully
* qualified id. If that cannot be found, it looks for any attachment data
* document where the id component matches (ignoring the domain component).
* If no matching data document can be found, a new one is created.
*
* TODO(user): Remove this method once the attachment id domain migration
* is complete.
*
* @param wavelet the wavelet within which to search for the data document.
* @param attachmentIdString the id of the attachment which forms the data
* doc id.
* @return the found or newly created data document.
* @throws InvalidIdException if an invalid attachment id is
* encountered.
*/
public static ObservableDocument getAttachmentDataDoc(Wavelet wavelet,
String attachmentIdString) throws InvalidIdException {
Preconditions.checkNotNull(attachmentIdString, "attachmentIdString must not be null");
if (attachmentIdString.startsWith(IdConstants.ATTACHMENT_METADATA_PREFIX)) {
Preconditions.illegalArgument("attachmentIdString must not start with "
+ IdConstants.ATTACHMENT_METADATA_PREFIX);
}
Set<String> documentIds = wavelet.getDocumentIds();
String attachDataDocId;
// First, search for a data doc that matches the id.
attachDataDocId = dataDocIdFromAttachmentId(attachmentIdString);
if (documentIds.contains(attachDataDocId)) {
return wavelet.getDocument(attachDataDocId);
}
// Second, strip off the domain component and look for pre-domain ids.
AttachmentId attachmentId = AttachmentId.deserialise(attachmentIdString);
attachDataDocId = dataDocIdFromAttachmentId(attachmentId.getId());
if (documentIds.contains(attachDataDocId)) {
return wavelet.getDocument(attachDataDocId);
}
// Third, check all attachment data docs where the id component matches.
for (String documentId : documentIds) {
if (IdUtil.isAttachmentDataDocument(documentId)) {
String[] docIdComponents = IdUtil.split(documentId);
if (docIdComponents != null && docIdComponents.length == 2) {
AttachmentId docAttachmentId = AttachmentId.deserialise(docIdComponents[1]);
if (docAttachmentId.getId().equals(attachmentId.getId())) {
return wavelet.getDocument(documentId);
}
} else {
// Using NOP logger as model package contains no dependencies.
LoggerBundle.NOP_IMPL.error().log("AttachmentDataDocHelper: Can't parse the" +
"attachment data doc id - " + documentId);
}
}
}
// Otherwise, create the data document for the given id.
attachDataDocId = dataDocIdFromAttachmentId(attachmentIdString);
return wavelet.getDocument(attachDataDocId);
}
示例8: toWaveletData
import org.waveprotocol.wave.model.wave.Wavelet; //导入方法依赖的package包/类
@Override
public WaveletData toWaveletData(Wavelet wavelet, Conversation conversation,
EventMessageBundle eventMessageBundle) {
final WaveletData waveletData = new WaveletData();
waveletData.setCreationTime(wavelet.getCreationTime());
waveletData.setCreator(wavelet.getCreatorId().getAddress());
waveletData.setWaveId(ApiIdSerializer.instance().serialiseWaveId(wavelet.getWaveId()));
waveletData.setWaveletId(ApiIdSerializer.instance().serialiseWaveletId(wavelet.getId()));
waveletData.setLastModifiedTime(wavelet.getLastModifiedTime());
waveletData.setParticipants(idsToParticipantIdList(wavelet.getParticipantIds()));
waveletData.setRootBlipId(conversation.getRootThread().getFirstBlip().getId());
waveletData.setTitle(getTitle(wavelet, conversation));
waveletData.setVersion(wavelet.getVersion());
// Add Data Docs. All data documents are silently name spaced under the
// robot prefix to avoid conflicts. Any docId containing a '+' will be
// ignored for now.
for (String documentId : wavelet.getDocumentIds()) {
if (IdUtil.isRobotDocId(documentId)) {
String[] parts = IdUtil.split(documentId);
if (parts.length == 2) {
Document document = wavelet.getDocument(documentId);
String val = XmlStringBuilder.innerXml(document).getXmlString();
waveletData.setDataDocument(parts[1], val);
}
}
}
// Add the tags.
if (wavelet.getDocument(IdConstants.TAGS_DOCUMENT_ID) != null) {
@SuppressWarnings({"unchecked", "rawtypes"})
TagsDocument tags = new TagsDocument(wavelet.getDocument(IdConstants.TAGS_DOCUMENT_ID));
tags.addListener(new TagsDocument.Listener() {
@Override
public void onAdd(String tagName) {
waveletData.addTag(tagName);
}
@Override
public void onRemove(int tagPosition) {
// Not called.
}});
tags.processInitialState();
}
// Add the participant roles.
ObservableDocument rolesDocument = wavelet.getDocument(IdConstants.ROLES_DATA_DOC_ID);
if (rolesDocument != null) {
DocumentBasedRoles roles = DocumentBasedRoles.create(rolesDocument);
for (ParticipantId participantId : wavelet.getParticipantIds()) {
waveletData.setParticipantRole(participantId.getAddress(),
roles.getRole(participantId).name());
}
}
return waveletData;
}
示例9: addTags
import org.waveprotocol.wave.model.wave.Wavelet; //导入方法依赖的package包/类
private void addTags(Wavelet wavelet) {
wavelet.getDocument(IdUtil.TAGS_DOCUMENT_ID);
}
示例10: getAttachmentDataDoc
import org.waveprotocol.wave.model.wave.Wavelet; //导入方法依赖的package包/类
/**
* Locates an attachment data doc for a given attachment id within a wavelet.
* First, it looks for an attachment data doc that matches the fully
* qualified id. If that cannot be found, it looks for any attachment data
* document where the id component matches (ignoring the domain component).
* If no matching data document can be found, a new one is created.
*
* TODO(user): Remove this method once the attachment id domain migration
* is complete.
*
* @param wavelet the wavelet within which to search for the data document.
* @param attachmentIdString the id of the attachment which forms the data
* doc id.
* @return the found or newly created data document.
* @throws InvalidIdException if an invalid attachment id is
* encountered.
*/
public static ObservableDocument getAttachmentDataDoc(Wavelet wavelet,
String attachmentIdString) throws InvalidIdException {
Preconditions.checkNotNull(attachmentIdString, "attachmentIdString must not be null");
if (attachmentIdString.startsWith(IdConstants.ATTACHMENT_METADATA_PREFIX)) {
Preconditions.illegalArgument("attachmentIdString must not start with "
+ IdConstants.ATTACHMENT_METADATA_PREFIX);
}
Set<String> documentIds = wavelet.getDocumentIds();
String attachDataDocId = null;
// First, search for a data doc that matches the id.
attachDataDocId = dataDocIdFromAttachmentId(attachmentIdString);
if (documentIds.contains(attachDataDocId)) {
return wavelet.getDocument(attachDataDocId);
}
// Second, strip off the domain component and look for pre-domain ids.
AttachmentId attachmentId = AttachmentId.deserialise(attachmentIdString);
attachDataDocId = dataDocIdFromAttachmentId(attachmentId.getId());
if (documentIds.contains(attachDataDocId)) {
return wavelet.getDocument(attachDataDocId);
}
// Third, check all attachment data docs where the id component matches.
for (String documentId : documentIds) {
if (IdUtil.isAttachmentDataDocument(documentId)) {
String[] docIdComponents = IdUtil.split(documentId);
if (docIdComponents != null && docIdComponents.length == 2) {
AttachmentId docAttachmentId = AttachmentId.deserialise(docIdComponents[1]);
if (docAttachmentId.getId().equals(attachmentId.getId())) {
return wavelet.getDocument(documentId);
}
} else {
// Using NOP logger as model package contains no dependencies.
LoggerBundle.NOP_IMPL.error().log("AttachmentDataDocHelper: Can't parse the" +
"attachment data doc id - " + documentId);
}
}
}
// Otherwise, create the data document for the given id.
attachDataDocId = dataDocIdFromAttachmentId(attachmentIdString);
return wavelet.getDocument(attachDataDocId);
}
示例11: toWaveletData
import org.waveprotocol.wave.model.wave.Wavelet; //导入方法依赖的package包/类
@Override
public WaveletData toWaveletData(Wavelet wavelet, Conversation conversation,
EventMessageBundle eventMessageBundle) {
final WaveletData waveletData = new WaveletData();
waveletData.setCreationTime(wavelet.getCreationTime());
waveletData.setCreator(wavelet.getCreatorId().getAddress());
waveletData.setWaveId(ApiIdSerializer.instance().serialiseWaveId(wavelet.getWaveId()));
waveletData.setWaveletId(ApiIdSerializer.instance().serialiseWaveletId(wavelet.getId()));
waveletData.setLastModifiedTime(wavelet.getLastModifiedTime());
waveletData.setParticipants(idsToParticipantIdList(wavelet.getParticipantIds()));
waveletData.setRootBlipId(conversation.getRootThread().getFirstBlip().getId());
waveletData.setTitle(getTitle(wavelet, conversation));
waveletData.setVersion(wavelet.getVersion());
// Add Data Docs. All data documents are silently name spaced under the
// robot prefix to avoid conflicts. Any docId containing a '+' will be
// ignored for now.
for (String documentId : wavelet.getDocumentIds()) {
if (IdUtil.isRobotDocId(documentId)) {
String[] parts = IdUtil.split(documentId);
if (parts.length == 2) {
Document document = wavelet.getDocument(documentId);
String val = XmlStringBuilder.innerXml(document).getXmlString();
waveletData.setDataDocument(parts[1], val);
}
}
}
// Add the tags.
if (wavelet.getDocument(IdConstants.TAGS_DOC_ID) != null) {
@SuppressWarnings({"unchecked", "rawtypes"})
TagsDocument tags = new TagsDocument(wavelet.getDocument(IdConstants.TAGS_DOC_ID));
tags.addListener(new TagsDocument.Listener() {
@Override
public void onAdd(String tagName) {
waveletData.addTag(tagName);
}
@Override
public void onRemove(int tagPosition) {
// Not called.
}});
tags.processInitialState();
}
// Add the participant roles.
ObservableDocument rolesDocument = wavelet.getDocument(IdConstants.ROLES_DATA_DOC_ID);
if (rolesDocument != null) {
DocumentBasedRoles roles = DocumentBasedRoles.create(rolesDocument);
for (ParticipantId participantId : wavelet.getParticipantIds()) {
waveletData.setParticipantRole(participantId.getAddress(),
roles.getRole(participantId).name());
}
}
return waveletData;
}
示例12: addTags
import org.waveprotocol.wave.model.wave.Wavelet; //导入方法依赖的package包/类
private void addTags(Wavelet wavelet) {
wavelet.getDocument(IdUtil.TAGS_DOC_ID);
}