/** * This method responds to the contents of tags in a way determined by the name of the tag (as * determined by the startElement method). */ public void characters(char[] ch, int start, int length) { String contents = new String(ch, start, length); if (tag_identifier == 1) classes.add(contents); else if (tag_identifier == 2) meta_data_info.add(contents); else if (tag_identifier == 3) current_root_classification.identifier = contents; else if (tag_identifier == 4) current_root_classification.role = contents; else if (tag_identifier == 5) current_subset_classification.start = Double.parseDouble(contents); else if (tag_identifier == 6) current_subset_classification.stop = Double.parseDouble(contents); }
/** * This method is called when the end tag of an XML element is encountered. * * @param name Name of the element that is encountered. */ public void endElement(String namespace, String name, String qName) { if (name.equals("data_set")) { // Store the classes in current_root_classification if (classes != null) { Object[] obj = (Object[]) classes.toArray(); String[] str = new String[obj.length]; for (int i = 0; i < str.length; i++) str[i] = (String) obj[i]; current_root_classification.classifications = str; } // Store the meta_data_keys in current_root_classification if (meta_data_keys != null) { Object[] obj = (Object[]) meta_data_keys.toArray(); String[] str = new String[obj.length]; for (int i = 0; i < str.length; i++) str[i] = (String) obj[i]; current_root_classification.misc_info_key = str; } // Store the meta_data_info in current_root_classification if (meta_data_info != null) { Object[] obj = (Object[]) meta_data_info.toArray(); String[] str = new String[obj.length]; for (int i = 0; i < str.length; i++) str[i] = (String) obj[i]; current_root_classification.misc_info_info = str; } // Store the sub-sets of the data set (null if none) if (subset_classifications != null) { Object[] obj = (Object[]) subset_classifications.toArray(); SegmentedClassification[] sc = new SegmentedClassification[obj.length]; for (int i = 0; i < sc.length; i++) sc[i] = (SegmentedClassification) obj[i]; current_root_classification.sub_classifications = sc; } // Reset variables classes = null; meta_data_keys = null; meta_data_info = null; subset_classifications = null; current_root_classification = null; } else if (name.equals("section")) { // Store the classes in current_subset_classification if (classes != null) { Object[] obj = (Object[]) classes.toArray(); String[] str = new String[obj.length]; for (int i = 0; i < str.length; i++) str[i] = (String) obj[i]; current_subset_classification.classifications = str; } // Reset variables classes = null; current_subset_classification = null; } }