Class StringQuotingChecker

java.lang.Object
com.fasterxml.jackson.dataformat.yaml.util.StringQuotingChecker
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
StringQuotingChecker.Default

public abstract class StringQuotingChecker extends Object implements Serializable
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-classes to provide alternate implementation.
Since:
2.12
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Default StringQuotingChecker implementation used unless custom implementation registered.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final Set<String>
    As per YAML null and boolean type specs, better retain quoting for some keys (property names) and values.
    private static final long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected boolean
    _isReservedKeyword(int firstChar, String name)
     
    protected boolean
    _looksLikeYAMLNumber(int firstChar, String name)
     
    protected boolean
    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
    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
    Looks like we may get names with "funny characters" so.
    abstract boolean
    Method called by YAMLGenerator to check whether given property name should be quoted: usually to prevent it from being read as non-String key (boolean or number)
    abstract boolean
    Method called by 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
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • RESERVED_KEYWORDS

      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.
  • Constructor Details

    • StringQuotingChecker

      public StringQuotingChecker()
  • Method Details

    • needToQuoteName

      public abstract boolean needToQuoteName(String name)
      Method called by YAMLGenerator to 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(String value)
      Method called by YAMLGenerator to 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(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 to check
      Returns:
      true if given value is a Boolean or Null representation (as per YAML 1.1 specification) or empty String
    • _isReservedKeyword

      protected boolean _isReservedKeyword(int firstChar, String name)
    • looksLikeYAMLNumber

      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.
    • _looksLikeYAMLNumber

      protected boolean _looksLikeYAMLNumber(int firstChar, String name)
    • valueHasQuotableChar

      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.
    • nameHasQuotableChar

      protected boolean nameHasQuotableChar(String inputStr)
      Looks like we may get names with "funny characters" so.
      Since:
      2.13.2