Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /* Jackson JSON-processor.
   *
   * Copyright (c) 2007- Tatu Saloranta, tatu.saloranta@iki.fi
   */
  
  package divconq.json3;

Enumeration for basic token types used for returning results of parsing JSON content.
 
 public enum JsonToken
 {
     /* Some notes on implementation:
      *
      * - Entries are to be ordered such that start/end array/object
      *   markers come first, then field name marker (if any), and
      *   finally scalar value tokens. This is assumed by some
      *   typing checks.
      */

    
NOT_AVAILABLE can be returned if JsonParser implementation can not currently return the requested token (usually next one), or even if any will be available, but that may be able to determine this in future. This is the case with non-blocking parsers -- they can not block to wait for more data to parse and must return something.
 
     NOT_AVAILABLE(null.),

    
START_OBJECT is returned when encountering '{' which signals starting of an Object value.
 
     START_OBJECT("{".),
        
    
END_OBJECT is returned when encountering '}' which signals ending of an Object value
 
     END_OBJECT("}".),

    
START_ARRAY is returned when encountering '[' which signals starting of an Array value
 
     START_ARRAY("[".),

    
END_ARRAY is returned when encountering ']' which signals ending of an Array value
 
     END_ARRAY("]".),
        
    
FIELD_NAME is returned when a String token is encountered as a field name (same lexical value, different function)
 
     FIELD_NAME(null.),
    
    
Placeholder token returned when the input source has a concept of embedded Object that are not accessible as usual structure (of starting with START_OBJECT, having values, ending with END_OBJECT), but as "raw" objects.

Note: this token is never returned by regular JSON readers, but only by readers that expose other kinds of source (like JsonNode-based JSON trees, Maps, Lists and such).

 
     VALUE_EMBEDDED_OBJECT(null.),

    
VALUE_STRING is returned when a String token is encountered in value context (array element, field value, or root-level stand-alone value)
 
     VALUE_STRING(null.),

    
VALUE_NUMBER_INT is returned when an integer numeric token is encountered in value context: that is, a number that does not have floating point or exponent marker in it (consists only of an optional sign, followed by one or more digits)
 
     VALUE_NUMBER_INT(null.),

    
VALUE_NUMBER_INT is returned when a numeric token other that is not an integer is encountered: that is, a number that does have floating point or exponent marker in it, in addition to one or more digits.
 
     VALUE_NUMBER_FLOAT(null.),
    
    
VALUE_TRUE is returned when encountering literal "true" in value context
    VALUE_TRUE("true".),

    
VALUE_FALSE is returned when encountering literal "false" in value context
    VALUE_FALSE("false".),

    
VALUE_NULL is returned when encountering literal "null" in value context
    VALUE_NULL("null".),
        ;
    
    final String _serialized;
    final char[] _serializedChars;
    final byte[] _serializedBytes;
    final int _id;
    
    final boolean _isStructStart_isStructEnd;
    final boolean _isNumber;
    final boolean _isBoolean;
    final boolean _isScalar;

    

Parameters:
token representation for this token, if there is a single static representation; null otherwise
    JsonToken(String tokenint id)
    {
        if (token == null) {
             = null;
             = null;
             = null;
        } else {
             = token;
             = token.toCharArray();
            // It's all in ascii, can just case...
            int len = .;
             = new byte[len];
            for (int i = 0; i < len; ++i) {
                [i] = (byte[i];
            }
        }
         = id;
        
         = (id == . || id == .);
         = (id == . || id == .);
         = (id == . || id == .);
         = (id == . || id == .);
         = ! && !
                && (id != .)
                && (id != .);
    }
    public final int id() { return ; }
    
    public final String asString() { return ; }
    public final char[] asCharArray() { return ; }
    public final byte[] asByteArray() { return ; }
    public final boolean isNumeric() { return ; }
    /*
     * Accessor that is functionally equivalent to:
     * <code>
     *    this == JsonToken.START_OBJECT || this == JsonToken.START_ARRAY
     * </code>
     * 
     * @since 2.3
     */
    public final boolean isStructStart() { return ; }
    /*
     * Accessor that is functionally equivalent to:
     * <code>
     *    this == JsonToken.END_OBJECT || this == JsonToken.END_ARRAY
     * </code>
     * 
     * @since 2.3
     */
    public final boolean isStructEnd() { return ; }
    /*
     * Method that can be used to check whether this token represents
     * a valid non-structured value. This means all tokens other than
     * Object/Array start/end markers all field names.
     */
    public final boolean isScalarValue() { return ; }
    public final boolean isBoolean() { return ; }
New to GrepCode? Check out our FAQ X