本文整理了Java中org.modeshape.schematic.document.Document.fields()
方法的一些代码示例,展示了Document.fields()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Document.fields()
方法的具体详情如下:
包路径:org.modeshape.schematic.document.Document
类名称:Document
方法名:fields
[英]Obtain an iterator over the Fields in this object.
[中]获取此对象中字段的迭代器。
代码示例来源:origin: org.modeshape/modeshape-schematic
protected void write( Document bson,
Writer writer ) throws IOException {
writer.append('{').append(' ');
Iterator<Field> iter = bson.fields().iterator();
if (iter.hasNext()) {
write(iter.next(), writer);
writer.append(' ');
while (iter.hasNext()) {
writer.append(',').append(' ');
write(iter.next(), writer);
writer.append(' ');
}
}
writer.append('}');
}
代码示例来源:origin: ModeShape/modeshape
protected void write( Document bson,
Writer writer ) throws IOException {
writer.append('{').append(' ');
Iterator<Field> iter = bson.fields().iterator();
if (iter.hasNext()) {
write(iter.next(), writer);
writer.append(' ');
while (iter.hasNext()) {
writer.append(',').append(' ');
write(iter.next(), writer);
writer.append(' ');
}
}
writer.append('}');
}
代码示例来源:origin: ModeShape/modeshape
@Override
public Map<String, Object> getIndexProperties() {
if (properties == null) {
// Read in the properties ...
properties = new HashMap<>();
for (Field field : doc.fields()) {
if (INDEX_PROVIDER_FIELDS.contains(field.getName())) continue;
properties.put(field.getName(), field.getValue());
}
}
return properties;
}
代码示例来源:origin: org.fcrepo/modeshape-jcr
@Override
public Map<String, Object> getIndexProperties() {
if (properties == null) {
// Read in the properties ...
properties = new HashMap<>();
for (Field field : doc.fields()) {
if (INDEX_PROVIDER_FIELDS.contains(field.getName())) continue;
properties.put(field.getName(), field.getValue());
}
}
return properties;
}
代码示例来源:origin: ModeShape/modeshape
public boolean hasProperties( Document document ) {
// Get the properties container ...
Document properties = document.getDocument(PROPERTIES);
if (properties == null) {
return false;
}
for (Field nsField : properties.fields()) {
Document urlProps = nsField.getValueAsDocument();
if (urlProps != null) {
for (Field propField : urlProps.fields()) {
if (!Null.matches(propField.getValue())) {
return true;
}
}
}
}
return false;
}
代码示例来源:origin: ModeShape/modeshape
public int countProperties( Document document ) {
// Get the properties container ...
Document properties = document.getDocument(PROPERTIES);
if (properties == null) {
return 0;
}
int count = 0;
for (Field nsField : properties.fields()) {
Document urlProps = nsField.getValueAsDocument();
if (urlProps != null) {
for (Field propField : urlProps.fields()) {
if (!Null.matches(propField.getValue())) {
++count;
}
}
}
}
return count;
}
代码示例来源:origin: org.fcrepo/modeshape-jcr
public boolean hasProperties( Document document ) {
// Get the properties container ...
Document properties = document.getDocument(PROPERTIES);
if (properties == null) {
return false;
}
for (Field nsField : properties.fields()) {
Document urlProps = nsField.getValueAsDocument();
if (urlProps != null) {
for (Field propField : urlProps.fields()) {
if (!Null.matches(propField.getValue())) {
return true;
}
}
}
}
return false;
}
代码示例来源:origin: org.fcrepo/modeshape-jcr
public int countProperties( Document document ) {
// Get the properties container ...
Document properties = document.getDocument(PROPERTIES);
if (properties == null) {
return 0;
}
int count = 0;
for (Field nsField : properties.fields()) {
Document urlProps = nsField.getValueAsDocument();
if (urlProps != null) {
for (Field propField : urlProps.fields()) {
if (!Null.matches(propField.getValue())) {
++count;
}
}
}
}
return count;
}
代码示例来源:origin: org.modeshape/modeshape-schematic
@Override
protected void doSetAllValues( Document values ) {
if (values != null && !values.isEmpty()) {
for (Field field : values.fields()) {
doSetValue(field.getName(), field.getValue());
}
}
}
代码示例来源:origin: ModeShape/modeshape
@Override
protected void doSetAllValues( Document values ) {
if (values != null && !values.isEmpty()) {
for (Field field : values.fields()) {
doSetValue(field.getName(), field.getValue());
}
}
}
代码示例来源:origin: ModeShape/modeshape
private int countFields( Document doc ) {
int fieldCount = 0;
for (Document.Field field : doc.fields()) {
assertThat(field, is(notNullValue()));
fieldCount++;
}
return fieldCount;
}
代码示例来源:origin: org.modeshape/modeshape-schematic
@Override
public boolean containsAll( Document document ) {
if (document == null) {
return true;
}
for (Field field : document.fields()) {
Object thisValue = this.get(field.getName());
Object thatValue = field.getValue();
if (!BsonUtils.valuesAreEqual(thisValue, thatValue)) {
return false;
}
}
return true;
}
代码示例来源:origin: ModeShape/modeshape
@Override
public boolean containsAll( Document document ) {
if (document == null) {
return true;
}
for (Field field : document.fields()) {
Object thisValue = this.get(field.getName());
Object thatValue = field.getValue();
if (!BsonUtils.valuesAreEqual(thisValue, thatValue)) {
return false;
}
}
return true;
}
代码示例来源:origin: ModeShape/modeshape
protected Map<String, Object> createJacksonData( Document document ) {
Map<String, Object> data = new LinkedHashMap<String, Object>();
for (Document.Field field : document.fields()) {
Object value = field.getValue();
data.put(field.getName(), createJacksonData(value));
}
return data;
}
代码示例来源:origin: ModeShape/modeshape
@Override
public boolean containsAll( Document document ) {
if (document instanceof Array) {
return containsAll((List<?>)document);
}
if (document != null) {
for (Field field : document.fields()) {
Object thisValue = get(field.getName());
Object thatValue = field.getValue();
if (!BsonUtils.valuesAreEqual(thisValue, thatValue)) {
return false;
}
}
}
return true;
}
代码示例来源:origin: org.modeshape/modeshape-schematic
@Override
public boolean containsAll( Document document ) {
if (document instanceof Array) {
return containsAll((List<?>)document);
}
if (document != null) {
for (Field field : document.fields()) {
Object thisValue = get(field.getName());
Object thatValue = field.getValue();
if (!BsonUtils.valuesAreEqual(thisValue, thatValue)) {
return false;
}
}
}
return true;
}
代码示例来源:origin: ModeShape/modeshape
protected BSONObject createMongoData( Document document ) {
BSONObject obj = new BasicBSONObject();
for (Document.Field field : document.fields()) {
Object value = field.getValue();
obj.put(field.getName(), createMongoData(value));
}
return obj;
}
代码示例来源:origin: ModeShape/modeshape
protected void write( String name,
Document document,
BsonDataOutput output ) {
if (name != null) {
output.writeByte(Type.DOCUMENT);
writeCString(name, output);
}
// Write the size for the document; we'll come back to this after we write the array ...
int arraySizePosition = output.size();
output.writeInt(-1);
for (Field field : document.fields()) {
write(field.getName(), field.getValue(), output);
}
output.writeByte(END_OF_DOCUMENT);
// Determine the number of bytes written in the array, and overwrite the value we wrote earlier ..
int arraySize = output.size() - arraySizePosition;
output.writeInt(arraySizePosition, arraySize);
}
代码示例来源:origin: ModeShape/modeshape
protected void assertMatch( Document doc1,
Document doc2 ) {
assertEquals(doc1.size(), doc2.size());
for (Document.Field field1 : doc1.fields()) {
if (field1.getValue() instanceof Document) {
assertMatch(field1.getValueAsDocument(), doc2.getDocument(field1.getName()));
} else {
Object value2 = doc2.get(field1.getName());
assertEquals(field1.getValue(), value2);
}
}
}
代码示例来源:origin: ModeShape/modeshape
protected void assertEquals( Document doc1,
Document doc2 ) {
assertTrue(doc1 != doc2);
Assert.assertEquals(doc1, doc2);
for (Field field : doc1.fields()) {
Object value2 = doc2.get(field.getName());
Assert.assertEquals(value2, field.getValue());
if (value2 instanceof Array) {
assertTrue(value2 != field.getValue());
assertEquals((Array)field.getValue(), (Array)value2);
} else if (value2 instanceof Document) {
assertTrue(value2 != field.getValue());
assertEquals(field.getValueAsDocument(), (Document)value2);
} else {
// The values can actually be the same instances since they're immutable ...
}
}
}
内容来源于网络,如有侵权,请联系作者删除!