Class ALfnHierarchicalResourceLocation
- All Implemented Interfaces:
ILfnResourceLocation
This base class assumes that hierarchical components are separated by a fixed separator and that the encoded location starts with a fixed prefix.
- Since:
- 2022.1
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ALfnHierarchicalResourceLocation
(String aPrefix, String aSeparator) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract ILfnResourceLocation
createResolvedLocation
(List<String> aResolvedComponents) Creates a new resource location from the hierarchical components determined byresolve(String)
.boolean
int
hashCode()
relativize
(ILfnResourceLocation aTarget) Generates a "relative" location for the given target, using this location as a base.Resolve a "relative" location against this resource location.toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.luciad.fusion.platform.resource.ILfnResourceLocation
getFileName, getLocation, getParent
-
Constructor Details
-
ALfnHierarchicalResourceLocation
Creates a new instance.- Parameters:
aPrefix
- the fixed prefix (for instancehttp://
for web resources)aSeparator
- the separator used to separate hierarchical components (for instance/
for URI paths)
-
-
Method Details
-
relativize
Generates a "relative" location for the given target, using this location as a base.The relative location is often encoded using elements like
..
to denote a parent and/name
to denote a child namedname
. However, implementations are free to encode the relative location in any way they please. The only requirement is thatbase.resolve(base.relativize(aTarget)).equals(aTarget)
.If there is no ancestry relationship between the target and this location, implementations must return the full
encoded form
of the target.The implementation in
ALfnHierarchicalResourceLocation
finds a common ancestor between this location andaTarget
. If there is no common ancestor,aTarget
's location is returned. If there is a common ancestor, the returned value starts with a number of".."
components equal to the number of times theILfnResourceLocation.getParent()
has to be used to get from this location to the common ancestor. Then the hierarchical components from the common ancestor toaTarget
are added. The components are separated using the separator provided to the constructor.- Specified by:
relativize
in interfaceILfnResourceLocation
- Parameters:
aTarget
- the location to provide a relative location for- Returns:
- the relative location, from this location
- See Also:
-
resolve
Resolve a "relative" location against this resource location.The relative location was either produced by
ILfnResourceLocation.relativize(ILfnResourceLocation)
or a manipulation of another resource location'sfile name
. Note that this means that the "relative" location may actually be the full encoded form of a resource location.If the relative location cannot be resolved, implementations should throw
IllegalArgumentException
.The returned resource location must be compatible with this location.
The implementation in
ALfnHierarchicalResourceLocation
uses the prefix provided to the constructor to determine whetheraRelative
is actually an absolute encoded location. If it is absolute, resolution is done on onlyaRelative
. If it is not absolute, resolution is done on the combination of this location's encoded form and theaRelative
.Resolution is performed by removing the prefix and splitting the remainder by the separator provided to the constructor. Empty components and
"."
components are considered redundant and removed. Then, consecutivename
and".."
components are removed. If at any point the list of hierarchical components starts with".."
, this is considered invalid and an exception is thrown. Finally, a new resolved location is constructed using the resulting list of components and returned.- Specified by:
resolve
in interfaceILfnResourceLocation
- Parameters:
aRelative
- the resource location to resolve- Returns:
- the resolved location
- See Also:
-
createResolvedLocation
Creates a new resource location from the hierarchical components determined byresolve(String)
.- Parameters:
aResolvedComponents
- the hierarchical components- Returns:
- the resource location
-
equals
-
hashCode
public int hashCode() -
toString
-