/**
 * @(#)SWFPushAction.java
 * @author  Intelligent Technology Inc.
 * @version 1.00 2002/4
 */
package	jp.co.iti.swf;

import	java.io.*;
import	java.util.StringTokenizer;

/**
 * SWF ACTION TAG(ID=12)のActionRecordのPushアクションを表す。
 */
public class SWFPushAction extends SWFActionRecord{
	public	static	final	int	STRING		= 0x0000;
	
	private	int			myType;
	private	Object[]	myLiteral;
	
	public	SWFPushAction(int code ,byte[] data) throws SWFActionRecordException{
		super(code ,data);
		
		byte[] delim = { 0x00 };
		
		SWFInputStream swfstream = new SWFInputStream(new ByteArrayInputStream(data));
		try{
			try{
				myType		= swfstream.readUI8();
				switch(myType){
					case	STRING:
						StringTokenizer tokens = new StringTokenizer(new String(data) ,new String(delim));
						int mx = tokens.countTokens();
						myLiteral	= new String[mx];
						for(int i=0;i<mx;i++){
							myLiteral[i] = tokens.nextToken();
//System.out.println("push "+myLiteral[i]);
						}
//						myLiteral	= swfstream.readString();
						break;
				}
			}finally{ swfstream.close(); }
		}catch(IOException e){ throw new SWFActionRecordException(); }
	}
	
	public	int			getType(){		return myType;		}
	public	Object[]	getLiteral(){	return myLiteral;	}
	
	/**
	 * このインスタンスの文字列表現を得る。
	 * @return	このインスタンスの文字列表現。
	 * @since	1.00
	 */
//	public String toString(){ return (null==myLiteral) ? null : myLiteral.toString(); }
}
