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.parsing;
A parser that capable of skipping as well read and write. This class is used by decoders who (unlink encoders) are required to implement methods to skip.
public class SkipParser extends Parser {
  
The clients implement this interface to skip symbols and actions.
  public interface SkipHandler {
    
Skips the action at the top of the stack.
    void skipAction() throws IOException;

    
Skips the symbol at the top of the stack.
    void skipTopSymbol() throws IOException;
  }
  
  private final SkipHandler skipHandler;
  public SkipParser(Symbol rootActionHandler symbolHandler,
      SkipHandler skipHandler)
    throws IOException {
    super(rootsymbolHandler);
    this. = skipHandler;
  }

  
Skips data by calling skipXyz or readXyz methods on this, until the parser stack reaches the target level.
  public final void skipTo(int targetthrows IOException {
    outer:
    while (target < ) {
      Symbol top = [ - 1];
      while (top.kind != ..) {
        if (top.kind == ..
            || top.kind == ..) {
          .skipAction();
        } else {
          --;
          pushProduction(top);
        }
        continue outer;
      }
    }
  }

  
Skips the repeater at the top the stack.
  public final void skipRepeater() throws IOException {
    int target = ;
    Symbol repeater = [--];
    assert repeater.kind == ..;
    pushProduction(repeater);
    skipTo(target);
  }

  
Pushes the given symbol on to the skip and skips it.

Parameters:
symToSkip The symbol that should be skipped.
  public final void skipSymbol(Symbol symToSkipthrows IOException {
    int target = ;
    pushSymbol(symToSkip);
    skipTo(target);
  }
New to GrepCode? Check out our FAQ X