Skip to content

Commit

Permalink
PrairieMetadata: fix critical errors
Browse files Browse the repository at this point in the history
This change fixes several metadata parsing bugs:

1) The relevant XML element is called "SubindexedValue", not
   "SubindexValue". Without this change, subindexed values are never
   read correctly, so e.g. X/Y/Z stage positions are not parsed.

2) The loop variable for subindexed values is "s", not "i".
   Without this change, an NPE is typically thrown during the
   SubindexedValues parsing loop.

3) Subindexed value table should be indexed on subindex, not index.

4) Parsing of subindexed values from old-style XML (<Key> elements)
   did not add the parsed subindexed value table to the data structure.
  • Loading branch information
ctrueden committed Oct 10, 2014
1 parent db9107a commit 073ddc2
Showing 1 changed file with 5 additions and 4 deletions.
Expand Up @@ -320,6 +320,7 @@ private void parseKeys(final Element el, final ValueTable table) {
for (int i=0; i<tokens.length; i++) {
subSubTable.put("" + i, new ValueItem(tokens[i], null));
}
subTable.put(index, subSubTable);
}
}
}
Expand Down Expand Up @@ -377,16 +378,16 @@ private void parsePVStateShard(final Element el, final ValueTable table) {
if (index == null) continue; // invalid <SubindexedValues> element
final ValueTable subSubTable = new ValueTable();
subTable.put(index, subSubTable);
// iterate over <SubindexValue> children
// iterate over <SubindexedValue> children
final NodeList subNodes =
sivElement.getElementsByTagName("SubindexValue");
sivElement.getElementsByTagName("SubindexedValue");
for (int s = 0; s < subNodes.getLength(); s++) {
final Element subElement = el(subNodes, i);
final Element subElement = el(subNodes, s);
final String subindex = attr(subElement, "subindex");
if (subindex == null) continue; // invalid <SubindexedValue> element
final String sValue = attr(subElement, "value");
final String sDescription = attr(subElement, "description");
subSubTable.put(index, new ValueItem(sValue, sDescription));
subSubTable.put(subindex, new ValueItem(sValue, sDescription));
}
}
}
Expand Down

0 comments on commit 073ddc2

Please sign in to comment.