Class OrientElement
- All Implemented Interfaces:
OIdentifiable,OSerializableStream,com.tinkerpop.blueprints.Element,Externalizable,Serializable,Comparable<OIdentifiable>,Comparator<OIdentifiable>
- Direct Known Subclasses:
OrientEdge,OrientVertex
- Author:
- Luca Garulli (l.garulli--(at)--orientdb.com) (http://orientdb.com)
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanstatic final Objectstatic final Stringprotected OIdentifiableprotected OrientConfigurableGraph.Settings -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedOrientElement(OrientBaseGraph rawGraph, OIdentifiable iRawElement) -
Method Summary
Modifier and TypeMethodDescriptionattach(OrientBaseGraph iNewGraph) (Blueprints Extension) Replaces current graph instance with new one on @detach -ed elements.protected voidprotected booleanprotected StringcheckForClassInSchema(String className) Check if a class already exists, otherwise create it at the fly.protected OrientBaseGraphintcompare(OIdentifiable iFirst, OIdentifiable iSecond) intcompareTo(OIdentifiable iOther) protected voidcopyTo(OrientElement iCopy) detach()(Blueprints Extension) Removes the reference to the current graph instance to let working offline.booleanfromStream(byte[] stream) (Blueprints Extension) Fills the Element from a byte[]abstract Stringabstract String(Blueprints Extension) Returns the element type in form of String between "Vertex" and "Edge".getGraph()(Blueprints Extension) Returns the Graph instance associated to the current element.getId()Returns the Element Id assuring to save it if it's transient yet.(Blueprints Extension) Returns the record's identity.abstract StringgetLabel()(Blueprints Extension) Gets all the properties from a Vertex or Edge in one shot.<T> TgetProperty(String key) Returns a Property value.(Blueprints Extension) Returns the underlying record.inthashCode()boolean(Blueprints Extension) Tells if the current element has been @detach ed.booleanisLocked()(Blueprints Extension) Checks if an Element is lockedvoidlock(boolean iExclusive) (Blueprints Extension) Locks current Element to prevent concurrent access.voidvoidreload()<T> TremoveProperty(String key) Removes a Property.voidsave()(Blueprints Extension) Saves current element.void(Blueprints Extension) Saves current element to a particular cluster.protected OrientBaseGraph<T extends OrientElement>
TsetProperties(Object... fields) (Blueprints Extension) Sets multiple properties in one shot against Vertices and Edges.protected <T extends OrientElement>
TsetPropertiesInternal(Object... fields) (Blueprints Extension) Sets multiple properties in one shot against Vertices and Edges without saving the element.voidsetProperty(String key, Object value) Sets a Property value.voidsetProperty(String key, Object value, OType iType) Sets a Property value specifying a type.protected voidsetPropertyInternal(com.tinkerpop.blueprints.Element element, ODocument doc, String key, Object value) voidSwitches to auto attachment mode, when graph element is automatically attached to currently open graph instance.voidswitchToManualAttachmentMode(OrientBaseGraph iNewGraph) Behavior is the same as forattach(OrientBaseGraph)method.byte[]toStream()(Blueprints Extension) Serializes the Element as byte[]voidunlock()(Blueprints Extension) Unlocks previous acquired @lock against the Element.final voidvalidateProperty(com.tinkerpop.blueprints.Element element, String key, Object value) (Blueprints Extension) Validates an Element property.voidMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLongMethods inherited from interface com.tinkerpop.blueprints.Element
getPropertyKeys, remove
-
Field Details
-
LABEL_FIELD_NAME
- See Also:
-
DEF_ORIGINAL_ID_FIELDNAME
-
classicDetachMode
protected boolean classicDetachMode -
settings
-
rawElement
-
-
Constructor Details
-
OrientElement
-
-
Method Details
-
getLabel
-
getBaseClassName
-
getElementType
(Blueprints Extension) Returns the element type in form of String between "Vertex" and "Edge". -
getProperties
(Blueprints Extension) Gets all the properties from a Vertex or Edge in one shot.- Returns:
- a map containing all the properties of the Vertex/Edge.
-
checkDeletedInTx
protected boolean checkDeletedInTx() -
setProperties
(Blueprints Extension) Sets multiple properties in one shot against Vertices and Edges. This improves performance avoiding to save the graph element at every property set.
Example:vertex.setProperties( "name", "Jill", "age", 33, "city", "Rome", "born", "Victoria, TX" );You can also pass a Map of values as first argument. In this case all the map entries will be set as element properties:Map<String,Object> props = new HashMap<String,Object>(); props.put("name", "Jill"); props.put("age", 33); props.put("city", "Rome"); props.put("born", "Victoria, TX"); vertex.setProperties(props);- Parameters:
fields- Odd number of fields to set as repeating pairs of key, value, or if one parameter is received and it's a Map, the Map entries are used as field key/value pairs.
-
setProperty
Sets a Property value.- Specified by:
setPropertyin interfacecom.tinkerpop.blueprints.Element- Parameters:
key- Property namevalue- Property value
-
setProperty
Sets a Property value specifying a type. This is useful when you don't have a schema on this property but you want to force the type.- Parameters:
key- Property namevalue- Property valueiType- Type to set
-
removeProperty
Removes a Property.- Specified by:
removePropertyin interfacecom.tinkerpop.blueprints.Element- Parameters:
key- Property name- Returns:
- Old value if any
-
getProperty
Returns a Property value.- Specified by:
getPropertyin interfacecom.tinkerpop.blueprints.Element- Parameters:
key- Property name- Returns:
- Property value if any, otherwise NULL.
-
getId
Returns the Element Id assuring to save it if it's transient yet.- Specified by:
getIdin interfacecom.tinkerpop.blueprints.Element
-
save
public void save()(Blueprints Extension) Saves current element. You don't need to call save() unless you're working against Temporary Vertices. -
save
(Blueprints Extension) Saves current element to a particular cluster. You don't need to call save() unless you're working against Temporary Vertices.- Parameters:
iClusterName- Cluster name or null to use the default "E"
-
hashCode
public int hashCode() -
toStream
(Blueprints Extension) Serializes the Element as byte[]- Specified by:
toStreamin interfaceOSerializableStream- Returns:
- The byte array representation of the object
- Throws:
OSerializationException- if the marshalling does not succeed- See Also:
-
fromStream
(Blueprints Extension) Fills the Element from a byte[]- Specified by:
fromStreamin interfaceOSerializableStream- Parameters:
stream- byte array representation of the object- Returns:
- The Object instance itself giving a "fluent interface". Useful to call multiple methods in chain.
- Throws:
OSerializationException- if the unmarshalling does not succeed
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
lock
public void lock(boolean iExclusive) (Blueprints Extension) Locks current Element to prevent concurrent access. If lock is exclusive, then no concurrent threads can read/write it. If the lock is shared, then concurrent threads can only read Element properties, but can't change them. Locks can be freed by calling @unlock or when the current transaction is closed (committed or rollbacked).- Specified by:
lockin interfaceOIdentifiable- Parameters:
iExclusive- True = Exclusive Lock, False = Shared Lock- See Also:
-
isLocked
public boolean isLocked()(Blueprints Extension) Checks if an Element is locked- Specified by:
isLockedin interfaceOIdentifiable
-
lockingStrategy
- Specified by:
lockingStrategyin interfaceOIdentifiable
-
unlock
public void unlock()(Blueprints Extension) Unlocks previous acquired @lock against the Element.- Specified by:
unlockin interfaceOIdentifiable- See Also:
-
getIdentity
(Blueprints Extension) Returns the record's identity.- Specified by:
getIdentityin interfaceOIdentifiable- Returns:
- ORID instance
-
getRecord
(Blueprints Extension) Returns the underlying record.- Specified by:
getRecordin interfaceOIdentifiable- Returns:
- ORecord instance
-
detach
(Blueprints Extension) Removes the reference to the current graph instance to let working offline. To reattach it use @attach.This methods works only in "classic detach/attach mode" when dettachment/attachment is done manually, by default it is done automatically, and currently active graph connection will be used as graph elements owner.
- Returns:
- Current object to allow chained calls.
-
switchToAutoAttachmentMode
public void switchToAutoAttachmentMode()Switches to auto attachment mode, when graph element is automatically attached to currently open graph instance. -
switchToManualAttachmentMode
Behavior is the same as forattach(OrientBaseGraph)method. -
attach
(Blueprints Extension) Replaces current graph instance with new one on @detach -ed elements. Use this method to pass elements between graphs or to switch between Tx and NoTx instances.This methods works only in "classic detach/attach mode" when detachment/attachment is done manually, by default it is done automatically, and currently active graph connection will be used as graph elements owner.
To set "classic detach/attach mode" please set custom database parameter
classicDetachModetotrue.- Parameters:
iNewGraph- The new Graph instance to use.- Returns:
- Current object to allow chained calls.
-
isDetached
public boolean isDetached()(Blueprints Extension) Tells if the current element has been @detach ed.This methods works only in "classic detach/attach mode" when detachment/attachment is done manually, by default it is done automatically, and currently active graph connection will be used as graph elements owner.
To set "classic detach/attach mode" please set custom database parameter
classicDetachModetotrue.- Returns:
- True if detached, otherwise false
-
equals
- Specified by:
equalsin interfaceComparator<OIdentifiable>- Overrides:
equalsin classObject
-
compare
- Specified by:
comparein interfaceComparator<OIdentifiable>
-
compareTo
- Specified by:
compareToin interfaceComparable<OIdentifiable>
-
getGraph
(Blueprints Extension) Returns the Graph instance associated to the current element. On @detach ed elements returns NULL. -
validateProperty
public final void validateProperty(com.tinkerpop.blueprints.Element element, String key, Object value) throws IllegalArgumentException (Blueprints Extension) Validates an Element property.- Parameters:
element- Element instancekey- Property namevalue- property value- Throws:
IllegalArgumentException
-
reload
public void reload() -
copyTo
-
checkClass
protected void checkClass() -
checkForClassInSchema
Check if a class already exists, otherwise create it at the fly. If a transaction is running commit changes, create the class and begin a new transaction.- Parameters:
className- Class's name
-
setPropertyInternal
-
setCurrentGraphInThreadLocal
-
checkIfAttached
-
setPropertiesInternal
(Blueprints Extension) Sets multiple properties in one shot against Vertices and Edges without saving the element. This improves performance avoiding to save the graph element at every property set. Example:vertex.setProperties( "name", "Jill", "age", 33, "city", "Rome", "born", "Victoria, TX" );You can also pass a Map of values as first argument. In this case all the map entries will be set as element properties:Map<String,Object> props = new HashMap<String,Object>(); props.put("name", "Jill"); props.put("age", 33); props.put("city", "Rome"); props.put("born", "Victoria, TX"); vertex.setProperties(props);- Parameters:
fields- Odd number of fields to set as repeating pairs of key, value, or if one parameter is received and it's a Map, the Map entries are used as field key/value pairs.
-