Package org.aksw.commons.path.core
Class PathBase<T,P extends Path<T>>
java.lang.Object
org.aksw.commons.path.core.PathBase<T,P>
- Type Parameters:
T-P-
- All Implemented Interfaces:
Serializable,Comparable<Path<T>>,Iterable<Path<T>>,Path<T>
Generic base implementation of the path interface.
Internally keeps a flag for whether the path is
absolute and a list of path segments.
All methods of this class are implemented against the
PathOps interface.
Complex or verbose type expressions can be abstracted by extending this
class as sketched below.
class MyPath extends PathBase<ComplexTypeExpression, MyPath> {
MyPath(PathOps<T, P> pathOps, boolean isAbsolute, List segments) {
super(pathOps, isAbsolute, segments);
}
}
class MyPathOps implements PathOps {
MyPath newPath(boolean isAbsolute, List segments) {
return new MyPath(this, isAbsolute, segments);
}
// Implement remaining methods
}
- Author:
- raven
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> intcompareLists(List<T> a, List<T> b, Comparator<T> comparator) intbooleanbooleangetName(int index) intgetRoot()Returns an object such as the file system underlying this path.inthashCode()booleanprotected booleanisParentToken(T item) iterator()protected Pstatic <T> List<T>relativize(List<T> a, List<T> b, T parentToken) relativize(Path<T> other) resolveSibling(Path<T> other) resolveSibling(T other) resolveSiblingStr(String other) resolveStr(String other) booleanstartsWith(Path<T> other) subpath(int beginIndex) Experimental.subpath(int beginIndex, int endIndex) static <T> List<T>toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
isAbsolute
protected boolean isAbsolute -
segments
-
segmentsView
-
pathOps
-
-
Constructor Details
-
PathBase
-
-
Method Details
-
newPath
-
getPathOps
-
toAbsolutePath
- Specified by:
toAbsolutePathin interfacePath<T>
-
isAbsolute
public boolean isAbsolute()- Specified by:
isAbsolutein interfacePath<T>
-
getRoot
-
getFileName
- Specified by:
getFileNamein interfacePath<T>
-
getParent
-
getNameCount
public int getNameCount()- Specified by:
getNameCountin interfacePath<T>
-
getName
-
subpath
-
subpath
Description copied from interface:PathExperimental. Not part of nio Path. -
startsWith
- Specified by:
startsWithin interfacePath<T>
-
endsWith
-
normalize
-
isParentToken
-
toList
-
resolveStr
- Specified by:
resolveStrin interfacePath<T>
-
resolve
-
relativize
- Specified by:
relativizein interfacePath<T>
-
toString
-
relativize
-
getSegments
- Specified by:
getSegmentsin interfacePath<T>
-
resolve
-
resolveSiblingStr
- Specified by:
resolveSiblingStrin interfacePath<T>
-
resolveSibling
- Specified by:
resolveSiblingin interfacePath<T>
-
resolveSibling
- Specified by:
resolveSiblingin interfacePath<T>
-
iterator
-
compareTo
- Specified by:
compareToin interfaceComparable<T>
-
compareLists
-
getSystem
Description copied from interface:PathReturns an object such as the file system underlying this path. Returns null if not applicable. Experimental. -
equals
-
hashCode
public int hashCode()
-