public class CmsEntity extends java.lang.Object implements com.google.gwt.event.logical.shared.HasValueChangeHandlers<CmsEntity>, java.io.Serializable
Modifier and Type | Class and Description |
---|---|
protected class |
CmsEntity.EntityChangeHandler
Handles child entity changes.
|
Modifier | Constructor and Description |
---|---|
protected |
CmsEntity()
Constructor.
|
|
CmsEntity(java.lang.String id,
java.lang.String typeName)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addAttributeValue(java.lang.String attributeName,
CmsEntity value)
Adds the given attribute value.
|
void |
addAttributeValue(java.lang.String attributeName,
java.lang.String value)
Adds the given attribute value.
|
protected <H extends com.google.gwt.event.shared.EventHandler> |
addHandler(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) |
CmsEntity |
cloneEntity()
Clones the given entity keeping all entity ids.
|
CmsEntity |
createDeepCopy(java.lang.String entityId)
Creates a deep copy of this entity.
|
void |
ensureChangeHandlers()
Ensures that the change event is also fired on child entity change.
|
boolean |
equals(java.lang.Object obj) |
void |
fireEvent(com.google.gwt.event.shared.GwtEvent<?> event) |
CmsEntityAttribute |
getAttribute(java.lang.String attributeName)
Returns an attribute.
|
java.util.List<CmsEntityAttribute> |
getAttributes()
Returns all entity attributes.
|
CmsEntity |
getEntityById(java.lang.String entityId)
Returns this or a child entity with the given id.
|
java.lang.String |
getId()
Returns the entity id.
|
java.lang.String |
getTypeName()
Returns the entity type name.
|
static java.lang.String |
getValueForPath(CmsEntity entity,
java.lang.String[] pathElements)
Returns the value of a simple attribute for the given path or
null , if the value does not exist. |
static java.util.List<java.lang.Object> |
getValuesForPath(java.lang.Object baseObject,
java.lang.String[] pathComponents)
Gets the list of values reachable from the given base object with the given path.
|
static java.util.List<java.lang.Object> |
getValuesForPathComponent(java.lang.Object entityOrString,
java.lang.String pathComponent)
Gets the values reachable from a given object (an entity or a string) with a single XPath component.
|
boolean |
hasAttribute(java.lang.String attributeName)
Returns if the entity has the given attribute.
|
int |
hashCode() |
void |
insertAttributeValue(java.lang.String attributeName,
CmsEntity value,
int index)
Inserts a new attribute value at the given index.
|
void |
insertAttributeValue(java.lang.String attributeName,
java.lang.String value,
int index)
Inserts a new attribute value at the given index.
|
void |
removeAttribute(java.lang.String attributeName)
Removes the given attribute.
|
void |
removeAttributeSilent(java.lang.String attributeName)
Removes the attribute without triggering any change events.
|
void |
removeAttributeValue(java.lang.String attributeName,
int index)
Removes a specific attribute value.
|
void |
setAttributeValue(java.lang.String attributeName,
CmsEntity value)
Sets the given attribute value.
|
void |
setAttributeValue(java.lang.String attributeName,
CmsEntity value,
int index)
Sets the given attribute value at the given index.
|
void |
setAttributeValue(java.lang.String attributeName,
java.lang.String value)
Sets the given attribute value.
|
void |
setAttributeValue(java.lang.String attributeName,
java.lang.String value,
int index)
Sets the given attribute value at the given index.
|
java.lang.String |
toJSON()
Returns the JSON string representation of this entity.
|
java.lang.String |
toString() |
protected CmsEntity()
public CmsEntity(java.lang.String id, java.lang.String typeName)
id
- the entity id/URItypeName
- the entity type namepublic void addAttributeValue(java.lang.String attributeName, CmsEntity value)
attributeName
- the attribute namevalue
- the attribute valuepublic void addAttributeValue(java.lang.String attributeName, java.lang.String value)
attributeName
- the attribute namevalue
- the attribute valueprotected final <H extends com.google.gwt.event.shared.EventHandler> com.google.gwt.event.shared.HandlerRegistration addHandler(H handler, com.google.gwt.event.shared.GwtEvent.Type<H> type)
H
- the type of handler to addtype
- the event typehandler
- the handlerHandlerRegistration
used to remove the handlerpublic com.google.gwt.event.shared.HandlerRegistration addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler<CmsEntity> handler)
addValueChangeHandler
in interface com.google.gwt.event.logical.shared.HasValueChangeHandlers<CmsEntity>
HasValueChangeHandlers.addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler)
public CmsEntity cloneEntity()
public CmsEntity createDeepCopy(java.lang.String entityId)
entityId
- the id of the new entity, if null
a generic id will be usedpublic void ensureChangeHandlers()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
Object.equals(java.lang.Object)
public void fireEvent(com.google.gwt.event.shared.GwtEvent<?> event)
fireEvent
in interface com.google.gwt.event.shared.HasHandlers
HasHandlers.fireEvent(com.google.gwt.event.shared.GwtEvent)
public CmsEntityAttribute getAttribute(java.lang.String attributeName)
attributeName
- the attribute namepublic java.util.List<CmsEntityAttribute> getAttributes()
public CmsEntity getEntityById(java.lang.String entityId)
Will return null
if no entity with the given id is present.
entityId
- the entity idpublic java.lang.String getId()
public java.lang.String getTypeName()
public static java.lang.String getValueForPath(CmsEntity entity, java.lang.String[] pathElements)
null
, if the value does not exist.entity
- the entity to get the value frompathElements
- the path elementspublic static java.util.List<java.lang.Object> getValuesForPath(java.lang.Object baseObject, java.lang.String[] pathComponents)
baseObject
- the base object (a CmsEntity or a string)pathComponents
- the path componentspublic static java.util.List<java.lang.Object> getValuesForPathComponent(java.lang.Object entityOrString, java.lang.String pathComponent)
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).
entityOrString
- the entity or string from which to get the values for the given path componentpathComponent
- the path componentpublic boolean hasAttribute(java.lang.String attributeName)
attributeName
- the attribute nametrue
if the entity has the given attributepublic int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()
public void insertAttributeValue(java.lang.String attributeName, CmsEntity value, int index)
attributeName
- the attribute namevalue
- the attribute valueindex
- the value indexpublic void insertAttributeValue(java.lang.String attributeName, java.lang.String value, int index)
attributeName
- the attribute namevalue
- the attribute valueindex
- the value indexpublic void removeAttribute(java.lang.String attributeName)
attributeName
- the attribute namepublic void removeAttributeSilent(java.lang.String attributeName)
attributeName
- the attribute namepublic void removeAttributeValue(java.lang.String attributeName, int index)
attributeName
- the attribute nameindex
- the value indexpublic void setAttributeValue(java.lang.String attributeName, CmsEntity value)
attributeName
- the attribute namevalue
- the attribute valuepublic void setAttributeValue(java.lang.String attributeName, CmsEntity value, int index)
attributeName
- the attribute namevalue
- the attribute valueindex
- the value indexpublic void setAttributeValue(java.lang.String attributeName, java.lang.String value)
attributeName
- the attribute namevalue
- the attribute valuepublic void setAttributeValue(java.lang.String attributeName, java.lang.String value, int index)
attributeName
- the attribute namevalue
- the attribute valueindex
- the value indexpublic java.lang.String toJSON()
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()