1 package org.lcsim.detector.identifier; 2 3 import java.util.List; 4 5 /** 6 * Holds an ordered and mapped list of {@link IIdentifierField} objects 7 * that define the fields of an {@link IIdentifier}. 8 * 9 * @author Jeremy McCormick 10 * @version $Id: IIdentifierDictionary.java,v 1.12 2013/01/24 22:26:35 jeremy Exp $ 11 */ 12 public interface IIdentifierDictionary 13 { 14 /** 15 * Get the name of this dictionary. 16 * @return The name of this IIdentifierDictionary. 17 */ 18 String getName(); 19 20 /** 21 * Get a field by name. 22 * @param fieldName The field. 23 * @return The field. 24 */ 25 IIdentifierField getField(String fieldName); 26 27 /** 28 * True if this <code>IdentifierDictionary</code> contains the field; false if not. 29 * @param fieldName The name of the field. 30 */ 31 boolean hasField(String fieldName); 32 33 /** 34 * Get the {@link IIdentifierField} at specified index. 35 * @return The field at position <code>index</code> in the field array. 36 * @throws ArrayIndexOutOfBoundsException if the index is not in bounds. 37 */ 38 IIdentifierField getField(int index); 39 40 /** 41 * Get the index of a named field. 42 * @param fieldName The name of the field. 43 * @return The index index of the field. 44 */ 45 int getFieldIndex(String fieldName); 46 47 /** 48 * Get the list of field names. 49 * @return The field names contained by this dictionary. 50 */ 51 List<String> getFieldNames(); 52 53 /** 54 * Get the list of fields. 55 * @return The list of fields. 56 */ 57 List<IIdentifierField> getFieldList(); 58 59 /** 60 * Get the number of fields in this dictionary. 61 * @return The number of fields in the dictionary. 62 */ 63 int getNumberOfFields(); 64 65 /** 66 * Get the max index in the field array. 67 * @return The max index in the field array. 68 */ 69 int getMaxIndex(); 70 71 /** 72 * Pack an expanded id . 73 * @param id The expanded id. 74 * @return The packed id. 75 */ 76 IIdentifier pack(IExpandedIdentifier id); 77 78 /** 79 * Unpack a packed id into an expanded id. 80 * @param compact The packed id. 81 * @return The expanded id. 82 */ 83 IExpandedIdentifier unpack(IIdentifier compact); 84 85 /** 86 * Unpack id, only including fields with indices in list. 87 * @param compact The packed id 88 * @param indices The indices of the fields to unpack. 89 * @return The expanded id. 90 */ 91 IExpandedIdentifier unpack(IIdentifier compact, List<Integer> indices); 92 93 /** 94 * Get the value of a field extracted from a packed id by name. 95 * @param compact The packed id. 96 * @param field The field name. 97 * @return The value of the field. 98 */ 99 int getFieldValue(IIdentifier compact, String field); 100 101 /** 102 * Get the value of a field extracted from a packed id by index. 103 * @param compact The packed id. 104 * @param field The field name. 105 * @return The value of the field. 106 */ 107 int getFieldValue(IIdentifier compact, int idx); 108 109 /** 110 * Check whether an expanded identifier is valid for this dictionary. 111 * This includes checking number of fields and the field values. 112 * @return True if id is valid; false if not. 113 */ 114 boolean isValid(IExpandedIdentifier id); 115 }