Package net.mtrop.doom.object
Interface TextObject
- All Known Implementing Classes:
EternityMapInfo
,HexenMapInfo
,Text
,UDMFMap
,UniversalMapInfo
,ZDoomMapInfo
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
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
Specific IOException for when a parsing exception occurs on read.static 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 aFile
.static <TO extends TextObject>
TOCreates a single object of a specific class from from aFile
, default encoding.static <TO extends TextObject>
TOread
(Class<TO> toClass, InputStream in) Creates a single object of a specific class from from anInputStream
, default encoding.static <TO extends TextObject>
TOread
(Class<TO> toClass, InputStream in, Charset charset) Creates a single object of a specific class from from anInputStream
.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
-
read
Creates a single object of a specific class from from anInputStream
, default encoding.- Type Parameters:
TO
- the object type, a subtype ofTextObject
.- Parameters:
toClass
- the class to create.in
- the input stream.- Returns:
- a single instance of the created object.
- Throws:
IOException
- if an error occurs during the read - most commonly a ParseException.- Since:
- 2.19.1
-
read
static <TO extends TextObject> TO read(Class<TO> toClass, InputStream in, Charset charset) throws IOException 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.in
- the input stream.charset
- the charset encoding to use for reading.- Returns:
- a single instance of the created object.
- Throws:
IOException
- if an error occurs during the read - most commonly a ParseException.- Since:
- 2.19.1
-
read
Creates a single object of a specific class from from aFile
.- Type Parameters:
TO
- the object type, a subtype ofTextObject
.- Parameters:
toClass
- the class to create.file
- the source file.- Returns:
- a single instance of the created object.
- Throws:
FileNotFoundException
- if the file could not be found.IOException
- if an error occurs during the read - most commonly a ParseException.SecurityException
- if the file could not be opened due to OS permissions.- Since:
- 2.19.1
-
read
static <TO extends TextObject> TO read(Class<TO> toClass, File file, Charset charset) throws IOException Creates a single object of a specific class from from aFile
, default encoding.- Type Parameters:
TO
- the object type, a subtype ofTextObject
.- Parameters:
toClass
- the class to create.file
- the source file.charset
- the charset encoding to use for reading.- Returns:
- a single instance of the created object.
- Throws:
FileNotFoundException
- if the file could not be found.IOException
- if an error occurs during the read - most commonly a ParseException.SecurityException
- if the file could not be opened due to OS permissions.- Since:
- 2.19.1
-
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:
- a new instance of the provided class.
- Throws:
IOException
- if an error occurs during the read - most commonly a ParseException.
-
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:
- a new instance of the provided class.
- Throws:
IOException
- if an error occurs during the read - most commonly a ParseException.
-