@@ -95,6 +95,11 @@ private static Supplier<DocumentBuilderFactory> createDocumentBuilderFactorySupp
9595 private boolean checkUnorderedGroupFields = true ;
9696 private boolean allowUnknownMessageFields = false ;
9797 private String beginString ;
98+ private String fullVersion ;
99+ private String majorVersion ;
100+ private int minorVersion ;
101+ private int extensionPack ;
102+ private int servicePack ;
98103 private final Map <String , Set <Integer >> messageFields = new HashMap <>();
99104 private final Map <String , Set <Integer >> requiredFields = new HashMap <>();
100105 private final Set <String > messages = new HashSet <>();
@@ -171,14 +176,57 @@ private void setVersion(String beginString) {
171176 }
172177
173178 /**
174- * Get the FIX version associated with this dictionary.
175- *
179+ * Get the FIX major/minor version associated with this dictionary.
180+ * E.g. FIX.5.0
176181 * @return the FIX version
177182 */
178183 public String getVersion () {
179184 return beginString ;
180185 }
181186
187+ private void setFullVersion (String fullVersion ) {
188+ this .fullVersion = fullVersion ;
189+ }
190+
191+ /**
192+ * Get the FIX major/minor/SP/EP version associated with this dictionary.
193+ * E.g. FIX.5.0.SP2_EP260
194+ * @return the full FIX version
195+ */
196+ public String getFullVersion () {
197+ return fullVersion ;
198+ }
199+
200+ /**
201+ * @return the ExtensionPack (EP), 0 if it is undefined.
202+ */
203+ public int getExtensionPack () {
204+ return extensionPack ;
205+ }
206+
207+ /**
208+ * @return the ServicePack (SP), 0 if it is undefined.
209+ */
210+ public int getServicePack () {
211+ return servicePack ;
212+ }
213+
214+ /**
215+ * @return the minor FIX version, 0 if it is undefined.
216+ */
217+ public int getMinorVersion () {
218+ return minorVersion ;
219+ }
220+
221+ /**
222+ * NOTE: this is of type String to cover the "Latest" case.
223+ *
224+ * @return the major FIX version
225+ */
226+ public String getMajorVersion () {
227+ return majorVersion ;
228+ }
229+
182230 private void addField (int field ) {
183231 fields .add (field );
184232 }
@@ -568,6 +616,11 @@ public void setAllowUnknownMessageFields(boolean allowUnknownFields) {
568616 private void copyFrom (DataDictionary rhs ) {
569617 hasVersion = rhs .hasVersion ;
570618 beginString = rhs .beginString ;
619+ fullVersion = rhs .fullVersion ;
620+ majorVersion = rhs .majorVersion ;
621+ minorVersion = rhs .minorVersion ;
622+ extensionPack = rhs .extensionPack ;
623+ servicePack = rhs .servicePack ;
571624
572625 copyMap (messageFields , rhs .messageFields );
573626 copyMap (requiredFields , rhs .requiredFields );
@@ -939,16 +992,35 @@ private void load(InputStream inputStream, DocumentBuilderFactory factory) throw
939992 throw new ConfigError ("major attribute not found on <fix>" );
940993 }
941994
942- if (!documentElement .hasAttribute ("minor" )) {
943- throw new ConfigError ("minor attribute not found on <fix>" );
944- }
995+ majorVersion = documentElement .getAttribute ("major" );
996+ minorVersion = getIntegerAttributeIfDefined (documentElement , "minor" );
997+ servicePack = getIntegerAttributeIfDefined (documentElement , "servicepack" );
998+ extensionPack = getIntegerAttributeIfDefined (documentElement , "extensionpack" );
945999
9461000 final String dictionaryType = documentElement .hasAttribute ("type" ) ? documentElement
9471001 .getAttribute ("type" ) : FIX_PREFIX ;
9481002
949- setVersion (dictionaryType + "." + documentElement .getAttribute ("major" ) + "."
950- + documentElement .getAttribute ("minor" ));
951-
1003+ if (FixVersions .LATEST .equals (majorVersion )) {
1004+ String version = dictionaryType + "." + majorVersion ;
1005+ setVersion (version );
1006+ String fullVersion = version ;
1007+ if (extensionPack > 0 ) {
1008+ fullVersion = fullVersion + "_EP" + extensionPack ;
1009+ }
1010+ setFullVersion (fullVersion );
1011+ } else {
1012+ String version = dictionaryType + "." + majorVersion + "." + minorVersion ;
1013+ setVersion (version );
1014+ String fullVersion = version ;
1015+ if (servicePack > 0 ) {
1016+ fullVersion = fullVersion + "SP" + servicePack ;
1017+ }
1018+ if (extensionPack > 0 ) {
1019+ fullVersion = fullVersion + "_EP" + extensionPack ;
1020+ }
1021+ setFullVersion (fullVersion );
1022+ }
1023+
9521024 // Index Components
9531025 final NodeList componentsNode = documentElement .getElementsByTagName ("components" );
9541026 if (componentsNode .getLength () > 0 ) {
@@ -1082,6 +1154,15 @@ private void load(InputStream inputStream, DocumentBuilderFactory factory) throw
10821154 calculateOrderedFields ();
10831155 }
10841156
1157+ private int getIntegerAttributeIfDefined (final Element documentElement , final String attribute ) throws ConfigError {
1158+ try {
1159+ return documentElement .hasAttribute (attribute )
1160+ ? Integer .valueOf (documentElement .getAttribute (attribute )) : 0 ;
1161+ } catch (NumberFormatException e ) {
1162+ throw new ConfigError ("Attribute " + attribute + " could not be parsed as Integer." , e );
1163+ }
1164+ }
1165+
10851166 public int getNumMessageCategories () {
10861167 return messageCategory .size ();
10871168 }
0 commit comments