1 61 62 63 64 package org.jaxen.util; 65 66 import java.util.AbstractList ; 67 68 74 public class SingletonList extends AbstractList { 75 private final Object element; 76 77 public SingletonList(Object element) { 78 this.element = element; 79 } 80 81 public int size() { 82 return 1; 83 } 84 85 public Object get(int index) { 86 if(index == 0) { 87 return element; 88 } 89 throw new IndexOutOfBoundsException (index + " != 0"); 90 } 91 } 92 | Popular Tags |