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
FieldsModifier 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
ConstructorsConstructorDescriptionUPParser()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 voidDisable tracing.final voidEnable tracing.Generate ParseException.final TokenGet the next Token.final TokengetToken(int index) Get the specific TokenReturn updatestatic voidExampleParses the specified update file to extract a list of updates.voidReInit(InputStream stream) Reinitializes the parser with a new input stream using the default encoding.voidReInit(InputStream stream, String encoding) Reinitializes the parser with a new input stream and a specified encoding.voidReinitializes the parser with a new reader.voidReinitializes 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
Updateobjects 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.
-