Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.fasterxml.jackson.databind.node;
  
  import java.util.List;
  
Abstract base class common to all standard com.fasterxml.jackson.databind.JsonNode implementations. The main addition here is that we declare that sub-classes must implement com.fasterxml.jackson.databind.JsonSerializable. This simplifies object mapping aspects a bit, as no external serializers are needed.
 
 public abstract class BaseJsonNode
     extends JsonNode
     implements JsonSerializable
 {
     protected BaseJsonNode() { }
 
     /*
     /**********************************************************
     /* Basic definitions for non-container types
     /**********************************************************
      */
 
     @Override
     public JsonNode findValue(String fieldName) {
         return null;
     }
 
     @Override
     public final JsonNode findPath(String fieldName)
     {
         JsonNode value = findValue(fieldName);
         if (value == null) {
             return MissingNode.getInstance();
         }
         return value;
     }
     
     // note: co-variant return type
     @Override
     public ObjectNode findParent(String fieldName) {
         return null;
     }
 
     @Override
     public List<JsonNodefindValues(String fieldNameList<JsonNodefoundSoFar) {
         return foundSoFar;
     }
 
     @Override
     public List<StringfindValuesAsText(String fieldNameList<StringfoundSoFar) {
         return foundSoFar;
     }
     
     @Override
     public List<JsonNodefindParents(String fieldNameList<JsonNodefoundSoFar) {
         return foundSoFar;
     }
     
     /*
     /**********************************************************
     /* Support for traversal-as-stream
     /**********************************************************
      */
 
     @Override
     public JsonParser traverse() {
         return new TreeTraversingParser(this);
     }

    
Method that can be used for efficient type detection when using stream abstraction for traversing nodes. Will return the first com.fasterxml.jackson.core.JsonToken that equivalent stream event would produce (for most nodes there is just one token but for structured/container types multiple)
 
     @Override
     public abstract JsonToken asToken();

    
Returns code that identifies type of underlying numeric value, if (and only if) node is a number node.
 
     @Override
     public JsonParser.NumberType numberType() {
         // most types non-numeric, so:
         return null
     }
 
     /*
     /**********************************************************
    /* JsonSerializable
    /**********************************************************
     */

    
Method called to serialize node instances using given generator.
//  @Override
    public abstract void serialize(JsonGenerator jgenSerializerProvider provider)
        throws IOExceptionJsonProcessingException;

    
Type information is needed, even if JsonNode instances are "plain" JSON, since they may be mixed with other types.
//  @Override
    public abstract void serializeWithType(JsonGenerator jgenSerializerProvider provider,
            TypeSerializer typeSer)
        throws IOExceptionJsonProcessingException;
New to GrepCode? Check out our FAQ X