Record Class ParseError
java.lang.Object
java.lang.Record
dev.jcputney.elearning.parser.input.scorm12.adl.prerequisite.ParseError
- Record Components:
originalExpression- the original expression string that failed to parseerrorMessage- a description of why parsing failederrorPosition- the character position where the error was detected (0-based), or -1 if unknown
- All Implemented Interfaces:
PrerequisiteExpression
public record ParseError(String originalExpression, String errorMessage, int errorPosition)
extends Record
implements PrerequisiteExpression
Represents a parse error when the prerequisite expression cannot be parsed.
This allows the parser to gracefully handle malformed expressions without throwing exceptions. Consumers can check if the result is a ParseError to determine if the expression was valid.
Example error scenarios:
- Unbalanced parentheses:
(ITEM-001 & ITEM-002 - Missing operand:
ITEM-001 & - Invalid characters:
ITEM-001 @ ITEM-002 - Empty expression:
""
-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.jcputney.elearning.parser.input.scorm12.adl.prerequisite.PrerequisiteExpression
PrerequisiteExpression.Visitor<T> -
Constructor Summary
ConstructorsConstructorDescriptionParseError(String originalExpression, String errorMessage) Creates a parse error with an unknown position.ParseError(String originalExpression, String errorMessage, int errorPosition) Creates an instance of aParseErrorrecord class. -
Method Summary
Modifier and TypeMethodDescription<T> Taccept(PrerequisiteExpression.Visitor<T> visitor) Accepts a visitor to process this expression.final booleanIndicates whether some other object is "equal to" this one.Returns the value of theerrorMessagerecord component.intReturns the value of theerrorPositionrecord component.final inthashCode()Returns a hash code value for this object.Returns the value of theoriginalExpressionrecord component.toString()Returns a string representation of this record class.
-
Constructor Details
-
ParseError
Creates a parse error with an unknown position.- Parameters:
originalExpression- the original expression stringerrorMessage- the error description
-
ParseError
Creates an instance of aParseErrorrecord class.- Parameters:
originalExpression- the value for theoriginalExpressionrecord componenterrorMessage- the value for theerrorMessagerecord componenterrorPosition- the value for theerrorPositionrecord component
-
-
Method Details
-
accept
Description copied from interface:PrerequisiteExpressionAccepts a visitor to process this expression.- Specified by:
acceptin interfacePrerequisiteExpression- Type Parameters:
T- the return type of the visitor- Parameters:
visitor- the visitor to accept- Returns:
- the result of the visitor processing this expression
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
originalExpression
Returns the value of theoriginalExpressionrecord component.- Returns:
- the value of the
originalExpressionrecord component
-
errorMessage
Returns the value of theerrorMessagerecord component.- Returns:
- the value of the
errorMessagerecord component
-
errorPosition
public int errorPosition()Returns the value of theerrorPositionrecord component.- Returns:
- the value of the
errorPositionrecord component
-