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>
public enum EXMLIncorrectCharacterHandling extends Enum<EXMLIncorrectCharacterHandling>
Define what to do, when an invalid character is to be serialized to XML.- Author:
- Philip Helger
-
-
Enum Constant Summary
Enum Constants Enum Constant Description DO_NOT_WRITE_LOG_WARNINGDo not write the invalid character to XML but at least log a warning.DO_NOT_WRITE_NO_LOGDo not write the invalid character to XML and do not log anything.THROW_EXCEPTIONThrow anIllegalArgumentExceptionin case of incorrect XML characters.WRITE_TO_FILE_LOG_WARNINGWrite the invalid character to the file.WRITE_TO_FILE_NO_LOGWrite the invalid character to the file.
-
Field Summary
Fields Modifier and Type Field Description static EXMLIncorrectCharacterHandlingDEFAULTThe default setting as it was in previous versions of ph-commons
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanisNotifyRequired()booleanisReplaceWithNothing()booleanisTestRequired()abstract voidnotifyOnInvalidXMLCharacter(String sText, Set<Character> aInvalidChars)Called in case XML data contains an invalid characterstatic EXMLIncorrectCharacterHandlingvalueOf(String name)Returns 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 Detail
-
THROW_EXCEPTION
public static final EXMLIncorrectCharacterHandling THROW_EXCEPTION
Throw anIllegalArgumentExceptionin case of incorrect XML characters.
-
WRITE_TO_FILE_NO_LOG
public static final EXMLIncorrectCharacterHandling 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
public static final EXMLIncorrectCharacterHandling 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
public static final EXMLIncorrectCharacterHandling 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
public static final EXMLIncorrectCharacterHandling DO_NOT_WRITE_LOG_WARNING
Do not write the invalid character to XML but at least log a warning. Will trigger character replacement.
-
-
Field Detail
-
DEFAULT
public static final EXMLIncorrectCharacterHandling DEFAULT
The default setting as it was in previous versions of ph-commons
-
-
Method Detail
-
values
public static EXMLIncorrectCharacterHandling[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (EXMLIncorrectCharacterHandling c : EXMLIncorrectCharacterHandling.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static EXMLIncorrectCharacterHandling valueOf(String name)
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
-
-