org.modeshape.schematic.document.Document.editable()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(2.3k)|赞(0)|评价(0)|浏览(99)

本文整理了Java中org.modeshape.schematic.document.Document.editable()方法的一些代码示例,展示了Document.editable()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Document.editable()方法的具体详情如下:
包路径:org.modeshape.schematic.document.Document
类名称:Document
方法名:editable

Document.editable介绍

[英]Returns an editable view of the given document. Any changes will be reflected directly in the underlying document
[中]

代码示例

代码示例来源:origin: org.fcrepo/modeshape-jcr

@Override
public EditableDocument edit( String key,
               boolean createIfMissing ) {
  if (isLocalSource(key)) {
    return localStore().edit(key, createIfMissing);
  }
  // It's federated, so we have to use the federated logic ...
  SchematicEntry entry = get(key);
  return entry != null ? entry.source().editable() : null;
}

代码示例来源:origin: ModeShape/modeshape

@Override
public EditableDocument edit( String key,
               boolean createIfMissing ) {
  if (isLocalSource(key)) {
    return localStore().edit(key, createIfMissing);
  }
  // It's federated, so we have to use the federated logic ...
  SchematicEntry entry = get(key);
  return entry != null ? entry.source().editable() : null;
}

代码示例来源:origin: ModeShape/modeshape

@Override
public EditableDocument editContent(String key, boolean createIfMissing) {
  SchematicEntry entry = getEntry(key);
  if (entry == null) {
    if (createIfMissing) {
      put(key, SchematicEntry.create(key));
    } else {
      return null;
    }
  }
  // look for an entry which was set for writing
  Document entryDocument = transactionalCaches.getForWriting(key);
  if (entryDocument == null) {
    // it's the first time we're editing this document as part of this tx so store this document for writing...
    entryDocument = transactionalCaches.putForWriting(key, entry.source());
  }
  return SchematicEntry.content(entryDocument).editable(); 
}

代码示例来源: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();
}

相关文章