本文整理了Java中org.modeshape.schematic.document.Document.getArray()
方法的一些代码示例,展示了Document.getArray()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Document.getArray()
方法的具体详情如下:
包路径:org.modeshape.schematic.document.Document
类名称:Document
方法名:getArray
[英]Get the array value in this document for the given field name.
[中]获取此文档中给定字段名的数组值。
代码示例来源:origin: ModeShape/modeshape
/**
* Returns a list with the cnd files which should be loaded at startup.
*
* @return a {@code non-null} string list
*/
public List<String> getNodeTypes() {
List<String> result = new ArrayList<String>();
List<?> configuredNodeTypes = doc.getArray(FieldName.NODE_TYPES);
if (configuredNodeTypes != null) {
for (Object configuredNodeType : configuredNodeTypes) {
result.add(configuredNodeType.toString());
}
}
return result;
}
代码示例来源:origin: org.fcrepo/modeshape-jcr
/**
* Returns a list with the cnd files which should be loaded at startup.
*
* @return a {@code non-null} string list
*/
public List<String> getNodeTypes() {
List<String> result = new ArrayList<String>();
List<?> configuredNodeTypes = doc.getArray(FieldName.NODE_TYPES);
if (configuredNodeTypes != null) {
for (Object configuredNodeType : configuredNodeTypes) {
result.add(configuredNodeType.toString());
}
}
return result;
}
代码示例来源:origin: ModeShape/modeshape
/**
* Get the name of the ModeShape authorization roles that each anonymous user should be assigned.
*
* @return the set of role names; never null or empty, and '{@value Default#ANONYMOUS_ROLES}' by default.
*/
public Set<String> getAnonymousRoles() {
Set<String> names = new HashSet<String>();
Collection<?> roles = anonymous.getArray(FieldName.ANONYMOUS_ROLES);
if (roles == null) roles = Default.ANONYMOUS_ROLES;
if (roles != null) {
for (Object value : roles) {
if (value instanceof String) {
names.add(((String)value).trim().toLowerCase());
}
}
}
return names;
}
代码示例来源: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: org.fcrepo/modeshape-jcr
/**
* Get the name of the ModeShape authorization roles that each anonymous user should be assigned.
*
* @return the set of role names; never null or empty, and '{@value Default#ANONYMOUS_ROLES}' by default.
*/
public Set<String> getAnonymousRoles() {
Set<String> names = new HashSet<String>();
Collection<?> roles = anonymous.getArray(FieldName.ANONYMOUS_ROLES);
if (roles == null) roles = Default.ANONYMOUS_ROLES;
if (roles != null) {
for (Object value : roles) {
if (value instanceof String) {
names.add(((String)value).trim().toLowerCase());
}
}
}
return names;
}
代码示例来源: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: ModeShape/modeshape
/**
* Obtain the names of the workspaces that were listed as being predefined. This includes the name
* {@link #getDefaultWorkspaceName() default workspace}.
*
* @return the set of predefined (non-system) workspace names; never null
*/
public Set<String> getPredefinedWorkspaceNames() {
Set<String> names = new HashSet<String>();
Document workspaces = doc.getDocument(FieldName.WORKSPACES);
if (workspaces != null) {
List<?> predefined = workspaces.getArray(FieldName.PREDEFINED);
if (predefined != null) {
for (Object value : predefined) {
if (value instanceof String) names.add((String)value);
}
}
}
names.add(getDefaultWorkspaceName());
return names;
}
代码示例来源:origin: org.fcrepo/modeshape-jcr
/**
* Obtain the names of the workspaces that were listed as being predefined. This includes the name
* {@link #getDefaultWorkspaceName() default workspace}.
*
* @return the set of predefined (non-system) workspace names; never null
*/
public Set<String> getPredefinedWorkspaceNames() {
Set<String> names = new HashSet<String>();
Document workspaces = doc.getDocument(FieldName.WORKSPACES);
if (workspaces != null) {
List<?> predefined = workspaces.getArray(FieldName.PREDEFINED);
if (predefined != null) {
for (Object value : predefined) {
if (value instanceof String) names.add((String)value);
}
}
}
names.add(getDefaultWorkspaceName());
return names;
}
代码示例来源:origin: ModeShape/modeshape
protected BucketedChildReferences( Document parent, DocumentTranslator translator ) {
// the power of 16 which indicates how many buckets
this.bucketIdLength = parent.getInteger(DocumentConstants.BUCKET_ID_LENGTH);
Long size = parent.getLong(DocumentConstants.SIZE);
this.size = size != null ? size : 0;
this.parentKey = translator.getKey(parent);
this.translator = translator;
List<?> bucketsArray = parent.getArray(DocumentConstants.BUCKETS);
if (bucketsArray == null) {
this.bucketIds = Collections.emptySet();
} else {
this.bucketIds = new HashSet<>(bucketsArray.size());
for (Object bucketId : bucketsArray) {
this.bucketIds.add(new BucketId(bucketId.toString()));
}
}
this.rangeBucketsById = new LinkedHashMap<>(bucketIds.size());
}
代码示例来源:origin: org.fcrepo/modeshape-jcr
protected BucketedChildReferences( Document parent, DocumentTranslator translator ) {
// the power of 16 which indicates how many buckets
this.bucketIdLength = parent.getInteger(DocumentConstants.BUCKET_ID_LENGTH);
Long size = parent.getLong(DocumentConstants.SIZE);
this.size = size != null ? size : 0;
this.parentKey = translator.getKey(parent);
this.translator = translator;
List<?> bucketsArray = parent.getArray(DocumentConstants.BUCKETS);
if (bucketsArray == null) {
this.bucketIds = Collections.emptySet();
} else {
this.bucketIds = new HashSet<>(bucketsArray.size());
for (Object bucketId : bucketsArray) {
this.bucketIds.add(new BucketId(bucketId.toString()));
}
}
this.rangeBucketsById = new LinkedHashMap<>(bucketIds.size());
}
代码示例来源:origin: org.modeshape/modeshape-schematic
protected void addValidatorsForEnum( Document parent,
Path parentPath,
Problems problems,
CompositeValidator validators ) {
List<?> enumValues = parent.getArray("enum");
if (enumValues != null && !enumValues.isEmpty()) {
String requiredName = parentPath.getLast();
if (requiredName != null) {
validators.add(new EnumValidator(requiredName, enumValues));
}
}
}
代码示例来源:origin: ModeShape/modeshape
protected void addValidatorsForEnum( Document parent,
Path parentPath,
Problems problems,
CompositeValidator validators ) {
List<?> enumValues = parent.getArray("enum");
if (enumValues != null && !enumValues.isEmpty()) {
String requiredName = parentPath.getLast();
if (requiredName != null) {
validators.add(new EnumValidator(requiredName, enumValues));
}
}
}
代码示例来源: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
/**
* Get the configuration information for the anonymous authentication provider.
*
* @return the anonymous provider configuration information; null if anonymous users are not allowed
*/
public AnonymousSecurity getAnonymous() {
Document anonymous = security.getDocument(FieldName.ANONYMOUS);
if (anonymous != null && anonymous.size() == 1) {
// Check the 'roleNames' field ...
List<?> roles = anonymous.getArray(FieldName.ANONYMOUS_ROLES);
if (roles != null && roles.isEmpty()) {
// Specified empty roles, so this is disabling anonymous logins ...
return null;
}
}
if (anonymous == null) anonymous = Schematic.newDocument();
return new AnonymousSecurity(anonymous);
}
代码示例来源:origin: org.fcrepo/modeshape-jcr
/**
* Get the configuration information for the anonymous authentication provider.
*
* @return the anonymous provider configuration information; null if anonymous users are not allowed
*/
public AnonymousSecurity getAnonymous() {
Document anonymous = security.getDocument(FieldName.ANONYMOUS);
if (anonymous != null && anonymous.size() == 1) {
// Check the 'roleNames' field ...
List<?> roles = anonymous.getArray(FieldName.ANONYMOUS_ROLES);
if (roles != null && roles.isEmpty()) {
// Specified empty roles, so this is disabling anonymous logins ...
return null;
}
}
if (anonymous == null) anonymous = Schematic.newDocument();
return new AnonymousSecurity(anonymous);
}
代码示例来源:origin: ModeShape/modeshape
protected void assertChildren( Document doc,
Segment... children ) {
List<?> childReferences = doc.getArray(DocumentTranslator.CHILDREN);
Iterator<?> actualIter = childReferences.iterator();
Iterator<Segment> expectedIter = Arrays.asList(children).iterator();
while (actualIter.hasNext()) {
ChildReference childRef = workspaceCache.translator().childReferenceFrom(actualIter.next());
if (!expectedIter.hasNext()) {
fail("Found \"" + childRef + "\" but not expecting any children");
}
Segment expectedName = expectedIter.next();
assertThat("Expecting child \"" + expectedName + "\" but found \"" + childRef.toString() + "\"",
childRef.getSegment(), is(expectedName));
}
if (expectedIter.hasNext()) {
fail("Expected \"" + expectedIter.next() + "\" but found no such child");
}
}
代码示例来源:origin: ModeShape/modeshape
protected void assertChildren( Document doc,
Name... children ) {
List<?> childReferences = doc.getArray(DocumentTranslator.CHILDREN);
Iterator<?> actualIter = childReferences.iterator();
Iterator<Name> expectedIter = Arrays.asList(children).iterator();
while (actualIter.hasNext()) {
ChildReference childRef = workspaceCache.translator().childReferenceFrom(actualIter.next());
if (!expectedIter.hasNext()) {
fail("Found \"" + childRef + "\" but not expecting any children");
}
Name expectedName = expectedIter.next();
assertThat("Expecting child \"" + expectedName + "[1]\" but found \"" + childRef.toString() + "\"",
childRef.getSegment(), is(segment(expectedName, 1)));
}
if (expectedIter.hasNext()) {
fail("Expected \"" + expectedIter.next() + "\" but found no such child");
}
}
代码示例来源:origin: ModeShape/modeshape
@Test
public void multipleWritersShouldBeExclusivelyLockedOnTheSameKey() throws Exception {
String rootKey = "3293af3317f1e7/";
Document root = Schematic.newDocument("children", new BasicArray());
runInTransaction(() -> localStore.put(rootKey, root));
int threadCount = 150;
int childrenForEachThread = 10;
ForkJoinPool forkJoinPool = new ForkJoinPool(threadCount);
forkJoinPool.submit(() -> IntStream.range(0, threadCount).parallel().forEach(i -> insertParentWithChildren(rootKey,
childrenForEachThread)))
.get();
Document rootDoc = localStore.get(rootKey).content();
List<?> children = rootDoc.getArray("children");
assertEquals("children corrupted", threadCount * childrenForEachThread, children.size());
assertEquals(threadCount * childrenForEachThread + 1, localStore.keys().size());
}
代码示例来源:origin: ModeShape/modeshape
/**
* Reads the input stream to load the JSON data as a Document, and then loads all of the documents within the "data" array
* field into the database.
*
* @param stream the stream containing the JSON data Document
*/
protected void loadJsonDocuments( InputStream stream ) {
runInTransaction(() -> {
Document document = Json.read(stream);
List<?> data = document.getArray("data");
if (data != null) {
for (Object value : data) {
if (value instanceof Document) {
Document dataDoc = (Document) value;
// Get the key ...
Document content = dataDoc.getDocument("content");
Document metadata = dataDoc.getDocument("metadata");
String key = metadata.getString("id");
schematicDb.put(key, content);
}
}
}
return null;
});
}
内容来源于网络,如有侵权,请联系作者删除!