1 /* 2 * Copyright 2001-2004 The Apache Software Foundation 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package org.apache.commons.cache.adt; 17 18 import java.util.LinkedList; // only used in JavaDoc comments, but this makes the warnings go away 19 /** 20 * A simple linked-listed inteface, supporting 21 * both singly and doubly linked lists. 22 * <p> 23 * Unlike {@link java.util.LinkedList}, this interface 24 * provides access to the list elements themselves, which 25 * may necessary for some uses. 26 * 27 * @see java.util.LinkedList 28 * 29 * @version $Id: Listable.java 155435 2005-02-26 13:17:27Z dirkv $ 30 * @author Rodney Waldhoff 31 */ 32 public interface Listable { 33 /** 34 * Return the <tt>Listable</tt> element following me, 35 * or <tt>null</tt> if I am the last element in the 36 * list. 37 * 38 * @return the <tt>Listable</tt> element following me, 39 * or <tt>null</tt>. 40 */ 41 public abstract Listable getNext(); 42 43 /** 44 * Return <tt>true</tt> if there is a <tt>Listable</tt> 45 * element following me, <tt>false</tt> otherwise. 46 * 47 * @return <tt>true</tt> if there is a <tt>Listable</tt> 48 * element following me, <tt>false</tt> otherwise. 49 */ 50 public abstract boolean hasNext(); 51 52 /** 53 * Change my next element to <i>next</i>. 54 * Note that this does not change the {@link #getPrev} 55 * value of <i>next</i>. 56 * 57 * @param next my new following sibling. 58 * @throws UnsupportedOperationException if I am a read-only list. 59 */ 60 public abstract void setNext(Listable next) throws UnsupportedOperationException; 61 62 /** 63 * Return the <tt>Listable</tt> element preceeding me, 64 * or <tt>null</tt> if I am the last element in the 65 * list. 66 * 67 * @return the <tt>Listable</tt> element preceeding me, 68 * or <tt>null</tt>. 69 * @throws UnsupportedOperationException if I am a singly-linked list. 70 */ 71 public abstract Listable getPrev() throws UnsupportedOperationException; 72 73 /** 74 * Return <tt>true</tt> if there is a <tt>Listable</tt> 75 * element preceeding me, <tt>false</tt> otherwise. 76 * 77 * @return <tt>true</tt> if there is a <tt>Listable</tt> 78 * element preceeding me, <tt>false</tt> otherwise. 79 * @throws UnsupportedOperationException if I am a singly-linked list. 80 */ 81 public abstract boolean hasPrev() throws UnsupportedOperationException; 82 83 /** 84 * Change my preceeding element to <i>prev</i>. 85 * Note that this does not change the {@link #getNext} 86 * value of <i>prev</i>. 87 * 88 * @param prev my new preceeding sibling. 89 * @throws UnsupportedOperationException if I am a singly-linked or read-only list. 90 */ 91 public abstract void setPrev(Listable prev) throws UnsupportedOperationException; 92 }