Package com.gengoai.io.resource
Class URIResource
- java.lang.Object
-
- com.gengoai.io.resource.BaseResource
-
- com.gengoai.io.resource.URIResource
-
- All Implemented Interfaces:
Resource
,Serializable
public class URIResource extends BaseResource
Resource that wraps a URI- Author:
- David B. Bracewell
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.gengoai.io.resource.Resource
Resource.Deserializer
-
-
Field Summary
-
Fields inherited from interface com.gengoai.io.resource.Resource
ALL_FILE_PATTERN
-
-
Constructor Summary
Constructors Constructor Description URIResource(URI uri)
Instantiates a new Uri resource.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Resource
append(byte[] byteArray)
Appends the given byte array content to the resource.Optional<File>
asFile()
Gets the resource as aFile
.Optional<URI>
asURI()
As uri optional.protected InputStream
createInputStream()
Create input stream input stream.protected OutputStream
createOutputStream()
Create output stream output stream.String
descriptor()
Descriptor string.boolean
equals(Object o)
boolean
exists()
Exists boolean.Resource
getChild(String relativePath)
Creates a new Resource that is relative to this resource.Resource
getParent()
Gets parent.int
hashCode()
String
path()
Gets path in the same mannar asFile.getPath()
-
Methods inherited from class com.gengoai.io.resource.BaseResource
baseName, canRead, canWrite, compressed, getCharset, inputStream, isCompressed, isDirectory, outputStream, setCharset, setCompression, setIsCompressed, toString, uncompressed
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.gengoai.io.resource.Resource
append, asPath, asURL, childIterator, childIterator, copy, delete, delete, deleteOnExit, forEach, getChildren, getChildren, getChildren, getChildren, getChildren, lines, mkdir, mkdirs, readBytes, reader, readLines, readObject, readToString, write, write, writeObject, writer
-
-
-
-
Constructor Detail
-
URIResource
public URIResource(URI uri)
Instantiates a new Uri resource.- Parameters:
uri
- the uri
-
-
Method Detail
-
append
public Resource append(byte[] byteArray) throws IOException
Description copied from interface:Resource
Appends the given byte array content to the resource.
- Parameters:
byteArray
- The content to append- Returns:
- the resource
- Throws:
IOException
- the io exception
-
asFile
public Optional<File> asFile()
Description copied from interface:Resource
Gets the resource as aFile
.- Specified by:
asFile
in interfaceResource
- Overrides:
asFile
in classBaseResource
- Returns:
- A
File
representing the resource.
-
asURI
public Optional<URI> asURI()
Description copied from interface:Resource
As uri optional.- Specified by:
asURI
in interfaceResource
- Overrides:
asURI
in classBaseResource
- Returns:
- the optional
-
createInputStream
protected InputStream createInputStream() throws IOException
Description copied from class:BaseResource
Create input stream input stream.- Overrides:
createInputStream
in classBaseResource
- Returns:
- the input stream
- Throws:
IOException
- the io exception
-
createOutputStream
protected OutputStream createOutputStream() throws IOException
Description copied from class:BaseResource
Create output stream output stream.- Overrides:
createOutputStream
in classBaseResource
- Returns:
- the output stream
- Throws:
IOException
- the io exception
-
descriptor
public String descriptor()
Description copied from interface:Resource
Descriptor string.- Specified by:
descriptor
in interfaceResource
- Overrides:
descriptor
in classBaseResource
- Returns:
- The string representation of the resource with protocol
-
exists
public boolean exists()
Description copied from interface:Resource
Exists boolean.- Returns:
- True if the resource exists, False if the resource does not exist.
-
getChild
public Resource getChild(String relativePath)
Description copied from interface:Resource
Creates a new Resource that is relative to this resource.
- Parameters:
relativePath
- The relative path for the new resource.- Returns:
- A new resource that is relative to this resource.
-
getParent
public Resource getParent()
Description copied from interface:Resource
Gets parent.- Returns:
- The parent resource (directory for file, parent directory for a directory)
-
path
public String path()
Description copied from interface:Resource
Gets path in the same mannar asFile.getPath()
- Specified by:
path
in interfaceResource
- Overrides:
path
in classBaseResource
- Returns:
- The full path to the resource including name
-
-