Package net.mtrop.doom.object
Interface TextObject
- All Known Implementing Classes:
UDMFMap
public interface TextObject
Common elements of all objects that are loaded from text data.
This provides a general interface for getting text-based object data.
- Author:
- Matthew Tropiano
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
static interface
TextObject.Transformer<TO extends TextObject>
Transformer interface for transform calls. -
Method Summary
Modifier and TypeMethodDescriptionstatic <TO extends TextObject>
TOCreates a single object of a specific class from a string.default void
Reads in the textual representation of this object and sets its fields.static <TO extends TextObject>
TOCreates a single object of a specific class from from anInputStream
.default void
Reads from aFile
and sets this object's fields.default void
Reads from aFile
and sets this object's fields.void
Reads from anReader
and sets this object's fields.default String
toText()
Gets the textual representation of this object.default void
Writes this object to aFile
.default void
Writes this object to aFile
.default void
Writes this object to aFile
.default void
Writes this object to aFile
.void
Writes this object to aWriter
.
-
Method Details
-
toText
Gets the textual representation of this object.- Returns:
- this object as a String.
-
fromText
Reads in the textual representation of this object and sets its fields.- Parameters:
string
- the string array to read from.- Throws:
IOException
- if a read error occurs.
-
readText
Reads from anReader
and sets this object's fields.- Parameters:
reader
- theReader
to read from.- Throws:
IOException
- if a read error occurs.
-
readFile
Reads from aFile
and sets this object's fields. The charset encoding used is the default platform encoding.- Parameters:
file
- theFile
to read from.- Throws:
FileNotFoundException
- if the file could not be found.IOException
- if a read error occurs.SecurityException
- if the file could not be opened due to OS permissions.- Since:
- 2.13.0
- See Also:
-
readFile
Reads from aFile
and sets this object's fields.- Parameters:
file
- theFile
to read from.charset
- the charset encoding to use for reading.- Throws:
FileNotFoundException
- if the file could not be found.IOException
- if a read error occurs.SecurityException
- if the file could not be opened due to OS permissions.- Since:
- 2.13.0
-
writeText
Writes this object to aWriter
.- Parameters:
writer
- theWriter
to write to.- Throws:
IOException
- if a write error occurs.
-
writeFile
Writes this object to aFile
. The file's contents are overwritten. The charset encoding used is the default platform encoding.- Parameters:
file
- theFile
to write to.- Throws:
FileNotFoundException
- if the file exists, but is a directory.IOException
- if a write error occurs.SecurityException
- if the file could not be written to due to OS permissions.- Since:
- 2.13.0
- See Also:
-
writeFile
Writes this object to aFile
. The file's contents are overwritten.- Parameters:
file
- theFile
to write to.charset
- the charset encoding to use for writing.- Throws:
FileNotFoundException
- if the file exists, but is a directory.IOException
- if a write error occurs.SecurityException
- if the file could not be written to due to OS permissions.- Since:
- 2.13.0
- See Also:
-
writeFile
Writes this object to aFile
. The charset encoding used is the default platform encoding.- Parameters:
file
- theFile
to write to.append
- if true, the content is written to the end of the file.- Throws:
FileNotFoundException
- if the file exists, but is a directory.IOException
- if a write error occurs.SecurityException
- if the file could not be written to due to OS permissions.- Since:
- 2.13.0
- See Also:
-
writeFile
Writes this object to aFile
.- Parameters:
file
- theFile
to write to.append
- if true, the content is written to the end of the file.charset
- the charset encoding to use for writing.- Throws:
FileNotFoundException
- if the file exists, but is a directory.IOException
- if a write error occurs.SecurityException
- if the file could not be written to due to OS permissions.- Since:
- 2.13.0
-
create
Creates a single object of a specific class from a string.- Type Parameters:
TO
- the object type, a subtype ofTextObject
.- Parameters:
toClass
- the class to create.string
- the string.- Returns:
- an array of length
count
of the created objects. - Throws:
IOException
- if an error occurs during the read - most commonly "not enough bytes".
-
read
Creates a single object of a specific class from from anInputStream
.- Type Parameters:
TO
- the object type, a subtype ofTextObject
.- Parameters:
toClass
- the class to create.reader
- the reader.- Returns:
- an array of length
count
of the created objects. - Throws:
IOException
- if an error occurs during the read - most commonly "not enough bytes".
-