Package space.arim.dazzleconf.backend
Class PathRoot
java.lang.Object
space.arim.dazzleconf.backend.PathRoot
- All Implemented Interfaces:
BinaryRoot,DataRoot,ReadableRoot
A data root from a file path.
Both textual and binary operations can be performed on this data root. If textual operations are used, then the charset specified at construction will be used to provide encoding.
-
Nested Class Summary
Nested classes/interfaces inherited from interface space.arim.dazzleconf.backend.DataRoot
DataRoot.Operation<R,U> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks whether the data is known to exist.<R> RopenInputStream(@NonNull DataRoot.Operation<R, @NonNull InputStream> operation) Opens an input stream for the data<R> RopenOutputStream(@NonNull DataRoot.Operation<R, @NonNull OutputStream> operation) Opens an output stream to the data<R> RopenReadChannel(@NonNull DataRoot.Operation<R, @NonNull ReadableByteChannel> operation) Opens a read channel for the data<R> RopenReader(@NonNull DataRoot.Operation<R, @NonNull Reader> operation) Opens a reader to the data<R> RopenWriteChannel(@NonNull DataRoot.Operation<R, @NonNull WritableByteChannel> operation) Opens a write channel to the data<R> RopenWriter(@NonNull DataRoot.Operation<R, @NonNull Writer> operation) Opens a writer for the data@NonNull StringReads to a stringvoidwriteString(@NonNull String content) Writes to a string
-
Constructor Details
-
PathRoot
Creates from a path and a charset.The charset will be used for operations which read or write textual data.
- Parameters:
path- the pathcharset- the charset
-
PathRoot
Creates from a path.UTF-8 charset will be used for operations which read or write textual data.
- Parameters:
path- the path
-
-
Method Details
-
dataExists
Description copied from interface:DataRootChecks whether the data is known to exist.- Specified by:
dataExistsin interfaceDataRoot- Returns:
- true if the data is known to be present, false if not present or if its existence cannot be determined
- Throws:
IOException- if checking for data existence failed
-
readString
Description copied from interface:ReadableRootReads to a string- Specified by:
readStringin interfaceReadableRoot- Returns:
- the read content
- Throws:
IOException- upon failure to open
-
openReader
public <R> R openReader(@NonNull DataRoot.Operation<R, @NonNull Reader> operation) throws IOExceptionDescription copied from interface:ReadableRootOpens a reader to the data- Specified by:
openReaderin interfaceReadableRoot- Type Parameters:
R- the result type- Parameters:
operation- the operation- Returns:
- the operation result
- Throws:
IOException- upon failure to open
-
writeString
Description copied from interface:ReadableRootWrites to a string- Specified by:
writeStringin interfaceReadableRoot- Parameters:
content- the content to write- Throws:
IOException- upon failure to write
-
openWriter
public <R> R openWriter(@NonNull DataRoot.Operation<R, @NonNull Writer> operation) throws IOExceptionDescription copied from interface:ReadableRootOpens a writer for the data- Specified by:
openWriterin interfaceReadableRoot- Type Parameters:
R- the result type- Parameters:
operation- the operation- Returns:
- the operation result
- Throws:
IOException- upon failure to open
-
openReadChannel
public <R> R openReadChannel(@NonNull DataRoot.Operation<R, @NonNull ReadableByteChannel> operation) throws IOExceptionDescription copied from interface:BinaryRootOpens a read channel for the data- Specified by:
openReadChannelin interfaceBinaryRoot- Type Parameters:
R- the result type- Parameters:
operation- the operation- Returns:
- the operation result
- Throws:
IOException- upon failure to open
-
openInputStream
public <R> R openInputStream(@NonNull DataRoot.Operation<R, @NonNull InputStream> operation) throws IOExceptionDescription copied from interface:BinaryRootOpens an input stream for the data- Specified by:
openInputStreamin interfaceBinaryRoot- Type Parameters:
R- the result type- Parameters:
operation- the operation- Returns:
- the operation result
- Throws:
IOException- upon failure to open
-
openWriteChannel
public <R> R openWriteChannel(@NonNull DataRoot.Operation<R, @NonNull WritableByteChannel> operation) throws IOExceptionDescription copied from interface:BinaryRootOpens a write channel to the data- Specified by:
openWriteChannelin interfaceBinaryRoot- Type Parameters:
R- the result type- Parameters:
operation- the operation- Returns:
- the operation result
- Throws:
IOException- upon failure to open
-
openOutputStream
public <R> R openOutputStream(@NonNull DataRoot.Operation<R, @NonNull OutputStream> operation) throws IOExceptionDescription copied from interface:BinaryRootOpens an output stream to the data- Specified by:
openOutputStreamin interfaceBinaryRoot- Type Parameters:
R- the result type- Parameters:
operation- the operation- Returns:
- the operation result
- Throws:
IOException- upon failure to open
-