Class CmsJspElementSettingValueWrapper

java.lang.Object
java.util.AbstractCollection<String>
org.opencms.jsp.util.CmsJspElementSettingValueWrapper
All Implemented Interfaces:
Iterable<String>, Collection<String>

Element setting access wrapper.

  • Field Details

    • m_cms

      protected CmsObject m_cms
      The wrapped OpenCms user context.
    • m_linkObj

      protected Optional<CmsJspLinkWrapper> m_linkObj
      Cached link wrapper - use Optional to distinguish 'uncached' state from 'does not exist'.
  • Method Details

    • getCmsObject

      Returns the current cms context.

      Returns:
      the cms context
      See Also:
      • A_CmsJspValueWrapper.getCmsObject()
    • getExists

      public boolean getExists()
      Returns if the setting has been configured.

      Returns:
      true if the setting has been configured
    • getIsEmpty

      public boolean getIsEmpty()
      Returns if the setting value is null or empty.

      Returns:
      true if the setting value is null or empty
    • getIsEmptyOrWhitespaceOnly

      public boolean getIsEmptyOrWhitespaceOnly()
      Returns if the setting value is null or white space only.

      Returns:
      true if the setting value is null or white space only
    • getObjectValue

      Returns the raw instance of the wrapped value.

      Returns:
      the raw instance of the wrapped value
      See Also:
      • A_CmsJspValueWrapper.getObjectValue()
    • getValue

      Deprecated.
      use getObjectValue() instead
      Returns the raw value.

      This may return null.

      Returns:
      the value
    • hashCode

      public int hashCode()
      The hash code is based in the String value of the element setting.

      Specified by:
      hashCode in interface Collection<String>
      See Also:
    • toString

      public String toString()
      Returns the string value.

      This will always be at least an empty String "", never null.

      Overrides:
      toString in class AbstractCollection<String>
      Returns:
      the string value
    • substituteLink

      public static String substituteLink(CmsObject cms, String target)
      Returns the substituted link to the given target.

      Parameters:
      cms - the cms context
      target - the link target
      Returns:
      the substituted link
    • equals

      public boolean equals(Object obj)
      Specified by:
      equals in interface Collection<String>
      Overrides:
      equals in class Object
      See Also:
    • getContains

      public Map<Object,Boolean> getContains()
      Returns a lazy initialized Map that provides Booleans which indicate if if the wrapped values String representation contains a specific String.

      The Object parameter is transformed to it's String representation to perform this check.

      Returns:
      a lazy initialized Map that provides Booleans which indicate if if the wrapped values String representation contains a specific String
    • getIsEqual

      public Map<Object,Boolean> getIsEqual()
      Returns a lazy initialized Map that provides Booleans which indicate if an Object is equal to the wrapped object.

      Returns:
      a lazy initialized Map that provides Booleans which indicate if an Object is equal to the wrapped object
    • getIsSet

      public boolean getIsSet()
      Returns true in case the wrapped value exists and is not empty or whitespace only.

      Returns:
      true in case the wrapped value exists and is not empty or whitespace only
    • getIsSetNotNone

      public boolean getIsSetNotNone()
      Returns true in case the wrapped value exists, is not empty or whitespace only and is also not equal to the String 'none'.

      Returns:
      true in case the wrapped value exists, is not empty or whitespace only and is also not equal to the String 'none'
    • getMathCeil

      public Long getMathCeil()
      Calculates the next largest integer from the wrapped value.

      Note that the result is an Object of type Long, so in case the wrapped value can not be converted to a number, null is returned. This means you can check for an empty result in the EL.

      Returns:
      the next largest integer for the wrapped value
    • getMathFloor

      public Long getMathFloor()
      Calculates the next smallest integer from the wrapped value.

      Note that the result is an Object of type Long, so in case the wrapped value can not be converted to a number, null is returned. This means you can check for an empty result in the EL.

      Returns:
      the next smallest integer for the wrapped value
    • getMathRound

      public Long getMathRound()
      Calculates the next integer from the wrapped value by rounding.

      Note that the result is an Object of type Long, so in case the wrapped value can not be converted to a number, null is returned. This means you can check for an empty result in the EL.

      Returns:
      the next integer for the wrapped value calculated by rounding
    • getStringValue

      @Deprecated public String getStringValue()
      Deprecated.
      use getToString() instead
      Returns the String value for the wrapped content value.

      This will return the empty String "" when getExists() returns false

      .

      Returns:
      the String value of the wrapped content value
    • getStripHtml

      public String getStripHtml()
      Assumes the wrapped value is a String and strips all HTML markup from this String.

      Returns:
      the wrapped value with all HTML stripped.
    • getToBoolean

      public boolean getToBoolean()
      Converts the wrapped value to a boolean.

      Returns:
      the boolean value
    • getToContainerPage

      public CmsJspContainerPageWrapper getToContainerPage()
      Tries to create a container page wrapper from the wrapped value.
      Returns:
      the container page wrapper or null if none could be created
    • getToDate

      public Date getToDate()
      Converts the wrapped value to a date.

      Returns:
      the date
      See Also:
    • getToDouble

      public Double getToDouble()
      Parses the wrapped value to a Double precision float.

      Note that the result is an Object of type Double, so in case the wrapped value can not be converted to a number, null is returned. This means you can check for an empty result in the EL.

      Returns:
      the Double precision float value
    • getToFloat

      public Double getToFloat()
      Parses the wrapped value to a Double precision float.

      Note that the result is an Object of type Double, so in case the wrapped value can not be converted to a number, null is returned. This means you can check for an empty result in the EL.

      Returns:
      the Double precision float value
    • getToImage

      public CmsJspImageBean getToImage()
      Returns a scaled image bean from the wrapped value.

      In case the value does not point to an image resource, null is returned.

      Returns:
      the scaled image bean
    • getToInstanceDate

      public CmsJspInstanceDateBean getToInstanceDate()
      Converts a date to an instance date bean.
      Returns:
      the instance date bean.
    • getToInteger

      public Long getToInteger()
      Parses the wrapped value to a Long integer.

      Note that the result is an Object of type Long, so in case the wrapped value can not be converted to a number, null is returned. This means you can check for an empty result in the EL.

      Returns:
      the Long integer value
      See Also:
    • getToLink

      public CmsJspLinkWrapper getToLink()
      Converts the value to a link wrapper.
      Returns:
      the link wrapper
    • getToLinkStr

      public String getToLinkStr()
      Returns the substituted link to the wrapped value.

      In case no link can be substituted from the wrapped value, an empty String "" is returned.

      Returns:
      the substituted link
    • getToLocale

      public Locale getToLocale()
      Converts the wrapped value to a java.util.Locale instance using the locale manager.
      Returns:
      the locale instance for the wrapped value
    • getToLong

      public Long getToLong()
      Parses the wrapped value to a Long integer.

      Note that the result is an Object of type Long, so in case the wrapped value can not be converted to a number, null is returned. This means you can check for an empty result in the EL.

      Returns:
      the Long integer value
      See Also:
    • getToResource

      public CmsJspResourceWrapper getToResource()
      Returns the resource this value if pointing to.

      It is assumed the value holds a valid resource UIR in the OpenCms VFS. In case the value cannot be converted to a resource, an error is logged but no exception is thrown.

      Returns:
      the resource this value if pointing to
    • getToString

      public String getToString()
      Returns the wrapped value as a String.

      This will always be at least an empty String "", never null.

      Returns:
      the wrapped value as a String
    • getTrimToSize

      public Map<Object,String> getTrimToSize()
      Returns a lazy initialized map that provides trimmed to size strings of the wrapped object string value. The size being the integer value of the key object.

      Returns:
      a map that provides trimmed to size strings of the wrapped object string value
    • isEmpty

      public boolean isEmpty()
      Supports the use of the empty operator in the JSP EL by implementing the Collection interface.

      Specified by:
      isEmpty in interface Collection<String>
      Overrides:
      isEmpty in class AbstractCollection<String>
      Returns:
      the value from getIsEmptyOrWhitespaceOnly() which is the inverse of getIsSet().

      See Also:
    • isValid

      public boolean isValid(List<String> allowedValues)
      Compares this value against a list of Strings and returns true in case the list contains the toString representation of this value, or a false otherwise.

      Parameters:
      allowedValues - the list of allowed String values
      Returns:
      returns true in case the list contains the toString representation of this value, or a false otherwise
      See Also:
    • iterator

      public Iterator<String> iterator()
      Supports the use of the empty operator in the JSP EL by implementing the Collection interface.

      Specified by:
      iterator in interface Collection<String>
      Specified by:
      iterator in interface Iterable<String>
      Specified by:
      iterator in class AbstractCollection<String>
      Returns:
      an empty Iterator in case AbstractCollection.isEmpty() is true, otherwise an Iterator that will return the String value of this wrapper exactly once.

      See Also:
    • size

      public int size()
      Supports the use of the empty operator in the JSP EL by implementing the Collection interface.

      Specified by:
      size in interface Collection<String>
      Specified by:
      size in class AbstractCollection<String>
      Returns:
      always returns 0.

      See Also:
    • toDouble

      public Double toDouble(Double def)
      Parses the wrapped value to a Double precision float, returning the default in case the number can not be parsed.

      Parameters:
      def - the default in case the wrapped value can not be converted to a number
      Returns:
      a Double precision float value
      See Also:
    • toFloat

      public Double toFloat(Double def)
      Parses the wrapped value to a Double precision float, returning the default in case the number can not be parsed.

      Parameters:
      def - the default in case the wrapped value can not be converted to a number
      Returns:
      a Double precision float value
      See Also:
    • toInteger

      public Long toInteger(Long def)
      Parses the wrapped value to a Long integer, returning the default in case the number can not be parsed.

      Parameters:
      def - the default in case the wrapped value can not be converted to a number
      Returns:
      a Long integer value
      See Also:
    • toLong

      public Long toLong(Long def)
      Parses the wrapped value to a Long integer, returning the default in case the number can not be parsed.

      Parameters:
      def - the default in case the wrapped value can not be converted to a number
      Returns:
      a Long integer value
      See Also:
    • useDefault

      public org.opencms.jsp.util.A_CmsJspValueWrapper useDefault(Object defaultValue)
      Returns a value wrapper for the provided default in case this value is empty.

      If this value is empty, the object returned will be of type CmsJspObjectValueWrapper. This means you can only use simple "get me the value as type X" operations on the result safely.

      Parameters:
      defaultValue - the object to generate the default value from
      Returns:
      a value wrapper for the provided default in case this value is empty.
      See Also:
    • validate

      public org.opencms.jsp.util.A_CmsJspValueWrapper validate(List<String> allowedValues)
      Compares this value against a list of Strings and returns this value in case the list contains the toString representation of this value, or a CmsJspObjectValueWrapper.NULL_VALUE_WRAPPER otherwise.

      Parameters:
      allowedValues - the list of allowed String values
      Returns:
      returns this value in case the list contains the toString representation of this value, or a CmsJspObjectValueWrapper.NULL_VALUE_WRAPPER otherwise
      See Also:
    • validate

      public org.opencms.jsp.util.A_CmsJspValueWrapper validate(List<String> allowedValues, Object defaultValue)
      Checks this value against a list of Strings and returns this value in case the list contains the toString representation of this value, or a CmsJspObjectValueWrapper based on the given default object otherwise.

      Parameters:
      allowedValues - the list of allowed String values
      defaultValue - the object to generate the default value from
      Returns:
      returns this value in case the list contains the toString representation of this value, or a CmsJspObjectValueWrapper based on the given default object otherwise
      See Also: