Class StringQuotingChecker
- java.lang.Object
-
- com.fasterxml.jackson.dataformat.yaml.util.StringQuotingChecker
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
StringQuotingChecker.Default
public abstract class StringQuotingChecker extends java.lang.Object implements java.io.SerializableHelper class that defines API used byYAMLGeneratorto 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
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classStringQuotingChecker.DefaultDefaultStringQuotingCheckerimplementation used unless custom implementation registered.
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Set<java.lang.String>RESERVED_KEYWORDSprivate static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description StringQuotingChecker()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected boolean_isReservedKeyword(int firstChar, java.lang.String name)protected boolean_looksLikeYAMLNumber(int firstChar, java.lang.String name)protected booleanfollowedOnlyByBlank(java.lang.String inputStr, int offset)protected booleanisBlank(char value)protected booleanisReservedKeyword(java.lang.String value)protected booleanlooksLikeYAMLNumber(java.lang.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 booleannameHasQuotableChar(java.lang.String inputStr)Looks like we may get names with "funny characters" so.abstract booleanneedToQuoteName(java.lang.String name)Method called byYAMLGeneratorto check whether given property name should be quoted: usually to prevent it from being read as non-String key (boolean or number)abstract booleanneedToQuoteValue(java.lang.String value)Method called byYAMLGeneratorto check whether given String value should be quoted: usually to prevent it from being value of different type (boolean or number).protected booleanprecededOnlyByBlank(java.lang.String inputStr, int offset)protected booleanvalueHasQuotableChar(java.lang.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.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
RESERVED_KEYWORDS
private static final java.util.Set<java.lang.String> RESERVED_KEYWORDS
-
-
Method Detail
-
needToQuoteName
public abstract boolean needToQuoteName(java.lang.String name)
Method called byYAMLGeneratorto check whether given property name should be quoted: usually to prevent it from being read as non-String key (boolean or number)
-
needToQuoteValue
public abstract boolean needToQuoteValue(java.lang.String value)
Method called byYAMLGeneratorto check whether given String value should be quoted: usually to prevent it from being value of different type (boolean or number).
-
isReservedKeyword
protected boolean isReservedKeyword(java.lang.String value)
Helper method that sub-classes may use to see if given String value is one of:- Parameters:
value- String to check- Returns:
trueif given value is a Boolean or Null representation (as per YAML 1.1 specification) or empty String
-
_isReservedKeyword
protected boolean _isReservedKeyword(int firstChar, java.lang.String name)
-
looksLikeYAMLNumber
protected boolean looksLikeYAMLNumber(java.lang.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.
-
_looksLikeYAMLNumber
protected boolean _looksLikeYAMLNumber(int firstChar, java.lang.String name)
-
valueHasQuotableChar
protected boolean valueHasQuotableChar(java.lang.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.
-
precededOnlyByBlank
protected boolean precededOnlyByBlank(java.lang.String inputStr, int offset)
-
followedOnlyByBlank
protected boolean followedOnlyByBlank(java.lang.String inputStr, int offset)
-
isBlank
protected boolean isBlank(char value)
-
nameHasQuotableChar
protected boolean nameHasQuotableChar(java.lang.String inputStr)
Looks like we may get names with "funny characters" so.- Since:
- 2.13.2
-
-