import java.util.*;


/**
 * A ticker symbol
 *
 *
 * @version 1.0
 * @author  Prof. David Bernstein, James Madison University
 *
 */
 public class TickerSymbol
 {
    protected int              securityType;
    protected String           symbol;
    

    public static final int    STOCK      = 0;
    public static final int    FUTURE     = 1;

    /**
     * Default constructor
     *
     */
     public TickerSymbol()
     {
			this.symbol = null;
     }

    /**
     * Constructor
     *
     * @param symbol       The ticker symbol for the security
     * @param securityType The type of security (STOCK, FUTURE)
     */
     public TickerSymbol(String symbol, int securityType)
     {
 			this.symbol = symbol;
			this.securityType = securityType;
     }

    /**
     * Return the secuirty type
     *
     * @return    The type of security (STOCK, FUTURE)
     */
     public int getSecurityType()
     {
        return securityType;
     }

    
    /**
     * Return the symbol
     *
     * @return    The symbol
     */
     public String getSymbol()
     {
        return symbol;
     }

    /**
     * Parse a String representation of a TickerSymbol into its components
     * and construct a TickerSymbol from them
     *
     * @param s    The String representation
     * @return     The TickerSymbol
     */
     public static TickerSymbol parseTickerSymbol(String s) 
                               throws NoSuchElementException
     {
			int                sType;
			String             symbol, token;
			StringTokenizer    tokenizer;
			TickerSymbol		 tempTickerSymbol;

			tokenizer = new StringTokenizer(s,",");
			symbol = tokenizer.nextToken();

			token =  tokenizer.nextToken().toUpperCase();

			sType = STOCK;
			if (token.equals("FUTURE")) 
				sType = FUTURE;

         tempTickerSymbol = new TickerSymbol (symbol, sType);
			return tempTickerSymbol;
    }

    /**
     * Return a String representation of this TickerSymbol
     */
     public String toString()
     {
			return symbol;
     }
} // end TickerSymbol
