View Javadoc

1   package org.lcsim.detector.identifier;
2   
3   /**
4    * Represents a single field within a numerical identifier.
5    *
6    * @author Jeremy McCormick
7    * @version $Id: IIdentifierField.java,v 1.8 2011/02/25 03:09:38 jeremy Exp $
8    */
9   public interface IIdentifierField
10  {
11      /**
12       * Get the string label associated with this field.
13       * @return The label.
14       */
15      public String getLabel();
16  
17      /**
18       * Get the number of bits in this field. 
19       * @return The number of bits in this field.
20       */
21      public int getNumberOfBits();
22  
23      /**
24       * Get offset, or starting position, of this field.
25       * @return The offset of the field.
26       */
27      public int getOffset();
28  
29      /**
30       * Get mask on as long value.
31       * @return The on mask as a long.
32       */
33      public long getLongMask();
34  
35      /**
36       * Get mask on as int value.
37       * @return The on mask on an int.
38       */
39      public int getIntegerMask();
40  
41      /**
42       * True if field is capable of holding signed values.
43       * @return True if field is signed.
44       */
45      public boolean isSigned();
46  
47      /**
48       * Get the order of this field in the id, or -1 if the 
49       * ordering is unknown.
50       * 
51       * @return The order this field in the id.
52       */
53      //public int getOrder();
54  
55      /**
56       * Unpack and return the value of this field from a 64-bit {@link IIdentifier}.
57       * 
58       * @return Field's int value. 
59       */
60      public int unpack( IIdentifier id );
61  
62      /**
63       * Unpack and return the value of this field from a raw long.
64       * 
65       * @return Field's int value. 
66       */
67      public int unpack( long value );
68  
69      /**
70       * Pack a single value of this field into a {@link IIdentifier}.
71       * 
72       * @param value A value to pack into this field.
73       * @return An identifier with the packed value.
74       */
75      public IIdentifier pack( int value );
76  
77      /**
78       * Pack a single value this field into an existing {@link IIdentifier},
79       * preserving the other field values that may be present.
80       * 
81       * @param value  The field value.
82       * @param id     An Identifier.
83       */
84      public void pack( int value, IIdentifier id );
85  
86      /**
87       * Get the field value from an {@link IExpandedIdentifier}.
88       * 
89       * @param id The <code>ExpandedIdentifier</code>.
90       * @return The field value.
91       * @throws IllegalArgumentException if field index is not valid for the id.
92       */
93      //public int getFieldValue( IExpandedIdentifier id );
94  
95      /**
96       * Get the maximum inclusive value that can be stored in this field.
97       * @return The maximum field value.
98       */
99      public int getMaxValue();
100 
101     /**
102      * Get the minimum inclusive value that can be stored in this field.
103      * @return The minimum field value.
104      */
105     public int getMinValue();
106 
107     /**
108      * True if value is within valid range of field values; false if not.
109      * @return True if value is valid; false if not.
110      */
111     public boolean isValidValue( int value );
112 }