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

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 Details

    • THROW_EXCEPTION

      public static final EXMLIncorrectCharacterHandling THROW_EXCEPTION
      Throw an IllegalArgumentException in 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 Details

  • Method Details

    • values

      public static EXMLIncorrectCharacterHandling[] 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

      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 name
      NullPointerException - if the argument is null
    • isTestRequired

      public boolean isTestRequired()
      Returns:
      true if this handling type requires a check for invalid characters.
    • isNotifyRequired

      public boolean isNotifyRequired()
      Returns:
      true notifyOnInvalidXMLCharacter(String, Set) should be invoked for this type?
    • isReplaceWithNothing

      public boolean isReplaceWithNothing()
      Returns:
      true if 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