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 /**
19 * An base implementation of {@link Listable}, supporting
20 * singly-linked lists.
21 *
22 * @version $Id: ListableBase.java 155435 2005-02-26 13:17:27Z dirkv $
23 * @author Rodney Waldhoff
24 */
25 public class ListableBase implements Listable, Cloneable {
26
27 /** My following sibling. */
28 protected transient Listable _next = null;
29
30 /**
31 * No arg constructor.
32 * Equivalent to {@link #ListableBase(org.apache.commons.cache.adt.Listable) <tt>ListableBase(null)</tt>}.
33 */
34 public ListableBase() {
35 }
36
37 /**
38 * Constructor.
39 * @param next the next element in the list.
40 */
41 public ListableBase(Listable next) {
42 _next = next;
43 }
44
45 public Listable getNext() {
46 return _next;
47 }
48
49 public boolean hasNext() {
50 return (null != _next);
51 }
52
53 public void setNext(Listable next) {
54 _next = next;
55 }
56
57 /**
58 * Throws {@link UnsupportedOperationException}.
59 */
60 public Listable getPrev() throws UnsupportedOperationException {
61 throw new UnsupportedOperationException();
62 }
63
64 /**
65 * Throws {@link UnsupportedOperationException}.
66 */
67 public boolean hasPrev() throws UnsupportedOperationException {
68 throw new UnsupportedOperationException();
69 }
70
71 /**
72 * Throws {@link UnsupportedOperationException}.
73 */
74 public void setPrev(Listable prev) throws UnsupportedOperationException {
75 throw new UnsupportedOperationException();
76 }
77 }