public class LenientErrorHandler extends Object implements IParserErrorHandler
The invalidValue(ca.uhn.fhir.parser.IParserErrorHandler.IParseLocation, String, String)
method will throw a DataFormatException by default since ignoring this type of error
can lead to data loss (since invalid values are silently ignored). See
setErrorOnInvalidValue(boolean) for information on this.
IParserErrorHandler.IParseLocation| Constructor and Description |
|---|
LenientErrorHandler()
Constructor which configures this handler to log all errors
|
LenientErrorHandler(boolean theLogErrors)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
containedResourceWithNoId(IParserErrorHandler.IParseLocation theLocation)
Invoked when a contained resource is parsed that has no ID specified (and is therefore invalid)
|
static String |
createIncorrectJsonTypeMessage(String theElementName,
JsonLikeValue.ValueType theExpected,
JsonLikeValue.ScalarType theExpectedScalarType,
JsonLikeValue.ValueType theFound,
JsonLikeValue.ScalarType theFoundScalarType) |
void |
incorrectJsonType(IParserErrorHandler.IParseLocation theLocation,
String theElementName,
JsonLikeValue.ValueType theExpected,
JsonLikeValue.ScalarType theExpectedScalarType,
JsonLikeValue.ValueType theFound,
JsonLikeValue.ScalarType theFoundScalarType)
Invoked if the wrong type of element is found while parsing JSON.
|
void |
invalidValue(IParserErrorHandler.IParseLocation theLocation,
String theValue,
String theError)
The parser detected an atttribute value that was invalid (such as: empty "" values are not permitted)
|
boolean |
isErrorOnInvalidValue()
If set to
false (default is true) invalid values will be logged. |
void |
missingRequiredElement(IParserErrorHandler.IParseLocation theLocation,
String theElementName)
Resource was missing a required element
|
LenientErrorHandler |
setErrorOnInvalidValue(boolean theErrorOnInvalidValue)
If set to
false (default is true) invalid values will be logged. |
void |
unexpectedRepeatingElement(IParserErrorHandler.IParseLocation theLocation,
String theElementName)
Invoked when an element repetition (e.g.
|
void |
unknownAttribute(IParserErrorHandler.IParseLocation theLocation,
String theElementName)
Invoked when an unknown element is found in the document.
|
void |
unknownElement(IParserErrorHandler.IParseLocation theLocation,
String theElementName)
Invoked when an unknown element is found in the document.
|
void |
unknownReference(IParserErrorHandler.IParseLocation theLocation,
String theReference)
Resource contained a reference that could not be resolved and needs to be resolvable (e.g.
|
public LenientErrorHandler()
public LenientErrorHandler(boolean theLogErrors)
theLogErrors - Should errors be logged?public void containedResourceWithNoId(IParserErrorHandler.IParseLocation theLocation)
IParserErrorHandlercontainedResourceWithNoId in interface IParserErrorHandlertheLocation - The location in the document. WILL ALWAYS BE NULL currently, as this is not yet implemented, but this parameter is included so that locations can be added in the future without
changing the API.public void incorrectJsonType(IParserErrorHandler.IParseLocation theLocation, String theElementName, JsonLikeValue.ValueType theExpected, JsonLikeValue.ScalarType theExpectedScalarType, JsonLikeValue.ValueType theFound, JsonLikeValue.ScalarType theFoundScalarType)
IParserErrorHandlerincorrectJsonType in interface IParserErrorHandlertheLocation - The location in the document. Note that this may be null as the ParseLocation feature is experimental. Use with caution, as the API may change.theElementName - The name of the element that was found.theExpected - The datatype that was expected at this locationtheExpectedScalarType - If theExpectedValueType is JsonLikeValue.ValueType.SCALAR, this is the specific scalar type expected. Otherwise this parameter will be null.theFound - The datatype that was found at this locationtheFoundScalarType - If theFoundValueType is JsonLikeValue.ValueType.SCALAR, this is the specific scalar type found. Otherwise this parameter will be null.public void invalidValue(IParserErrorHandler.IParseLocation theLocation, String theValue, String theError)
IParserErrorHandlerinvalidValue in interface IParserErrorHandlertheLocation - The location in the document. Note that this may be null as the ParseLocation feature is experimental. Use with caution, as the API may change.theValue - The actual valuetheError - A description of why the value was invalidpublic boolean isErrorOnInvalidValue()
false (default is true) invalid values will be logged. By
default invalid attribute values cause this error handler to throw a DataFormatException (unlike
other methods in this class which default to simply logging errors).
Note that empty values (e.g. "") will not lead to an error when this is set to
true, only invalid values (e.g. a gender code of foo)
setErrorOnInvalidValue(boolean)public void missingRequiredElement(IParserErrorHandler.IParseLocation theLocation, String theElementName)
IParserErrorHandlermissingRequiredElement in interface IParserErrorHandlertheLocation - The location in the document. Note that this may be null as the ParseLocation feature is experimental. Use with caution, as the API may change.public LenientErrorHandler setErrorOnInvalidValue(boolean theErrorOnInvalidValue)
false (default is true) invalid values will be logged. By
default invalid attribute values cause this error handler to throw a DataFormatException (unlike
other methods in this class which default to simply logging errors).
Note that empty values (e.g. "") will not lead to an error when this is set to
true, only invalid values (e.g. a gender code of foo)
this for easy method chainingisErrorOnInvalidValue()public void unexpectedRepeatingElement(IParserErrorHandler.IParseLocation theLocation, String theElementName)
IParserErrorHandlerunexpectedRepeatingElement in interface IParserErrorHandlertheLocation - The location in the document. Note that this may be null as the ParseLocation feature is experimental. Use with caution, as the API may change.theElementName - The name of the element that was found.public void unknownAttribute(IParserErrorHandler.IParseLocation theLocation, String theElementName)
IParserErrorHandlerunknownAttribute in interface IParserErrorHandlertheLocation - The location in the document. Note that this may be null as the ParseLocation feature is experimental. Use with caution, as the API may change.theElementName - The name of the attribute that was found.public void unknownElement(IParserErrorHandler.IParseLocation theLocation, String theElementName)
IParserErrorHandlerunknownElement in interface IParserErrorHandlertheLocation - The location in the document. Note that this may be null as the ParseLocation feature is experimental. Use with caution, as the API may change.theElementName - The name of the element that was found.public void unknownReference(IParserErrorHandler.IParseLocation theLocation, String theReference)
IParserErrorHandlerunknownReference in interface IParserErrorHandlertheLocation - The location in the document. Note that this may be null as the ParseLocation feature is experimental. Use with caution, as the API may change.theReference - The actual invalid reference (e.g. "#3")public static String createIncorrectJsonTypeMessage(String theElementName, JsonLikeValue.ValueType theExpected, JsonLikeValue.ScalarType theExpectedScalarType, JsonLikeValue.ValueType theFound, JsonLikeValue.ScalarType theFoundScalarType)
Copyright © 2014–2017 University Health Network. All rights reserved.