本文整理了Java中org.modeshape.schematic.document.Document.containsField()
方法的一些代码示例,展示了Document.containsField()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Document.containsField()
方法的具体详情如下:
包路径:org.modeshape.schematic.document.Document
类名称:Document
方法名:containsField
[英]Checks if this object contains a field with the given name.
[中]检查此对象是否包含具有给定名称的字段。
代码示例来源:origin: org.fcrepo/modeshape-jcr
protected boolean isFederatedDocument( Document document ) {
return document.containsField(FEDERATED_SEGMENTS);
}
代码示例来源:origin: ModeShape/modeshape
protected boolean isFederatedDocument( Document document ) {
return document.containsField(FEDERATED_SEGMENTS);
}
代码示例来源:origin: ModeShape/modeshape
/**
* Reads the children of the given block and returns a {@link ChildReferences} instance.
*
* @param block a {@code non-null} {@link Document} representing a block of children
* @param allowsSNS {@code true} if the child references instance should be SNS aware, {@code false} otherwise
* @return a {@code non-null} child references instance
*/
protected ChildReferences getChildReferencesFromBlock( Document block, boolean allowsSNS ) {
if (!block.containsField(CHILDREN)) {
return ImmutableChildReferences.EMPTY_CHILD_REFERENCES;
}
return ImmutableChildReferences.create(this, block, CHILDREN, allowsSNS);
}
代码示例来源:origin: org.fcrepo/modeshape-jcr
@Override
public List<Document> getChildren() {
List<Document> children = new ArrayList<Document>();
if (!federatedDocument.containsField(DocumentTranslator.CHILDREN)) {
return children;
}
List<?> childrenArray = federatedDocument.getArray(DocumentTranslator.CHILDREN);
for (Object child : childrenArray) {
assert child instanceof Document;
children.add((Document)child);
}
return children;
}
代码示例来源:origin: ModeShape/modeshape
@Override
public List<Document> getChildren() {
List<Document> children = new ArrayList<Document>();
if (!federatedDocument.containsField(DocumentTranslator.CHILDREN)) {
return children;
}
List<?> childrenArray = federatedDocument.getArray(DocumentTranslator.CHILDREN);
for (Object child : childrenArray) {
assert child instanceof Document;
children.add((Document)child);
}
return children;
}
代码示例来源:origin: org.fcrepo/modeshape-jcr
/**
* Reads the children of the given block and returns a {@link ChildReferences} instance.
*
* @param block a {@code non-null} {@link Document} representing a block of children
* @param allowsSNS {@code true} if the child references instance should be SNS aware, {@code false} otherwise
* @return a {@code non-null} child references instance
*/
protected ChildReferences getChildReferencesFromBlock( Document block, boolean allowsSNS ) {
if (!block.containsField(CHILDREN)) {
return ImmutableChildReferences.EMPTY_CHILD_REFERENCES;
}
return ImmutableChildReferences.create(this, block, CHILDREN, allowsSNS);
}
代码示例来源:origin: org.fcrepo/modeshape-jcr
@Override
public List<String> getParentIds() {
List<String> parents = new ArrayList<String>();
if (!federatedDocument.containsField(DocumentTranslator.PARENT)) {
return parents;
}
Object parentFieldValue = federatedDocument.get(DocumentTranslator.PARENT);
if (parentFieldValue instanceof Array) {
for (Array.Entry entry : ((Array)parentFieldValue).getEntries()) {
parents.add(entry.getValue().toString());
}
} else {
parents.add(parentFieldValue.toString());
}
return parents;
}
代码示例来源:origin: ModeShape/modeshape
@Override
public List<String> getParentIds() {
List<String> parents = new ArrayList<String>();
if (!federatedDocument.containsField(DocumentTranslator.PARENT)) {
return parents;
}
Object parentFieldValue = federatedDocument.get(DocumentTranslator.PARENT);
if (parentFieldValue instanceof Array) {
for (Array.Entry entry : ((Array)parentFieldValue).getEntries()) {
parents.add(entry.getValue().toString());
}
} else {
parents.add(parentFieldValue.toString());
}
return parents;
}
代码示例来源:origin: org.fcrepo/modeshape-jcr
if (!federation.containsField(FieldName.EXTERNAL_SOURCES)) {
return projectionsByWorkspace;
for (String sourceName : externalSources.keySet()) {
Document externalSource = externalSources.getDocument(sourceName);
if (!externalSource.containsField(FieldName.PROJECTIONS)) {
continue;
代码示例来源:origin: ModeShape/modeshape
if (!federation.containsField(FieldName.EXTERNAL_SOURCES)) {
return projectionsByWorkspace;
for (String sourceName : externalSources.keySet()) {
Document externalSource = externalSources.getDocument(sourceName);
if (!externalSource.containsField(FieldName.PROJECTIONS)) {
continue;
代码示例来源:origin: ModeShape/modeshape
@Override
public LinkedHashMap<String, Name> getChildrenMap() {
LinkedHashMap<String, Name> children = new LinkedHashMap<String, Name>();
if (!federatedDocument.containsField(DocumentTranslator.CHILDREN)) {
return children;
}
List<?> childrenArray = federatedDocument.getArray(DocumentTranslator.CHILDREN);
for (Object child : childrenArray) {
assert child instanceof Document;
Document childDocument = (Document)child;
String childId = translator.getKey(childDocument);
Name childName = translator.getNameFactory().create(childDocument.get(DocumentTranslator.NAME));
children.put(childId, childName);
}
return children;
}
代码示例来源:origin: org.fcrepo/modeshape-jcr
@Override
public LinkedHashMap<String, Name> getChildrenMap() {
LinkedHashMap<String, Name> children = new LinkedHashMap<String, Name>();
if (!federatedDocument.containsField(DocumentTranslator.CHILDREN)) {
return children;
}
List<?> childrenArray = federatedDocument.getArray(DocumentTranslator.CHILDREN);
for (Object child : childrenArray) {
assert child instanceof Document;
Document childDocument = (Document)child;
String childId = translator.getKey(childDocument);
Name childName = translator.getNameFactory().create(childDocument.get(DocumentTranslator.NAME));
children.put(childId, childName);
}
return children;
}
代码示例来源:origin: ModeShape/modeshape
public ChildReferences getChildReferences( WorkspaceCache cache,
Document document ) {
Name primaryType = getPrimaryType(document);
Set<Name> mixinTypes = getMixinTypes(document);
NodeTypes nodeTypes = getNodeTypes(cache);
boolean isUnorderedCollection = nodeTypes != null && nodeTypes.isUnorderedCollection(primaryType, mixinTypes);
if (isUnorderedCollection) {
return new BucketedChildReferences(document, this);
}
boolean hasChildren = document.containsField(CHILDREN);
boolean hasFederatedSegments = document.containsField(FEDERATED_SEGMENTS);
if (!hasChildren && !hasFederatedSegments) {
return ImmutableChildReferences.EMPTY_CHILD_REFERENCES;
}
boolean allowsSNS = nodeTypes == null || nodeTypes.allowsNameSiblings(primaryType, mixinTypes);
ChildReferences internalChildRefs = hasChildren ? ImmutableChildReferences.create(this, document, CHILDREN, allowsSNS) : ImmutableChildReferences.EMPTY_CHILD_REFERENCES;
ChildReferences externalChildRefs = hasFederatedSegments ? ImmutableChildReferences.create(this, document,
FEDERATED_SEGMENTS, allowsSNS) : ImmutableChildReferences.EMPTY_CHILD_REFERENCES;
// Now look at the 'childrenInfo' document for info about the next block of children ...
ChildReferencesInfo info = getChildReferencesInfo(document);
if (!hasChildren) {
return ImmutableChildReferences.create(externalChildRefs, info, cache, allowsSNS);
} else if (!hasFederatedSegments) {
return ImmutableChildReferences.create(internalChildRefs, info, cache, allowsSNS);
} else {
return ImmutableChildReferences.create(internalChildRefs, info, externalChildRefs, cache, allowsSNS);
}
}
代码示例来源:origin: org.fcrepo/modeshape-jcr
public ChildReferences getChildReferences( WorkspaceCache cache,
Document document ) {
Name primaryType = getPrimaryType(document);
Set<Name> mixinTypes = getMixinTypes(document);
NodeTypes nodeTypes = getNodeTypes(cache);
boolean isUnorderedCollection = nodeTypes != null && nodeTypes.isUnorderedCollection(primaryType, mixinTypes);
if (isUnorderedCollection) {
return new BucketedChildReferences(document, this);
}
boolean hasChildren = document.containsField(CHILDREN);
boolean hasFederatedSegments = document.containsField(FEDERATED_SEGMENTS);
if (!hasChildren && !hasFederatedSegments) {
return ImmutableChildReferences.EMPTY_CHILD_REFERENCES;
}
boolean allowsSNS = nodeTypes == null || nodeTypes.allowsNameSiblings(primaryType, mixinTypes);
ChildReferences internalChildRefs = hasChildren ? ImmutableChildReferences.create(this, document, CHILDREN, allowsSNS) : ImmutableChildReferences.EMPTY_CHILD_REFERENCES;
ChildReferences externalChildRefs = hasFederatedSegments ? ImmutableChildReferences.create(this, document,
FEDERATED_SEGMENTS, allowsSNS) : ImmutableChildReferences.EMPTY_CHILD_REFERENCES;
// Now look at the 'childrenInfo' document for info about the next block of children ...
ChildReferencesInfo info = getChildReferencesInfo(document);
if (!hasChildren) {
return ImmutableChildReferences.create(externalChildRefs, info, cache, allowsSNS);
} else if (!hasFederatedSegments) {
return ImmutableChildReferences.create(internalChildRefs, info, cache, allowsSNS);
} else {
return ImmutableChildReferences.create(internalChildRefs, info, externalChildRefs, cache, allowsSNS);
}
}
代码示例来源:origin: org.fcrepo/modeshape-jcr
/**
* Removes the repository info document, in case the repository has not yet been initialized (as indicated by the presence of
* the #REPOSITORY_INITIALIZED_AT_FIELD_NAME field). This should only be used during repository startup, in case an unexpected
* error occurs.
*/
public final void rollbackRepositoryInfo() {
SchematicEntry repositoryInfoEntry = this.documentStore.localStore().get(REPOSITORY_INFO_KEY);
if (repositoryInfoEntry != null && initializingRepository) {
localStore().runInTransaction(() -> {
Document repoInfoDoc = repositoryInfoEntry.content();
// we should only remove the repository info if it wasn't initialized successfully previously
// in a cluster, it may happen that another node finished initialization while this node crashed (in which case we
// should not remove the entry)
if (!repoInfoDoc.containsField(REPOSITORY_INITIALIZED_AT_FIELD_NAME)) {
this.documentStore.localStore().remove(REPOSITORY_INFO_KEY);
}
return null;
}, 0, REPOSITORY_INFO_KEY);
}
}
代码示例来源:origin: ModeShape/modeshape
/**
* Removes the repository info document, in case the repository has not yet been initialized (as indicated by the presence of
* the #REPOSITORY_INITIALIZED_AT_FIELD_NAME field). This should only be used during repository startup, in case an unexpected
* error occurs.
*/
public final void rollbackRepositoryInfo() {
SchematicEntry repositoryInfoEntry = this.documentStore.localStore().get(REPOSITORY_INFO_KEY);
if (repositoryInfoEntry != null && initializingRepository) {
localStore().runInTransaction(() -> {
Document repoInfoDoc = repositoryInfoEntry.content();
// we should only remove the repository info if it wasn't initialized successfully previously
// in a cluster, it may happen that another node finished initialization while this node crashed (in which case we
// should not remove the entry)
if (!repoInfoDoc.containsField(REPOSITORY_INITIALIZED_AT_FIELD_NAME)) {
this.documentStore.localStore().remove(REPOSITORY_INFO_KEY);
}
return null;
}, 0, REPOSITORY_INFO_KEY);
}
}
代码示例来源:origin: ModeShape/modeshape
protected void assertInfo( String key,
long expectedChildCount,
String expectedNextBlock,
String expectedLastBlock,
boolean firstBlock,
long expectedBlockSize ) {
Document doc = workspaceCache.documentStore().get(key).content();
Document info = doc.getDocument(DocumentTranslator.CHILDREN_INFO);
assertThat(info.getLong(DocumentTranslator.COUNT), is(expectedChildCount));
assertThat(info.getString(DocumentTranslator.NEXT_BLOCK), is(expectedNextBlock));
assertThat(info.getString(DocumentTranslator.LAST_BLOCK), is(expectedLastBlock));
if (firstBlock) {
assertThat(info.containsField(DocumentTranslator.BLOCK_SIZE), is(expectedNextBlock != null));
} else {
assertThat(info.getLong(DocumentTranslator.BLOCK_SIZE), is(expectedBlockSize));
}
}
}
代码示例来源:origin: ModeShape/modeshape
initializingRepository = initializerId.equals(content.getString(REPOSITORY_INITIALIZER_FIELD_NAME)) &&
creationDate.equals(content.getDate(REPOSITORY_CREATED_AT_FIELD_NAME));
if (initializingRepository || content.containsField(REPOSITORY_INITIALIZED_AT_FIELD_NAME)) {
persistedInitializerInfo.content().containsField(REPOSITORY_INITIALIZED_AT_FIELD_NAME);
}, 10, TimeUnit.MINUTES, JcrI18n.repositoryWasNeverInitializedAfterMinutes);
代码示例来源:origin: org.fcrepo/modeshape-jcr
initializingRepository = initializerId.equals(content.getString(REPOSITORY_INITIALIZER_FIELD_NAME)) &&
creationDate.equals(content.getDate(REPOSITORY_CREATED_AT_FIELD_NAME));
if (initializingRepository || content.containsField(REPOSITORY_INITIALIZED_AT_FIELD_NAME)) {
persistedInitializerInfo.content().containsField(REPOSITORY_INITIALIZED_AT_FIELD_NAME);
}, 10, TimeUnit.MINUTES, JcrI18n.repositoryWasNeverInitializedAfterMinutes);
内容来源于网络,如有侵权,请联系作者删除!