Class URI.Hierarchical
- Enclosing class:
URI
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.emf.common.util.URI
URI.Fragment, URI.Hierarchical, URI.Opaque, URI.URIPool -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final StringThe authority of the hierarchical URI.protected final StringThe device of the hierarchical URI.protected final intBit flags for the results of all the boolean no-argument methods.protected static final intTheflagsbit for representingURI.hasAbsolutePath().protected static final intTheflagsbit for representingURI.hasEmptyPath().protected static final intTheflagsbits for representingURI.hasPath().protected static final intTheflagsbit for representingURI.hasRelativePath().protected static final intTheflagsbit for representingURI.hasTrailingPathSeparator().protected static final intTheflagsbit for representingURI.isArchive().protected static final intTheflagsbit for representingURI.isCurrentDocumentReference().protected static final intTheflagsbit for representingURI.isFile().protected static final intTheflagsbit for representingURI.isPlatform().protected static final intTheflagsbit for representingURI.isPlatformPlugin().protected static final intTheflagsbit for representingURI.isPlatformResource().protected static final intTheflagsbit for representingURI.isPrefix().protected final StringThe query of the hierarchical URI.protected final StringThe scheme of the hierarchical URIs.protected final String[]The segments of the hierarchical URI.protected WeakReference<String> A weakly cached reference to the string representation.Fields inherited from class org.eclipse.emf.common.util.URI
ALPHA_HI, ALPHA_LO, ALPHANUM_HI, ALPHANUM_LO, ARCHIVE_IDENTIFIER, ARCHIVE_SCHEMES, ARCHIVE_SEPARATOR, AUTHORITY_SEPARATOR, AUTHORITY_SEPARATOR_HASH_CODE, DEBUG, DEVICE_IDENTIFIER, DIGIT_HI, DIGIT_LO, ENCODE_PLATFORM_RESOURCE_URIS, ESCAPE, FILE_EXTENSION_SEPARATOR, FRAGMENT_FIRST_SEPARATOR, FRAGMENT_LAST_SEPARATOR, FRAGMENT_NONE, FRAGMENT_SEPARATOR, hashCode, HEX_DIGITS, HEX_HI, HEX_LO, MAJOR_SEPARATOR_HI, MAJOR_SEPARATOR_LO, NO_SEGMENTS, ONE_EMPTY_SEGMENT, ONE_SELF_SEGMENT, PATH_CHAR_HI, PATH_CHAR_LO, PLATFORM_SEGMENT_RESERVED_HI, PLATFORM_SEGMENT_RESERVED_LO, POOL, PORT_SEPARATOR, QUERY_SEPARATOR, RESERVED_HI, RESERVED_LO, SCHEME_ARCHIVE, SCHEME_ARCHIVE_HASH_CODE, SCHEME_FILE, SCHEME_FILE_HASH_CODE, SCHEME_HTTP, SCHEME_HTTP_HASH_CODE, SCHEME_JAR, SCHEME_JAR_HASH_CODE, SCHEME_PLATFORM, SCHEME_PLATFORM_HASH_CODE, SCHEME_SEPARATOR, SCHEME_ZIP, SCHEME_ZIP_HASH_CODE, SEGMENT_CHAR_HI, SEGMENT_CHAR_LO, SEGMENT_EMPTY, SEGMENT_END_HI, SEGMENT_END_LO, SEGMENT_PARENT, SEGMENT_PLUGIN, SEGMENT_RESOURCE, SEGMENT_SELF, SEGMENT_SEPARATOR, UNRESERVED_HI, UNRESERVED_LO, URIC_HI, URIC_LO, USER_INFO_SEPARATOR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static intaccumulate(String[] stack, int sp, String segment, boolean preserveRootParents) appendFileExtension(String fileExtension) 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.appendQuery(String query) Returns the URI formed from this URI and the given query.appendSegment(String segment) 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.appendSegments(String[] segments) 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 is a hierarchical URI with an authority component, returns it;nullotherwise.protected voidcacheString(String string) protected String[]collapseSegments(boolean preserveRootParents) Finds an absolute URI that, when resolved against the givenbaseabsolute hierarchical URI usingresolve, will yield this absolute URI.device()If this is a hierarchical URI with a device component, returns it;nullotherwise.If this is a hierarchical URI with a path, returns a string representation of the path, including the authority and the device component;nullotherwise.If this is a hierarchical URI whose path includes a file extension, that file extension is returned; null otherwise.protected String[]findRelativePath(URI base, boolean preserveRootParents) protected voidprotected StringbooleanReturnstrueif this is a hierarchical URI with an absolute path, orfalseif it is non-hierarchical, has no path, or has a relative path.booleanReturnstrueif this is a hierarchical URI with an authority component;falseotherwise.protected booleanhasCollapsableSegments(boolean preserveRootParents) booleanReturnstrueif this is a hierarchical URI with a device component;falseotherwise.protected booleanbooleanReturnstrueif this is a hierarchical URI with an empty relative path;falseotherwise.booleanhasPath()Returnstrueif this is a hierarchical URI with an absolute or relative path;falseotherwise.booleanhasQuery()Returnstrueif this is a hierarchical URI with a query component;falseotherwise.booleanReturnstrueif this is a hierarchical URI with a relative path, orfalseif it is non-hierarchical, has no path, or has an absolute path.booleanReturnstrueif this is a hierarchical URI that has a path that ends with a trailing separator;falseotherwise.host()If this is a hierarchical URI with an authority component that has a host portion, returns it;nullotherwise.booleanReturnstrueif this is an archive URI.protected booleanisBase()booleanReturnstrueif 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;falseis returned otherwise.booleanisEmpty()booleanisFile()Returnstrueif this is a hierarchical URI that may refer directly to a locally accessible file.booleanReturnstrueif this a a hierarchical URI, orfalseif it is of the generic form.booleanReturnstrueif this is a platform URI, that is, an absolute, hierarchical URI, with "platform" scheme, no authority, and at least two segments;falseis returned otherwise.booleanReturnstrueif this is a platform plug-in URI, that is, aplatform URIwhose first segment is "plugin";falseis returned otherwise.booleanReturnstrueif this is a platform resource URI, that is, aplatform URIwhose first segment is "resource";falseis returned otherwise.booleanisPrefix()Returnstrueif 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;falseis returned otherwise.booleanReturnstrueif this is a relative URI, orfalseif it is an absolute URI.Returns the last segment in the segment array, ornull.protected booleanmatches(int validate, boolean hierarchical, String scheme, String authority, String device, boolean absolutePath, String[] segments, String query) protected booleanprotected booleanprotected String[]path()If this is a hierarchical URI with a path, returns a string representation of the path;nullotherwise.port()If this is a hierarchical URI with an authority component that has a port portion, returns it;nullotherwise.query()If this is a hierarchical URI with a query component, returns it;nullotherwise.protected String[]replacePrefix(URI oldPrefix, URI newPrefix) If this is a hierarchical URI reference andoldPrefixis a prefix of it, this returns the URI formed by replacing it bynewPrefix;nullotherwise.Resolves this URI reference against abaseabsolute hierarchical URI, returning the resulting absolute URI.scheme()If this is an absolute URI, returns the scheme component;nullotherwise.segment(int i) Provides fast, indexed access to individual segments in the path segment array.intReturns the number of elements in the segment array that would be returned bysegments.String[]segments()If this is a hierarchical URI with a path, returns an array containing the segments of the path; an empty array otherwise.protected booleansegmentsEqual(URI uri) Returns an unmodifiable list containing the same segments as the array returned bysegments.toPlatformString(boolean decode) If this is a platform URI, as determined byURI.isPlatform(), returns the workspace-relative or plug-in-based path to the resource, optionallydecodingthe segments in the process.toString()If this URI has a non-nullfileExtension, returns the URI formed by removing it; this URI unchanged, otherwise.If this URI has a non-nullquery, returns the URI formed by removing it; this URI unchanged, otherwise.trimSegments(int i) 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.userInfo()If this is a hierarchical URI with an authority component that has a user info portion, returns it;nullotherwise.Methods inherited from class org.eclipse.emf.common.util.URI
appendEscaped, appendFragment, contains, createDeviceURI, createFileURI, createGenericURI, createHierarchicalURI, createHierarchicalURI, createHierarchicalURI, createPlatformPluginURI, createPlatformResourceURI, createPlatformResourceURI, createURI, createURI, createURI, createURIWithCache, decode, deresolve, encode, encodeAuthority, encodeFragment, encodeOpaquePart, encodeQuery, encodeSegment, encodeURI, equals, firstInvalidSegment, fragment, hasFragment, hashCode, hasOpaquePart, highBitmask, highBitmask, highBitmask, isArchiveScheme, isEscaped, lowBitmask, lowBitmask, lowBitmask, main, matches, opaquePart, rawAppendFragment, resolve, splitInternFragment, trimFragment, unescape, validArchiveAuthority, validateURI, validAuthority, validDevice, validFragment, validJarAuthority, validOpaquePart, validQuery, validScheme, validSegment, validSegments, valueOf
-
Field Details
-
HAS_ABSOLUTE_PATH
protected static final int HAS_ABSOLUTE_PATHTheflagsbit for representingURI.hasAbsolutePath().- See Also:
-
HAS_RELATIVE_PATH
protected static final int HAS_RELATIVE_PATHTheflagsbit for representingURI.hasRelativePath().- See Also:
-
HAS_EMPTY_PATH
protected static final int HAS_EMPTY_PATHTheflagsbit for representingURI.hasEmptyPath().- See Also:
-
IS_CURRENT_DOCUMENT_REFERENCE
protected static final int IS_CURRENT_DOCUMENT_REFERENCETheflagsbit for representingURI.isCurrentDocumentReference().- See Also:
-
IS_FILE
protected static final int IS_FILETheflagsbit for representingURI.isFile().- See Also:
-
IS_PLATFORM
protected static final int IS_PLATFORMTheflagsbit for representingURI.isPlatform().- See Also:
-
IS_PLATFORM_RESOURCE
protected static final int IS_PLATFORM_RESOURCETheflagsbit for representingURI.isPlatformResource().- See Also:
-
IS_PLATFORM_PLUGIN
protected static final int IS_PLATFORM_PLUGINTheflagsbit for representingURI.isPlatformPlugin().- See Also:
-
IS_ARCHIVE
protected static final int IS_ARCHIVETheflagsbit for representingURI.isArchive().- See Also:
-
HAS_TRAILING_PATH_SEPARATOR
protected static final int HAS_TRAILING_PATH_SEPARATORTheflagsbit for representingURI.hasTrailingPathSeparator().- See Also:
-
IS_PREFIX
protected static final int IS_PREFIXTheflagsbit for representingURI.isPrefix().- See Also:
-
HAS_PATH
protected static final int HAS_PATHTheflagsbits for representingURI.hasPath().- See Also:
-
flags
protected final int flagsBit flags for the results of all the boolean no-argument methods. -
scheme
The scheme of the hierarchical URIs. -
authority
The authority of the hierarchical URI. -
device
The device of the hierarchical URI. -
segments
The segments of the hierarchical URI. -
query
The query of the hierarchical URI. -
toString
A weakly cached reference to the string representation.
-
-
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 theflagsbits. 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 thetoString().
-
-
Method Details
-
isRelative
public boolean isRelative()Description copied from class:URIReturnstrueif this is a relative URI, orfalseif it is an absolute URI.- Overrides:
isRelativein classURI
-
isBase
protected boolean isBase() -
isHierarchical
public boolean isHierarchical()Description copied from class:URIReturnstrueif this a a hierarchical URI, orfalseif it is of the generic form.- Overrides:
isHierarchicalin classURI
-
hasAuthority
public boolean hasAuthority()Description copied from class:URIReturnstrueif this is a hierarchical URI with an authority component;falseotherwise.- Overrides:
hasAuthorityin classURI
-
hasDevice
public boolean hasDevice()Description copied from class:URIReturnstrueif this is a hierarchical URI with a device component;falseotherwise. -
hasPath
public boolean hasPath()Description copied from class:URIReturnstrueif this is a hierarchical URI with an absolute or relative path;falseotherwise. -
hasDeviceOrPath
protected boolean hasDeviceOrPath()- Overrides:
hasDeviceOrPathin classURI
-
hasAbsolutePath
public boolean hasAbsolutePath()Description copied from class:URIReturnstrueif this is a hierarchical URI with an absolute path, orfalseif it is non-hierarchical, has no path, or has a relative path.- Overrides:
hasAbsolutePathin classURI
-
hasRelativePath
public boolean hasRelativePath()Description copied from class:URIReturnstrueif this is a hierarchical URI with a relative path, orfalseif it is non-hierarchical, has no path, or has an absolute path.- Overrides:
hasRelativePathin classURI
-
hasEmptyPath
public boolean hasEmptyPath()Description copied from class:URIReturnstrueif this is a hierarchical URI with an empty relative path;falseotherwise.Note that
!hasEmpty()does not imply that this URI has any path segments; however,hasRelativePath invalid input: '&'invalid input: '&' !hasEmptyPath()does.- Overrides:
hasEmptyPathin classURI
-
hasQuery
public boolean hasQuery()Description copied from class:URIReturnstrueif this is a hierarchical URI with a query component;falseotherwise. -
isCurrentDocumentReference
public boolean isCurrentDocumentReference()Description copied from class:URIReturnstrueif 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;falseis returned otherwise.- Overrides:
isCurrentDocumentReferencein classURI
-
isEmpty
public boolean isEmpty()Description copied from class:URI -
isFile
public boolean isFile()Description copied from class:URIReturnstrueif 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;falseis returned otherwise. -
isPlatform
public boolean isPlatform()Description copied from class:URIReturnstrueif this is a platform URI, that is, an absolute, hierarchical URI, with "platform" scheme, no authority, and at least two segments;falseis returned otherwise.- Overrides:
isPlatformin classURI
-
isPlatformResource
public boolean isPlatformResource()Description copied from class:URIReturnstrueif this is a platform resource URI, that is, aplatform URIwhose first segment is "resource";falseis returned otherwise.- Overrides:
isPlatformResourcein classURI- See Also:
-
isPlatformPlugin
public boolean isPlatformPlugin()Description copied from class:URIReturnstrueif this is a platform plug-in URI, that is, aplatform URIwhose first segment is "plugin";falseis returned otherwise.- Overrides:
isPlatformPluginin classURI- See Also:
-
isArchive
public boolean isArchive()Description copied from class:URIReturnstrueif 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. -
segmentsEqual
- Overrides:
segmentsEqualin classURI
-
scheme
Description copied from class:URIIf this is an absolute URI, returns the scheme component;nullotherwise. -
authority
Description copied from class:URIIf this is a hierarchical URI with an authority component, returns it;nullotherwise. -
userInfo
Description copied from class:URIIf this is a hierarchical URI with an authority component that has a user info portion, returns it;nullotherwise. -
host
Description copied from class:URIIf this is a hierarchical URI with an authority component that has a host portion, returns it;nullotherwise. -
port
Description copied from class:URIIf this is a hierarchical URI with an authority component that has a port portion, returns it;nullotherwise. -
device
Description copied from class:URIIf this is a hierarchical URI with a device component, returns it;nullotherwise. -
segments
Description copied from class:URIIf 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. -
rawSegments
- Overrides:
rawSegmentsin classURI
-
segmentsList
Description copied from class:URIReturns an unmodifiable list containing the same segments as the array returned bysegments.- Overrides:
segmentsListin classURI
-
segmentCount
public int segmentCount()Description copied from class:URIReturns the number of elements in the segment array that would be returned bysegments.- Overrides:
segmentCountin classURI
-
segment
Description copied from class:URIProvides fast, indexed access to individual segments in the path segment array. -
lastSegment
Description copied from class:URIReturns the last segment in the segment array, ornull.- Overrides:
lastSegmentin classURI
-
path
Description copied from class:URIIf this is a hierarchical URI with a path, returns a string representation of the path;nullotherwise. 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. -
devicePath
Description copied from class:URIIf this is a hierarchical URI with a path, returns a string representation of the path, including the authority and the device component;nullotherwise.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:
devicePathin classURI
-
query
Description copied from class:URIIf this is a hierarchical URI with a query component, returns it;nullotherwise. -
appendQuery
Description copied from class:URIReturns the URI formed from this URI and the given query.- Overrides:
appendQueryin classURI
-
trimQuery
Description copied from class:URIIf this URI has a non-nullquery, returns the URI formed by removing it; this URI unchanged, otherwise. -
resolve
Description copied from class:URIResolves this URI reference against abaseabsolute 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.
-
mergePath
-
accumulate
-
deresolve
public URI deresolve(URI base, boolean preserveRootParents, boolean anyRelPath, boolean shorterRelPath) Description copied from class:URIFinds an absolute URI that, when resolved against the givenbaseabsolute hierarchical URI usingresolve, will yield this absolute URI. Ifbaseis non-hierarchical or is relative, orthisis non-hierarchical or is relative,thiswill be returned.- Overrides:
deresolvein classURI- Parameters:
preserveRootParents- the boolean argument toresolve(URI, boolean)for which the returned URI should resolve to this URI.anyRelPath- iftrue, the returned URI's path (if any) will be relative, if possible. Iffalse, the form of the result's path will depend upon the next parameter.shorterRelPath- ifanyRelPathisfalseand this parameter istrue, 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 bothanyRelPathand this parameter arefalse, it will be absolute.
-
hasCollapsableSegments
protected boolean hasCollapsableSegments(boolean preserveRootParents) -
findRelativePath
-
collapseSegments
- Overrides:
collapseSegmentsin classURI
-
cacheString
- Overrides:
cacheStringin classURI
-
flushCachedString
protected void flushCachedString()- Overrides:
flushCachedStringin classURI
-
getCachedString
- Overrides:
getCachedStringin classURI
-
toString
-
matches
-
matches
-
matches
-
toFileString
Description copied from class:URIIf this URI may refer directly to a locally accessible file, as determined byisFile,decodesand 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:
toFileStringin classURI
-
toPlatformString
Description copied from class:URIIf this is a platform URI, as determined byURI.isPlatform(), returns the workspace-relative or plug-in-based path to the resource, optionallydecodingthe segments in the process.- Overrides:
toPlatformStringin classURI- See Also:
-
appendSegment
Description copied from class:URIReturns 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:
appendSegmentin classURI
-
appendSegments
Description copied from class:URIReturns 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:
appendSegmentsin classURI- 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
Description copied from class:URIReturns 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:
trimSegmentsin classURI- 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:URIReturnstrueif this is a hierarchical URI that has a path that ends with a trailing separator;falseotherwise.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:
hasTrailingPathSeparatorin classURI
-
fileExtension
Description copied from class:URIIf 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:
fileExtensionin classURI
-
appendFileExtension
Description copied from class:URIReturns 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:
appendFileExtensionin classURI
-
trimFileExtension
Description copied from class:URIIf this URI has a non-nullfileExtension, returns the URI formed by removing it; this URI unchanged, otherwise.- Overrides:
trimFileExtensionin classURI
-
isPrefix
public boolean isPrefix()Description copied from class:URIReturnstrueif 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;falseis returned otherwise. -
replacePrefix
Description copied from class:URIIf this is a hierarchical URI reference andoldPrefixis a prefix of it, this returns the URI formed by replacing it bynewPrefix;nullotherwise.In order to be a prefix, the
oldPrefix'sisPrefixmust returntrue, and it must match this URI's scheme, authority, and device. Also, the paths must match, up to prefix's end.- Overrides:
replacePrefixin classURI
-