Class URI.Hierarchical

java.lang.Object
org.eclipse.emf.common.util.URI
org.eclipse.emf.common.util.URI.Hierarchical
Enclosing class:
URI

protected static final class URI.Hierarchical extends URI
A subclass for representing a hierarchical URI.
  • Field Details

  • Constructor Details

    • Hierarchical

      protected Hierarchical(int hashCode, boolean hierarchical, String scheme, String authority, String device, boolean absolutePath, String[] segments, String query)
      Creates an instance from the components, computing the flags bits. Assertions are used to validate the integrity of the result. I.e., all components must be interned and the hash code must be equal to the hash code of the toString().
  • Method Details

    • isRelative

      public boolean isRelative()
      Description copied from class: URI
      Returns true if this is a relative URI, or false if it is an absolute URI.
      Overrides:
      isRelative in class URI
    • isBase

      protected boolean isBase()
      Overrides:
      isBase in class URI
    • isHierarchical

      public boolean isHierarchical()
      Description copied from class: URI
      Returns true if this a a hierarchical URI, or false if it is of the generic form.
      Overrides:
      isHierarchical in class URI
    • hasAuthority

      public boolean hasAuthority()
      Description copied from class: URI
      Returns true if this is a hierarchical URI with an authority component; false otherwise.
      Overrides:
      hasAuthority in class URI
    • hasDevice

      public boolean hasDevice()
      Description copied from class: URI
      Returns true if this is a hierarchical URI with a device component; false otherwise.
      Overrides:
      hasDevice in class URI
    • hasPath

      public boolean hasPath()
      Description copied from class: URI
      Returns true if this is a hierarchical URI with an absolute or relative path; false otherwise.
      Overrides:
      hasPath in class URI
    • hasDeviceOrPath

      protected boolean hasDeviceOrPath()
      Overrides:
      hasDeviceOrPath in class URI
    • hasAbsolutePath

      public boolean hasAbsolutePath()
      Description copied from class: URI
      Returns true if this is a hierarchical URI with an absolute path, or false if it is non-hierarchical, has no path, or has a relative path.
      Overrides:
      hasAbsolutePath in class URI
    • hasRelativePath

      public boolean hasRelativePath()
      Description copied from class: URI
      Returns true if this is a hierarchical URI with a relative path, or false if it is non-hierarchical, has no path, or has an absolute path.
      Overrides:
      hasRelativePath in class URI
    • hasEmptyPath

      public boolean hasEmptyPath()
      Description copied from class: URI
      Returns true if this is a hierarchical URI with an empty relative path; false otherwise.

      Note that !hasEmpty() does not imply that this URI has any path segments; however, hasRelativePath && !hasEmptyPath() does.

      Overrides:
      hasEmptyPath in class URI
    • hasQuery

      public boolean hasQuery()
      Description copied from class: URI
      Returns true if this is a hierarchical URI with a query component; false otherwise.
      Overrides:
      hasQuery in class URI
    • isCurrentDocumentReference

      public boolean isCurrentDocumentReference()
      Description copied from class: URI
      Returns true if this is a current document reference; that is, if it is a relative hierarchical URI with no authority, device or query components, and no path segments; false is returned otherwise.
      Overrides:
      isCurrentDocumentReference in class URI
    • isEmpty

      public boolean isEmpty()
      Description copied from class: URI
      Returns true if this is a current document reference with no fragment component; false otherwise.
      Overrides:
      isEmpty in class URI
      See Also:
    • isFile

      public boolean isFile()
      Description copied from class: URI
      Returns true if this is a hierarchical URI that may refer directly to a locally accessible file. This is considered to be the case for a file-scheme absolute URI, or for a relative URI with no query; false is returned otherwise.
      Overrides:
      isFile in class URI
    • isPlatform

      public boolean isPlatform()
      Description copied from class: URI
      Returns true if this is a platform URI, that is, an absolute, hierarchical URI, with "platform" scheme, no authority, and at least two segments; false is returned otherwise.
      Overrides:
      isPlatform in class URI
    • isPlatformResource

      public boolean isPlatformResource()
      Description copied from class: URI
      Returns true if this is a platform resource URI, that is, a platform URI whose first segment is "resource"; false is returned otherwise.
      Overrides:
      isPlatformResource in class URI
      See Also:
    • isPlatformPlugin

      public boolean isPlatformPlugin()
      Description copied from class: URI
      Returns true if this is a platform plug-in URI, that is, a platform URI whose first segment is "plugin"; false is returned otherwise.
      Overrides:
      isPlatformPlugin in class URI
      See Also:
    • isArchive

      public boolean isArchive()
      Description copied from class: URI
      Returns true if this is an archive URI. If so, it is also hierarchical, with an authority (consisting of an absolute URI followed by "!"), no device, and an absolute path.
      Overrides:
      isArchive in class URI
    • segmentsEqual

      protected boolean segmentsEqual(URI uri)
      Overrides:
      segmentsEqual in class URI
    • scheme

      public String scheme()
      Description copied from class: URI
      If this is an absolute URI, returns the scheme component; null otherwise.
      Overrides:
      scheme in class URI
    • authority

      public String authority()
      Description copied from class: URI
      If this is a hierarchical URI with an authority component, returns it; null otherwise.
      Overrides:
      authority in class URI
    • userInfo

      public String userInfo()
      Description copied from class: URI
      If this is a hierarchical URI with an authority component that has a user info portion, returns it; null otherwise.
      Overrides:
      userInfo in class URI
    • host

      public String host()
      Description copied from class: URI
      If this is a hierarchical URI with an authority component that has a host portion, returns it; null otherwise.
      Overrides:
      host in class URI
    • port

      public String port()
      Description copied from class: URI
      If this is a hierarchical URI with an authority component that has a port portion, returns it; null otherwise.
      Overrides:
      port in class URI
    • device

      public String device()
      Description copied from class: URI
      If this is a hierarchical URI with a device component, returns it; null otherwise.
      Overrides:
      device in class URI
    • segments

      public String[] segments()
      Description copied from class: URI
      If this is a hierarchical URI with a path, returns an array containing the segments of the path; an empty array otherwise. The leading separator in an absolute path is not represented in this array, but a trailing separator is represented by an empty-string segment as the final element.
      Overrides:
      segments in class URI
    • rawSegments

      protected String[] rawSegments()
      Overrides:
      rawSegments in class URI
    • segmentsList

      public List<String> segmentsList()
      Description copied from class: URI
      Returns an unmodifiable list containing the same segments as the array returned by segments.
      Overrides:
      segmentsList in class URI
    • segmentCount

      public int segmentCount()
      Description copied from class: URI
      Returns the number of elements in the segment array that would be returned by segments.
      Overrides:
      segmentCount in class URI
    • segment

      public String segment(int i)
      Description copied from class: URI
      Provides fast, indexed access to individual segments in the path segment array.
      Overrides:
      segment in class URI
    • lastSegment

      public String lastSegment()
      Description copied from class: URI
      Returns the last segment in the segment array, or null.
      Overrides:
      lastSegment in class URI
    • path

      public String path()
      Description copied from class: URI
      If this is a hierarchical URI with a path, returns a string representation of the path; null otherwise. The path consists of a leading segment separator character (a slash), if the path is absolute, followed by the slash-separated path segments. If this URI has a separate device component, it is not included in the path.
      Overrides:
      path in class URI
    • devicePath

      public String devicePath()
      Description copied from class: URI
      If this is a hierarchical URI with a path, returns a string representation of the path, including the authority and the device component; null otherwise.

      If there is no authority, the format of this string is:

         device/pathSegment1/pathSegment2...

      If there is an authority, it is:

         //authority/device/pathSegment1/pathSegment2...

      For an archive URI, it's just:

         authority/pathSegment1/pathSegment2...
      Overrides:
      devicePath in class URI
    • query

      public String query()
      Description copied from class: URI
      If this is a hierarchical URI with a query component, returns it; null otherwise.
      Overrides:
      query in class URI
    • appendQuery

      public URI appendQuery(String query)
      Description copied from class: URI
      Returns the URI formed from this URI and the given query.
      Overrides:
      appendQuery in class URI
    • trimQuery

      public URI trimQuery()
      Description copied from class: URI
      If this URI has a non-null query, returns the URI formed by removing it; this URI unchanged, otherwise.
      Overrides:
      trimQuery in class URI
    • resolve

      public URI resolve(URI base, boolean preserveRootParents)
      Description copied from class: URI
      Resolves this URI reference against a base absolute hierarchical URI, returning the resulting absolute URI. If already absolute, the URI itself is returned. URI resolution is described in detail in section 5.2 of RFC 2396, "Resolving Relative References to Absolute Form."

      During resolution, empty segments, self references ("."), and parent references ("..") are interpreted, so that they can be removed from the path. Step 6(g) gives a choice of how to handle the case where parent references point to a path above the root: the offending segments can be preserved or discarded. This method can do either.

      Overrides:
      resolve in class URI
      preserveRootParents - true if segments referring to the parent of the root path are to be preserved; false if they are to be discarded.
    • mergePath

      protected String[] mergePath(URI base, boolean preserveRootParents)
    • accumulate

      protected static int accumulate(String[] stack, int sp, String segment, boolean preserveRootParents)
    • deresolve

      public URI deresolve(URI base, boolean preserveRootParents, boolean anyRelPath, boolean shorterRelPath)
      Description copied from class: URI
      Finds an absolute URI that, when resolved against the given base absolute hierarchical URI using resolve, will yield this absolute URI. If base is non-hierarchical or is relative, or this is non-hierarchical or is relative, this will be returned.
      Overrides:
      deresolve in class URI
      preserveRootParents - the boolean argument to resolve(URI, boolean) for which the returned URI should resolve to this URI.
      anyRelPath - if true, the returned URI's path (if any) will be relative, if possible. If false, the form of the result's path will depend upon the next parameter.
      shorterRelPath - if anyRelPath is false and this parameter is true, the returned URI's path (if any) will be relative, if one can be found that is no longer (by number of segments) than the absolute path. If both anyRelPath and this parameter are false, it will be absolute.
    • hasCollapsableSegments

      protected boolean hasCollapsableSegments(boolean preserveRootParents)
    • findRelativePath

      protected String[] findRelativePath(URI base, boolean preserveRootParents)
    • collapseSegments

      protected String[] collapseSegments(boolean preserveRootParents)
      Overrides:
      collapseSegments in class URI
    • cacheString

      protected void cacheString(String string)
      Overrides:
      cacheString in class URI
    • flushCachedString

      protected void flushCachedString()
      Overrides:
      flushCachedString in class URI
    • getCachedString

      protected String getCachedString()
      Overrides:
      getCachedString in class URI
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • matches

      protected boolean matches(String string)
      Overrides:
      matches in class URI
    • matches

      protected boolean matches(int validate, boolean hierarchical, String scheme, String authority, String device, boolean absolutePath, String[] segments, String query)
      Overrides:
      matches in class URI
    • matches

      protected boolean matches(String base, String path)
      Overrides:
      matches in class URI
    • toFileString

      public String toFileString()
      Description copied from class: URI
      If this URI may refer directly to a locally accessible file, as determined by isFile, decodes and formats the URI as a pathname to that file; returns null otherwise.

      If there is no authority, the format of this string is:

         device/pathSegment1/pathSegment2...

      If there is an authority, it is:

         //authority/device/pathSegment1/pathSegment2...

      However, the character used as a separator is system-dependent and obtained from File.separatorChar.

      Overrides:
      toFileString in class URI
    • toPlatformString

      public String toPlatformString(boolean decode)
      Description copied from class: URI
      If this is a platform URI, as determined by URI.isPlatform(), returns the workspace-relative or plug-in-based path to the resource, optionally decoding the segments in the process.
      Overrides:
      toPlatformString in class URI
      See Also:
    • appendSegment

      public URI appendSegment(String segment)
      Description copied from class: URI
      Returns the URI formed by appending the specified segment on to the end of the path of this URI, if hierarchical; this URI unchanged, otherwise. If this URI has an authority and/or device, but no path, the segment becomes the first under the root in an absolute path.
      Overrides:
      appendSegment in class URI
    • appendSegments

      public URI appendSegments(String[] segments)
      Description copied from class: URI
      Returns the URI formed by appending the specified segments on to the end of the path of this URI, if hierarchical; this URI unchanged, otherwise. If this URI has an authority and/or device, but no path, the segments are made to form an absolute path.
      Overrides:
      appendSegments in class URI
      Parameters:
      segments - an array of non-null strings, each representing one segment of the path. If desired, a trailing separator should be represented by an empty-string segment as the last element of the array.
    • trimSegments

      public URI trimSegments(int i)
      Description copied from class: URI
      Returns the URI formed by trimming the specified number of segments (including empty segments, such as one representing a trailing separator) from the end of the path of this URI, if hierarchical; otherwise, this URI is returned unchanged.

      Note that if all segments are trimmed from an absolute path, the root absolute path remains.

      Overrides:
      trimSegments in class URI
      Parameters:
      i - the number of segments to be trimmed in the returned URI. If less than 1, this URI is returned unchanged; if equal to or greater than the number of segments in this URI's path, all segments are trimmed.
    • hasTrailingPathSeparator

      public boolean hasTrailingPathSeparator()
      Description copied from class: URI
      Returns true if this is a hierarchical URI that has a path that ends with a trailing separator; false otherwise.

      A trailing separator is represented as an empty segment as the last segment in the path; note that this definition does not include the lone separator in the root absolute path.

      Overrides:
      hasTrailingPathSeparator in class URI
    • fileExtension

      public String fileExtension()
      Description copied from class: URI
      If this is a hierarchical URI whose path includes a file extension, that file extension is returned; null otherwise. We define a file extension as any string following the last period (".") in the final path segment. If there is no path, the path ends in a trailing separator, or the final segment contains no period, then we consider there to be no file extension. If the final segment ends in a period, then the file extension is an empty string.
      Overrides:
      fileExtension in class URI
    • appendFileExtension

      public URI appendFileExtension(String fileExtension)
      Description copied from class: URI
      Returns the URI formed by appending a period (".") followed by the specified file extension to the last path segment of this URI, if it is hierarchical with a non-empty path ending in a non-empty segment; otherwise, this URI is returned unchanged.

      The extension is appended regardless of whether the segment already contains an extension.

      Overrides:
      appendFileExtension in class URI
    • trimFileExtension

      public URI trimFileExtension()
      Description copied from class: URI
      If this URI has a non-null fileExtension, returns the URI formed by removing it; this URI unchanged, otherwise.
      Overrides:
      trimFileExtension in class URI
    • isPrefix

      public boolean isPrefix()
      Description copied from class: URI
      Returns true if this is a hierarchical URI that ends in a slash; that is, it has a trailing path separator or is the root absolute path, and has no query and no fragment; false is returned otherwise.
      Overrides:
      isPrefix in class URI
    • replacePrefix

      public URI replacePrefix(URI oldPrefix, URI newPrefix)
      Description copied from class: URI
      If this is a hierarchical URI reference and oldPrefix is a prefix of it, this returns the URI formed by replacing it by newPrefix; null otherwise.

      In order to be a prefix, the oldPrefix's isPrefix must return true, and it must match this URI's scheme, authority, and device. Also, the paths must match, up to prefix's end.

      Overrides:
      replacePrefix in class URI