@@ -201,98 +201,101 @@ private List<Field> parseFieldsAndGroups(final Node node) throws XPathExpression
201
201
202
202
private Field parseGroupField (final NodeList nodeList , final int nodeIndex ) throws XPathExpressionException
203
203
{
204
- final String dimensionTypeName = getAttributeValue (nodeList .item (nodeIndex ), "dimensionType" , "groupSizeEncoding" );
204
+ final Node node = nodeList .item (nodeIndex );
205
+ final String dimensionTypeName = getAttributeValue (node , "dimensionType" , "groupSizeEncoding" );
205
206
Type dimensionType = typeByNameMap .get (dimensionTypeName );
206
207
if (dimensionType == null )
207
208
{
208
- handleError (nodeList . item ( nodeIndex ) , "could not find dimensionType: " + dimensionTypeName );
209
+ handleError (node , "could not find dimensionType: " + dimensionTypeName );
209
210
}
210
211
else if (!(dimensionType instanceof CompositeType ))
211
212
{
212
- handleError (nodeList . item ( nodeIndex ) , "dimensionType should be a composite type: " + dimensionTypeName );
213
+ handleError (node , "dimensionType should be a composite type: " + dimensionTypeName );
213
214
dimensionType = null ;
214
215
}
215
216
else
216
217
{
217
- ((CompositeType )dimensionType ).checkForWellFormedGroupSizeEncoding (nodeList . item ( nodeIndex ) );
218
+ ((CompositeType )dimensionType ).checkForWellFormedGroupSizeEncoding (node );
218
219
}
219
220
220
221
final Field field = new Field .Builder ()
221
- .name (getAttributeValue (nodeList . item ( nodeIndex ) , "name" ))
222
- .description (getAttributeValueOrNull (nodeList . item ( nodeIndex ) , "description" ))
223
- .id (Integer .parseInt (getAttributeValue (nodeList . item ( nodeIndex ) , "id" )))
224
- .blockLength (Integer .parseInt (getAttributeValue (nodeList . item ( nodeIndex ) , "blockLength" , "0" )))
225
- .sinceVersion (Integer .parseInt (getAttributeValue (nodeList . item ( nodeIndex ) , "sinceVersion" , "0" )))
222
+ .name (getAttributeValue (node , "name" ))
223
+ .description (getAttributeValueOrNull (node , "description" ))
224
+ .id (Integer .parseInt (getAttributeValue (node , "id" )))
225
+ .blockLength (Integer .parseInt (getAttributeValue (node , "blockLength" , "0" )))
226
+ .sinceVersion (Integer .parseInt (getAttributeValue (node , "sinceVersion" , "0" )))
226
227
.dimensionType ((CompositeType )dimensionType )
227
228
.build ();
228
229
229
- XmlSchemaParser .checkForValidName (nodeList . item ( nodeIndex ) , field .name ());
230
+ XmlSchemaParser .checkForValidName (node , field .name ());
230
231
231
- field .groupFields (parseFieldsAndGroups (nodeList . item ( nodeIndex ) )); // recursive call
232
+ field .groupFields (parseFieldsAndGroups (node )); // recursive call
232
233
233
234
return field ;
234
235
}
235
236
236
237
private Field parseField (final NodeList nodeList , final int nodeIndex )
237
238
{
238
- final String typeName = getAttributeValue (nodeList .item (nodeIndex ), "type" );
239
+ final Node node = nodeList .item (nodeIndex );
240
+ final String typeName = getAttributeValue (node , "type" );
239
241
final Type fieldType = typeByNameMap .get (typeName );
240
242
if (fieldType == null )
241
243
{
242
- handleError (nodeList . item ( nodeIndex ) , "could not find type: " + typeName );
244
+ handleError (node , "could not find type: " + typeName );
243
245
}
244
246
245
247
final Field field = new Field .Builder ()
246
- .name (getAttributeValue (nodeList . item ( nodeIndex ) , "name" ))
247
- .description (getAttributeValueOrNull (nodeList . item ( nodeIndex ) , "description" ))
248
- .id (Integer .parseInt (getAttributeValue (nodeList . item ( nodeIndex ) , "id" )))
249
- .offset (Integer .parseInt (getAttributeValue (nodeList . item ( nodeIndex ) , "offset" , "0" )))
250
- .semanticType (getAttributeValueOrNull (nodeList . item ( nodeIndex ) , "semanticType" ))
251
- .presence (Presence .get (getAttributeValue (nodeList . item ( nodeIndex ) , "presence" , "required" )))
252
- .sinceVersion (Integer .parseInt (getAttributeValue (nodeList . item ( nodeIndex ) , "sinceVersion" , "0" )))
253
- .epoch (getAttributeValue (nodeList . item ( nodeIndex ) , "epoch" , "unix" ))
254
- .timeUnit (getAttributeValue (nodeList . item ( nodeIndex ) , "timeUnit" , "nanosecond" ))
248
+ .name (getAttributeValue (node , "name" ))
249
+ .description (getAttributeValueOrNull (node , "description" ))
250
+ .id (Integer .parseInt (getAttributeValue (node , "id" )))
251
+ .offset (Integer .parseInt (getAttributeValue (node , "offset" , "0" )))
252
+ .semanticType (getAttributeValueOrNull (node , "semanticType" ))
253
+ .presence (Presence .get (getAttributeValue (node , "presence" , "required" )))
254
+ .sinceVersion (Integer .parseInt (getAttributeValue (node , "sinceVersion" , "0" )))
255
+ .epoch (getAttributeValue (node , "epoch" , "unix" ))
256
+ .timeUnit (getAttributeValue (node , "timeUnit" , "nanosecond" ))
255
257
.type (fieldType )
256
258
.build ();
257
259
258
- field .validate (nodeList . item ( nodeIndex ) );
260
+ field .validate (node );
259
261
260
262
return field ;
261
263
}
262
264
263
265
private Field parseDataField (final NodeList nodeList , final int nodeIndex )
264
266
{
265
- final String typeName = getAttributeValue (nodeList .item (nodeIndex ), "type" );
267
+ final Node node = nodeList .item (nodeIndex );
268
+ final String typeName = getAttributeValue (node , "type" );
266
269
final Type fieldType = typeByNameMap .get (typeName );
267
270
if (fieldType == null )
268
271
{
269
- handleError (nodeList . item ( nodeIndex ) , "could not find type: " + typeName );
272
+ handleError (node , "could not find type: " + typeName );
270
273
}
271
274
else if (!(fieldType instanceof CompositeType ))
272
275
{
273
- handleError (nodeList . item ( nodeIndex ) , "data type is not composite type: " + typeName );
276
+ handleError (node , "data type is not composite type: " + typeName );
274
277
}
275
278
else
276
279
{
277
- ((CompositeType )fieldType ).checkForWellFormedVariableLengthDataEncoding (nodeList . item ( nodeIndex ) );
280
+ ((CompositeType )fieldType ).checkForWellFormedVariableLengthDataEncoding (node );
278
281
((CompositeType )fieldType ).makeDataFieldCompositeType ();
279
282
}
280
283
281
284
final Field field = new Field .Builder ()
282
- .name (getAttributeValue (nodeList . item ( nodeIndex ) , "name" ))
283
- .description (getAttributeValueOrNull (nodeList . item ( nodeIndex ) , "description" ))
284
- .id (Integer .parseInt (getAttributeValue (nodeList . item ( nodeIndex ) , "id" )))
285
- .offset (Integer .parseInt (getAttributeValue (nodeList . item ( nodeIndex ) , "offset" , "0" )))
286
- .semanticType (getAttributeValueOrNull (nodeList . item ( nodeIndex ) , "semanticType" ))
287
- .presence (Presence .get (getAttributeValue (nodeList . item ( nodeIndex ) , "presence" , "required" )))
288
- .sinceVersion (Integer .parseInt (getAttributeValue (nodeList . item ( nodeIndex ) , "sinceVersion" , "0" )))
289
- .epoch (getAttributeValue (nodeList . item ( nodeIndex ) , "epoch" , "unix" ))
290
- .timeUnit (getAttributeValue (nodeList . item ( nodeIndex ) , "timeUnit" , "nanosecond" ))
285
+ .name (getAttributeValue (node , "name" ))
286
+ .description (getAttributeValueOrNull (node , "description" ))
287
+ .id (Integer .parseInt (getAttributeValue (node , "id" )))
288
+ .offset (Integer .parseInt (getAttributeValue (node , "offset" , "0" )))
289
+ .semanticType (getAttributeValueOrNull (node , "semanticType" ))
290
+ .presence (Presence .get (getAttributeValue (node , "presence" , "required" )))
291
+ .sinceVersion (Integer .parseInt (getAttributeValue (node , "sinceVersion" , "0" )))
292
+ .epoch (getAttributeValue (node , "epoch" , "unix" ))
293
+ .timeUnit (getAttributeValue (node , "timeUnit" , "nanosecond" ))
291
294
.type (fieldType )
292
295
.variableLength (true )
293
296
.build ();
294
297
295
- field .validate (nodeList . item ( nodeIndex ) );
298
+ field .validate (node );
296
299
297
300
return field ;
298
301
}
0 commit comments