@@ -35,6 +35,7 @@ public class Field
3535 private  final  int  offset ; // optional for field/data (not present for group) 
3636 private  final  String  semanticType ; // optional for field/data (not present for group?) 
3737 private  final  Presence  presence ; // optional, defaults to required 
38+  private  final  String  valueRef ; // optional, defaults to null 
3839 private  final  int  blockLength ; // optional for group (not present for field/data) 
3940 private  final  CompositeType  dimensionType ; // required for group (not present for field/data) 
4041 private  final  boolean  variableLength ; // true for data (false for field/group) 
@@ -53,6 +54,7 @@ public Field(
5354 final  int  offset ,
5455 final  String  semanticType ,
5556 final  Presence  presence ,
57+  final  String  valueRef ,
5658 final  int  blockLength ,
5759 final  CompositeType  dimensionType ,
5860 final  boolean  variableLength ,
@@ -67,6 +69,7 @@ public Field(
6769 this .offset  = offset ;
6870 this .semanticType  = semanticType ;
6971 this .presence  = presence ;
72+  this .valueRef  = valueRef ;
7073 this .blockLength  = blockLength ;
7174 this .dimensionType  = dimensionType ;
7275 this .variableLength  = variableLength ;
@@ -89,6 +92,35 @@ public void validate(final Node node)
8992 }
9093
9194 checkForValidName (node , name );
95+ 
96+  if  (type  instanceof  EnumType  && presence  == Presence .CONSTANT )
97+  {
98+  if  (null  == valueRef )
99+  {
100+  handleError (node , "valueRef not set for constant Enum" );
101+  }
102+  else 
103+  {
104+  final  int  periodIndex  = valueRef .indexOf ('.' );
105+  if  (-1  == periodIndex )
106+  {
107+  handleError (node , "valueRef format not valid for constant Enum: "  + valueRef );
108+  }
109+ 
110+  final  String  valueRefType  = valueRef .substring (0 , periodIndex );
111+  if  (!valueRefType .equals (type .name ()))
112+  {
113+  handleError (node , "valueRef Enum type not found: "  + valueRefType );
114+  }
115+ 
116+  final  String  validValueName  = valueRef .substring (periodIndex  + 1 );
117+  final  EnumType  enumType  = (EnumType )type ;
118+  if  (null  == enumType .getValidValue (validValueName ))
119+  {
120+  handleError (node , "valueRef Valid value name not found: "  + validValueName );
121+  }
122+  }
123+  }
92124 }
93125
94126 public  void  groupFields (final  List <Field > fields )
@@ -151,6 +183,16 @@ public int computedBlockLength()
151183 return  computedBlockLength ;
152184 }
153185
186+  public  Presence  presence ()
187+  {
188+  return  presence ;
189+  }
190+ 
191+  public  String  valueRef ()
192+  {
193+  return  valueRef ;
194+  }
195+ 
154196 public  String  semanticType ()
155197 {
156198 return  semanticType ;
@@ -191,6 +233,7 @@ public String toString()
191233 ", offset="  + offset  +
192234 ", semanticType='"  + semanticType  + '\''  +
193235 ", presence="  + presence  +
236+  ", valueRef='"  + valueRef  + '\''  +
194237 ", blockLength="  + blockLength  +
195238 ", dimensionType="  + dimensionType  +
196239 ", variableLength="  + variableLength  +
@@ -212,6 +255,7 @@ public static class Builder
212255 private  int  offset ;
213256 private  String  semanticType ;
214257 private  Presence  presence ;
258+  private  String  refValue ;
215259 private  int  blockLength ;
216260 private  CompositeType  dimensionType ;
217261 private  boolean  variableLength ;
@@ -261,6 +305,12 @@ public Builder presence(final Presence presence)
261305 return  this ;
262306 }
263307
308+  public  Builder  valueRef (final  String  refValue )
309+  {
310+  this .refValue  = refValue ;
311+  return  this ;
312+  }
313+ 
264314 public  Builder  blockLength (final  int  blockLength )
265315 {
266316 this .blockLength  = blockLength ;
@@ -307,6 +357,7 @@ public Field build()
307357 offset ,
308358 semanticType ,
309359 presence ,
360+  refValue ,
310361 blockLength ,
311362 dimensionType ,
312363 variableLength ,
0 commit comments