Package megamek.common.util.fileUtils
Class StandardTextfileStreamTokenizer
java.lang.Object
java.io.StreamTokenizer
megamek.common.util.fileUtils.StandardTextfileStreamTokenizer
This is a specialized StreamTokenizer that uses a configuration that many of MM's text files share.
This configuration uses # for comments, double quotes for strings and information
is processed line-wise. This class adds some methods to simplify line parsing.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a StreamTokenizer for the given InputStream.Creates a StreamTokenizer for the given Reader. -
Method Summary
Modifier and TypeMethodDescriptionReturns a list of tokens making up the next available input stream line.boolean
static boolean
isValidIncludeLine
(List<String> lineTokens) Returns true when the line given as its tokens is a valid line giving an include file.Methods inherited from class java.io.StreamTokenizer
commentChar, eolIsSignificant, lineno, lowerCaseMode, nextToken, ordinaryChar, ordinaryChars, parseNumbers, pushBack, quoteChar, resetSyntax, slashSlashComments, slashStarComments, toString, whitespaceChars, wordChars
-
Field Details
-
INCLUDE_KEY
- See Also:
-
-
Constructor Details
-
StandardTextfileStreamTokenizer
Creates a StreamTokenizer for the given Reader.- Parameters:
r
- The Reader to tokenize such as aFileReader
-
StandardTextfileStreamTokenizer
Creates a StreamTokenizer for the given InputStream.- Parameters:
is
- The InputStream to tokenize
-
-
Method Details
-
isValidIncludeLine
Returns true when the line given as its tokens is a valid line giving an include file. The tokens should be obtained fromgetLineTokens()
. A valid include line has exactly two tokens, the first being "include" and the second a filename.- Parameters:
lineTokens
- The tokens representing an input stream line- Returns:
- True when the tokens represent a valid include statement
- See Also:
-
getLineTokens
Returns a list of tokens making up the next available input stream line. Empty lines are skipped, i.e. the tokens list will normally not be empty. It may be empty when the end of the input stream is reached. UseisFinished()
to test if the stream is at its end.- Returns:
- The tokens of the next available line that is not empty
- Throws:
IOException
- See Also:
-
isFinished
public boolean isFinished()- Returns:
- True when the end of the input stream is reached. When this method returns true, the tokens
list returned by
getLineTokens()
is empty. The finished state is updated ingetLineTokens()
.
-