Class PDA
- java.lang.Object
-
- org.pgpainless.decryption_verification.syntax_check.PDA
-
public class PDA extends java.lang.ObjectPushdown Automaton for validating context-free languages. In PGPainless, this class is used to validate OpenPGP message packet sequences against the allowed syntax.- See Also:
- OpenPGP Message Syntax
-
-
Constructor Summary
Constructors Constructor Description PDA()Default constructor which initializes the PDA to work with theOpenPgpMessageSyntax.PDA(Syntax syntax, State initialState, StackSymbol... initialStack)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassertValid()Throw aMalformedOpenPgpMessageExceptionif the pda is not in a valid state right now.StategetState()Return the current state of the PDA.booleanisValid()Return true, if the PDA is in a valid state (the OpenPGP message is valid).voidnext(InputSymbol input)Process the nextInputSymbol.StackSymbolpeekStack()Peek at the stack, returning the topmost stack item without changing the stack.java.lang.StringtoString()
-
-
-
Constructor Detail
-
PDA
public PDA()
Default constructor which initializes the PDA to work with theOpenPgpMessageSyntax.
-
PDA
public PDA(@Nonnull Syntax syntax, @Nonnull State initialState, @Nonnull StackSymbol... initialStack)- Parameters:
syntax- syntaxinitialState- initial stateinitialStack- zero or more initial stack items (get pushed onto the stack in order of appearance)
-
-
Method Detail
-
next
public void next(@Nonnull InputSymbol input) throws MalformedOpenPgpMessageExceptionProcess the nextInputSymbol. This will either leave the PDA in the next state, or throw aMalformedOpenPgpMessageExceptionif the input symbol is rejected.- Parameters:
input- input symbol- Throws:
MalformedOpenPgpMessageException- if the input symbol is rejected
-
getState
@Nonnull public State getState()
Return the current state of the PDA.- Returns:
- state
-
peekStack
@Nullable public StackSymbol peekStack()
Peek at the stack, returning the topmost stack item without changing the stack.- Returns:
- topmost stack item, or null if stack is empty
-
isValid
public boolean isValid()
Return true, if the PDA is in a valid state (the OpenPGP message is valid).- Returns:
- true if valid, false otherwise
-
assertValid
public void assertValid() throws MalformedOpenPgpMessageExceptionThrow aMalformedOpenPgpMessageExceptionif the pda is not in a valid state right now.- Throws:
MalformedOpenPgpMessageException- if the pda is not in an acceptable state
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-