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:
  • Constructor Details

    • CmsEntity

      public CmsEntity(String id, String typeName)
      Constructor.

      Parameters:
      id - the entity id/URI
      typeName - the entity type name
    • CmsEntity

      protected CmsEntity()
      Constructor. For serialization only.

  • Method Details

    • getValueForPath

      public static String getValueForPath(CmsEntity entity, String[] pathElements)
      Returns the value of a simple attribute for the given path or null, if the value does not exist.

      Parameters:
      entity - the entity to get the value from
      pathElements - the path elements
      Returns:
      the value
    • getValuesForPath

      public static List<Object> getValuesForPath(Object baseObject, String[] pathComponents)
      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

      public static List<Object> getValuesForPathComponent(Object entityOrString, String pathComponent)
      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 component
      pathComponent - the path component
      Returns:
      the list of reachable values
    • addAttributeValue

      public void addAttributeValue(String attributeName, CmsEntity value)
      Adds the given attribute value.

      Parameters:
      attributeName - the attribute name
      value - the attribute value
    • addAttributeValue

      public void addAttributeValue(String attributeName, String value)
      Adds the given attribute value.

      Parameters:
      attributeName - the attribute name
      value - the attribute value
    • addValueChangeHandler

      public com.google.gwt.event.shared.HandlerRegistration addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler<CmsEntity> handler)
      Specified by:
      addValueChangeHandler in interface com.google.gwt.event.logical.shared.HasValueChangeHandlers<CmsEntity>
      See Also:
      • HasValueChangeHandlers.addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler)
    • cloneEntity

      Clones the given entity keeping all entity ids.

      Returns:
      returns the cloned instance
    • createDeepCopy

      public CmsEntity createDeepCopy(String entityId)
      Creates a deep copy of this entity.

      Parameters:
      entityId - the id of the new entity, if null a generic id will be used
      Returns:
      the entity copy
    • ensureChangeHandlers

      public void ensureChangeHandlers()
      Ensures that the change event is also fired on child entity change.

    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
      See Also:
    • fireEvent

      public void fireEvent(com.google.gwt.event.shared.GwtEvent<?> event)
      Specified by:
      fireEvent in interface com.google.gwt.event.shared.HasHandlers
      See Also:
      • HasHandlers.fireEvent(com.google.gwt.event.shared.GwtEvent)
    • getAttribute

      public CmsEntityAttribute getAttribute(String attributeName)
      Returns an attribute.

      Parameters:
      attributeName - the attribute name
      Returns:
      the attribute value
    • getAttributes

      Returns all entity attributes.

      Returns:
      the entity attributes
    • getEntityById

      public CmsEntity getEntityById(String entityId)
      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

      public String getId()
      Returns the entity id.

      Returns:
      the id
    • getTypeName

      public String getTypeName()
      Returns the entity type name.

      Returns:
      the entity type name
    • hasAttribute

      public boolean hasAttribute(String attributeName)
      Returns if the entity has the given attribute.

      Parameters:
      attributeName - the attribute name
      Returns:
      true if the entity has the given attribute
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
      See Also:
    • insertAttributeValue

      public void insertAttributeValue(String attributeName, CmsEntity value, int index)
      Inserts a new attribute value at the given index.

      Parameters:
      attributeName - the attribute name
      value - the attribute value
      index - the value index
    • insertAttributeValue

      public void insertAttributeValue(String attributeName, String value, int index)
      Inserts a new attribute value at the given index.

      Parameters:
      attributeName - the attribute name
      value - the attribute value
      index - the value index
    • removeAttribute

      public void removeAttribute(String attributeName)
      Removes the given attribute.

      Parameters:
      attributeName - the attribute name
    • removeAttributeSilent

      public void removeAttributeSilent(String attributeName)
      Removes the attribute without triggering any change events.

      Parameters:
      attributeName - the attribute name
    • removeAttributeValue

      public void removeAttributeValue(String attributeName, int index)
      Removes a specific attribute value.

      Parameters:
      attributeName - the attribute name
      index - the value index
    • setAttributeValue

      public void setAttributeValue(String attributeName, CmsEntity value)
      Sets the given attribute value. Will remove all previous attribute values.

      Parameters:
      attributeName - the attribute name
      value - the attribute value
    • setAttributeValue

      public void setAttributeValue(String attributeName, CmsEntity value, int index)
      Sets the given attribute value at the given index.

      Parameters:
      attributeName - the attribute name
      value - the attribute value
      index - the value index
    • setAttributeValue

      public void setAttributeValue(String attributeName, String value)
      Sets the given attribute value. Will remove all previous attribute values.

      Parameters:
      attributeName - the attribute name
      value - the attribute value
    • setAttributeValue

      public void setAttributeValue(String attributeName, String value, int index)
      Sets the given attribute value at the given index.

      Parameters:
      attributeName - the attribute name
      value - the attribute value
      index - the value index
    • toJSON

      public String toJSON()
      Returns the JSON string representation of this entity.

      Returns:
      the JSON string representation of this entity
    • toString

      public String toString()
      Overrides:
      toString in class Object
      See Also:
    • addHandler

      protected 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)
      Adds this handler to the widget.
      Type Parameters:
      H - the type of handler to add
      Parameters:
      type - the event type
      handler - the handler
      Returns:
      HandlerRegistration used to remove the handler