package lrs; /** * Represents the empty state. Singleton pattern. * @author Dung X. Nguyen Copyright 2000 - All rights reserved. * @since 09/22/00 */ class EmptyNode extends ANode { /** * Singleton Pattern. */ final static EmptyNode Singleton = new EmptyNode(); private EmptyNode() { } /** * Throws java.util.NoSuchElementException. */ LRStruct getRest(LRStruct owner) { throw new java.util.NoSuchElementException ("Empty list has no first."); } /** * Throws java.util.NoSuchElementException. */ Object getFirst(LRStruct owner) { throw new java.util.NoSuchElementException ("Empty list has no first."); } /** * Throws java.util.NoSuchElementException. */ void setRest(LRStruct tail, LRStruct owner) { throw new java.util.NoSuchElementException ("Empty list has no tail."); } /** * Throws java.util.NoSuchElementException. */ void setFirst(Object dat, LRStruct owner) { throw new java.util.NoSuchElementException ("Empty list has no first."); } void insertFront(Object dat, LRStruct owner) { owner.setHead(new NENode(dat)); } /** * Throws java.util.NoSuchElementException. */ Object removeFront(LRStruct owner) { throw new java.util.NoSuchElementException ("Empty list has no front."); } /** * Calls the visitor's empty case. */ Object execute(IAlgo algo, Object input, LRStruct owner) { return algo.forEmpty(owner, input); } }