package ch.psi.mxsc; import java.util.HashMap; /** * */ public class SampleInfo extends HashMap { public enum PuckType { Unipuck, MiniSpine, RT, Unknown } public enum SampleStatus { Mounted, HasBeenMounted, Present, Unknown } Object[] getData() { return new Object[]{ //), getStr("dewarName"), getEnum("puckType", PuckType.class, PuckType.Unknown) getStr("puckName"), getStr("userName"), getStr("puckBarcode"), getStr("puckAddress"), getStr("sampleName"), getInt("samplePosition"), getStr("sampleBarcode"), getEnum("sampleStatus", SampleStatus.class, SampleStatus.Unknown), getInt("sampleMountCount") }; } String getStr(String key) { Object value = get(key); return (value == null) ? "" : String.valueOf(get(key)); } int getInt(String key) { try { Object val =get(key); if (val instanceof Number){ return ((Number)val).intValue(); } return Integer.valueOf((String) val); } catch (Exception ex) { return -1; } } Object getEnum(String key, Class cls, Object def) { try { return Enum.valueOf(cls, getStr(key)); } catch (Exception ex) { return def; } } }