Package org.opencms.jsp.util
Class CmsJspLinkWrapper
- All Implemented Interfaces:
Iterable<String>
,Collection<String>
Wrapper for handling links in template/formatter JSP EL.
-
Field Summary
Modifier and TypeFieldDescriptionprotected CmsObject
Stored CMS context.protected Boolean
Cached internal/external state.protected String
The link literal from which this wrapper was created.protected Optional<CmsResource>
Cached link target resource.Cached links (online, perma, server). -
Constructor Summary
ConstructorDescriptionCmsJspLinkWrapper
(CmsObject cms, String link) Creates a new link wrapper.CmsJspLinkWrapper
(CmsObject cms, String link, boolean allowEmpty) Creates a new link wrapper. -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
Returnstrue
if the link is internal.getLink()
Performs normal link substitution.Gets the literal from which this wrapper was constructed.Performs online link substitution.Performs permalink substitution.Gets the resource wrapper for the link target.Performs server link substitution.Returns the wrapped link as a String as intoString()
.getToURI()
Converts the wrapped string to an URI object and returns it.int
hashCode()
boolean
isEmpty()
Returnstrue
if the wrapped link has been initialized.iterator()
int
size()
toString()
Returns the wrapped link as a String as ingetLink()
.toURI()
Converts the wrapped string to an URI object and returns it.Methods inherited from class java.util.AbstractCollection
add, addAll, clear, contains, containsAll, remove, removeAll, retainAll, toArray, toArray
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, spliterator, stream, toArray
-
Field Details
-
m_cms
Stored CMS context. -
m_link
The link literal from which this wrapper was created. -
m_internal
Cached internal/external state. -
m_resource
Cached link target resource. -
m_stringCache
Cached links (online, perma, server).
-
-
Constructor Details
-
CmsJspLinkWrapper
Creates a new link wrapper.The link parameter should be in the same format that you enter in an XML content of field of type OpenCmsVarLink, i.e. either a full external URL or a site path with a query string attached.
- Parameters:
cms
- the CMS contextlink
- the link to wrap
-
CmsJspLinkWrapper
Creates a new link wrapper.The link parameter should be in the same format that you enter in an XML content of field of type OpenCmsVarLink, i.e. either a full external URL or a site path with a query string attached.
- Parameters:
cms
- the CMS contextlink
- the link to wrapallowEmpty
- iftrue
then empty links are allowed
-
-
Method Details
-
equals
- Specified by:
equals
in interfaceCollection<String>
- Overrides:
equals
in classObject
- See Also:
-
getIsInternal
Returnstrue
if the link is internal.- Returns:
true
if the link is internal
-
getLink
Performs normal link substitution.- Returns:
- the substituted link
-
getLiteral
Gets the literal from which this wrapper was constructed.- Returns:
- the original link literal
-
getOnlineLink
Performs online link substitution.- Returns:
- the online link
-
getPermaLink
Performs permalink substitution.- Returns:
- the permalink
-
getResource
Gets the resource wrapper for the link target.- Returns:
- the resource wrapper for the target
-
getServerLink
Performs server link substitution.- Returns:
- the server link
-
getToString
Returns the wrapped link as a String as intoString()
.- Returns:
- the wrapped link as a String
-
getToURI
Converts the wrapped string to an URI object and returns it.If the wrapped string cannont be converted, returns null.
- Returns:
- the URI object for the wrapped string, or null if conversion fails
-
hashCode
- Specified by:
hashCode
in interfaceCollection<String>
- Overrides:
hashCode
in classObject
- See Also:
-
isEmpty
Returnstrue
if the wrapped link has been initialized.- Specified by:
isEmpty
in interfaceCollection<String>
- Overrides:
isEmpty
in classAbstractCollection<String>
- Returns:
true
if the wrapped link has been initialized
-
iterator
- Specified by:
iterator
in interfaceCollection<String>
- Specified by:
iterator
in interfaceIterable<String>
- Specified by:
iterator
in classAbstractCollection<String>
- See Also:
-
size
- Specified by:
size
in interfaceCollection<String>
- Specified by:
size
in classAbstractCollection<String>
- See Also:
-
toString
Returns the wrapped link as a String as ingetLink()
.- Overrides:
toString
in classAbstractCollection<String>
- Returns:
- the wrapped link as a String
- See Also:
-
toURI
Converts the wrapped string to an URI object and returns it.If the wrapped string cannont be converted, returns null.
- Returns:
- the URI object for the wrapped string, or null if conversion fails
-