RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.util.parser.TextFileParser Class Referenceabstract

A simple parser designed for text files. More...

Inheritance diagram for com.runehive.util.parser.TextFileParser:
Collaboration diagram for com.runehive.util.parser.TextFileParser:

Public Member Functions

void deserialize ()
 The method that deserializes the file information.
abstract void parse (BufferedReader reader) throws IOException
 The method called when the file is being parsed.
 TextFileParser (String path)
 Creates a new TextFileParser.
 TextFileParser (String path, boolean log)
 Creates a new TextFileParser.
Public Member Functions inherited from com.runehive.util.parser.GenericParser
 GenericParser (String path, String extension, boolean log)
 Creates a new GenericParser.
final int getIndex ()
 Gets the current index of the line being parsed.
void onRead ()
 The method called after all the data has been parsed.
void run ()
String toString ()

Additional Inherited Members

Protected Attributes inherited from com.runehive.util.parser.GenericParser
int index
 The index of the current line being parsed.
final Path path
 The path of the file to parse.

Detailed Description

A simple parser designed for text files.

Author
Seven

Definition at line 13 of file TextFileParser.java.

Constructor & Destructor Documentation

◆ TextFileParser() [1/2]

com.runehive.util.parser.TextFileParser.TextFileParser ( String path)

Creates a new TextFileParser.

Parameters
pathThe path of the file to parse.

Definition at line 21 of file TextFileParser.java.

21 {
22 this(path, true);
23 }

References com.runehive.util.parser.GenericParser.path.

◆ TextFileParser() [2/2]

com.runehive.util.parser.TextFileParser.TextFileParser ( String path,
boolean log )

Creates a new TextFileParser.

Parameters
pathThe path of the file to parse.
logThe flag that denotes to log messages.

Definition at line 34 of file TextFileParser.java.

34 {
35 super(path, ".txt", log);
36 }

References com.runehive.util.parser.GenericParser.log, and com.runehive.util.parser.GenericParser.path.

Member Function Documentation

◆ deserialize()

void com.runehive.util.parser.TextFileParser.deserialize ( )

The method that deserializes the file information.

Reimplemented from com.runehive.util.parser.GenericParser.

Definition at line 47 of file TextFileParser.java.

47 {
48 try(BufferedReader reader = new BufferedReader(new FileReader(path.toFile()))) {
49 while(reader.readLine() != null) {
50 parse(reader);
51 index++;
52 }
53 reader.close();
54 } catch (FileNotFoundException e) {
55 e.printStackTrace();
56 } catch (IOException e) {
57 e.printStackTrace();
58 }
59 }
val index

References com.runehive.util.parser.GenericParser.index, parse(), and com.runehive.util.parser.GenericParser.path.

Here is the call graph for this function:

◆ parse()

abstract void com.runehive.util.parser.TextFileParser.parse ( BufferedReader reader) throws IOException
abstract

The method called when the file is being parsed.

Parameters
readerThe underlying parser.

Referenced by deserialize().

Here is the caller graph for this function:

The documentation for this class was generated from the following file: