本文整理了Java中org.modeshape.schematic.document.Document.clone()
方法的一些代码示例,展示了Document.clone()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Document.clone()
方法的具体详情如下:
包路径:org.modeshape.schematic.document.Document
类名称:Document
方法名:clone
[英]Obtain a clone of this document.
[中]获取此文档的克隆。
代码示例来源:origin: ModeShape/modeshape
@Override
public Document execute( Repository repository,
Git git,
CallSpecification spec,
DocumentWriter writer,
Values values ) {
return root.clone(); // return a copy
}
}
代码示例来源:origin: ModeShape/modeshape
protected Document putForWriting(String id, Document doc) {
if (write.replace(id, doc) == null) {
// when storing a value for the first time, clone it for the write cache
write.putIfAbsent(id, doc.clone());
}
return write.get(id);
}
代码示例来源:origin: ModeShape/modeshape
protected Object cloneValue( Object value ) {
if (value == null) return null;
if (value instanceof Document) return ((Document)value).clone();
if (value instanceof Collection) {
Collection<?> original = (Collection<?>)value;
Collection<Object> copy = original.stream().map(this::cloneValue).collect(Collectors.toList());
return copy;
}
// everything else should be immutable ...
return value;
}
代码示例来源:origin: org.modeshape/modeshape-schematic
protected Object cloneValue( Object value ) {
if (value == null) return null;
if (value instanceof Document) return ((Document)value).clone();
if (value instanceof Collection) {
Collection<?> original = (Collection<?>)value;
Collection<Object> copy = original.stream().map(this::cloneValue).collect(Collectors.toList());
return copy;
}
// everything else should be immutable ...
return value;
}
代码示例来源:origin: org.fcrepo/modeshape-jcr
/**
* Create a copy of this configuration that uses the supplied environment.
*
* @param environment the environment that should be used for the repository; may be null
* @return the new configuration; never null
*/
public RepositoryConfiguration with( Environment environment ) {
return new RepositoryConfiguration(doc.clone(), docName, environment);
}
代码示例来源:origin: org.fcrepo/modeshape-jcr
/**
* Create a copy of this configuration that uses the supplied document name.
*
* @param docName the new document name; may be null
* @return the new configuration; never null
*/
public RepositoryConfiguration withName( String docName ) {
return new RepositoryConfiguration(doc.clone(), docName, environment);
}
代码示例来源:origin: ModeShape/modeshape
/**
* Create a copy of this configuration that uses the supplied environment.
*
* @param environment the environment that should be used for the repository; may be null
* @return the new configuration; never null
*/
public RepositoryConfiguration with( Environment environment ) {
return new RepositoryConfiguration(doc.clone(), docName, environment);
}
代码示例来源:origin: ModeShape/modeshape
/**
* Create a copy of this configuration that uses the supplied document name.
*
* @param docName the new document name; may be null
* @return the new configuration; never null
*/
public RepositoryConfiguration withName( String docName ) {
return new RepositoryConfiguration(doc.clone(), docName, environment);
}
代码示例来源:origin: org.modeshape/modeshape-schematic
@Override
public MutableArray clone() {
BasicArray clone = new BasicArray();
for (Object value : this) {
value = unwrap(value);
if (value instanceof Array) {
value = ((Array)value).clone();
} else if (value instanceof Document) {
value = ((Document)value).clone();
}// every other kind of value is immutable
clone.addValue(value);
}
return clone;
}
代码示例来源:origin: ModeShape/modeshape
@Override
public MutableArray clone() {
BasicArray clone = new BasicArray();
for (Object value : this) {
value = unwrap(value);
if (value instanceof Array) {
value = ((Array)value).clone();
} else if (value instanceof Document) {
value = ((Document)value).clone();
}// every other kind of value is immutable
clone.addValue(value);
}
return clone;
}
代码示例来源:origin: ModeShape/modeshape
@Override
public MutableDocument clone() {
BasicDocument clone = new BasicDocument();
for (Field field : this.fields()) {
Object value = unwrap(field.getValue());
if (value instanceof Array) {
value = ((Array)value).clone();
} else if (value instanceof Document) {
value = ((Document)value).clone();
}// every other kind of value is immutable
clone.put(field.getName(), value);
}
return clone;
}
代码示例来源:origin: org.modeshape/modeshape-schematic
@Override
public MutableDocument clone() {
BasicDocument clone = new BasicDocument();
for (Field field : this.fields()) {
Object value = unwrap(field.getValue());
if (value instanceof Array) {
value = ((Array)value).clone();
} else if (value instanceof Document) {
value = ((Document)value).clone();
}// every other kind of value is immutable
clone.put(field.getName(), value);
}
return clone;
}
代码示例来源:origin: ModeShape/modeshape
@Override
public EditableDocument editContent( String key, boolean createIfMissing ) {
TransactionStore.TransactionMap<String, Document> txContent = transactionalContent(true);
Document existingTxDoc = txContent.get(key);
if (existingTxDoc == null && createIfMissing) {
existingTxDoc = SchematicEntry.create(key).source();
txContent.put(key, existingTxDoc);
}
if (existingTxDoc == null) {
return null;
}
if (!txContent.isSameTransaction(key)) {
// this transaction is processing this key for the first time, so we need to clone it
existingTxDoc = existingTxDoc.clone();
if (!txContent.trySet(key, existingTxDoc, true)) {
throw new FileProviderException("cannot write new value for the first time");
}
}
return SchematicEntry.content(existingTxDoc).editable();
}
内容来源于网络,如有侵权,请联系作者删除!