Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.fasterxml.jackson.databind.node;
  
  import java.util.Iterator;
  import java.util.List;
  
  
This intermediate base class is used for all container nodes, specifically, array and object nodes.
 
 public abstract class ContainerNode<T extends ContainerNode<T>>
     extends BaseJsonNode
 {
    
We will keep a reference to the Object (usually TreeMapper) that can construct instances of nodes to add to this container node.
 
     protected final JsonNodeFactory _nodeFactory;
 
     protected ContainerNode(JsonNodeFactory nc)
     {
          = nc;
     }
 
     // all containers are mutable: can't define:
 //    @Override public abstract <T extends JsonNode> T deepCopy();
     
     @Override
     public boolean isContainerNode() { return true; }
 
     @Override
     public abstract JsonToken asToken();
     
     @Override
     public String asText() { return ""; }
 
     /*
     /**********************************************************
     /* Find methods; made abstract again to ensure implementation
     /**********************************************************
      */
 
     @Override
     public abstract JsonNode findValue(String fieldName);
     
     @Override
     public abstract ObjectNode findParent(String fieldName);
 
     @Override
     public abstract List<JsonNodefindValues(String fieldNameList<JsonNodefoundSoFar);
     
     @Override
     public abstract List<JsonNodefindParents(String fieldNameList<JsonNodefoundSoFar);
 
     @Override
     public abstract List<StringfindValuesAsText(String fieldNameList<StringfoundSoFar);
     
     /*
     /**********************************************************
     /* Methods reset as abstract to force real implementation
     /**********************************************************
      */
 
     @Override
     public abstract int size();
 
     @Override
     public abstract JsonNode get(int index);
 
     @Override
     public abstract JsonNode get(String fieldName);
 
     /*
     /**********************************************************
     /* NodeCreator implementation, just dispatch to
     /* the real creator
     /**********************************************************
      */

    
Factory method that constructs and returns an empty ArrayNode Construction is done using registered JsonNodeFactory.
 
     public final ArrayNode arrayNode() { return .arrayNode(); }

    
Factory method that constructs and returns an empty ObjectNode Construction is done using registered JsonNodeFactory.
 
     public final ObjectNode objectNode() { return .objectNode(); }
 
     public final NullNode nullNode() { return .nullNode(); }
 
    public final BooleanNode booleanNode(boolean v) { return .booleanNode(v); }
    public final NumericNode numberNode(byte v) { return .numberNode(v); }
    public final NumericNode numberNode(short v) { return .numberNode(v); }
    public final NumericNode numberNode(int v) { return .numberNode(v); }
    public final NumericNode numberNode(long v) { return .numberNode(v); }
    public final NumericNode numberNode(float v) { return .numberNode(v); }
    public final NumericNode numberNode(double v) { return .numberNode(v); }
    public final NumericNode numberNode(BigDecimal v) { return (.numberNode(v)); }
    public final TextNode textNode(String text) { return .textNode(text); }
    public final BinaryNode binaryNode(byte[] data) { return .binaryNode(data); }
    public final BinaryNode binaryNode(byte[] dataint offsetint length) { return .binaryNode(dataoffsetlength); }
    public final POJONode POJONode(Object pojo) { return .POJONode(pojo); }
    /*
    /**********************************************************
    /* Common mutators
    /**********************************************************
     */

    
Method for removing all children container has (if any)

Returns:
Container node itself (to allow method call chaining)
    public abstract T removeAll();
    /*
    /**********************************************************
    /* Helper classes
    /**********************************************************
     */
    protected static class NoNodesIterator
        implements Iterator<JsonNode>
    {
        final static NoNodesIterator instance = new NoNodesIterator();
        private NoNodesIterator() { }
        public static NoNodesIterator instance() { return ; }
//      @Override
        public boolean hasNext() { return false; }
//      @Override
        public JsonNode next() { throw new NoSuchElementException(); }
//      @Override
        public void remove() {
            // could as well throw IllegalOperationException?
            throw new IllegalStateException();
        }
    }
    protected static class NoStringsIterator
        implements Iterator<String>
    {
        final static NoStringsIterator instance = new NoStringsIterator();
        private NoStringsIterator() { }
        public static NoStringsIterator instance() { return ; }
//      @Override
        public boolean hasNext() { return false; }
//      @Override
        public String next() { throw new NoSuchElementException(); }
//      @Override
        public void remove() {
            // could as well throw IllegalOperationException?
            throw new IllegalStateException();
        }
    }
New to GrepCode? Check out our FAQ X