001/*
002 * Copyright 2010 The Apache Software Foundation
003 *
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *     http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing, software
015 * distributed under the License is distributed on an "AS IS" BASIS,
016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017 * See the License for the specific language governing permissions and
018 * limitations under the License.
019 */
020
021package org.apache.hadoop.hbase.rest;
022
023import java.io.IOException;
024import java.util.Iterator;
025 
026import org.apache.hadoop.hbase.KeyValue;
027import org.apache.hadoop.hbase.filter.Filter;
028import org.apache.hadoop.hbase.rest.model.ScannerModel;
029
030public abstract class ResultGenerator implements Iterator<KeyValue> {
031
032  public static ResultGenerator fromRowSpec(final String table, 
033      final RowSpec rowspec, final Filter filter) throws IOException {
034    if (rowspec.isSingleRow()) {
035      return new RowResultGenerator(table, rowspec, filter);
036    } else {
037      return new ScannerResultGenerator(table, rowspec, filter);
038    }
039  }
040
041  public static Filter buildFilter(final String filter) throws Exception {
042    return ScannerModel.buildFilter(filter);
043  }
044
045  public abstract void putBack(KeyValue kv);
046
047  public abstract void close();
048}