key0-96/
key0-96/doc/key/
key0-96/doc/key/credits/
key0-96/doc/key/developers/
key0-96/doc/key/developers/resources/
key0-96/setup/caves/
key0-96/setup/help/
key0-96/setup/ruins/
key0-96/src/
key0-96/src/commands/
key0-96/src/events/
key0-96/src/hack/
key0-96/src/sql/
key0-96/src/swing/
key0-96/src/talker/forest/
key0-96/src/talker/objects/
key0-96/src/terminals/
/*
**               j###t  ########## ####   ####
**              j###t   ########## ####   ####
**             j###T               "###L J###"
**          ######P'    ##########  #########
**          ######k,    ##########   T######T
**          ####~###L   ####
**          #### q###L  ##########   .#####
**          ####  \###L ##########   #####"
**
**  Class History
**
**  Date        Name         Description
**  ---------|------------|-----------------------------------------------
**  18Jul97    merlin       created class
**  19Jul97    subtle       now implements Thing, implemented read() and
**                          look
**
*/

package key;

import key.*;
import key.collections.*;
import key.primitive.StringSymbol;

import java.io.*;
import java.util.Enumeration;

/**
  *  A StringSet a a collections of String
  *  META: make this into a Thing
 */
public class StringSet extends Atom
{
	public static final AtomicElement[] ELEMENTS =
	{
		AtomicElement.construct( StringSet.class, Paragraph.class, "description",
			AtomicElement.PUBLIC_FIELD,
			"the description of this stringset" ),
		AtomicElement.construct( StringSet.class, String.class, "called",
			AtomicElement.PUBLIC_FIELD,
			"the title of this string set" )
	};

	public static final AtomicStructure STRUCTURE = new AtomicStructure( Atom.STRUCTURE, ELEMENTS );
	
	protected StringKeyCollection strings;
	public Paragraph description;
	public String called;
	
	public StringSet()
	{
		description = new TextParagraph( "A leather-bound book\n" );
		called = "the leather-bound book";
		strings = new StringKeyCollection();
	}

	public StringSet( Object key )
	{
		this();
		setKey( key );
	}
	
	public AtomicStructure getDeclaredStructure()
	{
		return( STRUCTURE );
	}
	
	public void addString( String string ) throws NonUniqueKeyException, BadKeyException
	{
		strings.link( new StringSymbol( string ) );
	}

	public void removeString( String string ) throws BadKeyException
	{
		strings.unlink( new StringSymbol( string ) );
	}
	
	public Object get( String s )
	{
		return( strings.get( s ) );
	}

	public Object getElementAt( int i )
	{
		return( strings.getElementAt( i ) );
    }
	
	public int count()
	{
		return( strings.count() );
	}
	
	/*
	public Paragraph read( String args )
	{
		MultiParagraph mp = new MultiParagraph();
		
		StringBuffer sb = new StringBuffer();

		for( Enumeration e = elements(); e.hasMoreElements(); )
		{
			sb.append( (String) e.nextElement() );
			sb.append( '\n' );
		}

		mp.append( new HeadingParagraph( called ) );
		mp.append( new TextParagraph( sb.toString() ) );
		mp.append( LineParagraph.LINE );

		return( mp );
	}
	*/
	
	public Enumeration elements()
	{
		return( strings.elements() );
	}
	
	/*
	public Paragraph look()
	{
		return( description );
	}
	*/
}