Package com.helger.xml.serialize.write
Enum EXMLIncorrectCharacterHandling
java.lang.Object
java.lang.Enum<EXMLIncorrectCharacterHandling>
com.helger.xml.serialize.write.EXMLIncorrectCharacterHandling
- All Implemented Interfaces:
Serializable,Comparable<EXMLIncorrectCharacterHandling>,java.lang.constant.Constable
Define what to do, when an invalid character is to be serialized to XML.
- Author:
- Philip Helger
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionDo not write the invalid character to XML but at least log a warning.Do not write the invalid character to XML and do not log anything.Throw anIllegalArgumentExceptionin case of incorrect XML characters.Write the invalid character to the file.Write the invalid character to the file. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final EXMLIncorrectCharacterHandlingThe default setting as it was in previous versions of ph-commons -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanbooleanabstract voidnotifyOnInvalidXMLCharacter(String sText, Set<Character> aInvalidChars) Called in case XML data contains an invalid characterReturns the enum constant of this type with the specified name.static EXMLIncorrectCharacterHandling[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
THROW_EXCEPTION
Throw anIllegalArgumentExceptionin case of incorrect XML characters. -
WRITE_TO_FILE_NO_LOG
Write the invalid character to the file. This will result in a file that cannot be read with the Java XML parser.
This is the fastest option. This is how it was handled in ph-commons ≤ 3.3.6. This option will most probably result in unreadable XML files as no replacement takes place! -
WRITE_TO_FILE_LOG_WARNING
Write the invalid character to the file. This will result in a file that cannot be read with the Java XML parser.
This is the second fastest option but will most probably result in unreadable XML files as no replacement takes place! -
DO_NOT_WRITE_NO_LOG
Do not write the invalid character to XML and do not log anything. This means silently fixing the problem as the replacement is written. -
DO_NOT_WRITE_LOG_WARNING
Do not write the invalid character to XML but at least log a warning. Will trigger character replacement.
-
-
Field Details
-
DEFAULT
The default setting as it was in previous versions of ph-commons
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
isTestRequired
public boolean isTestRequired()- Returns:
trueif this handling type requires a check for invalid characters.
-
isNotifyRequired
public boolean isNotifyRequired()- Returns:
truenotifyOnInvalidXMLCharacter(String, Set)should be invoked for this type?
-
isReplaceWithNothing
public boolean isReplaceWithNothing()- Returns:
trueif all invalid characters should be replaced with nothing, meaning that they are simply ignored on writing.
-
notifyOnInvalidXMLCharacter
public abstract void notifyOnInvalidXMLCharacter(@Nonnull @Nonempty String sText, @Nonnull Set<Character> aInvalidChars) Called in case XML data contains an invalid character- Parameters:
sText- The XML string where the error occurs.aInvalidChars- The invalid characters detected within the text
-