package latte.lattice; 

import java.lang.reflect.Method;

public class Element implements Cloneable {

	Object element;
	int type;
	
	public Element(Object element) {
		this();
		this.element = element;
	}

	public Element() {
		
	}
	public String toString () {
		
		if (element instanceof Integer) {
			return ((Integer) element).toString();
		}
		return element.toString();
	}

	public Element clone() { 
		if (element instanceof Number || element instanceof Boolean || element instanceof String) {
			return new Element(element);
		}
		try {
			Class<?> clzz = this.element.getClass();
			Method meth = clzz.getMethod("clone", new Class[0]);
			Object dupl = meth.invoke(this.element, new Object[0]);
			return (Element) dupl; // unchecked warning
		} catch (Exception e) {
			System.err.print("\nCannot Clone 'word':\n\t" + e.getMessage());
			e.printStackTrace();
			System.exit(-1);
			return null;
		}
	}
}
