|
ModeShape Distribution 3.0.0.Beta4 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.modeshape.jcr.cache.document.DocumentTranslator
public class DocumentTranslator
A utility class that encapsulates all the logic for reading from and writing to Document
instances.
Nested Class Summary | |
---|---|
static class |
DocumentTranslator.ChildReferencesInfo
|
Field Summary | |
---|---|
static String |
BLOCK_SIZE
|
static String |
CHILDREN
|
static String |
CHILDREN_INFO
|
static String |
COUNT
|
static String |
KEY
|
static String |
LARGE_VALUE
|
static String |
LAST_BLOCK
|
static String |
NAME
|
static String |
NEXT_BLOCK
|
static String |
PARENT
|
static String |
PROPERTIES
|
static String |
REFERENCE_COUNT
|
static String |
REFERRERS
|
static String |
SHA1
|
static String |
STRONG
|
static String |
WEAK
|
Constructor Summary | |
---|---|
DocumentTranslator(ExecutionContext context,
SchematicDb database,
long largeStringSize)
|
Method Summary | |
---|---|
void |
addPropertyValues(EditableDocument document,
Name propertyName,
boolean isMultiple,
Collection<?> values,
Set<BinaryKey> unusedBinaryKeys)
|
void |
changeChildren(NodeKey key,
EditableDocument document,
SessionNode.ChangedChildren changedChildren,
ChildReferences appended)
|
void |
changeReferrers(EditableDocument document,
SessionNode.ReferrerChanges changes)
|
protected ChildReference |
childReferenceFrom(Object value)
|
int |
countProperties(Document document)
|
protected boolean |
decrementBinaryReferenceCount(Object fieldValue,
Set<BinaryKey> unusedBinaryKeys)
Decrement the reference count for the binary value. |
EditableDocument |
fromChildReference(ChildReference ref)
|
ChildReferences |
getChildReferences(WorkspaceCache cache,
Document document)
|
DocumentTranslator.ChildReferencesInfo |
getChildReferencesInfo(Document document)
|
NodeKey |
getParentKey(Document document,
String primaryWorkspaceKey,
String secondaryWorkspaceKey)
Obtain the preferred key for the parent of this node. |
Set<NodeKey> |
getParentKeys(Document document,
String primaryWorkspaceKey,
String secondaryWorkspaceKey)
|
void |
getProperties(Document document,
Map<Name,Property> result)
|
Property |
getProperty(Document document,
Name propertyName)
|
Set<NodeKey> |
getReferrers(Document document,
CachedNode.ReferenceType type)
|
boolean |
hasProperties(Document document)
|
boolean |
hasProperty(Document document,
Name propertyName)
|
protected void |
incrementBinaryReferenceCount(BinaryKey binaryKey,
Set<BinaryKey> unusedBinaryKeys)
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)
|
boolean |
isLocked(EditableDocument doc)
Checks if the given document is already locked |
protected String |
keyForBinaryReferenceDocument(String sha1)
|
protected String |
mergeChildren(NodeKey key,
EditableDocument document,
EditableArray children,
boolean isFirst,
String nextBlock)
Modify the supplied document (with the given key) to merge in all of the children from the next block. |
protected void |
optimizeChildrenBlocks(NodeKey key,
EditableDocument document,
int targetCountPerBlock,
int tolerance)
Note that this method changes the underlying db as well as the given document, so *it must* be called either from a transactional context or it must be followed by a session.save call, otherwise there might be inconsistencies between what a session sees as "persisted" state and the reality. |
protected Property |
propertyFor(Name propertyName,
Object fieldValue)
|
Property |
removeProperty(EditableDocument document,
Name propertyName,
Set<BinaryKey> unusedBinaryKeys)
|
void |
removePropertyValues(EditableDocument document,
Name propertyName,
Collection<?> values,
Set<BinaryKey> unusedBinaryKeys)
|
protected Object |
resolveLargeValue(String sha1)
|
protected List<Path.Segment> |
segmentsFrom(List<?> segmentValues)
|
void |
setKey(EditableDocument document,
NodeKey key)
|
void |
setParents(EditableDocument document,
NodeKey parent,
NodeKey oldParent,
SessionNode.ChangedAdditionalParents additionalParents)
|
void |
setProperty(EditableDocument document,
Property property,
Set<BinaryKey> unusedBinaryKeys)
|
protected boolean |
splitChildren(NodeKey key,
EditableDocument document,
EditableArray children,
int targetCountPerBlock,
int tolerance,
boolean isFirst,
String nextBlock)
Split the children in the given document (with the given key) into two or more blocks, based upon the specified number of desired children per block and a tolerance. |
protected Object |
valueFromDocument(Object value)
|
protected Object |
valueToDocument(Object value,
Set<BinaryKey> unusedBinaryKeys)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String SHA1
public static final String PARENT
public static final String LARGE_VALUE
public static final String PROPERTIES
public static final String CHILDREN
public static final String CHILDREN_INFO
public static final String COUNT
public static final String BLOCK_SIZE
public static final String NEXT_BLOCK
public static final String LAST_BLOCK
public static final String NAME
public static final String KEY
public static final String REFERRERS
public static final String WEAK
public static final String STRONG
public static final String REFERENCE_COUNT
Constructor Detail |
---|
public DocumentTranslator(ExecutionContext context, SchematicDb database, long largeStringSize)
Method Detail |
---|
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 preferrably exist; may be nullsecondaryWorkspaceKey
- the key for the workspace in which the parent should exist if not in the primary workspace;
may be null
public Set<NodeKey> getParentKeys(Document document, String primaryWorkspaceKey, String secondaryWorkspaceKey)
public void getProperties(Document document, Map<Name,Property> result)
public int countProperties(Document document)
public boolean hasProperties(Document document)
public boolean hasProperty(Document document, Name propertyName)
public Property getProperty(Document document, Name propertyName)
protected Property propertyFor(Name propertyName, Object fieldValue)
public void setProperty(EditableDocument document, Property property, Set<BinaryKey> unusedBinaryKeys)
public Property removeProperty(EditableDocument document, Name propertyName, Set<BinaryKey> unusedBinaryKeys)
public void addPropertyValues(EditableDocument document, Name propertyName, boolean isMultiple, Collection<?> values, Set<BinaryKey> unusedBinaryKeys)
public void removePropertyValues(EditableDocument document, Name propertyName, Collection<?> values, Set<BinaryKey> unusedBinaryKeys)
public void setParents(EditableDocument document, NodeKey parent, NodeKey oldParent, SessionNode.ChangedAdditionalParents additionalParents)
public void setKey(EditableDocument document, NodeKey key)
public void changeChildren(NodeKey key, 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)
public 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 void changeReferrers(EditableDocument document, SessionNode.ReferrerChanges changes)
protected Object valueToDocument(Object value, Set<BinaryKey> unusedBinaryKeys)
protected final String keyForBinaryReferenceDocument(String sha1)
protected void incrementBinaryReferenceCount(BinaryKey binaryKey, Set<BinaryKey> unusedBinaryKeys)
binaryKey
- the key for the binary value; never nullunusedBinaryKeys
- the set of binary keys that are considered unused; may be nullprotected boolean decrementBinaryReferenceCount(Object fieldValue, Set<BinaryKey> unusedBinaryKeys)
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 null
protected Object valueFromDocument(Object value)
protected List<Path.Segment> segmentsFrom(List<?> segmentValues)
protected Object resolveLargeValue(String sha1)
protected void optimizeChildrenBlocks(NodeKey key, EditableDocument document, int targetCountPerBlock, int tolerance)
Note that this method changes the underlying db as well as the given document, so *it must* be called either from a transactional context or it must be followed by a session.save call, otherwise there might be inconsistencies between what a session sees as "persisted" state and the reality.
key
- document
- targetCountPerBlock
- tolerance
- protected boolean splitChildren(NodeKey key, EditableDocument document, EditableArray children, int targetCountPerBlock, int tolerance, boolean isFirst, String nextBlock)
Note this method returns very quickly if the method determines that there is no work to do.
Note that this method changes the underlying db as well as the given document, so *it must* be called either from a transactional context or it must be followed by a session.save call, otherwise there might be inconsistencies between what a session sees as "persisted" state and the reality.
key
- the key for the document whose children are to be split; may not be nulldocument
- the document whose children are to be split; may not be nullchildren
- the children that are to be split; may not be nulltargetCountPerBlock
- the goal for the number of children in each block; must be positivetolerance
- a tolerance that when added to and subtraced from the targetCountPerBlock
gives an acceptable
range for the number of children; must be positive but smaller than targetCountPerBlock
isFirst
- true if the supplied document is the first node document, or false if it is a block documentnextBlock
- the key for the next block of children; may be null if the supplied document is the last document and
there is no next block
protected String mergeChildren(NodeKey key, EditableDocument document, EditableArray children, boolean isFirst, String nextBlock)
Note that this method changes the underlying db as well as the given document, so *it must* be called either from a transactional context or it must be followed by a session.save call, otherwise there might be inconsistencies between what a session sees as "persisted" state and the reality.
key
- the key for the document whose children are to be merged with the next block; may not be nulldocument
- the document to be modified with the next block's children; may not be nullchildren
- the children into which are to be merged the next block's children; may not be nullisFirst
- true if the supplied document is the first node document, or false if it is a block documentnextBlock
- the key for the next block of children; may be null if the supplied document is the last document and
there is no next block
public boolean isLocked(EditableDocument doc)
doc
- the document
|
ModeShape Distribution 3.0.0.Beta4 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |