Package org.broadinstitute.http.nio
Class HttpPath
java.lang.Object
org.broadinstitute.http.nio.HttpPath
Path for HTTP/S.
The HTTP/S paths holds the following information:
-
The
HttpFileSystemoriginating the path. The protocol is retrieved, if necessary, from the provider of the File System. - The hostname and domain for the URL/URI in a single authority String.
- If present, the path component of the URL/URI.
- If present, the query and reference Strings.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanprivate final HttpFileSystemprivate final byte[]private int[]private final Stringprivate final String -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateHttpPath(HttpFileSystem fs, String query, String reference, boolean absolute, byte... normalizedPath) Internal constructor.(package private)HttpPath(HttpFileSystem fs, String path, String query, String reference) Creates a new Path in the providedHttpFileSystem, with optional query and reference. -
Method Summary
Modifier and TypeMethodDescriptionprivate static charcheckNotNull(String path, char c) intprivate static byte[]concatPaths(byte[] array1, byte[] array2) private booleanendsWith(byte[] other, boolean pathVersion) Private method to test endsWith only for the path component.booleanbooleanbooleanprivate HttpPathfromRelativeString(String other) private static intgetLastIndexWithoutTrailingSlash(byte[] path) Gets the last index to consider in the path bytes.getName(int index) intprivate static byte[]getNormalizedPathBytes(String path, boolean checkRelative) Gets the path as a normalized (without multiple slashes) array of bytes.private static byte[]getNormalizedPathBytes(String path, int len, int offset) getRoot()inthashCode()private voidCreates the array of offsets if not already created.booleanprivate static booleanisDoubleSeparator(char prevChar, char c) iterator()register(WatchService watcher, WatchEvent.Kind<?>... events) register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) relativize(Path other) private HttpPathresolveSibling(String other) private booleanstartsWith(byte[] other) Private method to test startsWith only for the path component.booleanstartsWith(String other) booleanstartsWith(Path other) subpath(int beginIndex, int endIndex) private HttpPathsubpath(int beginIndex, int endIndex, boolean absolute) Helper method to implement different subpath routines with different absolute/relative status.toFile()Unsupported method.toRealPath(LinkOption... options) toString()toUri()private StringtoUriString(boolean includeRoot) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface java.nio.file.Path
resolveSibling
-
Field Details
-
fs
-
normalizedPath
private final byte[] normalizedPath -
offsets
private volatile int[] offsets -
query
-
reference
-
absolute
private final boolean absolute
-
-
Constructor Details
-
HttpPath
private HttpPath(HttpFileSystem fs, String query, String reference, boolean absolute, byte... normalizedPath) Internal constructor.- Parameters:
fs- file system. Shouldn't benull.query- query. May benull.reference- reference. May benull.normalizedPath- normalized path (as a byte array). Shouldn't benull.
-
HttpPath
HttpPath(HttpFileSystem fs, String path, String query, String reference) Creates a new Path in the providedHttpFileSystem, with optional query and reference.- Parameters:
fs- file system representing the base URL (scheme and authority).path- path (absolute) component for the URL (required).query- query component for the URL (optional).reference- reference component for the URL (optional).
-
-
Method Details
-
getFileSystem
- Specified by:
getFileSystemin interfacePath
-
isAbsolute
public boolean isAbsolute()- Specified by:
isAbsolutein interfacePath
-
getRoot
-
getFileName
- Specified by:
getFileNamein interfacePath
-
getParent
-
getNameCount
public int getNameCount()- Specified by:
getNameCountin interfacePath
-
getName
-
subpath
-
subpath
Helper method to implement different subpath routines with different absolute/relative status.The contract of this method is the same as
Path.subpath(int, int)).- Parameters:
beginIndex- the index of the first element, inclusiveendIndex- the index of the last element, exclusiveabsolute-trueif the returned path is absolute;falseotherwise.- Returns:
- a new path object that is a subsequence of the nams elements in this
HttpPath.
-
startsWith
- Specified by:
startsWithin interfacePath
-
startsWith
- Specified by:
startsWithin interfacePath
-
startsWith
private boolean startsWith(byte[] other) Private method to test startsWith only for the path component.The contract for this method is the same as
startsWith(Path)(Path)}, but only for the path component.- Parameters:
other- the other path component.- Returns:
trueifnormalizedPathends withother;falseotherwise.
-
endsWith
-
endsWith
-
endsWith
private boolean endsWith(byte[] other, boolean pathVersion) Private method to test endsWith only for the path component.The contract for this method is the same as
endsWith(Path), but only for the path component.- Parameters:
other- the other path component.pathVersion- iffalse, perform an extra check for the String version.- Returns:
trueifnormalizedPathends withother;falseotherwise.
-
normalize
-
resolve
-
resolve
-
resolve
-
resolveSibling
- Specified by:
resolveSiblingin interfacePath
-
relativize
- Specified by:
relativizein interfacePath
-
fromRelativeString
-
toUri
-
toAbsolutePath
- Specified by:
toAbsolutePathin interfacePath
-
toRealPath
- Specified by:
toRealPathin interfacePath- Throws:
IOException
-
toFile
Unsupported method. -
register
public WatchKey register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) throws IOException - Specified by:
registerin interfacePath- Specified by:
registerin interfaceWatchable- Throws:
IOException
-
register
- Specified by:
registerin interfacePath- Specified by:
registerin interfaceWatchable- Throws:
IOException
-
iterator
-
compareTo
- Specified by:
compareToin interfaceComparable<Path>- Specified by:
compareToin interfacePath
-
equals
-
hashCode
public int hashCode() -
toString
-
toUriString
-
initOffsets
private void initOffsets()Creates the array of offsets if not already created. -
getNormalizedPathBytes
Gets the path as a normalized (without multiple slashes) array of bytes.- Parameters:
path- path to convert into byte[]checkRelative- iftrue, check if the path is absolute.- Returns:
- array of bytes, without multiple slashes together.
-
getNormalizedPathBytes
-
isDoubleSeparator
private static boolean isDoubleSeparator(char prevChar, char c) -
checkNotNull
-
getLastIndexWithoutTrailingSlash
private static int getLastIndexWithoutTrailingSlash(byte[] path) Gets the last index to consider in the path bytes.If the lst index is a trailing slash
HttpUtils.HTTP_PATH_SEPARATOR_CHAR, it should not be considered for some operations. This method takes into account that problem.- Parameters:
path- bytes representing the path.- Returns:
- last index of path to consider.
-
concatPaths
private static byte[] concatPaths(byte[] array1, byte[] array2)
-