public class SegmentParser extends Object
SegmentParser
serves as a base class for parsing segments.
This base class provides means for parsing segments into their various
kinds of record. Descendants typically parametrise its behaviour by
overriding the on...()
methods as needed. By default those
methods just initiate the traversal of the same named record.
A typical usage for e.g. printing out the sizes of all templates would look as follows:
new TestParser() { protected void onTemplate(RecordId parentId, RecordId templateId) { TemplateInfo templateInfo = parseTemplate(parentId, templateId); System.out.println(templateInfo.size); } }.parseNode(null, nodeId);
Modifier and Type | Class and Description |
---|---|
static class |
SegmentParser.BlobInfo
Return type of
parseBlob(RecordId) . |
static class |
SegmentParser.BlobType
Type of blobs (and strings)
|
static class |
SegmentParser.ListBucketInfo
Return type of
parseListBucket(RecordId, int, int, int) . |
static class |
SegmentParser.ListInfo
Return type of
parseList(RecordId, RecordId, int) . |
static class |
SegmentParser.MapInfo
Result type of
parseMap(RecordId, RecordId, MapRecord) . |
static class |
SegmentParser.NodeInfo
Result type of
parseNode(RecordId) . |
static class |
SegmentParser.PropertyInfo
Result type of
parseProperty(RecordId, RecordId, PropertyTemplate) . |
static class |
SegmentParser.TemplateInfo
Result type of
parseTemplate(RecordId) . |
static class |
SegmentParser.ValueInfo
Result type of
parseValue(RecordId, RecordId, Type) . |
Constructor and Description |
---|
SegmentParser(SegmentReader reader) |
Modifier and Type | Method and Description |
---|---|
protected void |
onBlob(RecordId parentId,
RecordId blobId)
Callback called by
parseValue(RecordId, RecordId, Type) upon encountering a blob. |
protected void |
onList(RecordId parentId,
RecordId listId,
int count)
Callback called by
parseNode(RecordId) ,
parseProperty(RecordId, RecordId, PropertyTemplate) ,
parseTemplate(RecordId) ,
parseBlob(RecordId) and
parseString(RecordId) upon encountering a list. |
protected void |
onListBucket(RecordId parentId,
RecordId listId,
int index,
int count,
int capacity)
Callback called by
parseList(RecordId, RecordId, int) and
parseListBucket(RecordId, int, int, int) upon encountering a list
bucket. |
protected void |
onMap(RecordId parentId,
RecordId mapId,
MapRecord map)
Callback called by
parseNode(RecordId) ,
parseMapDiff(RecordId, MapRecord) and
parseMapBranch(RecordId, MapRecord) upon encountering a map. |
protected void |
onMapBranch(RecordId parentId,
RecordId mapId,
MapRecord map)
Callback called by
parseMap(RecordId, RecordId, MapRecord) upon encountering
a map branch. |
protected void |
onMapDiff(RecordId parentId,
RecordId mapId,
MapRecord map)
Callback called by
parseMap(RecordId, RecordId, MapRecord) upon encountering
a map diff. |
protected void |
onMapLeaf(RecordId parentId,
RecordId mapId,
MapRecord map)
Callback called by
parseMap(RecordId, RecordId, MapRecord) upon encountering
a map leaf. |
protected void |
onNode(RecordId parentId,
RecordId nodeId)
Callback called by
parseNode(RecordId) upon encountering
a child node. |
protected void |
onProperty(RecordId parentId,
RecordId propertyId,
PropertyTemplate template)
Callback called by
parseNode(RecordId) upon encountering
a property. |
protected void |
onString(RecordId parentId,
RecordId stringId)
Callback called by
parseTemplate(RecordId) ,
parseMapLeaf(RecordId, MapRecord) and
parseValue(RecordId, RecordId, Type) upon encountering a string. |
protected void |
onTemplate(RecordId parentId,
RecordId templateId)
Callback called by
parseNode(RecordId) upon encountering
a template |
protected void |
onValue(RecordId parentId,
RecordId valueId,
org.apache.jackrabbit.oak.api.Type<?> type)
Callback called by
parseProperty(RecordId, RecordId, PropertyTemplate) upon
encountering a value. |
SegmentParser.BlobInfo |
parseBlob(RecordId blobId)
Parse a blob record
|
SegmentParser.ListInfo |
parseList(RecordId parentId,
RecordId listId,
int count)
Parse a list record
|
SegmentParser.ListBucketInfo |
parseListBucket(RecordId listId,
int index,
int count,
int capacity)
Parse item of list buckets
|
SegmentParser.MapInfo |
parseMap(RecordId parentId,
RecordId mapId,
MapRecord map)
Parse a map record
|
SegmentParser.MapInfo |
parseMapBranch(RecordId mapId,
MapRecord map)
Parse a map branch record
|
SegmentParser.MapInfo |
parseMapDiff(RecordId mapId,
MapRecord map)
Parse a map diff record
|
SegmentParser.MapInfo |
parseMapLeaf(RecordId mapId,
MapRecord map)
Parse a map leaf record
|
SegmentParser.NodeInfo |
parseNode(RecordId nodeId)
Parse a node record
|
SegmentParser.PropertyInfo |
parseProperty(RecordId parentId,
RecordId propertyId,
PropertyTemplate template)
Parse a property
|
SegmentParser.BlobInfo |
parseString(RecordId stringId)
Parse a string record
|
SegmentParser.TemplateInfo |
parseTemplate(RecordId templateId)
Parse a template record
|
SegmentParser.ValueInfo |
parseValue(RecordId parentId,
RecordId valueId,
org.apache.jackrabbit.oak.api.Type<?> type)
Parse a value record
|
public SegmentParser(@Nonnull SegmentReader reader)
protected void onNode(RecordId parentId, RecordId nodeId)
parseNode(RecordId)
upon encountering
a child node.parentId
- id of the parent nodenodeId
- if of the child nodeprotected void onTemplate(RecordId parentId, RecordId templateId)
parseNode(RecordId)
upon encountering
a templateparentId
- id of the node being parsedtemplateId
- id of the templateprotected void onMap(RecordId parentId, RecordId mapId, MapRecord map)
parseNode(RecordId)
,
parseMapDiff(RecordId, MapRecord)
and
parseMapBranch(RecordId, MapRecord)
upon encountering a map.parentId
- the id of the parent of the mapmapId
- the id of the mapmap
- the mapprotected void onMapDiff(RecordId parentId, RecordId mapId, MapRecord map)
parseMap(RecordId, RecordId, MapRecord)
upon encountering
a map diff.parentId
- the id of the parent mapmapId
- the id of the mapmap
- the mapprotected void onMapLeaf(RecordId parentId, RecordId mapId, MapRecord map)
parseMap(RecordId, RecordId, MapRecord)
upon encountering
a map leaf.parentId
- the id of the parent mapmapId
- the id of the mapmap
- the mapprotected void onMapBranch(RecordId parentId, RecordId mapId, MapRecord map)
parseMap(RecordId, RecordId, MapRecord)
upon encountering
a map branch.parentId
- the id of the parent mapmapId
- the id of the mapmap
- the mapprotected void onProperty(RecordId parentId, RecordId propertyId, PropertyTemplate template)
parseNode(RecordId)
upon encountering
a property.parentId
- the id of the parent nodepropertyId
- the id of the propertytemplate
- the property templateprotected void onValue(RecordId parentId, RecordId valueId, org.apache.jackrabbit.oak.api.Type<?> type)
parseProperty(RecordId, RecordId, PropertyTemplate)
upon
encountering a value.parentId
- the id the value's parentvalueId
- the id of the valuetype
- the type of the valueprotected void onBlob(RecordId parentId, RecordId blobId)
parseValue(RecordId, RecordId, Type)
upon encountering a blob.parentId
- the id of the blob's parentblobId
- the id of the blobprotected void onString(RecordId parentId, RecordId stringId)
parseTemplate(RecordId)
,
parseMapLeaf(RecordId, MapRecord)
and
parseValue(RecordId, RecordId, Type)
upon encountering a string.parentId
- the id of the string's parentstringId
- the id of the stringprotected void onList(RecordId parentId, RecordId listId, int count)
parseNode(RecordId)
,
parseProperty(RecordId, RecordId, PropertyTemplate)
,
parseTemplate(RecordId)
,
parseBlob(RecordId)
and
parseString(RecordId)
upon encountering a list.parentId
- the id of the list's parentlistId
- the id of the listcount
- the number of elements in the listprotected void onListBucket(RecordId parentId, RecordId listId, int index, int count, int capacity)
parseList(RecordId, RecordId, int)
and
parseListBucket(RecordId, int, int, int)
upon encountering a list
bucket.parentId
- the id of the list's parentlistId
- the id of the listindex
- the index into the bucketcount
- the number of items in the bucketcapacity
- the capacity of the bucketpublic SegmentParser.NodeInfo parseNode(RecordId nodeId)
nodeId
- public SegmentParser.TemplateInfo parseTemplate(RecordId templateId)
templateId
- public SegmentParser.MapInfo parseMap(RecordId parentId, RecordId mapId, MapRecord map)
parentId
- parent of this map or null
if nonemapId
- map
- public SegmentParser.MapInfo parseMapDiff(RecordId mapId, MapRecord map)
mapId
- map
- public SegmentParser.MapInfo parseMapLeaf(RecordId mapId, MapRecord map)
mapId
- map
- public SegmentParser.MapInfo parseMapBranch(RecordId mapId, MapRecord map)
mapId
- map
- public SegmentParser.PropertyInfo parseProperty(RecordId parentId, RecordId propertyId, PropertyTemplate template)
parentId
- propertyId
- template
- public SegmentParser.ValueInfo parseValue(RecordId parentId, RecordId valueId, org.apache.jackrabbit.oak.api.Type<?> type)
parentId
- parent of the value record, null
if nonevalueId
- type
- public SegmentParser.BlobInfo parseBlob(RecordId blobId)
blobId
- public SegmentParser.BlobInfo parseString(RecordId stringId)
stringId
- public SegmentParser.ListInfo parseList(RecordId parentId, RecordId listId, int count)
parentId
- parent of the list, null
if nonelistId
- count
- public SegmentParser.ListBucketInfo parseListBucket(RecordId listId, int index, int count, int capacity)
listId
- index
- index of the first item to parsecount
- number of items to parsecapacity
- total number of itemsCopyright © 2012-2016 The Apache Software Foundation. All Rights Reserved.