rlgamekit.item
Class AbstractItem

java.lang.Object
  extended by rlgamekit.item.AbstractItem

public class AbstractItem
extends java.lang.Object

A read only data container for generic item data.

Check http://www.funkelwerk.de/forum/index.php?topic=341.0 for more details on the design ideas behind this class

See Also:
IndividualItem

Constructor Summary
AbstractItem(ItemConfiguration config, java.io.BufferedReader reader)
          Create a new abstratc item fromm the data accessed through the reader.
AbstractItem(ItemConfiguration config, java.lang.String key)
          Create a new, empty abstract item.
AbstractItem(ItemConfiguration config, java.lang.String key, java.lang.String[] sval, int[] ival, Triplet[] tval)
          Create a new abstract item from the data sets.
 
Method Summary
 int getInt(int index)
          Access integer data through index
 java.lang.String getKey()
          Unique key (within an item catalog) for this item data
 java.lang.String getString(int index)
          Access string data through index
 Triplet getTriplet(int index)
          Access triplet data through index
 java.lang.String toString()
           
 void write(java.io.Writer writer)
          Write the item data through the given writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractItem

public AbstractItem(ItemConfiguration config,
                    java.io.BufferedReader reader)
             throws java.io.IOException
Create a new abstratc item fromm the data accessed through the reader.

Parameters:
config - The item config to use to interpret the data
reader - The reader to read the data
Throws:
java.io.IOException - IOException will be thrown on read errors, including data integrity check fails.

AbstractItem

public AbstractItem(ItemConfiguration config,
                    java.lang.String key)
Create a new, empty abstract item. Since abstract items are read only, such are only good for dummy purposes.

Parameters:
config - The item config to use to interpret the data
key - Must be unique within an item catalog
See Also:
ItemCatalog

AbstractItem

public AbstractItem(ItemConfiguration config,
                    java.lang.String key,
                    java.lang.String[] sval,
                    int[] ival,
                    Triplet[] tval)
Create a new abstract item from the data sets.

Parameters:
config - The item config to use to interpret the data
key - Must be unique within an item catalog
sval - String values
ival - Integer values
tval - triplet values
See Also:
ItemCatalog
Method Detail

getKey

public java.lang.String getKey()
Unique key (within an item catalog) for this item data


getString

public java.lang.String getString(int index)
Access string data through index


getInt

public int getInt(int index)
Access integer data through index


getTriplet

public Triplet getTriplet(int index)
Access triplet data through index


write

public void write(java.io.Writer writer)
           throws java.io.IOException
Write the item data through the given writer. Format is a simple plain text list of item data.

Parameters:
writer - The writer to write to.
Throws:
java.io.IOException - IOException is thrown if write errors occur.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object