|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opencms.jsp.util.CmsJspContentAccessValueWrapper
public final class CmsJspContentAccessValueWrapper
Allows direct access to XML content values, with possible iteration of sub-nodes.
The implementation is optimized for performance and uses lazy initializing of the requested values as much as possible.
CmsJspContentAccessBean
,
CmsJspTagContentAccess
Nested Class Summary | |
---|---|
class |
CmsJspContentAccessValueWrapper.CmsHasValueTransformer
Provides a Map with Booleans that indicate if a nested sub value (xpath) for the current value is available in the XML content. |
class |
CmsJspContentAccessValueWrapper.CmsValueListTransformer
Provides a Map which lets the user access nested sub value Lists from the current value, the input is assumed to be a String that represents an xpath in the XML content. |
class |
CmsJspContentAccessValueWrapper.CmsValueTransformer
Provides a Map which lets the user a nested sub value from the current value, the input is assumed to be a String that represents an xpath in the XML content. |
class |
CmsJspContentAccessValueWrapper.CmsXmlValueTransformer
Provides a Map which lets the user directly access sub-nodes of the XML represented by the current value, the input is assumed to be a String that represents an xpath in the XML content. |
Field Summary | |
---|---|
protected static CmsJspContentAccessValueWrapper |
NULL_VALUE_WRAPPER
Constant for the null (non existing) value. |
Method Summary | |
---|---|
protected java.lang.String |
createPath(java.lang.Object input)
Returns the path to the XML content based on the current element path. |
static CmsJspContentAccessValueWrapper |
createWrapper(CmsObject cms,
I_CmsXmlContentValue value)
Factory method to create a new XML content value wrapper. |
boolean |
equals(java.lang.Object obj)
|
boolean |
getExists()
Returns true in case this value actually exists in the XML content it was requested from. |
java.util.Map |
getHasValue()
Returns a lazy initialized Map that provides Booleans that indicate if a nested sub value (xpath) for the current value is available in the XML content. |
int |
getIndex()
Returns the node index of the XML content value in the source XML document, starting with 0. |
boolean |
getIsEmpty()
Returns true in case the value is empty, that is either null or an empty String. |
boolean |
getIsEmptyOrWhitespaceOnly()
Returns true in case the value is empty or whitespace only,
that is either null or String that contains only whitespace chars. |
java.util.Locale |
getLocale()
Returns the Locale of the current XML content value. |
java.lang.String |
getPath()
Returns the path to the current XML content value. |
CmsJspContentAccessValueWrapper |
getResolve()
Short form of getResolveMacros() . |
CmsJspContentAccessValueWrapper |
getResolveMacros()
Turn on macro resolving for the wrapped value. |
java.lang.String |
getStringValue()
Returns the String value of the wrapped content value. |
java.util.Map |
getValue()
Returns a lazy initialized Map that provides the nested sub values for the current value from the XML content. |
java.util.Map |
getValueList()
Returns a lazy initialized Map that provides the Lists of nested sub values for the current value from the XML content. |
java.util.Map |
getXmlText()
Returns a lazy initialized Map that provides direct access to the XML element for the current value from the XML content. |
int |
hashCode()
|
CmsObject |
obtainCmsObject()
Returns the wrapped OpenCms user context. |
I_CmsXmlContentValue |
obtainContentValue()
Returns the wrapped content value. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final CmsJspContentAccessValueWrapper NULL_VALUE_WRAPPER
Method Detail |
---|
public static CmsJspContentAccessValueWrapper createWrapper(CmsObject cms, I_CmsXmlContentValue value)
In case either parameter is null
, the NULL_VALUE_WRAPPER
is returned.
cms
- the current users OpenCms contextvalue
- the value to warp
null
if any parameter is null
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
Object.equals(java.lang.Object)
public boolean getExists()
true
in case this value actually exists in the XML content it was requested from.Usage example on a JSP with the JSTL:
<cms:contentload ... > <cms:contentaccess var="content" /> <c:if test="${content.value['Link'].exists}" > The content has a "Link" value! </c:if> </cms:contentload>
true
in case this value actually exists in the XML content it was requested frompublic java.util.Map getHasValue()
The provided Map key is assumed to be a String that represents the relative xpath to the value.
In case the current value is not a nested XML content value, or the XML content value does not exist,
the CmsConstantMap.CONSTANT_BOOLEAN_FALSE_MAP
is returned.
Usage example on a JSP with the JSTL:
<cms:contentload ... > <cms:contentaccess var="content" /> <c:if test="${content.value['Link'].hasValue['Description']}" > The content has a "Description" value as sub element to the "Link" value! </c:if> </cms:contentload>Please note that you can also test if a sub-value exists like this:
<c:if test="${content.value['Link'].value['Description'].exists}" > ... </c:if>
public int getIndex()
In case the XML content value does not exist, -1
is returned.
Usage example on a JSP with the JSTL:
<cms:contentload ... > <cms:contentaccess var="content" /> The locale of the Link node: ${content.value['Link'].locale} </cms:contentload>
public boolean getIsEmpty()
true
in case the value is empty, that is either null
or an empty String.
In case the XML content value does not exist, true
is returned.
Usage example on a JSP with the JSTL:
<cms:contentload ... > <cms:contentaccess var="content" /> <c:if test="${content.value['Link'].isEmpty}" > The content of the "Link" value is empty. </c:if> </cms:contentload>
true
in case the value is emptypublic boolean getIsEmptyOrWhitespaceOnly()
true
in case the value is empty or whitespace only,
that is either null
or String that contains only whitespace chars.
In case the XML content value does not exist, true
is returned.
Usage example on a JSP with the JSTL:
<cms:contentload ... > <cms:contentaccess var="content" /> <c:if test="${content.value['Link'].isEmptyOrWhitespaceOnly}" > The content of the "Link" value is empty or contains only whitespace chars. </c:if> </cms:contentload>
true
in case the value is empty or whitespace onlypublic java.util.Locale getLocale()
In case the XML content value does not exist, the OpenCms system default Locale is returned.
Usage example on a JSP with the JSTL:
<cms:contentload ... > <cms:contentaccess var="content" /> The locale of the Link node: ${content.value['Link'].locale} </cms:contentload>
public java.lang.String getPath()
In case the XML content value does not exist, an empty String ""
is returned.
Usage example on a JSP with the JSTL:
<cms:contentload ... > <cms:contentaccess var="content" /> The path to the Link node in the XML: ${content.value['Link'].path} </cms:contentload>
public CmsJspContentAccessValueWrapper getResolve()
getResolveMacros()
.
getResolveMacros()
public CmsJspContentAccessValueWrapper getResolveMacros()
Macro resolving is turned off by default.
When turned on, a macro resolver is initialized with
the current OpenCms user context and the URI of the current resource.
This means known macros contained in the wrapped value will be resolved when the output String is generated.
For example, a %(property.Title)
in the value would be replaced with the
value of the title property. Macros that can not be resolved will be kept.
Usage example on a JSP with the JSTL:
<cms:contentload ... > <cms:contentaccess var="content" /> The text with macros resolved: ${content.value['Text'].resolveMacros} </cms:contentload>
CmsMacroResolver
public java.lang.String getStringValue()
Note that this will return the empty String ""
when getExists()
returns false
.
toString()
public java.util.Map getValue()
The provided Map key is assumed to be a String that represents the relative xpath to the value.
In case the current value is not a nested XML content value, or the XML content value does not exist,
the CmsJspContentAccessBean.CONSTANT_NULL_VALUE_WRAPPER_MAP
is returned.
Usage example on a JSP with the JSTL:
<cms:contentload ... > <cms:contentaccess var="content" /> The Link Description: ${content.value['Link'].value['Description']} </cms:contentload>Please note that this example will only work if the 'Link' element is mandatory in the schema definition of the XML content.
public java.util.Map getValueList()
The provided Map key is assumed to be a String that represents the relative xpath to the value. Use this method in case you want to iterate over a List of values form the XML content.
In case the current value is not a nested XML content value, or the XML content value does not exist,
the CmsConstantMap.CONSTANT_EMPTY_LIST_MAP
is returned.
Usage example on a JSP with the JSTL:
<cms:contentload ... > <cms:contentaccess var="content" /> <c:forEach var="desc" items="${content.value['Link'].valueList['Description']}"> ${desc} </c:forEach> </cms:contentload>
public java.util.Map getXmlText()
public int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()
public CmsObject obtainCmsObject()
Note that this will return null
when getExists()
returns false
.
public I_CmsXmlContentValue obtainContentValue()
Note that this will return null
when getExists()
returns false
. Method name does not start with "get" to prevent using it in the expression language.
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
,
getStringValue()
protected java.lang.String createPath(java.lang.Object input)
This is used to create xpath information for sub-elements in the transformers.
input
- the additional path that is appended to the current path
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |