package osa.attribute.atgrammar.grammar.symbols;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2005</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

public class OutputSymbol
  extends Symbol
  {
  public OutputSymbol(String symbol_name)
    {
    super(symbol_name);
    symbol_type=Symbol.OUTPUT_SYMBOL;
    is_cloned=false;
    original_reference=this;
    }

  public Object clone()
    {
    // creating clone instance
    OutputSymbol cloned=new OutputSymbol(original_reference.getOriginalName());
    // setting corresponding symbol index
    cloned.symbol_index=getCounterValue();
    incrementCounter();
    // storing reference to original
    if(is_cloned)
      {
      cloned.original_reference=this.original_reference;
      }
    else
      {
      cloned.original_reference=this;
      }
    cloned.is_cloned=true;
    // copying fields

    // cloning attributes
    Attribute temp_attribute;
    int attr_count=this.getAttrubutesCount();
    for(int i=0;i<attr_count;i++)
       {
       temp_attribute=(Attribute)attributes_list.get(i);
       cloned.attributes_list.add(temp_attribute.clone());
       }

    return cloned;
    }
  }