Top Description Inners Constructors Methods
com.fasterxml.jackson.dataformat.xml

public final Class XmlNameProcessors

extends Object
Class Inheritance
Imports
java.util.Base64, java.util.regex.Pattern

Contains default XmlNameProcessor implementations.

Processors should be set in the XmlMapper#setXmlNameProcessor(XmlNameProcessor) and/or the XmlMapper.Builder#xmlNameProcessor(XmlNameProcessor) methods.

Since
2.14

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class
pack-priv static class
pack-priv static class

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static XmlNameProcessor
newAlwaysOnBase64Processor()

Similar to newBase64Processor(String), however, names will always be escaped with base64.

public static XmlNameProcessor
newBase64Processor(String
The prefix to use for name that are escaped
prefix
)

Generates a new processor that escapes all names that contains characters OTHER than following characters:

  • Lower- or upper-case ASCII letter (a to z, A to Z)
  • Digit (0 to 9) in position OTHER than the first characters
  • Underscore
  • Hyphen (-) in position OTHER than the first character
  • Colon (only exposed if underlying parser is in non-namespace-aware mode)
public static XmlNameProcessor
newBase64Processor()

Convenience method equivalent to calling newBase64Processor(String) with "base64_tag_"

public static XmlNameProcessor
newPassthroughProcessor()

Generates a new processor that does nothing and just passes through the names as-is.

public static XmlNameProcessor
newReplacementProcessor(String
The replacement string to replace invalid characters with
replacement
)

Generates a new processor that replaces all characters that are NOT one of:

  • Lower- or upper-case ASCII letter (a to z, A to Z)
  • Digit (0 to 9) in position OTHER than the first character
  • Underscore
  • Hyphen (-) in position OTHER than the first character
  • Colon (only exposed if underlying parser is in non-namespace-aware mode)
public static XmlNameProcessor
newReplacementProcessor()

Convenience method equivalent to calling newReplacementProcessor(String) with "_"

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

XmlNameProcessorsback to summary
private XmlNameProcessors()

Method Detail

newAlwaysOnBase64Processorback to summary
public static XmlNameProcessor newAlwaysOnBase64Processor()

Similar to newBase64Processor(String), however, names will always be escaped with base64. No magic prefix is required for this case, since adding one would be redundant because all names will be base64 encoded.

newBase64Processorback to summary
public static XmlNameProcessor newBase64Processor(String prefix)

Generates a new processor that escapes all names that contains characters OTHER than following characters:

  • Lower- or upper-case ASCII letter (a to z, A to Z)
  • Digit (0 to 9) in position OTHER than the first characters
  • Underscore
  • Hyphen (-) in position OTHER than the first character
  • Colon (only exposed if underlying parser is in non-namespace-aware mode)
with a base64-encoded version. Here the base64url encoder and decoders are used. The = padding characters are always omitted.

With this processor set, a map with the keys "123" and "$ I am <fancy>! &;" will be written as:

<DTO>
     <badMap>
         <base64_tag_JCBJIGFtIDxmYW5jeT4hICY7>xyz</base64_tag_JCBJIGFtIDxmYW5jeT4hICY7>
         <base64_tag_MTIz>bar</base64_tag_MTIz>
     </badMap>
 </DTO>
 

Note

you must ensure that no incoming element or attribute name starts with prefix, otherwise decoding will not work.

Parameters
prefix:String

The prefix to use for name that are escaped

Since
2.14
newBase64Processorback to summary
public static XmlNameProcessor newBase64Processor()

Convenience method equivalent to calling newBase64Processor(String) with "base64_tag_"

Since
2.14
newPassthroughProcessorback to summary
public static XmlNameProcessor newPassthroughProcessor()

Generates a new processor that does nothing and just passes through the names as-is. Using this processor may generate invalid XML.

With this processor set, a map with the keys "123" and "$ I am <fancy>! &;" will be written as:

<DTO>
    <badMap>
        <$ I am <fancy>! &;>xyz</$ I am <fancy>! &;>
        <123>bar</123>
    </badMap>
</DTO>

This is the default behavior for backwards compatibility.

Since
2.14
newReplacementProcessorback to summary
public static XmlNameProcessor newReplacementProcessor(String replacement)

Generates a new processor that replaces all characters that are NOT one of:

  • Lower- or upper-case ASCII letter (a to z, A to Z)
  • Digit (0 to 9) in position OTHER than the first character
  • Underscore
  • Hyphen (-) in position OTHER than the first character
  • Colon (only exposed if underlying parser is in non-namespace-aware mode)
in an XML name with a replacement string. This is a one-way processor, since there is no way to reverse this replacement step.

With this processor set (and "_" as the replacement string), a map with the keys "123" and "$ I am <fancy>! &;" will be written as:

Note

this processor works for US-ASCII based element and attribute names but is unlikely to work well for many "international" use cases.

