Package org.tweetyproject.preferences.io
Class UPParser
java.lang.Object
org.tweetyproject.preferences.io.UPParser
- All Implemented Interfaces:
UPParserConstants
Update Parser for reading updates for dynamic Preference Aggregation
Please note: update file syntax changed from
(index, operation, amount, element)
e.g. (1, WEAKEN, 2, a)
to
(index, operation(amount), element)
e.g. (1, -2, a)
where
-(/+) is equal to WEAKEN(/STRENGTHEN)
and 2 is the amount
-
Field Summary
Modifier and TypeFieldDescriptionNext token.Current token.Generated Token Manager.Fields inherited from interface org.tweetyproject.preferences.io.UPParserConstants
DEFAULT, ELEMENT, EOF, EOL, INDEX, LBRA, OPERATION, RBRA, tokenImage
-
Constructor Summary
ConstructorDescriptionUPParser()
ConstructorUPParser
(InputStream stream) Constructor with InputStream.UPParser
(InputStream stream, String encoding) Constructs a parser with an input stream and a specified encoding.Constructs a parser with a reader.Constructs a parser with a provided token manager. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
Disable tracing.final void
Enable tracing.Generate ParseException.final Token
Get the next Token.final Token
getToken
(int index) Get the specific TokenReturn updatestatic void
ExampleParses the specified update file to extract a list of updates.void
ReInit
(InputStream stream) Reinitializes the parser with a new input stream using the default encoding.void
ReInit
(InputStream stream, String encoding) Reinitializes the parser with a new input stream and a specified encoding.void
Reinitializes the parser with a new reader.void
Reinitializes the parser with a new token manager.
-
Field Details
-
token_source
Generated Token Manager. -
token
Current token. -
jj_nt
Next token.
-
-
Constructor Details
-
UPParser
public UPParser()Constructor -
UPParser
-
UPParser
Constructs a parser with an input stream and a specified encoding.- Parameters:
stream
- The input stream to read from.encoding
- The character encoding of the input stream.- Throws:
RuntimeException
- If the specified encoding is unsupported.
-
UPParser
Constructs a parser with a reader.- Parameters:
stream
- The reader to read from.
-
UPParser
Constructs a parser with a provided token manager.- Parameters:
tm
- The token manager to use for token processing.
-
-
Method Details
-
parse
public static ArrayList<Update<String>> parse(String updatefile) throws ParseException, FileNotFoundException Parses the specified update file to extract a list of updates.- Parameters:
updatefile
- The path to the update file to be parsed.- Returns:
- A list of
Update
objects containing the parsed updates. - Throws:
ParseException
- If an error occurs during the parsing process.FileNotFoundException
- If the specified file cannot be found.
-
main
Example- Parameters:
args
- the args- Throws:
ParseException
- error
-
getUpdate
Return update- Returns:
- update
- Throws:
ParseException
- errorFileNotFoundException
- error
-
ReInit
Reinitializes the parser with a new input stream and a specified encoding.- Parameters:
stream
- The new input stream to read from.encoding
- The character encoding of the new input stream.- Throws:
RuntimeException
- If the specified encoding is unsupported.
-
ReInit
Reinitializes the parser with a new input stream using the default encoding.- Parameters:
stream
- The new input stream to read from.
-
ReInit
Reinitializes the parser with a new reader.- Parameters:
stream
- The new reader to read from.
-
ReInit
Reinitializes the parser with a new token manager.- Parameters:
tm
- The new token manager to use for token processing.
-
getNextToken
-
getToken
Get the specific Token- Parameters:
index
- the index- Returns:
- a token
-
generateParseException
-
enable_tracing
public final void enable_tracing()Enable tracing. -
disable_tracing
public final void disable_tracing()Disable tracing.
-