P - the type of the PersistenceBackend targeted by this handler.public abstract class AbstractPersistenceHandler<P extends PersistenceBackend> extends Object implements PersistenceHandler
PersistenceHandler that persists data in a PersistenceBackend, based on received events.| Modifier and Type | Field and Description |
|---|---|
protected static long |
DEFAULT_CACHE_SIZE
The default cache size.
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractPersistenceHandler(P backend)
Constructs a new
AbstractPersistenceHandler on top of the backend. |
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
addAttribute(Id id,
String name,
int index,
boolean many,
Object value)
Adds a new attribute to the element identified by the given
id. |
protected abstract void |
addElement(Id id,
String nsUri,
String name,
boolean root)
Adds a new element.
|
protected abstract void |
addReference(Id id,
String name,
int index,
boolean many,
boolean containment,
Id idReference)
Adds a new reference to the element identified by the given
id. |
protected Id |
createElement(Classifier classifier,
Id id)
Creates an element from the given
classifier with the given id. |
protected abstract Id |
getId(String reference)
Returns the
Id of the given reference. |
protected Id |
getOrCreateMetaClass(MetaClassifier metaClassifier)
Creates a metaclass form the given
metaClassifier and returns its Id. |
protected P |
getPersistenceBackend()
Returns the
backend where to store data. |
void |
processAttribute(Attribute attribute)
Process an attribute in the current element.
|
void |
processCharacters(String characters)
Process a set of characters.
|
void |
processEndDocument()
Process the end of a document.
|
void |
processEndElement()
Process the end of the current element.
|
void |
processReference(Reference reference)
Process a reference from the current element to another element.
|
void |
processStartDocument()
Process the start of a document.
|
void |
processStartElement(Classifier classifier)
Process the start of an element.
|
protected abstract void |
setMetaClass(Id id,
Id metaClassId)
Defines the metaclass to the element identified by the given
id. |
protected static final long DEFAULT_CACHE_SIZE
It is calculated according to the maximum memory dedicated to the JVM.
protected AbstractPersistenceHandler(P backend)
AbstractPersistenceHandler on top of the backend.backend - the persistence back-end where to store dataprotected P getPersistenceBackend()
backend where to store data.protected abstract Id getId(String reference)
Id of the given reference.reference - the referenceIdprotected abstract void addElement(Id id, String nsUri, String name, boolean root)
id - the identifier of the new elementnsUri - the URI of the new elementname - the name of the new elementroot - true if the new element is a root nodeprotected abstract void addAttribute(Id id, String name, int index, boolean many, Object value)
id.id - the identifier of the elementname - the name of the attributeindex - the index of the attribute if it's a multi-valued attributemany - true if the attribute is multi-valuedvalue - the value of the attributeprotected abstract void addReference(Id id, String name, int index, boolean many, boolean containment, Id idReference)
id.id - the identifier of the elementname - the name of the referenceindex - the index of the reference if it's a multi-valued referencemany - true if the reference is multi-valuedcontainment - true if the reference is a containmentidReference - the identifier of the referenced elementprotected abstract void setMetaClass(Id id, Id metaClassId)
id.id - the identifier of the elementmetaClassId - the identifier of the metaclasspublic void processStartDocument()
InputHandlerprocessStartDocument in interface InputHandlerInputNotifier.notifyStartDocument()public void processStartElement(Classifier classifier)
InputHandlerprocessStartElement in interface InputHandlerclassifier - the classifier of the new elementInputNotifier.notifyStartElement(Classifier)public void processAttribute(Attribute attribute)
InputHandlerAn attribute is a simple key/value.
processAttribute in interface InputHandlerattribute - the new attributeInputNotifier.notifyAttribute(Attribute)public void processReference(Reference reference)
InputHandlerA reference is an attribute which is link to another element.
processReference in interface InputHandlerreference - the new referenceInputNotifier.notifyReference(Reference)public void processEndElement()
InputHandlerprocessEndElement in interface InputHandlerInputNotifier.notifyEndElement()public void processEndDocument()
InputHandlerprocessEndDocument in interface InputHandlerInputNotifier.notifyEndDocument()public void processCharacters(String characters)
InputHandlerprocessCharacters in interface InputHandlercharacters - the new charactersInputNotifier.notifyCharacters(String)protected Id createElement(@Nonnull Classifier classifier, @Nonnull Id id)
classifier with the given id.
If id is null, it is calculated by the getId(String) method.
classifier - the information about the new elementid - the identifier of the elementidNullPointerException - if any of the parameters is nullprotected Id getOrCreateMetaClass(@Nonnull MetaClassifier metaClassifier)
metaClassifier and returns its Id.metaClassifier - the meta classifierId of the created metaclassNullPointerException - if the metaClassifier is nullCopyright © 2013–2017 Atlanmod INRIA LINA Mines Nantes. All rights reserved.