Class Location
java.lang.Object
com.polarion.subterra.base.location.Location
- All Implemented Interfaces:
ILocation,Serializable
Sole implementation of
ILocation.- Author:
- Stepan Roh, Polarion Software
- See Also:
-
Field Summary
Fields inherited from interface com.polarion.subterra.base.location.ILocation
COMPONENT_DELIM, COMPONENT_DELIM_CHAR -
Method Summary
Modifier and TypeMethodDescriptionaddOneComponentTowards(String path) Returns the location for which it holds:Append given location to this location and return new location.Append given location path to this location and return new location.booleancontainsComponent(String component) booleancontainsComponentSequence(String sequence) Same asILocation.containsComponentSequence(List)but sequence defined as String (e.f.booleancontainsComponentSequence(List<String> sequence) Shortcut forfindComponentSequence(sequence) != -1booleanWhether this location has repository name.static ILocationdeserializeLocation(String strLocation) Converts the string representation produced byILocation.serialize()back into object.deserializeLocations(String strLocs) booleanintfindComponentSequence(String sequence) Same asILocation.findComponentSequence(List)but sequence defined as String (e.g.intfindComponentSequence(List<String> sequence) Searches this path components for the given sequence and if found, returns the position of the first component from the sequence in this location'sILocation.getComponents().getAbsoluteLocation(ILocation root) Compute absolute location from root location and this location and return new location.static ILocationCanonicalize given location.getComponent(int n) Returnsn-thcomponent of the location.intThe resulting list is unmodifiable.Returns the first coponent of this location.Return last component of this location.Returns the extension of the last component of this location, i.e.Returns the last component of this location without the extension, i.e.static ILocationgetLocation(String locPath) Return location for given location path.static ILocationgetLocation(String repoName, String locPath, String revisionName) Returns location for given parameters.Return location path.static ILocationgetLocationWithRepository(String repoName, String locPath) Return location for given repository name and location path.static ILocationgetLocationWithRepositoryAndRevision(String repoName, String locPath, String revision) Return location for given repository name, location path and revision.static ILocationgetLocationWithRevision(String locPath, String revision) Return location for given location path and revision.Return parent location (location without last component).getRelativeLocation(ILocation root) Relativize this location against given root (which may be relative) and return new location.Return repository name (if any).Return revision (if any).inthashCode()booleanWhether this location has revision.booleanhasRootLocation(ILocation root) Whether given location is root of this location.booleanWhether this location is relative (locations with repository names are always absolute).parseSequence(String sequence) removeFirstComponents(int n) Removes the firstncomponents from the location path.Remove repository name (if any) from this location and return new location.Remove revision from this location and return new location.replaceLocationPath(String locPath) Replace current location path with given location path and return new location.Converts the location intoString.static Stringserialize(Collection<ILocation> locs) setComponent(int n, String newComponent) Creates new location, which is same as this one, but hasnewComponenton thenthplace.setRepositoryName(String repositoryName) Returns new location with specified repository name.setRevision(String revision) Set revision of this location and return new location.booleanstartsWithComponentSequence(String sequence) Same asILocation.startsWithComponentSequence(List)but sequence defined as String (e.f.booleanstartsWithComponentSequence(List<String> sequence) Shortcut forfindComponentSequence(sequence) == 0toString()
-
Method Details
-
getLocationWithRepositoryAndRevision
public static ILocation getLocationWithRepositoryAndRevision(String repoName, String locPath, String revision) Return location for given repository name, location path and revision.- Parameters:
repoName- repository namelocPath- location pathrevision- revision- Returns:
- new location
- Throws:
IllegalArgumentException- if given location path is relativeIllegalArgumentException- if given repository name isnullIllegalArgumentException- if given location path isnullIllegalArgumentException- if given revision isnull
-
getLocationWithRevision
Return location for given location path and revision.- Parameters:
locPath- location pathrevision- revision- Returns:
- new location
- Throws:
IllegalArgumentException- if given location path isnullIllegalArgumentException- if given revision isnull
-
getLocationWithRepository
Return location for given repository name and location path.- Parameters:
repoName- repository namelocPath- location path- Returns:
- new location
- Throws:
IllegalArgumentException- if given location path is relativeIllegalArgumentException- if given repository name isnullIllegalArgumentException- if given location path isnull
-
getLocation
Return location for given location path.- Parameters:
locPath- location path- Returns:
- new location
- Throws:
IllegalArgumentException- if given location path isnull
-
getLocation
Returns location for given parameters. Unlike factory methods with specialized names, this implementation does allownullrepoNameandrevisionName.- Parameters:
repoName- repository namelocPath- location pathrevisionName- revision name- Returns:
- new location
-
containsRepositoryName
public boolean containsRepositoryName()Description copied from interface:ILocationWhether this location has repository name.- Specified by:
containsRepositoryNamein interfaceILocation- Returns:
trueif this location contains repository name
-
isRelative
public boolean isRelative()Description copied from interface:ILocationWhether this location is relative (locations with repository names are always absolute).- Specified by:
isRelativein interfaceILocation- Returns:
trueif this location is relative
-
getAbsoluteLocation
Description copied from interface:ILocationCompute absolute location from root location and this location and return new location.- Specified by:
getAbsoluteLocationin interfaceILocation- Parameters:
root- root absolute location- Returns:
- new location or this location if it is already absolute
-
getRelativeLocation
Description copied from interface:ILocationRelativize this location against given root (which may be relative) and return new location.- Specified by:
getRelativeLocationin interfaceILocation- Parameters:
root- root location- Returns:
- new location
-
hasRootLocation
Description copied from interface:ILocationWhether given location is root of this location.Positive answer allows
ILocation.getRelativeLocation(ILocation)to succeed.- Specified by:
hasRootLocationin interfaceILocation- Parameters:
root- root location- Returns:
trueif given location is root of this location
-
getComponentCount
public int getComponentCount()- Specified by:
getComponentCountin interfaceILocation- Returns:
- Number of components in this location, or path depth.
-
getLastComponent
Description copied from interface:ILocationReturn last component of this location.Same as
getComponent(getComponentCount()-1)- Specified by:
getLastComponentin interfaceILocation- Returns:
- last component name or
nullfor empty location - See Also:
-
getLastComponentExtension
Description copied from interface:ILocationReturns the extension of the last component of this location, i.e. the suffix of the last component starting with the last '.'. Returns an empty string if there is no '.' in the last component. Returns null if this location is empty (i.e. ifILocation.getLastComponent()returns null).- Specified by:
getLastComponentExtensionin interfaceILocation
-
getLastComponentWithoutExtension
Description copied from interface:ILocationReturns the last component of this location without the extension, i.e. the prefix of the last component before the last '.'. Returns the entire last component if there is no '.' in it. Returns null if this location is empty (i.e. ifILocation.getLastComponent()returns null).- Specified by:
getLastComponentWithoutExtensionin interfaceILocation
-
getFirstComponent
Description copied from interface:ILocationReturns the first coponent of this location.Same as
getComponent(0)- Specified by:
getFirstComponentin interfaceILocation- Returns:
- first component name or
nullfor empty location - See Also:
-
getComponent
Description copied from interface:ILocationReturnsn-thcomponent of the location. The n can range from 0 (first component) togetComponentCount()-1(lastComponent).- Specified by:
getComponentin interfaceILocation- Returns:
- The given component or
nullif such component does not exist in this location. - See Also:
-
getComponents
Description copied from interface:ILocationThe resulting list is unmodifiable.- Specified by:
getComponentsin interfaceILocation- Returns:
- The list of string component names, as if returned by
ILocation.getComponent(int), the list lenght is the same asILocation.getComponentCount().
-
findComponentSequence
Description copied from interface:ILocationSearches this path components for the given sequence and if found, returns the position of the first component from the sequence in this location'sILocation.getComponents().- Specified by:
findComponentSequencein interfaceILocation- Parameters:
sequence- List ofString- Returns:
- Position of first component from sequence or -1 if not found.
-
findComponentSequence
Description copied from interface:ILocationSame asILocation.findComponentSequence(List)but sequence defined as String (e.g. "/some/sequence") the leading and trailing slashes are ignored.- Specified by:
findComponentSequencein interfaceILocation- Parameters:
sequence- location component sequence- Returns:
- Position of first component from sequence or -1 if not found.
-
containsComponentSequence
Description copied from interface:ILocationShortcut forfindComponentSequence(sequence) != -1- Specified by:
containsComponentSequencein interfaceILocation- Parameters:
sequence- List ofString- Returns:
trueif this location contains the specified sequence- See Also:
-
containsComponentSequence
Description copied from interface:ILocationSame asILocation.containsComponentSequence(List)but sequence defined as String (e.f. "/some/sequence") the leading and trailing / have no meaning.- Specified by:
containsComponentSequencein interfaceILocation- Parameters:
sequence- location component sequence- Returns:
trueif this location contains the specified sequence
-
containsComponent
- Specified by:
containsComponentin interfaceILocation
-
startsWithComponentSequence
Description copied from interface:ILocationShortcut forfindComponentSequence(sequence) == 0- Specified by:
startsWithComponentSequencein interfaceILocation- Parameters:
sequence- location component sequence- Returns:
trueif this location strts with the specified sequence- See Also:
-
startsWithComponentSequence
Description copied from interface:ILocationSame asILocation.startsWithComponentSequence(List)but sequence defined as String (e.f. "/some/sequence") the leading and trailing / have no meaning.- Specified by:
startsWithComponentSequencein interfaceILocation- Parameters:
sequence- location component sequence- Returns:
trueif this location strts with the specified sequence
-
parseSequence
-
removeFirstComponents
Description copied from interface:ILocationRemoves the firstncomponents from the location path.- Specified by:
removeFirstComponentsin interfaceILocation- Parameters:
n- number of components- Returns:
- Returns
thisifn == 0or relative location, obtained fromthisby removingncomponents.
-
setComponent
Description copied from interface:ILocationCreates new location, which is same as this one, but hasnewComponenton thenthplace.- Specified by:
setComponentin interfaceILocation- Parameters:
n- Component number, 0..getComponentCount() (inclusive, exclusive)newComponent- the new content of the component to be replaced- Returns:
- the component with replaced component
-
addOneComponentTowards
Description copied from interface:ILocationReturns the location for which it holds:new_location.getParentLocation().equals(this)The extra segment is taken from the given path.
Example:
this: [REPO]/some/ path: /some/longer/path/to/go result: [REPO]/some/longer/
- Specified by:
addOneComponentTowardsin interfaceILocation- Parameters:
path- Such thatthis.getLocationPath()is parent of the given path.- Returns:
- New locations, such that
new_location.getParentLocation().equals(this).
-
append
Description copied from interface:ILocationAppend given location path to this location and return new location. -
append
Description copied from interface:ILocationAppend given location to this location and return new location. Revision of given location is ignored. -
getRepositoryName
Description copied from interface:ILocationReturn repository name (if any).- Specified by:
getRepositoryNamein interfaceILocation- Returns:
- repository name or
null
-
setRepositoryName
Description copied from interface:ILocationReturns new location with specified repository name.- Specified by:
setRepositoryNamein interfaceILocation- Returns:
- new location
-
removeRepositoryName
Description copied from interface:ILocationRemove repository name (if any) from this location and return new location.- Specified by:
removeRepositoryNamein interfaceILocation- Returns:
- new location
-
getLocationPath
Description copied from interface:ILocationReturn location path.- Specified by:
getLocationPathin interfaceILocation- Returns:
- location path
-
getParentLocation
Description copied from interface:ILocationReturn parent location (location without last component).- Specified by:
getParentLocationin interfaceILocation- Returns:
- new location or
nullif there is no parent
-
equals
-
hashCode
public int hashCode() -
toString
-
getRevision
Description copied from interface:ILocationReturn revision (if any).- Specified by:
getRevisionin interfaceILocation- Returns:
- revision or
null
-
removeRevision
Description copied from interface:ILocationRemove revision from this location and return new location.- Specified by:
removeRevisionin interfaceILocation- Returns:
- new location
-
setRevision
Description copied from interface:ILocationSet revision of this location and return new location.- Specified by:
setRevisionin interfaceILocation- Parameters:
revision- revision- Returns:
- new location
-
replaceLocationPath
Description copied from interface:ILocationReplace current location path with given location path and return new location.- Specified by:
replaceLocationPathin interfaceILocation- Parameters:
locPath- location path to replace with- Returns:
- new location
-
hasRevision
public boolean hasRevision()Description copied from interface:ILocationWhether this location has revision.- Specified by:
hasRevisionin interfaceILocation- Returns:
trueif this location has revision
-
deserializeLocation
Converts the string representation produced byILocation.serialize()back into object.- Parameters:
strLocation- TheStringrepresentation.- Returns:
- Parsed
ILocation - Throws:
IllegalArgumentException- If the string is not valid location.
-
deserializeLocations
- Since:
- 3.5.2
-
serialize
- Since:
- 3.5.2
-
serialize
Description copied from interface:ILocationConverts the location intoString. The exact format of the resulting string is not defined. UsedeserializeLocation(String)to convert the resulting string back to object.The resulting
Stringshould be human readable. -
getCanonicalLocation
Canonicalize given location.Location path component "." is removed, ".." is removed together with its predecessor.
- Parameters:
loc- location to canonicalize- Returns:
- canonicalized location (not
null) - Throws:
IllegalArgumentException- if loc is null
-