Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 
 package org.apache.avro.io;
 
 
An implementation of Encoder that ensures that the sequence of operations conforms to a schema.
 
 public class ValidatingEncoder extends ParsingEncoder 
   implements Parser.ActionHandler {
   protected final Encoder out;
   protected final Parser parser;
  
Has anything been written into the collections?
 
   protected BitSet isEmpty = new BitSet();
 
   ValidatingEncoder(Symbol rootEncoder outthrows IOException {
     this. = out;
     this. = new Parser(rootthis);
   }
 
   public ValidatingEncoder(Schema schemaEncoder inthrows IOException {
     this(new ValidatingGrammarGenerator().generate(schema), in);
   }
 
   @Override
   public void flush() throws IOException {
     .flush();
   }
 
   @Override
   public void init(OutputStream outthrows IOException {
     flush();
     .reset();
     this..init(out);
   }
 
   @Override
   public void writeNull() throws IOException {
     .writeNull();
   }
 
   @Override
   public void writeBoolean(boolean bthrows IOException {
     .writeBoolean(b);
   }
 
   @Override
   public void writeInt(int nthrows IOException {
     .writeInt(n);
   }
 
   @Override
   public void writeLong(long nthrows IOException {
     .writeLong(n);
   }
 
   @Override
   public void writeFloat(float fthrows IOException {
     .writeFloat(f);
   }
 
   @Override
   public void writeDouble(double dthrows IOException {
    .writeDouble(d);
  }
  public void writeString(Utf8 utf8throws IOException {
    .writeString(utf8);
  }
  public void writeBytes(ByteBuffer bytesthrows IOException {
    .writeBytes(bytes);
  }
  public void writeBytes(byte[] bytesint startint lenthrows IOException {
    .writeBytes(bytesstartlen);
  }
  public void writeFixed(byte[] bytesint startint lenthrows IOException {
    if (len != top.size) {
      throw new AvroTypeException(
        "Incorrect length for fixed binary: expected " +
        top.size + " but received " + len + " bytes.");
    }
    .writeFixed(bytesstartlen);
  }
  public void writeEnum(int ethrows IOException {
    if (e < 0 || e >= top.size) {
      throw new AvroTypeException(
          "Enumeration out of range: max is " +
          top.size + " but received " + e);
    }
    .writeEnum(e);
  }
  public void writeArrayStart() throws IOException {
    push();
  }
  public void writeArrayEnd() throws IOException {
    pop();
  }
  public void writeMapStart() throws IOException {
    push();
  }
  public void writeMapEnd() throws IOException {
    .writeMapEnd();
    pop();
  }
  public void setItemCount(long itemCountthrows IOException {
    super.setItemCount(itemCount);
    .setItemCount(itemCount);
  }
  public void startItem() throws IOException {
    super.startItem();
    .startItem();
  }
  public void writeIndex(int unionIndexthrows IOException {
    .pushSymbol(top.getSymbol(unionIndex));
    .writeIndex(unionIndex);
  }
  public Symbol doAction(Symbol inputSymbol topthrows IOException {
    return null;
  }

  
Have we written at least one item into the current collection?
  protected final boolean isTopEmpty() {
    return .get();
  }
New to GrepCode? Check out our FAQ X