<DTO>
     <badMap>
         <__I_am__fancy_____>xyz</__I_am__fancy_____>
         <_23>bar</_23>
     </badMap>
 </DTO>
 
Parameters
replacement:String

The replacement string to replace invalid characters with

Since
2.14
newReplacementProcessorback to summary
public static XmlNameProcessor newReplacementProcessor()

Convenience method equivalent to calling newReplacementProcessor(String) with "_"

Since
2.14
com.fasterxml.jackson.dataformat.xml back to summary

pack-priv Class XmlNameProcessors.AlwaysOnBase64NameProcessor

extends Object
implements XmlNameProcessor
Class Inheritance
  • java.lang.Object
  • com.fasterxml.jackson.dataformat.xml.XmlNameProcessors.AlwaysOnBase64NameProcessor
All Implemented Interfaces
com.fasterxml.jackson.dataformat.xml.XmlNameProcessor, java.io.Serializable

Field Summary

Modifier and TypeField and Description
private static final Base64.Decoder
private static final Base64.Encoder
private static final long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
decodeName(XmlNameProcessor.XmlName
The name to encode
name
)

Implements com.fasterxml.jackson.dataformat.xml.XmlNameProcessor.decodeName.

Used during XML deserialization.

public void
encodeName(XmlNameProcessor.XmlName
The name to encode
name
)

Implements com.fasterxml.jackson.dataformat.xml.XmlNameProcessor.encodeName.

Used during XML serialization.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BASE64_DECODERback to summary
private static final Base64.Decoder BASE64_DECODER
BASE64_ENCODERback to summary
private static final Base64.Encoder BASE64_ENCODER
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

AlwaysOnBase64NameProcessorback to summary
public AlwaysOnBase64NameProcessor()

Method Detail

decodeNameback to summary
public void decodeName(XmlNameProcessor.XmlName name)

Implements com.fasterxml.jackson.dataformat.xml.XmlNameProcessor.decodeName.

Doc from com.fasterxml.jackson.dataformat.xml.XmlNameProcessor.decodeName.

Used during XML deserialization.

This method should process the provided XmlName and revert the encoding done in the encodeName(XmlName) method.

Note

Depending on the use case, it is not always required (or even possible) to reverse an encoding with 100% accuracy.

Parameters
name:XmlNameProcessor.XmlName

The name to encode

Annotations
@Override
encodeNameback to summary
public void encodeName(XmlNameProcessor.XmlName name)

Implements com.fasterxml.jackson.dataformat.xml.XmlNameProcessor.encodeName.

Doc from com.fasterxml.jackson.dataformat.xml.XmlNameProcessor.encodeName.

Used during XML serialization.

This method should process the provided XmlName and escape / encode invalid XML characters.

Parameters
name:XmlNameProcessor.XmlName

The name to encode

Annotations
@Override
com.fasterxml.jackson.dataformat.xml back to summary

pack-priv Class XmlNameProcessors.Base64NameProcessor

extends Object
implements XmlNameProcessor
Class Inheritance
  • java.lang.Object
  • com.fasterxml.jackson.dataformat.xml.XmlNameProcessors.Base64NameProcessor
All Implemented Interfaces
com.fasterxml.jackson.dataformat.xml.XmlNameProcessor, java.io.Serializable

Field Summary

Modifier and TypeField and Description
private final String
private static final Base64.Decoder
private static final Base64.Encoder
private static final long
private static final Pattern

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
decodeName(XmlNameProcessor.XmlName
The name to encode
name
)

Implements com.fasterxml.jackson.dataformat.xml.XmlNameProcessor.decodeName.

Used during XML deserialization.

public void
encodeName(XmlNameProcessor.XmlName
The name to encode
name
)

Implements com.fasterxml.jackson.dataformat.xml.XmlNameProcessor.encodeName.

Used during XML serialization.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_prefixback to summary
private final String _prefix
BASE64_DECODERback to summary
private static final Base64.Decoder BASE64_DECODER
BASE64_ENCODERback to summary
private static final Base64.Encoder BASE64_ENCODER
serialVersionUIDback to summary
private static final long serialVersionUID
VALID_XML_NAMEback to summary
private static final Pattern VALID_XML_NAME

Constructor Detail

Base64NameProcessorback to summary
public Base64NameProcessor(String prefix)

Method Detail

decodeNameback to summary
public void decodeName(XmlNameProcessor.XmlName name)

Implements com.fasterxml.jackson.dataformat.xml.XmlNameProcessor.decodeName.

Doc from com.fasterxml.jackson.dataformat.xml.XmlNameProcessor.decodeName.

Used during XML deserialization.

This method should process the provided XmlName and revert the encoding done in the encodeName(XmlName) method.

Note

Depending on the use case, it is not always required (or even possible) to reverse an encoding with 100% accuracy.

Parameters
name:XmlNameProcessor.XmlName

