package au.gov.ansto.bragg.nexus.base;
import java.util.Hashtable;
import java.util.Map;
import neutron.nexus.NexusFile;
/** Remapping support for NX types.
 * 
 * 
 * <p>2005-10-25: The NeXus meta-DTD XML files do not contain types with bit descriptors !
 * Remap through this intermediary. 
 * </p>
 *
 * @author dke
 */
public class NXtypes {
    
	static public final int NULL_TYPE = 0;

        static public final String NULL_UNIT = "NULL";
	
	static public final int NX_FLOAT = NexusFile.NX_FLOAT32;
	
        static public final int NX_INT = NexusFile.NX_INT32;
	
        static public final int NX_CHAR = NexusFile.NX_CHAR;
	
        static public final int NX_BOOLEAN = -1;//NexusFile.?
	
        static public final int NX_BINARY = -2;//NexusFile.?

	static public final int NX_FLOAT_OR_NX_INT = -3; 
		//NexusFile.NX_UNLIMITED;//?
	
	/** WARNING: no obvious mapping */
	static public final int ISO8601 = NexusFile.NX_CHAR;
	
	/* special types for extension */
	static public final String $NXlog = "NXlog";
	
        static public final String $NXnote = "NXnote";
	
        static public final String $NXdata = "NXdata";
	
        static public final String $NXbeam = "NXbeam";
	
        static public final String $NXgeometry = "NXgeometry";
	
        static public final String $NXorientation = "NXorientation";
	
        static public final String $NXenvironment = "NXenvironment";
	
        static public final String $NXsensor = "NXsensor";
	//static public final String DESCRIPTION = "description";
        
	static public final String[] SPECIAL_TYPES = {
		$NXlog,
		$NXdata,
		$NXnote,
		$NXbeam,
		$NXgeometry,
		$NXorientation,
		$NXenvironment,
		$NXsensor
                //DESCRIPTION
	};
        
        static public Map<String,Class> $NXtypeToJavaClass  = new Hashtable<String,Class>();

        static {
            $NXtypeToJavaClass.put("NX_CHAR",String.class);
            $NXtypeToJavaClass.put("NX_FLOAT",Float.class);
            $NXtypeToJavaClass.put("NX_FLOAT32",Float.class);
            $NXtypeToJavaClass.put("NX_DOUBLE",Double.class);
            $NXtypeToJavaClass.put("NX_INT",Integer.class);
            $NXtypeToJavaClass.put("NX_INT32",Integer.class);
        } //TODO extend to complicated array types
        
        static public Class getJavaClassFor$NXtype(String $NXtype) {
            if ($NXtypeToJavaClass.containsKey($NXtype)) return $NXtypeToJavaClass.get($NXtype);
            return Object.class;
        }
	
}
