Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.fasterxml.jackson.core.json;
  
Extension of com.fasterxml.jackson.core.JsonStreamContext, which implements core methods needed, and also exposes more complete API to parser implementation classes.
 
 public final class JsonReadContext
     extends JsonStreamContext
 {
     // // // Configuration
 
     protected final JsonReadContext _parent;
 
     // // // Location information (minus source reference)
 
     protected int _lineNr;
     protected int _columnNr;
 
     protected String _currentName;
 
     /*
     /**********************************************************
     /* Simple instance reuse slots; speeds up things
     /* a bit (10-15%) for docs with lots of small
     /* arrays/objects (for which allocation was
     /* visible in profile stack frames)
     /**********************************************************
      */
 
     protected JsonReadContext _child = null;
 
     /*
     /**********************************************************
     /* Instance construction, reuse
     /**********************************************************
      */
 
     public JsonReadContext(JsonReadContext parentint typeint lineNrint colNr)
     {
         super();
          = type;
          = parent;
          = lineNr;
          = colNr;
          = -1;
     }
 
     protected void reset(int typeint lineNrint colNr)
     {
          = type;
          = -1;
          = lineNr;
          = colNr;
          = null;
     }
 
     // // // Factory methods
 
     public static JsonReadContext createRootContext(int lineNrint colNr)
     {
         return new JsonReadContext(nulllineNrcolNr);
     }
 
     public static JsonReadContext createRootContext()
     {
         return new JsonReadContext(null, 1, 0);
     }
     
     public JsonReadContext createChildArrayContext(int lineNrint colNr)
     {
         JsonReadContext ctxt = ;
         if (ctxt == null) {
              = ctxt = new JsonReadContext(thislineNrcolNr);
             return ctxt;
         }
         ctxt.reset(lineNrcolNr);
         return ctxt;
     }
 
     public JsonReadContext createChildObjectContext(int lineNrint colNr)
     {
         JsonReadContext ctxt = ;
         if (ctxt == null) {
              = ctxt = new JsonReadContext(thislineNrcolNr);
             return ctxt;
         }
         ctxt.reset(lineNrcolNr);
         return ctxt;
     }
 
     /*
     /**********************************************************
     /* Abstract method implementation
     /**********************************************************
      */
    @Override
    public String getCurrentName() { return ; }
    @Override
    public JsonReadContext getParent() { return ; }
    /*
    /**********************************************************
    /* Extended API
    /**********************************************************
     */

    

Returns:
Location pointing to the point where the context start marker was found
    public JsonLocation getStartLocation(Object srcRef)
    {
        /* We don't keep track of offsets at this level (only
         * reader does)
         */
        long totalChars = -1L;
        return new JsonLocation(srcReftotalChars);
    }
    /*
    /**********************************************************
    /* State changes
    /**********************************************************
     */
    public boolean expectComma()
    {
        /* Assumption here is that we will be getting a value (at least
         * before calling this method again), and
         * so will auto-increment index to avoid having to do another call
         */
        int ix = ++// starts from -1
        return ( !=  && ix > 0);
    }
    public void setCurrentName(String name)
    {
         = name;
    }
    /*
    /**********************************************************
    /* Overridden standard methods
    /**********************************************************
     */

    
Overridden to provide developer readable "JsonPath" representation of the context.
    @Override
    public String toString()
    {
        StringBuilder sb = new StringBuilder(64);
        switch () {
        case :
            sb.append("/");
            break;
        case :
            sb.append('[');
            sb.append(getCurrentIndex());
            sb.append(']');
            break;
        case :
            sb.append('{');
            if ( != null) {
                sb.append('"');
                CharTypes.appendQuoted(sb);
                sb.append('"');
            } else {
                sb.append('?');
            }
            sb.append('}');
            break;
        }
        return sb.toString();
    }
New to GrepCode? Check out our FAQ X