Top Description Inners Fields Constructors Methods
com.fasterxml.jackson.dataformat.yaml.util

public abstract Class StringQuotingChecker

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Known Direct Subclasses
com.fasterxml.jackson.dataformat.yaml.util.StringQuotingChecker.Default
Imports
java.util.Arrays, .HashSet, .Set

Helper class that defines API used by com.fasterxml.jackson.dataformat.yaml.YAMLGenerator to check whether property names and String values need to be quoted or not. Also contains default logic implementation; may be sub-classed to provide alternate implementation.
Since
2.12

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
StringQuotingChecker.Default

Default StringQuotingChecker implementation used unless custom implementation registered.

Field Summary

Modifier and TypeField and Description
private static final Set<String>
RESERVED_KEYWORDS

As per YAML null and boolean type specs, better retain quoting for some keys (property names) and values.

private static final long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected boolean
_isReservedKeyword(int firstChar, String name)

protected boolean
_looksLikeYAMLNumber(int firstChar, String name)

protected boolean
followedOnlyByBlank(String inputStr, int offset)

protected boolean
isBlank(char value)

protected boolean

Returns:

true if given value is a Boolean or Null representation (as per YAML 1.1 specification) or empty String
isReservedKeyword
(String
String to check
value
)

Helper method that sub-classes may use to see if given String value is one of:

  • YAML 1.1 keyword representing boolean
  • YAML 1.1 keyword representing null value
  • empty String (length 0) and returns true if so.
protected boolean
looksLikeYAMLNumber(String name)

Helper method that sub-classes may use to see if given String value looks like a YAML 1.1 numeric value and would likely be considered a number when parsing unless quoting is used.

protected boolean
nameHasQuotableChar(String inputStr)

Looks like we may get names with "funny characters" so.

public abstract boolean
needToQuoteName(String name)

Method called by com.fasterxml.jackson.dataformat.yaml.YAMLGenerator to check whether given property name should be quoted: usually to prevent it from being read as non-String key (boolean or number)

public abstract boolean
needToQuoteValue(String value)

Method called by com.fasterxml.jackson.dataformat.yaml.YAMLGenerator to check whether given String value should be quoted: usually to prevent it from being value of different type (boolean or number).

protected boolean
precededOnlyByBlank(String inputStr, int offset)

protected boolean
valueHasQuotableChar(String inputStr)

As per YAML Plain Styleunquoted strings are restricted to a reduced charset and must be quoted in case they contain one of the following characters or character combinations.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

RESERVED_KEYWORDSback to summary
private static final Set<String> RESERVED_KEYWORDS

As per YAML null and boolean type specs, better retain quoting for some keys (property names) and values.

serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

StringQuotingCheckerback to summary
public StringQuotingChecker()

Method Detail

_isReservedKeywordback to summary
protected boolean _isReservedKeyword(int firstChar, String name)
_looksLikeYAMLNumberback to summary
protected boolean _looksLikeYAMLNumber(int firstChar, String name)
followedOnlyByBlankback to summary
protected boolean followedOnlyByBlank(String inputStr, int offset)
isBlankback to summary
protected boolean isBlank(char value)
isReservedKeywordback to summary
protected boolean isReservedKeyword(String value)

Helper method that sub-classes may use to see if given String value is one of:

  • YAML 1.1 keyword representing boolean
  • YAML 1.1 keyword representing null value
  • empty String (length 0)
  • and returns true if so.
    Parameters
    value:String

    String to check

    Returns:boolean

    true if given value is a Boolean or Null representation (as per YAML 1.1 specification) or empty String

looksLikeYAMLNumberback to summary
protected boolean looksLikeYAMLNumber(String name)

Helper method that sub-classes may use to see if given String value looks like a YAML 1.1 numeric value and would likely be considered a number when parsing unless quoting is used.

nameHasQuotableCharback to summary
protected boolean nameHasQuotableChar(String inputStr)

Looks like we may get names with "funny characters" so.

Since
2.13.2
needToQuoteNameback to summary
public abstract boolean needToQuoteName(String name)

Method called by com.fasterxml.jackson.dataformat.yaml.YAMLGenerator to check whether given property name should be quoted: usually to prevent it from being read as non-String key (boolean or number)

needToQuoteValueback to summary
public abstract boolean needToQuoteValue(String value)

Method called by com.fasterxml.jackson.dataformat.yaml.YAMLGenerator to check whether given String value should be quoted: usually to prevent it from being value of different type (boolean or number).

precededOnlyByBlankback to summary
protected boolean precededOnlyByBlank(String inputStr, int offset)
valueHasQuotableCharback to summary
protected boolean valueHasQuotableChar(String inputStr)

As per YAML Plain Styleunquoted strings are restricted to a reduced charset and must be quoted in case they contain one of the following characters or character combinations.

com.fasterxml.jackson.dataformat.yaml.util back to summary

public Class StringQuotingChecker.Default

extends StringQuotingChecker
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable

Default StringQuotingChecker implementation used unless custom implementation registered.

Field Summary

Modifier and TypeField and Description
private static final StringQuotingChecker.Default
private static final long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static StringQuotingChecker.Default
public boolean
needToQuoteName(String name)

Implements abstract com.fasterxml.jackson.dataformat.yaml.util.StringQuotingChecker.needToQuoteName.

Default implementation will call isReservedKeyword(String) and looksLikeYAMLNumber(String) to determine if quoting should be applied.

public boolean
needToQuoteValue(String value)

Implements abstract com.fasterxml.jackson.dataformat.yaml.util.StringQuotingChecker.needToQuoteValue.

Default implementation will call isReservedKeyword(String) and valueHasQuotableChar(String) to determine if quoting should be applied.

Inherited from com.fasterxml.jackson.dataformat.yaml.util.StringQuotingChecker:
_isReservedKeyword_looksLikeYAMLNumberfollowedOnlyByBlankisBlankisReservedKeywordlooksLikeYAMLNumbernameHasQuotableCharprecededOnlyByBlankvalueHasQuotableChar

Field Detail

INSTANCEback to summary
private static final StringQuotingChecker.Default INSTANCE
serialVersionUIDback to summary
private static final long serialVersionUID

Hides com.fasterxml.jackson.dataformat.yaml.util.StringQuotingChecker.serialVersionUID.

Constructor Detail

Defaultback to summary
public Default()

Method Detail

instanceback to summary
public static StringQuotingChecker.Default instance()
needToQuoteNameback to summary
public boolean needToQuoteName(String name)

Implements abstract com.fasterxml.jackson.dataformat.yaml.util.StringQuotingChecker.needToQuoteName.

Default implementation will call isReservedKeyword(String) and looksLikeYAMLNumber(String) to determine if quoting should be applied.

Annotations
@Override
needToQuoteValueback to summary
public boolean needToQuoteValue(String value)

Implements abstract com.fasterxml.jackson.dataformat.yaml.util.StringQuotingChecker.needToQuoteValue.

Default implementation will call isReservedKeyword(String) and valueHasQuotableChar(String) to determine if quoting should be applied.

Annotations
@Override