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
FieldsModifier and TypeFieldDescriptionprotected CmsObjectStored CMS context.protected BooleanCached internal/external state.protected StringThe link literal from which this wrapper was created.protected Optional<CmsResource> Cached link target resource.Cached links (online, perma, server). -
Constructor Summary
ConstructorsConstructorDescriptionCmsJspLinkWrapper(CmsObject cms, String link) Creates a new link wrapper.CmsJspLinkWrapper(CmsObject cms, String link, boolean allowEmpty) Creates a new link wrapper.CmsJspLinkWrapper(CmsObject cms, CmsResource resource) Creates a new link wrapper for a specific resource. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanChecks if the link is 'external', which is not just the opposite of 'internal', in this case.booleanReturnstrueif 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.inthashCode()booleanisEmpty()Returnstrueif the wrapped link has been initialized.iterator()intsize()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, 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
-
m_cms
Stored CMS context. -
m_internal
Cached internal/external state. -
m_link
The link literal from which this wrapper was created. -
m_resource
Cached link target resource. -
m_stringCache
Cached links (online, perma, server).
-
-
Constructor Details
-
CmsJspLinkWrapper
Creates a new link wrapper for a specific resource.- Parameters:
cms- the CMS contextresource- the resource to link to
-
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- iftruethen empty links are allowed
-
-
Method Details
-
equals
- Specified by:
equalsin interfaceCollection<String>- Overrides:
equalsin classObject- See Also:
-
getIsExternal
Checks if the link is 'external', which is not just the opposite of 'internal', in this case.A link is external if it's either an internal link pointing to a different site, or a link to a location outside OpenCms, unless the domain is listed in the sitemap attribute 'template.editor.links.externalWhitelist' for the current subsite.
- Returns:
- the 'external' status of the link
-
getIsInternal
Returnstrueif the link is internal.- Returns:
trueif 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:
hashCodein interfaceCollection<String>- Overrides:
hashCodein classObject- See Also:
-
isEmpty
Returnstrueif the wrapped link has been initialized.- Specified by:
isEmptyin interfaceCollection<String>- Overrides:
isEmptyin classAbstractCollection<String>- Returns:
trueif the wrapped link has been initialized
-
iterator
- Specified by:
iteratorin interfaceCollection<String>- Specified by:
iteratorin interfaceIterable<String>- Specified by:
iteratorin classAbstractCollection<String>- See Also:
-
size
- Specified by:
sizein interfaceCollection<String>- Specified by:
sizein classAbstractCollection<String>- See Also:
-
toString
Returns the wrapped link as a String as ingetLink().- Overrides:
toStringin 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
-