}
if (node.hasChildNodes()) {
NodeList children = node.getChildNodes();
int count = children.getLength();
if (count > 2) {
throw new IIOInvalidTreeException
("app0JFIF node cannot have > 2 children", node);
}
for (int i = 0; i < count; i++) {
Node child = children.item(i);
String name = child.getNodeName();
if (name.equals("JFXX")) {
if ((!extSegments.isEmpty()) && fromScratch) {
throw new IIOInvalidTreeException
("app0JFIF node cannot have > 1 JFXX node", node);
}
NodeList exts = child.getChildNodes();
int extCount = exts.getLength();
for (int j = 0; j < extCount; j++) {
Node ext = exts.item(j);
extSegments.add(new JFIFExtensionMarkerSegment(ext));
}
}
if (name.equals("app2ICC")) {
if ((iccSegment != null) && fromScratch) {
throw new IIOInvalidTreeException
("> 1 ICC APP2 Marker Segment not supported", node);
}
iccSegment = new ICCMarkerSegment(child);
}
}