org.zmpp.vm
Class DefaultDictionary

java.lang.Object
  extended by org.zmpp.vm.DefaultDictionary
All Implemented Interfaces:
Dictionary

public class DefaultDictionary
extends Object
implements Dictionary

This class implements a view on the dictionary within a memory map.

Version:
1.0
Author:
Wei-ju Wu

Constructor Summary
DefaultDictionary(MemoryReadAccess map, int address)
          Constructor.
 
Method Summary
 int getEntryAddress(int entryNum)
          Returns the entry address at the specified position.
 int getEntryLength()
          Returns the length of a dictionary entry.
 int getNumberOfEntries()
          Returns the number of dictionary entries.
 int getNumberOfSeparators()
          Returns the number of separators.
 byte getSeparator(int i)
          Returns the separator at position i as a ZSCII character.
 int lookup(String token)
          Looks up a string in the dictionary.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultDictionary

public DefaultDictionary(MemoryReadAccess map,
                         int address)
Constructor.

Parameters:
map - the memory map
address - the start address of the dictionary
Method Detail

getNumberOfSeparators

public int getNumberOfSeparators()
Returns the number of separators.

Specified by:
getNumberOfSeparators in interface Dictionary
Returns:
the number of separators

getSeparator

public byte getSeparator(int i)
Returns the separator at position i as a ZSCII character.

Specified by:
getSeparator in interface Dictionary
Parameters:
i - the separator number, zero-based
Returns:
the separator

getEntryLength

public int getEntryLength()
Returns the length of a dictionary entry.

Specified by:
getEntryLength in interface Dictionary
Returns:
the entry length

getNumberOfEntries

public int getNumberOfEntries()
Returns the number of dictionary entries.

Specified by:
getNumberOfEntries in interface Dictionary
Returns:
the number of entries

getEntryAddress

public int getEntryAddress(int entryNum)
Returns the entry address at the specified position.

Specified by:
getEntryAddress in interface Dictionary
Parameters:
entryNum - entry number between (0 - getNumberOfEntries() - 1)
Returns:
the entry address

lookup

public int lookup(String token)
Looks up a string in the dictionary. The word will be truncated to the maximum word length and looked up. The result is the address of the entry or 0 if it is not found.

Specified by:
lookup in interface Dictionary
Parameters:
token - a token
Returns:
the address of the token or 0


Copyright © 2005 . All Rights Reserved.