Class ContextName


  • public final class ContextName
    extends java.lang.Object
    Utility class to manage context names so there is one place where the conversions between baseName, path and version take place.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String ROOT_NAME
      The name used for the root context.
    • Constructor Summary

      Constructors 
      Constructor Description
      ContextName​(java.lang.String name, boolean stripFileExtension)
      Creates an instance from a context name, display name, base name, directory name, WAR name or context.xml name.
      ContextName​(java.lang.String path, java.lang.String version)
      Construct an instance from a path and version.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static ContextName extractFromPath​(java.lang.String path)
      Extract the final component of the given path which is assumed to be a base name and generate a ContextName from that base name.
      java.lang.String getBaseName()
      Returns the base name of this context.
      java.lang.String getDisplayName()
      Returns the display name of this context.
      java.lang.String getName()
      Returns the name of this context.
      java.lang.String getPath()
      Returns the path of this context.
      java.lang.String getVersion()
      Returns the version of this context.
      boolean isPathValid()
      Checks if the path for this instance is valid.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • ROOT_NAME

        public static final java.lang.String ROOT_NAME
        The name used for the root context.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ContextName

        public ContextName​(java.lang.String name,
                           boolean stripFileExtension)
        Creates an instance from a context name, display name, base name, directory name, WAR name or context.xml name.
        Parameters:
        name - The name to use as the basis for this object
        stripFileExtension - If a .war or .xml file extension is present at the end of the provided name should it be removed?
      • ContextName

        public ContextName​(java.lang.String path,
                           java.lang.String version)
        Construct an instance from a path and version.
        Parameters:
        path - Context path to use
        version - Context version to use
    • Method Detail

      • getBaseName

        public java.lang.String getBaseName()
        Returns the base name of this context.
        Returns:
        the base name
      • getPath

        public java.lang.String getPath()
        Returns the path of this context.
        Returns:
        the context path
      • getVersion

        public java.lang.String getVersion()
        Returns the version of this context.
        Returns:
        the context version
      • getName

        public java.lang.String getName()
        Returns the name of this context.
        Returns:
        the context name
      • getDisplayName

        public java.lang.String getDisplayName()
        Returns the display name of this context.
        Returns:
        the display name
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • isPathValid

        public boolean isPathValid()
        Checks if the path for this instance is valid.
        Returns:
        true if the path given/calculated for this instance is valid, otherwise false
      • extractFromPath

        public static ContextName extractFromPath​(java.lang.String path)
        Extract the final component of the given path which is assumed to be a base name and generate a ContextName from that base name.
        Parameters:
        path - The path that ends in a base name
        Returns:
        the ContextName generated from the given base name