1 package org.lcsim.detector.identifier; 2 3 4 /** 5 * 6 * Implementation of {@link IIdentifierHelper}. 7 * 8 * @author Jeremy McCormick 9 * @version $Id: IdentifierHelper.java,v 1.16 2011/02/25 03:09:38 jeremy Exp $ 10 */ 11 12 public class IdentifierHelper implements IIdentifierHelper { 13 private IIdentifierDictionary iddict = null; 14 15 /* 16 * public IExpandedIdentifier unpack( IIdentifier id, int start, int nfields) { return IdentifierUtil.unpack( iddict, id, start, nfields ); } 17 * 18 * public IExpandedIdentifier unpack( IIdentifier id, int start) { return IdentifierUtil.unpack( iddict, id, start ); } 19 * 20 * public IExpandedIdentifier unpack(IIdentifier compact, List<Integer> indices) { return IdentifierUtil.unpack(iddict, compact, indices); } 21 */ 22 23 public IdentifierHelper(IIdentifierDictionary iddict) { 24 this.iddict = iddict; 25 } 26 27 public IIdentifierDictionary getIdentifierDictionary() { 28 return iddict; 29 } 30 31 public IIdentifier pack(IExpandedIdentifier id) { 32 // return IdentifierUtil.pack(getIdentifierDictionary(), id ); 33 return iddict.pack(id); 34 } 35 36 public IExpandedIdentifier unpack(IIdentifier id) { 37 // return IdentifierUtil.unpack( iddict, id ); 38 return iddict.unpack(id); 39 } 40 41 /* 42 * public int getValue( IIdentifier compact, IIdentifierField desc ) { //return IdentifierUtil.getValue( compact, desc ); return iddict.getFieldValue(compact, desc.getLabel()); } 43 */ 44 45 public int getValue(IIdentifier compact, int idx) { 46 // return IdentifierUtil.getValue( iddict, compact, field ); 47 return iddict.getFieldValue(compact, idx); 48 } 49 50 /* 51 * public void setValue(IExpandedIdentifier expid, String field, int value) { expid.setValue(getFieldIndex(field), value); } 52 * 53 * public void setValue(IExpandedIdentifier expid, int index, int value) { expid.setValue(index, value); } 54 */ 55 56 public int getFieldIndex(String fieldName) { 57 return iddict.getFieldIndex(fieldName); 58 } 59 60 public boolean hasField(String fieldName) { 61 return iddict.hasField(fieldName); 62 } 63 64 public int getValue(IIdentifier compact, String field) { 65 // return IdentifierUtil.getValue( iddict, compact, field ); 66 return iddict.getField(field).unpack(compact); 67 } 68 69 public IExpandedIdentifier createExpandedIdentifier() { 70 return new ExpandedIdentifier(getIdentifierDictionary().getNumberOfFields()); 71 } 72 73 /* 74 * public IIdentifier pack(IExpandedIdentifier id, int start) { return IdentifierUtil.pack( iddict, id, start ); } 75 * 76 * public IIdentifier pack(IExpandedIdentifier id, int start, int nfields) { return IdentifierUtil.pack( iddict, id, start, nfields ); } 77 */ 78 }