public class DocumentTranslator extends Object implements DocumentConstants
Document
instances.Modifier and Type | Class and Description |
---|---|
static class |
DocumentTranslator.ChildReferencesInfo |
BLOCK_SIZE, BUCKET_ID_LENGTH, BUCKETS, CACHEABLE_FIELD, CHILDREN, CHILDREN_INFO, COUNT, EXTERNAL_BINARY_ID_FIELD, FEDERATED_SEGMENTS, KEY, LAST_BLOCK, LENGTH, LENGTH_FIELD, NAME, NEXT_BLOCK, PARENT, PROPERTIES, QUERYABLE_FIELD, REFERENCE_COUNT, REFERENCE_FIELD, REFERRERS, SHA1, SHA1_FIELD, SIMPLE_REFERENCE_FIELD, SIZE, SOURCE_NAME_FIELD, STRONG, WEAK, WEAK_REFERENCE_FIELD
Constructor and Description |
---|
DocumentTranslator(ExecutionContext context,
DocumentStore documentStore,
long largeStringSize) |
Modifier and Type | Method and Description |
---|---|
protected void |
addChildrenToBuckets(EditableDocument parentDoc,
ChildReferences appended) |
protected void |
addFederatedSegment(EditableDocument document,
String externalNodeKey,
String name) |
protected void |
addInternalProperties(EditableDocument doc,
Map<String,Object> properties) |
void |
addPropertyValues(EditableDocument document,
Name propertyName,
boolean isMultiple,
Collection<?> values,
Set<BinaryKey> unusedBinaryKeys,
Set<BinaryKey> usedBinaryKeys) |
protected String |
bucketKey(String parentKey,
String bucketId) |
void |
changeChildren(EditableDocument document,
SessionNode.ChangedChildren changedChildren,
ChildReferences appended) |
void |
changeReferrers(EditableDocument document,
SessionNode.ReferrerChanges changes) |
protected ChildReference |
childReferenceFrom(Object value) |
int |
countProperties(Document document) |
protected void |
decrementBinaryReferenceCount(Object fieldValue,
Set<BinaryKey> unusedBinaryKeys,
Set<BinaryKey> usedBinaryKeys)
Decrement the reference count for the binary value.
|
EditableDocument |
fromChildReference(ChildReference ref) |
Set<NodeKey> |
getAdditionalParentKeys(Document document) |
ChildReferences |
getChildReferences(WorkspaceCache cache,
Document document) |
protected ChildReferences |
getChildReferencesFromBlock(Document block,
boolean allowsSNS)
Reads the children of the given block and returns a
ChildReferences instance. |
DocumentTranslator.ChildReferencesInfo |
getChildReferencesInfo(Document document) |
String |
getKey(Document document) |
Set<String> |
getMixinTypeNames(Document document) |
Set<Name> |
getMixinTypes(Document document) |
NameFactory |
getNameFactory() |
protected NodeTypes |
getNodeTypes(WorkspaceCache cache) |
NodeKey |
getParentKey(Document document,
String primaryWorkspaceKey,
String secondaryWorkspaceKey)
Obtain the preferred
key for the parent of this node. |
Name |
getPrimaryType(Document document) |
String |
getPrimaryTypeName(Document document) |
void |
getProperties(Document document,
Map<Name,Property> result) |
Property |
getProperty(Document document,
Name propertyName) |
Property |
getProperty(Document document,
String propertyName) |
PropertyFactory |
getPropertyFactory() |
ReferenceFactory |
getReferenceFactory() |
Map<NodeKey,Integer> |
getReferrerCounts(Document document,
CachedNode.ReferenceType type) |
Set<NodeKey> |
getReferrers(Document document,
CachedNode.ReferenceType type) |
ValueFactory<String> |
getStringFactory() |
boolean |
hasProperties(Document document) |
boolean |
hasProperty(Document document,
Name propertyName) |
protected void |
incrementBinaryReferenceCount(BinaryKey binaryKey,
Set<BinaryKey> unusedBinaryKeys,
Set<BinaryKey> usedBinaryKeys)
Increment the reference count for the stored binary value with the supplied SHA-1 hash.
|
protected long |
insertChildren(EditableDocument document,
Map<NodeKey,SessionNode.Insertions> insertionsByBeforeKey,
Set<NodeKey> removals,
Map<NodeKey,Name> newNames) |
protected boolean |
isCacheable(Document document) |
protected boolean |
isFederatedDocument(Document document) |
boolean |
isLocked(EditableDocument doc)
Checks if the given document is already locked
|
protected boolean |
isQueryable(Document document) |
protected String |
keyForBinaryReferenceDocument(String sha1) |
protected BucketedChildReferences.Bucket |
loadBucket(String parentKey,
org.modeshape.jcr.cache.document.BucketId bucketId) |
protected void |
persistBucketRemovalChanges(NodeKey parentKey,
Map<org.modeshape.jcr.cache.document.BucketId,Set<NodeKey>> removalsPerBucket) |
protected Map<org.modeshape.jcr.cache.document.BucketId,Set<NodeKey>> |
preRemoveChildrenFromBuckets(WorkspaceCache wsCache,
EditableDocument parentDoc,
Set<NodeKey> removals) |
protected Property |
propertyFor(Name propertyName,
Object fieldValue) |
protected void |
removeAllBucketsFromUnorderedCollection(NodeKey parentDocKey) |
protected void |
removeFederatedSegments(EditableDocument federatedDocument,
Set<String> externalNodeKeys) |
protected void |
removeInteralProperties(EditableDocument doc,
Set<String> properties) |
Property |
removeProperty(EditableDocument document,
Name propertyName,
Set<BinaryKey> unusedBinaryKeys,
Set<BinaryKey> usedBinaryKeys) |
void |
removePropertyValues(EditableDocument document,
Name propertyName,
Collection<?> values,
Set<BinaryKey> unusedBinaryKeys,
Set<BinaryKey> usedBinaryKeys) |
protected List<Path.Segment> |
segmentsFrom(List<?> segmentValues) |
void |
setCacheable(EditableDocument document,
boolean cacheable)
Marks the given document as cacheable, by setting a flag.
|
void |
setKey(EditableDocument document,
NodeKey key) |
void |
setKey(EditableDocument document,
String key) |
void |
setParents(EditableDocument document,
NodeKey parent,
NodeKey oldParent,
SessionNode.ChangedAdditionalParents additionalParents) |
void |
setProperty(EditableDocument document,
Property property,
Set<BinaryKey> unusedBinaryKeys,
Set<BinaryKey> usedBinaryKeys) |
void |
setQueryable(EditableDocument document,
boolean queryable)
Marks the given document as queryable, by setting a flag.
|
Object |
valueFromDocument(Object value) |
protected Object |
valueToDocument(Object value,
Set<BinaryKey> unusedBinaryKeys,
Set<BinaryKey> usedBinaryKeys) |
DocumentTranslator |
withLargeStringSize(long largeStringSize) |
public DocumentTranslator(ExecutionContext context, DocumentStore documentStore, long largeStringSize)
public DocumentTranslator withLargeStringSize(long largeStringSize)
public final ValueFactory<String> getStringFactory()
public final NameFactory getNameFactory()
public final ReferenceFactory getReferenceFactory()
public final PropertyFactory getPropertyFactory()
public NodeKey getParentKey(Document document, String primaryWorkspaceKey, String secondaryWorkspaceKey)
key
for the parent of this node. Because a node can be used in more than once place,
it may technically have more than one parent. Therefore, in such cases this method prefers the parent that is in the
primaryWorkspaceKey
and, if there is no such parent, the parent that is in the secondaryWorkspaceKey
.document
- the document for the node; may not be nullprimaryWorkspaceKey
- the key for the workspace in which the parent should preferably exist; may be nullsecondaryWorkspaceKey
- the key for the workspace in which the parent should exist if not in the primary workspace;
may be nullpublic int countProperties(Document document)
public boolean hasProperties(Document document)
public void setProperty(EditableDocument document, Property property, Set<BinaryKey> unusedBinaryKeys, Set<BinaryKey> usedBinaryKeys)
public Property removeProperty(EditableDocument document, Name propertyName, Set<BinaryKey> unusedBinaryKeys, Set<BinaryKey> usedBinaryKeys)
public void addPropertyValues(EditableDocument document, Name propertyName, boolean isMultiple, Collection<?> values, Set<BinaryKey> unusedBinaryKeys, Set<BinaryKey> usedBinaryKeys)
public void removePropertyValues(EditableDocument document, Name propertyName, Collection<?> values, Set<BinaryKey> unusedBinaryKeys, Set<BinaryKey> usedBinaryKeys)
public void setParents(EditableDocument document, NodeKey parent, NodeKey oldParent, SessionNode.ChangedAdditionalParents additionalParents)
public void setKey(EditableDocument document, NodeKey key)
public void setKey(EditableDocument document, String key)
public void changeChildren(EditableDocument document, SessionNode.ChangedChildren changedChildren, ChildReferences appended)
protected long insertChildren(EditableDocument document, Map<NodeKey,SessionNode.Insertions> insertionsByBeforeKey, Set<NodeKey> removals, Map<NodeKey,Name> newNames)
public ChildReferences getChildReferences(WorkspaceCache cache, Document document)
protected NodeTypes getNodeTypes(WorkspaceCache cache)
protected ChildReferences getChildReferencesFromBlock(Document block, boolean allowsSNS)
ChildReferences
instance.block
- a non-null
Document
representing a block of childrenallowsSNS
- true
if the child references instance should be SNS aware, false
otherwisenon-null
child references instancepublic DocumentTranslator.ChildReferencesInfo getChildReferencesInfo(Document document)
protected ChildReference childReferenceFrom(Object value)
public EditableDocument fromChildReference(ChildReference ref)
public Set<NodeKey> getReferrers(Document document, CachedNode.ReferenceType type)
public Map<NodeKey,Integer> getReferrerCounts(Document document, CachedNode.ReferenceType type)
public void changeReferrers(EditableDocument document, SessionNode.ReferrerChanges changes)
protected Object valueToDocument(Object value, Set<BinaryKey> unusedBinaryKeys, Set<BinaryKey> usedBinaryKeys)
protected void incrementBinaryReferenceCount(BinaryKey binaryKey, Set<BinaryKey> unusedBinaryKeys, Set<BinaryKey> usedBinaryKeys)
binaryKey
- the key for the binary value; never nullunusedBinaryKeys
- the set of binary keys that are considered unused; may be nullusedBinaryKeys
- the set of binary keys that are considered used; may be nullprotected void decrementBinaryReferenceCount(Object fieldValue, Set<BinaryKey> unusedBinaryKeys, Set<BinaryKey> usedBinaryKeys)
fieldValue
- the value in the document that may contain a binary value reference; may be nullunusedBinaryKeys
- the set of binary keys that are considered unused; may be nullusedBinaryKeys
- the set of binary keys that are considered used; may be nullprotected List<Path.Segment> segmentsFrom(List<?> segmentValues)
public boolean isLocked(EditableDocument doc)
doc
- the documentprotected boolean isFederatedDocument(Document document)
protected void removeFederatedSegments(EditableDocument federatedDocument, Set<String> externalNodeKeys)
protected boolean isQueryable(Document document)
public void setQueryable(EditableDocument document, boolean queryable)
document
- a EditableDocument
instance; never nullqueryable
- a boolean which indicates whether the document should be queryable or not.public void setCacheable(EditableDocument document, boolean cacheable)
document
- a EditableDocument
instance; never nullcacheable
- a boolean which indicates whether the document should be cacheable or not.protected boolean isCacheable(Document document)
protected void addFederatedSegment(EditableDocument document, String externalNodeKey, String name)
protected BucketedChildReferences.Bucket loadBucket(String parentKey, org.modeshape.jcr.cache.document.BucketId bucketId)
protected void addChildrenToBuckets(EditableDocument parentDoc, ChildReferences appended)
protected Map<org.modeshape.jcr.cache.document.BucketId,Set<NodeKey>> preRemoveChildrenFromBuckets(WorkspaceCache wsCache, EditableDocument parentDoc, Set<NodeKey> removals)
protected void persistBucketRemovalChanges(NodeKey parentKey, Map<org.modeshape.jcr.cache.document.BucketId,Set<NodeKey>> removalsPerBucket)
protected void removeAllBucketsFromUnorderedCollection(NodeKey parentDocKey)
protected void addInternalProperties(EditableDocument doc, Map<String,Object> properties)
protected void removeInteralProperties(EditableDocument doc, Set<String> properties)
Copyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.