Class Text
java.lang.Object
net.mtrop.doom.text.Text
- All Implemented Interfaces:
CharSequence,TextObject
A generic text object.
Contains only a StringBuilder that can be written to or read from.
- Since:
- 2.19.0
- Author:
- Matthew Tropiano
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.mtrop.doom.object.TextObject
TextObject.ParseException, TextObject.Reflect, TextObject.Transformer<TO extends TextObject> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncharcharAt(int index) <TO extends TextObject>
TOReturns a new object, where the contents of this Text is read as a different TextObject-implementing object.getMatcherForPattern(Pattern regex) Returns a Matcher for a given RegEx pattern.intReturns the index of the first occurrence of the provided string.intReturns the index of the first occurrence of the provided string, starting from a provided index.intlastIndexOf(String str) Returns the index of the last occurrence of the provided string.intlastIndexOf(String str, int fromIndex) Returns the index of the last occurrence of the provided string, starting from a provided index, searching backwards.intlength()voidReads from anReaderand sets this object's fields.subSequence(int start, int end) toString()voidWrites this object to aWriter.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty
-
Constructor Details
-
Text
public Text()Creates a new Text object.
-
-
Method Details
-
length
public int length()- Specified by:
lengthin interfaceCharSequence
-
charAt
public char charAt(int index) - Specified by:
charAtin interfaceCharSequence
-
indexOf
Returns the index of the first occurrence of the provided string.- Parameters:
str- the string to search for.- Returns:
- the index or -1 if not found.
-
indexOf
Returns the index of the first occurrence of the provided string, starting from a provided index.- Parameters:
str- the string to search for.fromIndex- the index to start searching from.- Returns:
- the index or -1 if not found.
-
lastIndexOf
Returns the index of the last occurrence of the provided string.- Parameters:
str- the string to search for.- Returns:
- the index or -1 if not found.
-
lastIndexOf
Returns the index of the last occurrence of the provided string, starting from a provided index, searching backwards.- Parameters:
str- the string to search for.fromIndex- the index to start searching from.- Returns:
- the index or -1 if not found.
-
getMatcherForPattern
-
subSequence
- Specified by:
subSequencein interfaceCharSequence
-
getBuilder
- Returns:
- a reference to the underlying StringBuilder.
-
create
Returns a new object, where the contents of this Text is read as a different TextObject-implementing object.- Type Parameters:
TO- the TextObject subtype.- Parameters:
toClass- the class to create.- Returns:
- the new object.
- Throws:
IOException- if an error occurs during the read - most commonly a ParseException.
-
toString
- Specified by:
toStringin interfaceCharSequence- Overrides:
toStringin classObject
-
readText
Description copied from interface:TextObjectReads from anReaderand sets this object's fields.- Specified by:
readTextin interfaceTextObject- Parameters:
reader- theReaderto read from.- Throws:
IOException- if a read error occurs.
-
writeText
Description copied from interface:TextObjectWrites this object to aWriter.- Specified by:
writeTextin interfaceTextObject- Parameters:
writer- theWriterto write to.- Throws:
IOException- if a write error occurs.
-