Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   package com.fasterxml.jackson.databind.util;
   
   import java.io.IOException;
   import java.io.InputStream;
   import java.io.OutputStream;
   import java.math.BigDecimal;
   import java.math.BigInteger;
   
  
Utility class used for efficient storage of com.fasterxml.jackson.core.JsonToken sequences, needed for temporary buffering. Space efficient for different sequence lengths (especially so for smaller ones; but not significantly less efficient for larger), highly efficient for linear iteration and appending. Implemented as segmented/chunked linked list of tokens; only modifications are via appends.

Note that before version 2.0, this class was located in the "core" bundle, not data-binding; but since it was only used by data binding, was moved here to reduce size of core package

  
  public class TokenBuffer
  /* Won't use JsonGeneratorBase, to minimize overhead for validity
   * checking
   */
      extends JsonGenerator
  {
      protected final static int DEFAULT_PARSER_FEATURES = JsonParser.Feature.collectDefaults();
  
      /*
      /**********************************************************
      /* Configuration
      /**********************************************************
       */

    
Object codec to use for stream-based object conversion through parser/generator interfaces. If null, such methods can not be used.
  
      protected ObjectCodec _objectCodec;

    
Bit flag composed of bits that indicate which com.fasterxml.jackson.core.JsonGenerator.Features are enabled.

NOTE: most features have no effect on this class

  
      protected int _generatorFeatures;
  
      protected boolean _closed;
      
      /*
      /**********************************************************
      /* Token buffering state
      /**********************************************************
       */

    
First segment, for contents this buffer has
  
      protected Segment _first;

    
Last segment of this buffer, one that is used for appending more tokens
  
      protected Segment _last;
    
    
Offset within last segment,
  
      protected int _appendOffset;
  
      /*
      /**********************************************************
      /* Output state
      /**********************************************************
       */
  
      protected JsonWriteContext _writeContext;
  
      /*
      /**********************************************************
      /* Life-cycle
      /**********************************************************
       */

    

Parameters:
codec Object codec to use for stream-based object conversion through parser/generator interfaces. If null, such methods can not be used.
 
     public TokenBuffer(ObjectCodec codec)
     {
          = codec;
          = JsonWriteContext.createRootContext();
         // at first we have just one segment
          =  = new Segment();
          = 0;
     }
 
     @Override
     public Version version() {
         return ..version();
     }

    
Method used to create a com.fasterxml.jackson.core.JsonParser that can read contents stored in this buffer. Will use default _objectCodec for object conversions.

Note: instances are not synchronized, that is, they are not thread-safe if there are concurrent appends to the underlying buffer.

Returns:
Parser that can be used for reading contents stored in this buffer
 
     public JsonParser asParser()
     {
         return asParser();
     }

    
Method used to create a com.fasterxml.jackson.core.JsonParser that can read contents stored in this buffer.

Note: instances are not synchronized, that is, they are not thread-safe if there are concurrent appends to the underlying buffer.

Parameters:
codec Object codec to use for stream-based object conversion through parser/generator interfaces. If null, such methods can not be used.
Returns:
Parser that can be used for reading contents stored in this buffer
 
     public JsonParser asParser(ObjectCodec codec)
     {
         return new Parser(codec);
     }

    

Parameters:
src Parser to use for accessing source information like location, configured codec
 
     public JsonParser asParser(JsonParser src)
     {
         Parser p = new Parser(src.getCodec());
         p.setLocation(src.getTokenLocation());
         return p;
     }
     
     /*
     /**********************************************************
     /* Other custom methods not needed for implementing interfaces
     /**********************************************************
      */

    
Helper method that will append contents of given buffer into this buffer. Not particularly optimized; can be made faster if there is need.

Returns:
This buffer
 
     public TokenBuffer append(TokenBuffer other)
         throws IOExceptionJsonGenerationException
     {
         JsonParser jp = other.asParser();
         while (jp.nextToken() != null) {
             this.copyCurrentEvent(jp);
         }
         return this;
     }
    
    
Helper method that will write all contents of this buffer using given com.fasterxml.jackson.core.JsonGenerator.

Note: this method would be enough to implement JsonSerializer for TokenBuffer type; but we can not have upwards references (from core to mapper package); and as such we also can not take second argument.

 
     public void serialize(JsonGenerator jgen)
         throws IOExceptionJsonGenerationException
     {
         Segment segment = ;
         int ptr = -1;
 
         while (true) {
             if (++ptr >= .) {
                 ptr = 0;
                 segment = segment.next();
                 if (segment == nullbreak;
             }
             JsonToken t = segment.type(ptr);
             if (t == nullbreak;
 
             // Note: copied from 'copyCurrentEvent'...
             switch (t) {
             case :
                 jgen.writeStartObject();
                 break;
             case :
                 jgen.writeEndObject();
                 break;
             case :
                 jgen.writeStartArray();
                 break;
             case :
                 jgen.writeEndArray();
                 break;
             case :
             {
                 // 13-Dec-2010, tatu: Maybe we should start using different type tokens to reduce casting?
                 Object ob = segment.get(ptr);
                 if (ob instanceof SerializableString) {
                     jgen.writeFieldName((SerializableStringob);
                 } else {
                     jgen.writeFieldName((Stringob);
                 }
             }
                 break;
             case :
                 {
                     Object ob = segment.get(ptr);
                     if (ob instanceof SerializableString) {
                         jgen.writeString((SerializableStringob);
                     } else {
                         jgen.writeString((Stringob);
                     }
                 }
                 break;
             case :
                 {
                     Number n = (Numbersegment.get(ptr);
                     if (n instanceof BigInteger) {
                         jgen.writeNumber((BigIntegern);
                     } else if (n instanceof Long) {
                         jgen.writeNumber(n.longValue());
                     } else {
                         jgen.writeNumber(n.intValue());
                     }
                 }
                 break;
             case :
                 {
                     Object n = segment.get(ptr);
                     if (n instanceof BigDecimal) {
                         jgen.writeNumber((BigDecimaln);
                     } else if (n instanceof Float) {
                         jgen.writeNumber(((Floatn).floatValue());
                     } else if (n instanceof Double) {
                         jgen.writeNumber(((Doublen).doubleValue());
                     } else if (n == null) {
                         jgen.writeNull();
                     } else if (n instanceof String) {
                         jgen.writeNumber((Stringn);
                     } else {
                         throw new JsonGenerationException("Unrecognized value type for VALUE_NUMBER_FLOAT: "+n.getClass().getName()+", can not serialize");
                     }
                 }
                 break;
             case :
                 jgen.writeBoolean(true);
                 break;
             case :
                 jgen.writeBoolean(false);
                 break;
             case :
                 jgen.writeNull();
                 break;
             case :
                 jgen.writeObject(segment.get(ptr));
                 break;
             default:
                 throw new RuntimeException("Internal error: should never end up through this code path");
             }
         }
     }
 
     @Override
     public String toString()
     {
         // Let's print up to 100 first tokens...
         final int MAX_COUNT = 100;
 
         StringBuilder sb = new StringBuilder();
         sb.append("[TokenBuffer: ");
         JsonParser jp = asParser();
         int count = 0;
 
         while (true) {
             JsonToken t;
             try {
                 t = jp.nextToken();
                 if (t == nullbreak;
                 if (count < MAX_COUNT) {
                     if (count > 0) {
                         sb.append(", ");
                     }
                     sb.append(t.toString());
                     if (t == .) {
                         sb.append('(');
                         sb.append(jp.getCurrentName());
                         sb.append(')');
                     }
                 }
             } catch (IOException ioe) { // should never occur
                 throw new IllegalStateException(ioe);
             }
             ++count;
         }
 
         if (count >= MAX_COUNT) {
             sb.append(" ... (truncated ").append(count-MAX_COUNT).append(" entries)");
         }
         sb.append(']');
         return sb.toString();
     }
         
     /*
     /**********************************************************
     /* JsonGenerator implementation: configuration
     /**********************************************************
      */
 
     @Override
     public JsonGenerator enable(Feature f) {
          |= f.getMask();
         return this;
     }
 
     @Override
     public JsonGenerator disable(Feature f) {
          &= ~f.getMask();
         return this;
     }
 
     //public JsonGenerator configure(SerializationFeature f, boolean state) { }
 
     @Override
     public boolean isEnabled(Feature f) {
         return ( & f.getMask()) != 0;
     }
 
     @Override
         // No-op: we don't indent
         return this;
     }
 
     @Override
     public JsonGenerator setCodec(ObjectCodec oc) {
          = oc;
         return this;
     }
 
     @Override
     public ObjectCodec getCodec() { return ; }
 
     @Override
     public final JsonWriteContext getOutputContext() { return ; }
 
     /*
     /**********************************************************
     /* JsonGenerator implementation: low-level output handling
     /**********************************************************
      */
 
     @Override
     public void flush() throws IOException { /* NOP */ }
 
     @Override
     public void close() throws IOException {
          = true;
     }
 
     @Override
     public boolean isClosed() { return ; }
 
     /*
     /**********************************************************
     /* JsonGenerator implementation: write methods, structural
     /**********************************************************
      */
 
     @Override
     public final void writeStartArray()
         throws IOExceptionJsonGenerationException
     {
         _append(.);
     }
 
     @Override
     public final void writeEndArray()
         throws IOExceptionJsonGenerationException
     {
         _append(.);
         // Let's allow unbalanced tho... i.e. not run out of root level, ever
         JsonWriteContext c = .getParent();
         if (c != null) {
              = c;
         }
     }
 
     @Override
     public final void writeStartObject()
         throws IOExceptionJsonGenerationException
     {
         _append(.);
     }
 
     @Override
     public final void writeEndObject()
         throws IOExceptionJsonGenerationException
     {
         _append(.);
         // Let's allow unbalanced tho... i.e. not run out of root level, ever
         JsonWriteContext c = .getParent();
         if (c != null) {
              = c;
         }
     }
 
     @Override
     public final void writeFieldName(String name)
         throws IOExceptionJsonGenerationException
     {
         _append(.name);
         .writeFieldName(name);
     }
 
     @Override
     public void writeFieldName(SerializableString name)
         throws IOExceptionJsonGenerationException
     {
         _append(.name);
         .writeFieldName(name.getValue());
     }
     
     /*
     /**********************************************************
     /* JsonGenerator implementation: write methods, textual
     /**********************************************************
      */
 
     @Override
     public void writeString(String textthrows IOException,JsonGenerationException {
         if (text == null) {
             writeNull();
         } else {
             _append(.text);
         }
     }
 
     @Override
     public void writeString(char[] textint offsetint lenthrows IOExceptionJsonGenerationException {
         writeString(new String(textoffsetlen));
     }
 
     @Override
     public void writeString(SerializableString textthrows IOExceptionJsonGenerationException {
         if (text == null) {
             writeNull();
         } else {
             _append(.text);
         }
     }
     
     @Override
     public void writeRawUTF8String(byte[] textint offsetint length)
         throws IOExceptionJsonGenerationException
     {
         // could add support for buffering if we really want it...
         _reportUnsupportedOperation();
     }
 
     @Override
     public void writeUTF8String(byte[] textint offsetint length)
         throws IOExceptionJsonGenerationException
     {
         // could add support for buffering if we really want it...
         _reportUnsupportedOperation();
     }
 
     @Override
     public void writeRaw(String textthrows IOExceptionJsonGenerationException {
         _reportUnsupportedOperation();
     }
 
     @Override
     public void writeRaw(String textint offsetint lenthrows IOExceptionJsonGenerationException {
         _reportUnsupportedOperation();
     }
 
     @Override
     public void writeRaw(SerializableString textthrows IOExceptionJsonGenerationException {
         _reportUnsupportedOperation();
     }
     
     @Override
     public void writeRaw(char[] textint offsetint lenthrows IOExceptionJsonGenerationException {
         _reportUnsupportedOperation();
     }
 
     @Override
     public void writeRaw(char cthrows IOExceptionJsonGenerationException {
         _reportUnsupportedOperation();
     }
 
     @Override
     public void writeRawValue(String textthrows IOExceptionJsonGenerationException {
         _reportUnsupportedOperation();
     }
 
     @Override
     public void writeRawValue(String textint offsetint lenthrows IOExceptionJsonGenerationException {
         _reportUnsupportedOperation();
     }
 
     @Override
     public void writeRawValue(char[] textint offsetint lenthrows IOExceptionJsonGenerationException {
         _reportUnsupportedOperation();
     }
 
     /*
     /**********************************************************
     /* JsonGenerator implementation: write methods, primitive types
     /**********************************************************
      */
 
     @Override
     public void writeNumber(int ithrows IOExceptionJsonGenerationException {
         _append(., Integer.valueOf(i));
     }
 
     @Override
     public void writeNumber(long lthrows IOExceptionJsonGenerationException {
         _append(., Long.valueOf(l));
     }
 
     @Override
     public void writeNumber(double dthrows IOException,JsonGenerationException {
         _append(., Double.valueOf(d));
     }
 
     @Override
     public void writeNumber(float fthrows IOExceptionJsonGenerationException {
         _append(., Float.valueOf(f));
     }
 
     @Override
     public void writeNumber(BigDecimal decthrows IOException,JsonGenerationException {
         if (dec == null) {
             writeNull();
         } else {
             _append(.dec);
         }
     }
 
     @Override
     public void writeNumber(BigInteger vthrows IOExceptionJsonGenerationException {
         if (v == null) {
             writeNull();
         } else {
             _append(.v);
         }
     }
 
     @Override
     public void writeNumber(String encodedValuethrows IOExceptionJsonGenerationException {
         /* 03-Dec-2010, tatu: related to [JACKSON-423], should try to keep as numeric
          *   identity as long as possible
          */
         _append(.encodedValue);
     }
 
     @Override
     public void writeBoolean(boolean statethrows IOException,JsonGenerationException {
         _append(state ? . : .);
     }
 
     @Override
     public void writeNull() throws IOExceptionJsonGenerationException {
         _append(.);
     }
 
     /*
     /***********************************************************
     /* JsonGenerator implementation: write methods for POJOs/trees
     /***********************************************************
      */
 
     @Override
     public void writeObject(Object value)
         throws IOExceptionJsonProcessingException
     {
         // embedded means that no conversions should be done...
         _append(.value);
     }
 
     @Override
     public void writeTree(TreeNode rootNode)
         throws IOExceptionJsonProcessingException
     {
         /* 31-Dec-2009, tatu: no need to convert trees either is there?
          *  (note: may need to re-evaluate at some point)
          */
         _append(.rootNode);
     }
 
     /*
     /***********************************************************
     /* JsonGenerator implementation; binary
     /***********************************************************
      */
 
     @Override
     public void writeBinary(Base64Variant b64variantbyte[] dataint offsetint len)
         throws IOExceptionJsonGenerationException
     {
         /* 31-Dec-2009, tatu: can do this using multiple alternatives; but for
          *   now, let's try to limit number of conversions.
          *   The only (?) tricky thing is that of whether to preserve variant,
          *   seems pointless, so let's not worry about it unless there's some
          *   compelling reason to.
          */
         byte[] copy = new byte[len];
         System.arraycopy(dataoffsetcopy, 0, len);
         writeObject(copy);
     }

    
Although we could support this method, it does not necessarily make sense: we can not make good use of streaming because buffer must hold all the data. Because of this, currently this will simply throw java.lang.UnsupportedOperationException
 
     @Override
     public int writeBinary(Base64Variant b64variantInputStream dataint dataLength) {
         throw new UnsupportedOperationException();
     }
     
     /*
     /**********************************************************
     /* JsonGenerator implementation; pass-through copy
     /**********************************************************
      */
 
     @Override
     public void copyCurrentEvent(JsonParser jpthrows IOExceptionJsonProcessingException
     {
         switch (jp.getCurrentToken()) {
         case :
             writeStartObject();
             break;
         case :
             writeEndObject();
             break;
         case :
             writeStartArray();
             break;
         case :
             writeEndArray();
             break;
         case :
             writeFieldName(jp.getCurrentName());
             break;
         case :
             if (jp.hasTextCharacters()) {
                 writeString(jp.getTextCharacters(), jp.getTextOffset(), jp.getTextLength());
             } else {
                 writeString(jp.getText());
             }
             break;
         case :
             switch (jp.getNumberType()) {
             case :
                 writeNumber(jp.getIntValue());
                 break;
             case :
                 writeNumber(jp.getBigIntegerValue());
                 break;
             default:
                 writeNumber(jp.getLongValue());
             }
             break;
         case :
             switch (jp.getNumberType()) {
             case :
                 writeNumber(jp.getDecimalValue());
                 break;
             case :
                 writeNumber(jp.getFloatValue());
                 break;
             default:
                 writeNumber(jp.getDoubleValue());
             }
             break;
         case :
             writeBoolean(true);
             break;
         case :
             writeBoolean(false);
             break;
         case :
             writeNull();
             break;
         case :
             writeObject(jp.getEmbeddedObject());
             break;
         default:
             throw new RuntimeException("Internal error: should never end up through this code path");
         }
     }
 
     @Override
     public void copyCurrentStructure(JsonParser jpthrows IOExceptionJsonProcessingException {
         JsonToken t = jp.getCurrentToken();
 
         // Let's handle field-name separately first
         if (t == .) {
             writeFieldName(jp.getCurrentName());
             t = jp.nextToken();
             // fall-through to copy the associated value
         }
 
         switch (t) {
         case :
             writeStartArray();
             while (jp.nextToken() != .) {
                 copyCurrentStructure(jp);
             }
             writeEndArray();
             break;
         case :
             writeStartObject();
             while (jp.nextToken() != .) {
                 copyCurrentStructure(jp);
             }
             writeEndObject();
             break;
         default// others are simple:
             copyCurrentEvent(jp);
         }
     }
     
     /*
     /**********************************************************
     /* Internal methods
     /**********************************************************
      */
     protected final void _append(JsonToken type) {
         Segment next = .append(type);
         if (next == null) {
             ++;
         } else {
              = next;
              = 1; // since we added first at 0
         }
     }
 
     protected final void _append(JsonToken typeObject value) {
         Segment next = .append(typevalue);
         if (next == null) {
             ++;
         } else {
              = next;
              = 1;
         }
     }
 
     protected final void _appendRaw(int rawTypeObject value) {
         Segment next = .appendRaw(rawTypevalue);
         if (next == null) {
             ++;
         } else {
              = next;
              = 1;
         }
     }
     
     protected void _reportUnsupportedOperation() {
         throw new UnsupportedOperationException("Called operation not supported for TokenBuffer");
     }
     
     /*
     /**********************************************************
     /* Supporting classes
     /**********************************************************
      */
 
     protected final static class Parser
         extends ParserMinimalBase
     {
         protected ObjectCodec _codec;
 
         /*
         /**********************************************************
         /* Parsing state
         /**********************************************************
          */

        
Currently active segment
 
         protected Segment _segment;

        
Pointer to current token within current segment
 
         protected int _segmentPtr;

        
Information about parser context, context in which the next token is to be parsed (root, array, object).
 
         protected JsonReadContext _parsingContext;
         
         protected boolean _closed;
 
         protected transient ByteArrayBuilder _byteBuilder;
 
         protected JsonLocation _location = null;
         
         /*
         /**********************************************************
         /* Construction, init
         /**********************************************************
          */
         
         public Parser(Segment firstSegObjectCodec codec)
         {
             super(0);
              = firstSeg;
              = -1; // not yet read
              = codec;
              = JsonReadContext.createRootContext(-1, -1);
         }
 
         public void setLocation(JsonLocation l) {
              = l;
         }
         
         @Override
         public ObjectCodec getCodec() { return ; }
 
         @Override
         public void setCodec(ObjectCodec c) {  = c; }
 
         @Override
         public Version version() {
             return ..version();
         }
         
         /*
         /**********************************************************
         /* Extended API beyond JsonParser
         /**********************************************************
          */
         
         public JsonToken peekNextToken()
             throws IOExceptionJsonParseException
         {
             // closed? nothing more to peek, either
             if (return null;
             Segment seg = ;
             int ptr = +1;
             if (ptr >= .) {
                 ptr = 0;
                 seg = (seg == null) ? null : seg.next();
             }
             return (seg == null) ? null : seg.type(ptr);
         }
         
         /*
         /**********************************************************
         /* Closeable implementation
         /**********************************************************
          */
 
         @Override
         public void close() throws IOException {
             if (!) {
                  = true;
             }
         }
 
         /*
         /**********************************************************
         /* Public API, traversal
         /**********************************************************
          */
         
         @Override
         public JsonToken nextToken() throws IOExceptionJsonParseException
         {
             // If we are closed, nothing more to do
             if ( || ( == null)) return null;
 
             // Ok, then: any more tokens?
             if (++ >= .) {
                  = 0;
                  = .next();
                 if ( == null) {
                     return null;
                 }
             }
              = .type();
             // Field name? Need to update context
             if ( == .) {
                 Object ob = _currentObject();
                 String name = (ob instanceof String) ? ((Stringob) : ob.toString();
                 .setCurrentName(name);
             } else if ( == .) {
                  = .createChildObjectContext(-1, -1);
             } else if ( == .) {
                  = .createChildArrayContext(-1, -1);
             } else if ( == .
                     ||  == .) {
                 // Closing JSON Object/Array? Close matching context
                  = .getParent();
                 // but allow unbalanced cases too (more close markers)
                 if ( == null) {
                      = JsonReadContext.createRootContext(-1, -1);
                 }
             }
             return ;
         }
 
         @Override
         public boolean isClosed() { return ; }
 
         /*
         /**********************************************************
         /* Public API, token accessors
         /**********************************************************
          */
         
         @Override
         public JsonStreamContext getParsingContext() { return ; }
 
         @Override
         public JsonLocation getTokenLocation() { return getCurrentLocation(); }
 
         @Override
         public JsonLocation getCurrentLocation() {
             return ( == null) ? . : ;
         }
 
         @Override
         public String getCurrentName() { return .getCurrentName(); }
 
         @Override
         public void overrideCurrentName(String name)
         {
             // Simple, but need to look for START_OBJECT/ARRAY's "off-by-one" thing:
             JsonReadContext ctxt = ;
             if ( == . ||  == .) {
                 ctxt = ctxt.getParent();
             }
             ctxt.setCurrentName(name);
         }
         
         /*
         /**********************************************************
         /* Public API, access to token information, text
         /**********************************************************
          */
         
         @Override
         public String getText()
         {
             // common cases first:
             if ( == .
                     ||  == .) {
                 Object ob = _currentObject();
                 if (ob instanceof String) {
                     return (Stringob;
                 }
                 return (ob == null) ? null : ob.toString();
             }
             if ( == null) {
                 return null;
             }
             switch () {
            case :
            case :
                Object ob = _currentObject();
                return (ob == null) ? null : ob.toString();
            }
            return .asString();
        }
        @Override
        public char[] getTextCharacters() {
            String str = getText();
            return (str == null) ? null : str.toCharArray();
        }
        @Override
        public int getTextLength() {
            String str = getText();
            return (str == null) ? 0 : str.length();
        }
        @Override
        public int getTextOffset() { return 0; }
        @Override
        public boolean hasTextCharacters() {
            // We never have raw buffer available, so:
            return false;
        }
        
        /*
        /**********************************************************
        /* Public API, access to token information, numeric
        /**********************************************************
         */
        @Override
        public BigInteger getBigIntegerValue() throws IOExceptionJsonParseException
        {
            Number n = getNumberValue();
            if (n instanceof BigInteger) {
                return (BigIntegern;
            }
            switch (getNumberType()) {
            case :
                return ((BigDecimaln).toBigInteger();
            }
            // int/long is simple, but let's also just truncate float/double:
            return BigInteger.valueOf(n.longValue());
        }
        @Override
        public BigDecimal getDecimalValue() throws IOExceptionJsonParseException
        {
            Number n = getNumberValue();
            if (n instanceof BigDecimal) {
                return (BigDecimaln;
            }
            switch (getNumberType()) {
            case :
            case :
                return BigDecimal.valueOf(n.longValue());
            case :
                return new BigDecimal((BigIntegern);
            }
            // float or double
            return BigDecimal.valueOf(n.doubleValue());
        }
        @Override
        public double getDoubleValue() throws IOExceptionJsonParseException {
            return getNumberValue().doubleValue();
        }
        @Override
        public float getFloatValue() throws IOExceptionJsonParseException {
            return getNumberValue().floatValue();
        }
        @Override
        public int getIntValue() throws IOExceptionJsonParseException
        {
            // optimize common case:
            if ( == .) {
                return ((Number_currentObject()).intValue();
            }
            return getNumberValue().intValue();
        }
        @Override
        public long getLongValue() throws IOExceptionJsonParseException {
            return getNumberValue().longValue();
        }
        @Override
        public NumberType getNumberType() throws IOExceptionJsonParseException
        {
            Number n = getNumberValue();
            if (n instanceof Integerreturn .;
            if (n instanceof Longreturn .;
            if (n instanceof Doublereturn .;
            if (n instanceof BigDecimalreturn .;
            if (n instanceof Floatreturn .;
            if (n instanceof BigIntegerreturn .;
            return null;
        }
        @Override
        public final Number getNumberValue() throws IOExceptionJsonParseException {
            _checkIsNumber();
            return (Number_currentObject();
        }
        
        /*
        /**********************************************************
        /* Public API, access to token information, other
        /**********************************************************
         */
        @Override
        public Object getEmbeddedObject()
        {
            if ( == .) {
                return _currentObject();
            }