/* * 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.ambari.view.hive2.client; import com.beust.jcommander.internal.Lists; import org.apache.commons.lang.NotImplementedException; import java.util.Iterator; import java.util.List; public class EmptyCursor implements Cursor<Row, ColumnDescription> { private List<Row> rows = Lists.newArrayList(); private List<ColumnDescription> desc = Lists.newArrayList(); @Override public boolean isResettable() { return false; } @Override public void reset() { } @Override public int getOffset() { return 0; } @Override public List<ColumnDescription> getDescriptions() { return desc; } @Override public void keepAlive() { // Do Nothing } /** * Returns an iterator over a set of elements of type T. * * @return an Iterator. */ @Override public Iterator<Row> iterator() { return rows.iterator(); } /** * Returns {@code true} if the iteration has more elements. * (In other words, returns {@code true} if {@link #next} would * return an element rather than throwing an exception.) * * @return {@code true} if the iteration has more elements */ @Override public boolean hasNext() { return false; } /** * Returns the next element in the iteration. * * @return the next element in the iteration * @throws NotImplementedException if the iteration has no more elements */ @Override public Row next() { throw new NotImplementedException(); } /** * Removes from the underlying collection the last element returned * by this iterator (optional operation). This method can be called * only once per call to {@link #next}. The behavior of an iterator * is unspecified if the underlying collection is modified while the * iteration is in progress in any way other than by calling this * method. * * @throws UnsupportedOperationException if the {@code remove} * operation is not supported by this iterator * @throws IllegalStateException if the {@code next} method has not * yet been called, or the {@code remove} method has already * been called after the last call to the {@code next} * method */ @Override public void remove() { throw new NotImplementedException(); } }