Class StringQuotingChecker
java.lang.Object
tools.jackson.dataformat.yaml.util.StringQuotingChecker
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
StringQuotingChecker.Default
Helper class that defines API used by
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
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDefaultStringQuotingCheckerimplementation used unless custom implementation registered. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean_isReservedKeyword(int firstChar, String name) protected boolean_looksLikeYAMLNumber(int firstChar, String name) protected booleanfollowedOnlyByBlank(String inputStr, int offset) protected booleanisBlank(char value) protected booleanisReservedKeyword(String value) protected booleanlooksLikeYAMLNumber(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(String inputStr) Looks like we may get names with "funny characters" so.abstract booleanneedToQuoteName(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(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(String inputStr, int offset) protected booleanvalueHasQuotableChar(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.
-
Constructor Details
-
StringQuotingChecker
public StringQuotingChecker()
-
-
Method Details
-
needToQuoteName
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
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
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
-
looksLikeYAMLNumber
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
-
valueHasQuotableChar
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
-
followedOnlyByBlank
-
isBlank
protected boolean isBlank(char value) -
nameHasQuotableChar
Looks like we may get names with "funny characters" so.- Since:
- 2.13.2
-