wyvern.lib.properties
Class TavernMenu

java.lang.Object
  extended bywyvern.lib.properties.TavernMenu
All Implemented Interfaces:
SelfExternalizable

public class TavernMenu
extends java.lang.Object
implements SelfExternalizable

Encapsulates a menu from which players can order food and drink.

Version:
1.0, Nov 07, 1999
Author:
Steve Yegge

Nested Class Summary
 class TavernMenu.MenuItem
          Encapsulates a single menu entry.
 
Field Summary
static int DRINK
           
protected  java.util.LinkedList entries_
           
static int FOOD
           
 
Constructor Summary
TavernMenu()
           
 
Method Summary
 void barf(java.lang.String type, java.lang.String name)
          Throws a semi-descriptive parse error.
 java.util.List getEntries()
          Returns a list of MenuItem objects comprising this menu.
protected  void parseElement(org.w3c.dom.Element node)
          Parses an XML element from the externalized menu.
 void readData(org.w3c.dom.Node bean)
          Tells the object to parse its externalized representation from a list of lines.
 boolean shouldWrite()
          Returns true if we should write the object at all.
 java.util.List writeData()
          Tells the object to write its properties out to a text file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

entries_

protected java.util.LinkedList entries_

DRINK

public static final int DRINK
See Also:
Constant Field Values

FOOD

public static final int FOOD
See Also:
Constant Field Values
Constructor Detail

TavernMenu

public TavernMenu()
Method Detail

getEntries

public java.util.List getEntries()
Returns a list of MenuItem objects comprising this menu.

Returns:
the menu items - can be null or empty if the menu is empty.

readData

public void readData(org.w3c.dom.Node bean)
              throws java.lang.Exception
Tells the object to parse its externalized representation from a list of lines.

Specified by:
readData in interface SelfExternalizable
Parameters:
bean - the XML DOM representation of the externalized bean.
Throws:
java.lang.Exception

parseElement

protected void parseElement(org.w3c.dom.Element node)
                     throws java.lang.Exception
Parses an XML element from the externalized menu.

Parameters:
node - the element
Throws:
java.lang.Exception

barf

public void barf(java.lang.String type,
                 java.lang.String name)
Throws a semi-descriptive parse error.


writeData

public java.util.List writeData()
                         throws java.lang.Exception
Tells the object to write its properties out to a text file.

Specified by:
writeData in interface SelfExternalizable
Returns:
a String representation that can be written to the text file.
Throws:
java.lang.Exception

shouldWrite

public boolean shouldWrite()
Returns true if we should write the object at all.

Specified by:
shouldWrite in interface SelfExternalizable
Returns:
true - it's OK to have an empty menu