Class CmsJspObjectValueWrapper
- All Implemented Interfaces:
Iterable<String>,Collection<String>
- Since:
- 11.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CmsObjectThe wrapped OpenCms user context.protected Optional<CmsJspLinkWrapper> Cached link wrapper - use Optional to distinguish 'uncached' state from 'does not exist'.protected static final CmsJspObjectValueWrapperConstant for the null (non existing) value. -
Method Summary
Modifier and TypeMethodDescriptionstatic CmsJspObjectValueWrappercreateWrapper(CmsObject cms, Object value) Factory method to create a new XML content value wrapper.booleanReturns the current cms context.Returns a lazy initialized Map that provides Booleans which indicate if if the wrapped values String representation contains a specific String.booleanReturnstruein case there was an object wrapped.booleanReturnstruein case the object is empty, that is eithernullor an empty String.booleanReturnstruein case the object is empty or whitespace only, that is eithernullor an empty String.Returns a lazy initialized Map that provides Booleans which indicate if an Object is equal to the wrapped object.booleangetIsSet()Returnstruein case the wrapped value exists and is not empty or whitespace only.booleanReturnstruein case the wrapped value exists, is not empty or whitespace only and is also not equal to the String'none'.Calculates the next largest integer from the wrapped value.Calculates the next smallest integer from the wrapped value.Calculates the next integer from the wrapped value by rounding.Returns the wrapped object value.Deprecated.Assumes the wrapped value is a String and strips all HTML markup from this String.booleanConverts the wrapped value to a boolean.Tries to create a container page wrapper from the wrapped value.Converts the wrapped value to a date.Parses the wrapped value to a Double precision float.Parses the wrapped value to a Double precision float.Returns a scaled image bean from the wrapped value.Converts a date to an instance date bean.Parses the wrapped value to a Long integer.Converts the value to a link wrapper.Returns the substituted link to the wrapped value.Converts the wrapped value to a java.util.Locale instance using the locale manager.Parses the wrapped value to a Long integer.Returns the resource this value if pointing to.Returns the wrapped value as a String.Returns a lazy initialized map that provides trimmed to size strings of the wrapped object string value.inthashCode()booleanisEmpty()Supports the use of theemptyoperator in the JSP EL by implementing the Collection interface.booleanCompares this value against a list of Strings and returnstruein case the list contains the toString representation of this value, or afalseotherwise.iterator()Supports the use of theemptyoperator in the JSP EL by implementing the Collection interface.intsize()Supports the use of theemptyoperator in the JSP EL by implementing the Collection interface.static StringsubstituteLink(CmsObject cms, String target) Returns the substituted link to the given target.Parses the wrapped value to a Double precision float, returning the default in case the number can not be parsed.Parses the wrapped value to a Double precision float, returning the default in case the number can not be parsed.Parses the wrapped value to a Long integer, returning the default in case the number can not be parsed.Parses the wrapped value to a Long integer, returning the default in case the number can not be parsed.toString()org.opencms.jsp.util.A_CmsJspValueWrapperuseDefault(Object defaultValue) Returns a value wrapper for the provided default in case this value is empty.org.opencms.jsp.util.A_CmsJspValueWrapperCompares this value against a list of Strings and returns this value in case the list contains the toString representation of this value, or aNULL_VALUE_WRAPPERotherwise.org.opencms.jsp.util.A_CmsJspValueWrapperChecks this value against a list of Strings and returns this value in case the list contains the toString representation of this value, or aCmsJspObjectValueWrapperbased on the given default object otherwise.Methods inherited from class java.util.AbstractCollection
add, addAll, clear, contains, containsAll, remove, removeAll, retainAll, toArray, toArrayMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, spliterator, stream, toArray
-
Field Details
-
NULL_VALUE_WRAPPER
Constant for the null (non existing) value. -
m_cms
The wrapped OpenCms user context. -
m_linkObj
Cached link wrapper - use Optional to distinguish 'uncached' state from 'does not exist'.
-
-
Method Details
-
createWrapper
Factory method to create a new XML content value wrapper.In case either parameter is
null, theNULL_VALUE_WRAPPERis returned.- Parameters:
cms- the current users OpenCms contextvalue- the object to warp- Returns:
- a new content value wrapper instance, or
nullif any parameter isnull
-
getExists
Returnstruein case there was an object wrapped.- Returns:
truein case there was an object wrapped
-
getIsEmpty
Returnstruein case the object is empty, that is eithernullor an empty String.In case the object does not exist,
trueis returned.- Returns:
truein case the object is empty
-
getIsEmptyOrWhitespaceOnly
Returnstruein case the object is empty or whitespace only, that is eithernullor an empty String.In case the object does not exist,
trueis returned.- Returns:
truein case the object is empty
-
getObjectValue
Returns the wrapped object value.- Returns:
- the wrapped object value
-
getToDate
Converts the wrapped value to a date. Keeps it as date, if it already is one.- Returns:
- the date
- See Also:
-
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
- See Also:
-
hashCode
- Specified by:
hashCodein interfaceCollection<String>- See Also:
-
toString
- Overrides:
toStringin classAbstractCollection<String>- See Also:
-
substituteLink
Returns the substituted link to the given target.- Parameters:
cms- the cms contexttarget- the link target- Returns:
- the substituted link
-
equals
- Specified by:
equalsin interfaceCollection<String>- Overrides:
equalsin classObject- See Also:
-
getCmsObject
Returns the current cms context.- Returns:
- the cms context
-
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
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()Returnstruein case the wrapped value exists and is not empty or whitespace only.- Returns:
truein case the wrapped value exists and is not empty or whitespace only
-
getIsSetNotNone
public boolean getIsSetNotNone()Returnstruein case the wrapped value exists, is not empty or whitespace only and is also not equal to the String'none'.- Returns:
truein case the wrapped value exists, is not empty or whitespace only and is also not equal to the String'none'
-
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,nullis returned. This means you can check for anemptyresult in the EL.- Returns:
- the next largest integer for the wrapped value
-
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,nullis returned. This means you can check for anemptyresult in the EL.- Returns:
- the next smallest integer for the wrapped value
-
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,nullis returned. This means you can check for anemptyresult in the EL.- Returns:
- the next integer for the wrapped value calculated by rounding
-
getStringValue
Deprecated.usegetToString()insteadReturns the String value for the wrapped content value.This will return the empty String
""whengetExists()returnsfalse.
- Returns:
- the String value of the wrapped content value
-
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
Tries to create a container page wrapper from the wrapped value.- Returns:
- the container page wrapper or null if none could be created
-
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,nullis returned. This means you can check for anemptyresult in the EL.- Returns:
- the Double precision float value
-
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,nullis returned. This means you can check for anemptyresult in the EL.- Returns:
- the Double precision float value
-
getToImage
Returns a scaled image bean from the wrapped value.In case the value does not point to an image resource,
nullis returned.- Returns:
- the scaled image bean
-
getToInstanceDate
Converts a date to an instance date bean.- Returns:
- the instance date bean.
-
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,nullis returned. This means you can check for anemptyresult in the EL.- Returns:
- the Long integer value
- See Also:
-
getToLink
Converts the value to a link wrapper.- Returns:
- the link wrapper
-
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
Converts the wrapped value to a java.util.Locale instance using the locale manager.- Returns:
- the locale instance for the wrapped value
-
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,nullis returned. This means you can check for anemptyresult in the EL.- Returns:
- the Long integer value
- See Also:
-
getToString
Returns the wrapped value as a String.This will always be at least an empty String
"", nevernull.- Returns:
- the wrapped value as a 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 theemptyoperator in the JSP EL by implementing the Collection interface.- Specified by:
isEmptyin interfaceCollection<String>- Overrides:
isEmptyin classAbstractCollection<String>- Returns:
- the value from
getIsEmptyOrWhitespaceOnly()which is the inverse ofgetIsSet(). - See Also:
-
isValid
Compares this value against a list of Strings and returnstruein case the list contains the toString representation of this value, or afalseotherwise.- Parameters:
allowedValues- the list of allowed String values- Returns:
- returns
truein case the list contains the toString representation of this value, or afalseotherwise - See Also:
-
iterator
Supports the use of theemptyoperator in the JSP EL by implementing the Collection interface.- Specified by:
iteratorin interfaceCollection<String>- Specified by:
iteratorin interfaceIterable<String>- Specified by:
iteratorin classAbstractCollection<String>- Returns:
- an empty Iterator in case
AbstractCollection.isEmpty()istrue, otherwise an Iterator that will return the String value of this wrapper exactly once. - See Also:
-
size
public int size()Supports the use of theemptyoperator in the JSP EL by implementing the Collection interface.- Specified by:
sizein interfaceCollection<String>- Specified by:
sizein classAbstractCollection<String>- Returns:
- always returns 0.
- See Also:
-
toDouble
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
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
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
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
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
Compares this value against a list of Strings and returns this value in case the list contains the toString representation of this value, or aNULL_VALUE_WRAPPERotherwise.- 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
NULL_VALUE_WRAPPERotherwise - 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 aCmsJspObjectValueWrapperbased on the given default object otherwise.- Parameters:
allowedValues- the list of allowed String valuesdefaultValue- 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
CmsJspObjectValueWrapperbased on the given default object otherwise - See Also:
-
getToString()instead