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 classSpecific IOException for when a parsing exception occurs on read.static classstatic interfaceTextObject.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 voidReads 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, default encoding.static <TO extends TextObject>
TOCreates a single object of a specific class from from aFile.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 aReader.default voidReads from aFileand sets this object's fields.default voidReads from aFileand sets this object's fields.voidReads from anReaderand sets this object's fields.default StringtoText()Gets the textual representation of this object.default voidWrites this object to aFile.default voidWrites this object to aFile.default voidWrites this object to aFile.default voidWrites this object to aFile.voidWrites 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 anReaderand sets this object's fields.- Parameters:
reader- theReaderto read from.- Throws:
IOException- if a read error occurs.
-
readFile
Reads from aFileand sets this object's fields. The charset encoding used is the default platform encoding.- Parameters:
file- theFileto 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 aFileand sets this object's fields.- Parameters:
file- theFileto 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- theWriterto 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- theFileto 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- theFileto 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- theFileto 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- theFileto 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, default encoding.- 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.- 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 aReader.- 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.
-