Package org.opencms.acacia.shared
Class CmsEntity
java.lang.Object
org.opencms.acacia.shared.CmsEntity
- All Implemented Interfaces:
com.google.gwt.event.logical.shared.HasValueChangeHandlers<CmsEntity>
,com.google.gwt.event.shared.HasHandlers
,Serializable
public class CmsEntity
extends Object
implements com.google.gwt.event.logical.shared.HasValueChangeHandlers<CmsEntity>, Serializable
Serializable entity implementation.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
Handles child entity changes. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAttributeValue
(String attributeName, String value) Adds the given attribute value.void
addAttributeValue
(String attributeName, CmsEntity value) Adds the given attribute value.protected final <H extends com.google.gwt.event.shared.EventHandler>
com.google.gwt.event.shared.HandlerRegistrationaddHandler
(H handler, com.google.gwt.event.shared.GwtEvent.Type<H> type) Adds this handler to the widget.com.google.gwt.event.shared.HandlerRegistration
addValueChangeHandler
(com.google.gwt.event.logical.shared.ValueChangeHandler<CmsEntity> handler) Clones the given entity keeping all entity ids.createDeepCopy
(String entityId) Creates a deep copy of this entity.void
Ensures that the change event is also fired on child entity change.boolean
void
fireEvent
(com.google.gwt.event.shared.GwtEvent<?> event) getAttribute
(String attributeName) Returns an attribute.Returns all entity attributes.getEntityById
(String entityId) Returns this or a child entity with the given id.getId()
Returns the entity id.Returns the entity type name.static String
getValueForPath
(CmsEntity entity, String[] pathElements) Returns the value of a simple attribute for the given path ornull
, if the value does not exist.getValuesForPath
(Object baseObject, String[] pathComponents) Gets the list of values reachable from the given base object with the given path.getValuesForPathComponent
(Object entityOrString, String pathComponent) Gets the values reachable from a given object (an entity or a string) with a single XPath component.boolean
hasAttribute
(String attributeName) Returns if the entity has the given attribute.int
hashCode()
void
insertAttributeValue
(String attributeName, String value, int index) Inserts a new attribute value at the given index.void
insertAttributeValue
(String attributeName, CmsEntity value, int index) Inserts a new attribute value at the given index.void
removeAttribute
(String attributeName) Removes the given attribute.void
removeAttributeSilent
(String attributeName) Removes the attribute without triggering any change events.void
removeAttributeValue
(String attributeName, int index) Removes a specific attribute value.void
setAttributeValue
(String attributeName, String value) Sets the given attribute value.void
setAttributeValue
(String attributeName, String value, int index) Sets the given attribute value at the given index.void
setAttributeValue
(String attributeName, CmsEntity value) Sets the given attribute value.void
setAttributeValue
(String attributeName, CmsEntity value, int index) Sets the given attribute value at the given index.toJSON()
Returns the JSON string representation of this entity.toString()
-
Constructor Details
-
CmsEntity
Constructor.- Parameters:
id
- the entity id/URItypeName
- the entity type name
-
CmsEntity
protected CmsEntity()Constructor. For serialization only.
-
-
Method Details
-
getValuesForPath
Gets the list of values reachable from the given base object with the given path.- Parameters:
baseObject
- the base object (a CmsEntity or a string)pathComponents
- the path components- Returns:
- the list of values for the given path (either of type String or CmsEntity)
-
getValuesForPathComponent
Gets the values reachable from a given object (an entity or a string) with a single XPath component.If entityOrString is a string, and pathComponent is "VALUE", a list containing only entityOrString is returned. Otherwise, entityOrString is assumed to be an entity, and the pathComponent is interpreted as a field of the entity (possibly with an index).
- Parameters:
entityOrString
- the entity or string from which to get the values for the given path componentpathComponent
- the path component- Returns:
- the list of reachable values
-
addAttributeValue
Adds the given attribute value.- Parameters:
attributeName
- the attribute namevalue
- the attribute value
-
cloneEntity
Clones the given entity keeping all entity ids.- Returns:
- returns the cloned instance
-
createDeepCopy
Creates a deep copy of this entity.- Parameters:
entityId
- the id of the new entity, ifnull
a generic id will be used- Returns:
- the entity copy
-
ensureChangeHandlers
Ensures that the change event is also fired on child entity change. -
equals
-
getAttribute
Returns an attribute.- Parameters:
attributeName
- the attribute name- Returns:
- the attribute value
-
getAttributes
Returns all entity attributes.- Returns:
- the entity attributes
-
getEntityById
Returns this or a child entity with the given id.Will return
null
if no entity with the given id is present.- Parameters:
entityId
- the entity id- Returns:
- the entity
-
getId
Returns the entity id.- Returns:
- the id
-
getTypeName
Returns the entity type name.- Returns:
- the entity type name
-
hasAttribute
Returns if the entity has the given attribute.- Parameters:
attributeName
- the attribute name- Returns:
true
if the entity has the given attribute
-
hashCode
-
insertAttributeValue
Inserts a new attribute value at the given index.- Parameters:
attributeName
- the attribute namevalue
- the attribute valueindex
- the value index
-
removeAttribute
Removes the given attribute.- Parameters:
attributeName
- the attribute name
-
removeAttributeSilent
Removes the attribute without triggering any change events.- Parameters:
attributeName
- the attribute name
-
removeAttributeValue
Removes a specific attribute value.- Parameters:
attributeName
- the attribute nameindex
- the value index
-
setAttributeValue
Sets the given attribute value. Will remove all previous attribute values.- Parameters:
attributeName
- the attribute namevalue
- the attribute value
-
setAttributeValue
Sets the given attribute value at the given index.- Parameters:
attributeName
- the attribute namevalue
- the attribute valueindex
- the value index
-
toJSON
Returns the JSON string representation of this entity.- Returns:
- the JSON string representation of this entity
-
toString