Interface AIInOut
-
- All Known Implementing Classes:
AIInOut.AIFileInOut
,AIInOut.AIFileSegmentInOut
,AIInOut.AIStreamInOut
public interface AIInOut
AIInOut is an interface that represents an input or output for AI tasks. We join input and output since in some cases we need to read the file, too.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
AIInOut.AIFileInOut
AIFileInOut is an implementation of AIInOut that reads from a file.static class
AIInOut.AIFileSegmentInOut
AIFileSegmentInOut is an implementation of AIInOut that reads from a segment of a segmented file.static class
AIInOut.AIStreamInOut
AIStreamInOut is an implementation of AIInOut that reads from an input stream.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default boolean
exists()
File
getFile()
The underlying file.static AIInOut
of(File file)
Creates an AIInOut instance that reads from a file.static AIInOut
of(InputStream in)
Creates an AIInOut instance that reads from an input stream.static AIInOut
of(Path path)
Creates an AIInOut instance that reads from a file.static AIInOut
of(SegmentedFile segmentedFile, int segmentIndex)
Creates an AIInOut instance that reads from a segment of a segmented file.String
read()
Reads the input and returns it as a string.default boolean
sameFile(AIInOut other)
void
write(String content)
Writes a string to the output.
-
-
-
Method Detail
-
read
String read() throws IllegalStateException
Reads the input and returns it as a string.- Returns:
- the input as a string
- Throws:
IllegalStateException
- if the input cannot be read
-
write
void write(String content)
Writes a string to the output.- Parameters:
content
- the string to write
-
getFile
File getFile()
The underlying file.
-
sameFile
default boolean sameFile(AIInOut other)
-
exists
default boolean exists()
-
of
@Nullable static AIInOut of(@Nullable File file)
Creates an AIInOut instance that reads from a file.- Parameters:
file
- the file to read from- Returns:
- an AIInOut instance
-
of
@Nullable static AIInOut of(@Nullable Path path)
Creates an AIInOut instance that reads from a file.- Parameters:
path
- the path to the file to read from- Returns:
- an AIInOut instance
-
of
@Nonnull static AIInOut of(@Nonnull SegmentedFile segmentedFile, int segmentIndex)
Creates an AIInOut instance that reads from a segment of a segmented file.- Parameters:
segmentedFile
- the segmented file to read fromsegmentIndex
- the index of the segment to read- Returns:
- an AIInOut instance
-
of
static AIInOut of(InputStream in)
Creates an AIInOut instance that reads from an input stream. Writing is not supported.- Parameters:
in
- the input stream to read from- Returns:
- an AIInOut instance
-
-