Class UPParser

java.lang.Object
org.tweetyproject.preferences.io.UPParser
All Implemented Interfaces:
UPParserConstants

public class UPParser extends Object implements 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 Details

    • token_source

      public UPParserTokenManager token_source
      Generated Token Manager.
    • token

      public Token token
      Current token.
    • jj_nt

      public Token jj_nt
      Next token.
  • Constructor Details

    • UPParser

      public UPParser()
      Constructor
    • UPParser

      public UPParser(InputStream stream)
      Constructor with InputStream.
      Parameters:
      stream - input stream
    • UPParser

      public UPParser(InputStream stream, String encoding)
      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

      public UPParser(Reader stream)
      Constructs a parser with a reader.
      Parameters:
      stream - The reader to read from.
    • UPParser

      public UPParser(UPParserTokenManager tm)
      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

      public static void main(String[] args) throws ParseException
      Example
      Parameters:
      args - the args
      Throws:
      ParseException - error
    • getUpdate

      public final ArrayList<Update<String>> getUpdate() throws ParseException, FileNotFoundException
      Return update
      Returns:
      update
      Throws:
      ParseException - error
      FileNotFoundException - error
    • ReInit

      public void ReInit(InputStream stream, String encoding)
      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

      public void ReInit(InputStream stream)
      Reinitializes the parser with a new input stream using the default encoding.
      Parameters:
      stream - The new input stream to read from.
    • ReInit

      public void ReInit(Reader stream)
      Reinitializes the parser with a new reader.
      Parameters:
      stream - The new reader to read from.
    • ReInit

      public void ReInit(UPParserTokenManager tm)
      Reinitializes the parser with a new token manager.
      Parameters:
      tm - The new token manager to use for token processing.
    • getNextToken

      public final Token getNextToken()
      Get the next Token.
      Returns:
      next token
    • getToken

      public final Token getToken(int index)
      Get the specific Token
      Parameters:
      index - the index
      Returns:
      a token
    • generateParseException

      public ParseException generateParseException()
      Generate ParseException.
      Returns:
      ParseException
    • enable_tracing

      public final void enable_tracing()
      Enable tracing.
    • disable_tracing

      public final void disable_tracing()
      Disable tracing.