The name to encode

Annotations
@Override
encodeNameback to summary
public void encodeName(XmlNameProcessor.XmlName name)

Implements com.fasterxml.jackson.dataformat.xml.XmlNameProcessor.encodeName.

Doc from com.fasterxml.jackson.dataformat.xml.XmlNameProcessor.encodeName.

Used during XML serialization.

This method should process the provided XmlName and escape / encode invalid XML characters.

Parameters
name:XmlNameProcessor.XmlName

The name to encode

Annotations
@Override
com.fasterxml.jackson.dataformat.xml back to summary

pack-priv Class XmlNameProcessors.PassthroughProcessor

extends Object
implements XmlNameProcessor
Class Inheritance
  • java.lang.Object
  • com.fasterxml.jackson.dataformat.xml.XmlNameProcessors.PassthroughProcessor
All Implemented Interfaces
com.fasterxml.jackson.dataformat.xml.XmlNameProcessor, java.io.Serializable

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
decodeName(XmlNameProcessor.XmlName
The name to encode
name
)

Implements com.fasterxml.jackson.dataformat.xml.XmlNameProcessor.decodeName.

Used during XML deserialization.

public void
encodeName(XmlNameProcessor.XmlName
The name to encode
name
)

Implements com.fasterxml.jackson.dataformat.xml.XmlNameProcessor.encodeName.

Used during XML serialization.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

PassthroughProcessorback to summary
public PassthroughProcessor()

Method Detail

decodeNameback to summary
public void decodeName(XmlNameProcessor.XmlName name)

Implements com.fasterxml.jackson.dataformat.xml.XmlNameProcessor.decodeName.

Doc from com.fasterxml.jackson.dataformat.xml.XmlNameProcessor.decodeName.

Used during XML deserialization.

This method should process the provided XmlName and revert the encoding done in the encodeName(XmlName) method.

Note

Depending on the use case, it is not always required (or even possible) to reverse an encoding with 100% accuracy.

Parameters
name:XmlNameProcessor.XmlName

The name to encode

Annotations
@Override
encodeNameback to summary
public void encodeName(XmlNameProcessor.XmlName name)

Implements com.fasterxml.jackson.dataformat.xml.XmlNameProcessor.encodeName.

Doc from com.fasterxml.jackson.dataformat.xml.XmlNameProcessor.encodeName.

Used during XML serialization.

This method should process the provided XmlName and escape / encode invalid XML characters.

Parameters
name:XmlNameProcessor.XmlName

The name to encode

Annotations
@Override
com.fasterxml.jackson.dataformat.xml back to summary

pack-priv Class XmlNameProcessors.ReplaceNameProcessor

extends Object
implements XmlNameProcessor
Class Inheritance
  • java.lang.Object
  • com.fasterxml.jackson.dataformat.xml.XmlNameProcessors.ReplaceNameProcessor
All Implemented Interfaces
com.fasterxml.jackson.dataformat.xml.XmlNameProcessor, java.io.Serializable

Field Summary

Modifier and TypeField and Description
private final String
private static final Pattern
private static final Pattern
private static final long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
decodeName(XmlNameProcessor.XmlName
The name to encode
name
)

Implements com.fasterxml.jackson.dataformat.xml.XmlNameProcessor.decodeName.

Used during XML deserialization.

public void
encodeName(XmlNameProcessor.XmlName
The name to encode
name
)

Implements com.fasterxml.jackson.dataformat.xml.XmlNameProcessor.encodeName.

Used during XML serialization.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_replacementback to summary
private final String _replacement
BEGIN_MATCHERback to summary
private static final Pattern BEGIN_MATCHER
MAIN_MATCHERback to summary
private static final Pattern MAIN_MATCHER
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

ReplaceNameProcessorback to summary
public ReplaceNameProcessor(String replacement)

Method Detail

decodeNameback to summary
public void decodeName(XmlNameProcessor.XmlName name)

Implements com.fasterxml.jackson.dataformat.xml.XmlNameProcessor.decodeName.

Doc from com.fasterxml.jackson.dataformat.xml.XmlNameProcessor.decodeName.

Used during XML deserialization.

This method should process the provided XmlName and revert the encoding done in the encodeName(XmlName) method.

Note

Depending on the use case, it is not always required (or even possible) to reverse an encoding with 100% accuracy.

Parameters
name:XmlNameProcessor.XmlName

The name to encode

Annotations
@Override
encodeNameback to summary
public void encodeName(XmlNameProcessor.XmlName name)

Implements com.fasterxml.jackson.dataformat.xml.XmlNameProcessor.encodeName.

Doc from com.fasterxml.jackson.dataformat.xml.XmlNameProcessor.encodeName.

Used during XML serialization.

This method should process the provided XmlName and escape / encode invalid XML characters.

Parameters
name:XmlNameProcessor.XmlName

The name to encode

Annotations
@Override