Interface StatementWriter
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
Resumed statement state. -
Method Summary
Modifier and TypeMethodDescriptionvoid
endStatement
(@NonNull StatementSourceReference ref) Ends current opened statement.@NonNull ModelProcessingPhase
getPhase()
Return current model processing phase.Optional<? extends StatementWriter.ResumedStatement>
resumeStatement
(int childId) Attempt to resume a child statement.void
startStatement
(int childId, @NonNull QName name, @Nullable String argument, @NonNull StatementSourceReference ref) Starts statement with supplied name and location in source.void
storeStatement
(int expectedChildren, boolean fullyDefined) Store a defined statement, hinting at the number of children it is expected to have and indicating whether it has been fully defined.
-
Method Details
-
resumeStatement
Attempt to resume a child statement. If the statement has been previously defined, aStatementWriter.ResumedStatement
instance is returned.If an empty optional is returned, the caller is expected to follow-up with
startStatement(int, QName, String, StatementSourceReference)
to define the statement.If the returned resumed statement indicates
StatementWriter.ResumedStatement.isFullyDefined()
, the caller should take no further action with this or any of the child statements. Otherwise this call is equivalent of issuingstartStatement(int, QName, String, StatementSourceReference)
and the caller is expected to process any child statements. The caller should callstoreStatement(int, boolean)
before finishing processing withendStatement(StatementSourceReference)
.- Parameters:
childId
- Child- Returns:
- A resumed statement or empty if the statement has not previously been defined.
-
storeStatement
void storeStatement(int expectedChildren, boolean fullyDefined) Store a defined statement, hinting at the number of children it is expected to have and indicating whether it has been fully defined. This method should be called beforeendStatement(StatementSourceReference)
when the caller is taking advantage ofresumeStatement(int)
.- Parameters:
expectedChildren
- Number of expected children, cannot be negativefullyDefined
- True if the statement and all its descendants have been defined.
-
startStatement
void startStatement(int childId, @NonNull QName name, @Nullable String argument, @NonNull StatementSourceReference ref) Starts statement with supplied name and location in source.Each started statement must also be closed by
endStatement(StatementSourceReference)
in order for stream to be correct.If statement has substatements, in order to start substatement, call to
startStatement(int, QName, String, StatementSourceReference)
needs to be done for substatement.- Parameters:
childId
- Child identifier, unique among siblingsname
- Fully qualified name of statement.argument
- String representation of value as appeared in source, null if not presentref
- Identifier of location in source, which will be used for reporting in case of statement processing error.- Throws:
SourceException
- if statement is not valid according to current context.
-
endStatement
Ends current opened statement.- Parameters:
ref
- Identifier of location in source, which will be used for reporting in case of statement processing error.- Throws:
SourceException
- if closed statement is not valid in current context, or there is no such statement
-
getPhase
@NonNull ModelProcessingPhase getPhase()Return current model processing phase.- Returns:
- current processing phase
-