Class CmsJspLinkWrapper

  • All Implemented Interfaces:
    java.lang.Iterable<java.lang.String>, java.util.Collection<java.lang.String>

    public class CmsJspLinkWrapper
    extends java.util.AbstractCollection<java.lang.String>
    Wrapper for handling links in template/formatter JSP EL.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected CmsObject m_cms
      Stored CMS context.
      protected java.lang.Boolean m_internal
      Cached internal/external state.
      protected java.lang.String m_link
      The link literal from which this wrapper was created.
      protected java.util.Optional<CmsResource> m_resource
      Cached link target resource.
      protected java.util.Map<java.lang.String,​java.lang.String> m_stringCache
      Cached links (online, perma, server).
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      boolean getIsInternal()
      Returns true if the link is internal.
      java.lang.String getLink()
      Performs normal link substitution.
      java.lang.String getLiteral()
      Gets the literal from which this wrapper was constructed.
      java.lang.String getOnlineLink()
      Performs online link substitution.
      java.lang.String getPermaLink()
      Performs permalink substitution.
      CmsJspResourceWrapper getResource()
      Gets the resource wrapper for the link target.
      java.lang.String getServerLink()
      Performs server link substitution.
      java.lang.String getToString()
      Returns the wrapped link as a String as in toString().
      int hashCode()  
      boolean isEmpty()
      Returns true if the wrapped link has been initialized.
      java.util.Iterator<java.lang.String> iterator()  
      int size()  
      java.lang.String toString()
      Returns the wrapped link as a String as in getLink().
      • 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
      • Methods inherited from interface java.lang.Iterable

        forEach
    • Field Detail

      • m_link

        protected java.lang.String m_link
        The link literal from which this wrapper was created.
      • m_internal

        protected java.lang.Boolean m_internal
        Cached internal/external state.
      • m_stringCache

        protected java.util.Map<java.lang.String,​java.lang.String> m_stringCache
        Cached links (online, perma, server).
    • Constructor Detail

      • CmsJspLinkWrapper

        public CmsJspLinkWrapper​(CmsObject cms,
                                 java.lang.String link)
        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 context
        link - the link to wrap
      • CmsJspLinkWrapper

        public CmsJspLinkWrapper​(CmsObject cms,
                                 java.lang.String link,
                                 boolean allowEmpty)
        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 context
        link - the link to wrap
        allowEmpty - if true then empty links are allowed
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object obj)
        Specified by:
        equals in interface java.util.Collection<java.lang.String>
        Overrides:
        equals in class java.lang.Object
        See Also:
        Object.equals(java.lang.Object)
      • getIsInternal

        public boolean getIsInternal()
        Returns true if the link is internal.
        Returns:
        true if the link is internal
      • getLink

        public java.lang.String getLink()
        Performs normal link substitution.
        Returns:
        the substituted link
      • getLiteral

        public java.lang.String getLiteral()
        Gets the literal from which this wrapper was constructed.
        Returns:
        the original link literal
      • getOnlineLink

        public java.lang.String getOnlineLink()
        Performs online link substitution.
        Returns:
        the online link
      • getPermaLink

        public java.lang.String getPermaLink()
        Performs permalink substitution.
        Returns:
        the permalink
      • getServerLink

        public java.lang.String getServerLink()
        Performs server link substitution.
        Returns:
        the server link
      • getToString

        public java.lang.String getToString()
        Returns the wrapped link as a String as in toString().

        Returns:
        the wrapped link as a String
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Collection<java.lang.String>
        Overrides:
        hashCode in class java.lang.Object
        See Also:
        Collection.hashCode()
      • isEmpty

        public boolean isEmpty()
        Returns true if the wrapped link has been initialized.

        Specified by:
        isEmpty in interface java.util.Collection<java.lang.String>
        Overrides:
        isEmpty in class java.util.AbstractCollection<java.lang.String>
        Returns:
        true if the wrapped link has been initialized
      • iterator

        public java.util.Iterator<java.lang.String> iterator()
        Specified by:
        iterator in interface java.util.Collection<java.lang.String>
        Specified by:
        iterator in interface java.lang.Iterable<java.lang.String>
        Specified by:
        iterator in class java.util.AbstractCollection<java.lang.String>
        See Also:
        AbstractCollection.iterator()
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<java.lang.String>
        Specified by:
        size in class java.util.AbstractCollection<java.lang.String>
        See Also:
        AbstractCollection.size()
      • toString

        public java.lang.String toString()
        Returns the wrapped link as a String as in getLink().

        Overrides:
        toString in class java.util.AbstractCollection<java.lang.String>
        Returns:
        the wrapped link as a String
        See Also:
        getLiteral()