public void startElement( String uri, String localName, String qName, org.xml.sax.Attributes atts) throws SAXException { if (DICTIONARY_ELEMENT.equals(localName)) { mAttributes = new Attributes(); for (int i = 0; i < atts.getLength(); i++) { mAttributes.setValue(atts.getLocalName(i), atts.getValue(i)); } /* get the attribute here ... */ if (mAttributes.getValue(ATTRIBUTE_CASE_SENSITIVE) != null) { mIsCaseSensitiveDictionary = Boolean.valueOf(mAttributes.getValue(ATTRIBUTE_CASE_SENSITIVE)); } mAttributes = null; } else if (ENTRY_ELEMENT.equals(localName)) { mAttributes = new Attributes(); for (int i = 0; i < atts.getLength(); i++) { mAttributes.setValue(atts.getLocalName(i), atts.getValue(i)); } } else if (TOKEN_ELEMENT.equals(localName)) { mIsInsideTokenElement = true; } }
public void init(String name, Attributes atts) { logger.log(LogService.LOG_DEBUG, "Here is IconHandler:init()"); // $NON-NLS-1$ super.init(name, atts); String icon_resource_val = atts.getValue(RESOURCE); if (icon_resource_val == null) { _isParsedDataValid = false; logger.log( LogService.LOG_ERROR, NLS.bind( MetaTypeMsg.MISSING_ATTRIBUTE, new Object[] { RESOURCE, name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName() })); return; } String icon_size_val = atts.getValue(SIZE); if (icon_size_val == null) { // Not a problem, because SIZE is an optional attribute. icon_size_val = "0"; // $NON-NLS-1$ } else if (icon_size_val.equalsIgnoreCase("")) { // $NON-NLS-1$ icon_size_val = "0"; // $NON-NLS-1$ } _icon = new Icon(icon_resource_val, Integer.parseInt(icon_size_val), _dp_bundle); }
public void init( String name, Attributes atts, Hashtable<String, ObjectClassDefinitionImpl> ocds_hashtable) { logger.log(LogService.LOG_DEBUG, "Here is OcdHandler():init()"); // $NON-NLS-1$ super.init(name, atts); _parent_OCDs_hashtable = ocds_hashtable; collectExtensionAttributes(atts); String ocd_name_val = atts.getValue(NAME); if (ocd_name_val == null) { _isParsedDataValid = false; logger.log( LogService.LOG_ERROR, NLS.bind( MetaTypeMsg.MISSING_ATTRIBUTE, new Object[] { NAME, name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName() })); return; } String ocd_description_val = atts.getValue(DESCRIPTION); if (ocd_description_val == null) { // Not a problem, because DESCRIPTION is an optional attribute. } _refID = atts.getValue(ID); if (_refID == null) { _isParsedDataValid = false; logger.log( LogService.LOG_ERROR, NLS.bind( MetaTypeMsg.MISSING_ATTRIBUTE, new Object[] { ID, name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName() })); return; } _ocd = new ObjectClassDefinitionImpl( ocd_name_val, ocd_description_val, _refID, _dp_localization, extensionAttributes); }
public void startElement(String uri, String sName, String qName, Attributes attrs) { if (qName.equals("PROPSTABLE")) { // LogUtil.fine(attrs.getValue("DESC")); propsAl = new ArrayList(); } else if (qName.equals("PROPSROW")) { curPROPSROW_DESC = attrs.getValue("DESC"); curProps = new Properties(); } else { // LogUtil.fine(qName); curKEY_DESC = attrs.getValue("DESC"); curKey = qName; textFlag = true; } }
public void startElement(String uri, String localName, String qName, Attributes atts) { logger.log( LogService.LOG_DEBUG, "Here is ObjectHandler:startElement():" //$NON-NLS-1$ + qName); if (!_isParsedDataValid) return; String name = getName(localName, qName); if (name.equalsIgnoreCase(ATTRIBUTE)) { AttributeHandler attributeHandler = new AttributeHandler(this); attributeHandler.init(name, atts); // The ATTRIBUTE element is only used by RFC94, do nothing for it here. } else { logger.log( LogService.LOG_WARNING, NLS.bind( MetaTypeMsg.UNEXPECTED_ELEMENT, new Object[] { name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName() })); } }
public void startElement(String uri, String localName, String qName, Attributes atts) { logger.log( LogService.LOG_DEBUG, "Here is MetaDataHandler:startElement():" //$NON-NLS-1$ + qName); String name = getName(localName, qName); if (name.equalsIgnoreCase(DESIGNATE)) { DesignateHandler designateHandler = new DesignateHandler(this); designateHandler.init(name, atts); if (designateHandler._isParsedDataValid) { _dp_designateHandlers.addElement(designateHandler); } } else if (name.equalsIgnoreCase(OCD)) { OcdHandler ocdHandler = new OcdHandler(this); ocdHandler.init(name, atts, _dp_OCDs); } else { logger.log( LogService.LOG_WARNING, NLS.bind( MetaTypeMsg.UNEXPECTED_ELEMENT, new Object[] { name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName() })); } }
public static String saxElementToDebugString(String uri, String qName, Attributes attributes) { // Open start tag final StringBuilder sb = new StringBuilder("<"); sb.append(qName); final Set<String> declaredPrefixes = new HashSet<String>(); mapPrefixIfNeeded(declaredPrefixes, uri, qName, sb); // Attributes if any for (int i = 0; i < attributes.getLength(); i++) { mapPrefixIfNeeded(declaredPrefixes, attributes.getURI(i), attributes.getQName(i), sb); sb.append(' '); sb.append(attributes.getQName(i)); sb.append("=\""); sb.append(attributes.getValue(i)); sb.append('\"'); } // Close start tag sb.append('>'); // Content sb.append("[...]"); // Close element with end tag sb.append("</"); sb.append(qName); sb.append('>'); return sb.toString(); }
public void startElement(String uri, String localName, String qName, Attributes atts) { logger.log( LogService.LOG_DEBUG, "Here is OcdHandler:startElement():" //$NON-NLS-1$ + qName); if (!_isParsedDataValid) return; String name = getName(localName, qName); if (name.equalsIgnoreCase(AD)) { AttributeDefinitionHandler attributeDefHandler = new AttributeDefinitionHandler(this); attributeDefHandler.init(name, atts, _ad_vector); } else if (name.equalsIgnoreCase(ICON)) { IconHandler iconHandler = new IconHandler(this); iconHandler.init(name, atts); if (iconHandler._isParsedDataValid) icons.add(iconHandler._icon); } else { logger.log( LogService.LOG_WARNING, NLS.bind( MetaTypeMsg.UNEXPECTED_ELEMENT, new Object[] { name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName() })); } }
public void startElement(String uri, String localName, String qName, Attributes atts) { logger.log( LogService.LOG_DEBUG, "Here is AttributeDefinitionHandler:startElement():" //$NON-NLS-1$ + qName); if (!_isParsedDataValid) return; String name = getName(localName, qName); if (name.equalsIgnoreCase(OPTION)) { OptionHandler optionHandler = new OptionHandler(this); optionHandler.init(name, atts); if (optionHandler._isParsedDataValid) { // Only add valid Option _optionLabel_vector.addElement(optionHandler._label_val); _optionValue_vector.addElement(optionHandler._value_val); } } else { logger.log( LogService.LOG_WARNING, NLS.bind( MetaTypeMsg.UNEXPECTED_ELEMENT, new Object[] { name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName() })); } }
@Override public void startElement(String namespaceURI, String localName, String raxName, Attributes atts) throws SAXException { try { if (raxName.equals("xmwp:security")) { message.setKey(atts.getValue("key")); } else if (raxName.equals("request")) { request = true; inform = false; } else if (raxName.equals("inform")) { inform = true; request = false; } else { // INFORM elements if (inform) { message.addInform(getInformXMWPElement(namespaceURI, localName, raxName, atts)); } // REQUEST elements else if (request) { message.addRequest(getRequestXMWPElement(namespaceURI, localName, raxName, atts)); } } } catch (XMWPException e) { throw new SAXException(e); } }
public void startElement(String uri, String localName, String qName, Attributes atts) { logger.log( LogService.LOG_DEBUG, "Here is DesignateHandler:startElement():" //$NON-NLS-1$ + qName); if (!_isParsedDataValid) return; String name = getName(localName, qName); if (name.equalsIgnoreCase(OBJECT)) { ObjectHandler objectHandler = new ObjectHandler(this); objectHandler.init(name, atts); if (objectHandler._isParsedDataValid) { _ocdref = objectHandler._ocdref; } } else { logger.log( LogService.LOG_WARNING, NLS.bind( MetaTypeMsg.UNEXPECTED_ELEMENT, new Object[] { name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName() })); } }
public void startElement(String nm, String ln, String qn, Attributes as) throws SAXException { if (level++ == 0) for (int i = 0; i < as.getLength(); i++) if (attributename.equals("*") || attributename.equals(as.getQName(i))) { char[] s = as.getValue(i).toCharArray(); next.characters(s, 0, s.length); } }
/** * Processes xml:language reference is there is one. * * @param atts the attributes potentially containing xml:language declaration */ private void processXMLLanguage(@Nonnull Attributes atts) { checkNotNull(atts, "atts cannot be null"); languages.add(0, language); String value = atts.getValue(XMLLANG); if (value != null) { language = value; } }
public void startElement(String uri, String localName, String qname, Attributes atts) { super.startElement(uri, localName, qname, atts); if (localName.equals(DataExport.FIELD_EXPORT)) { String type = atts.getValue(DataExport.EXPORT_TYPE); textImport = (type != null && type.equals(DataExport.EXPORT_TYPE_TEXT)); } else if (localName.equals(DataRecord.ENCODING_RECORD)) { // begin of record record = dataAccess.getPersistence().createNewRecord(); fieldsInImport = new ArrayList<String>(); return; } else { if (atts.getValue("key") != null && atts.getValue("key").equalsIgnoreCase("true")) { overrideKeyField = localName; } } }
public void startElement( String namespaceURI, String lName, // local name String qName, // qualified name Attributes attrs) throws SAXException { element = qName; if (element.compareToIgnoreCase("presence") == 0) { presenceTag = new PresenceTag(); String entity = attrs.getValue("entity").trim(); presenceTag.setEntity(entity); } if (element.compareToIgnoreCase("presentity") == 0) { presentityTag = new PresentityTag(); String id = attrs.getValue("id").trim(); presentityTag.setId(id); } if (element.compareToIgnoreCase("tuple") == 0) { tupleTag = new TupleTag(); String id = attrs.getValue("id").trim(); tupleTag.setId(id); } if (element.compareToIgnoreCase("status") == 0) { statusTag = new StatusTag(); } if (element.compareToIgnoreCase("basic") == 0) { basicTag = new BasicTag(); } if (element.compareToIgnoreCase("contact") == 0) { contactTag = new ContactTag(); String priority = attrs.getValue("priority").trim(); if (priority != null) { try { contactTag.setPriority(Float.parseFloat(priority)); } catch (Exception e) { e.printStackTrace(); } } } if (element.compareToIgnoreCase("note") == 0) { noteTag = new NoteTag(); } }
public void init(String name, Attributes attributes) { logger.log(LogService.LOG_DEBUG, "Here is MetaDataHandler():init()"); // $NON-NLS-1$ super.init(name, attributes); _dp_localization = attributes.getValue(LOCALIZATION); if (_dp_localization == null) { // Not a problem, because LOCALIZATION is an optional attribute. } // The global variable "_dp_localization" will be used within // OcdHandler and AttributeDefinitionHandler later. }
public void startElement(String uri, String name, String tag, Attributes atts) { out.append("<").append(tag); if (atts != null) for (int i = 0; i < atts.getLength(); i++) out.append(" ") .append(atts.getQName(i)) .append("=\"") .append(atts.getValue(i)) .append("\""); out.append(">"); }
public void startElement(String nm, String ln, String qn, Attributes as) throws SAXException { children = new Bag(); Bag attributes = new Bag(); for (int i = 0; i < as.getLength(); i++) attributes.add(new Tuple(new MR_string(as.getQName(i)), new MR_string(as.getValue(i)))); Tuple t = new Tuple(3); t.set(0, new MR_string(qn)); t.set(1, attributes); t.set(2, children); stack.push(new Union((byte) 0, t)); }
@Override public void handleAttributes(String elx, String localName, String el, Attributes attr) throws SAXException { setPeptideId(attr.getValue("peak")); // num="1" setScore(XTandemSaxUtilities.getRequiredDoubleAttribute("score", attr)); setRawScore(XTandemSaxUtilities.getRequiredDoubleAttribute("raw_score", attr)); setHyperScore(XTandemSaxUtilities.getRequiredDoubleAttribute("hyperscore", attr)); boolean decoy = XTandemSaxUtilities.getBooleanAttribute("decoy", attr, false); if (decoy) setDecoy(decoy); return; }
public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException { if ("row".equals(name)) { // 如果是行开始 清空cell数据 重来 rowNumber = Integer.valueOf(attributes.getValue("r")); // 当前行号 if (rowNumber == 1) { return; } currentCellData.clear(); } lastContents = ""; }
public void init(String name, Attributes atts) { logger.log(LogService.LOG_DEBUG, "Here is DesignateHandler():init()"); // $NON-NLS-1$ super.init(name, atts); _pid_val = atts.getValue(PID); _factory_val = atts.getValue(FACTORY); if (_pid_val == null && _factory_val == null) { _isParsedDataValid = false; logger.log( LogService.LOG_ERROR, NLS.bind( MetaTypeMsg.MISSING_DESIGNATE_PID_AND_FACTORYPID, new Object[] { elementId, _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName() })); return; } _bundle_val = atts.getValue(BUNDLE); if (_bundle_val == null) { // Not a problem because BUNDLE is an optional attribute. } String optional_str = atts.getValue(OPTIONAL); if (optional_str == null) { // Not a problem, because OPTIONAL is an optional attribute. // The default value is "false". _optional_val = false; } else { _optional_val = Boolean.valueOf(optional_str).booleanValue(); } String merge_str = atts.getValue(MERGE); if (merge_str == null) { // Not a problem, because MERGE is an optional attribute. // The default value is "false". _merge_val = false; } else { _merge_val = Boolean.valueOf(merge_str).booleanValue(); } }
public void init(String name, Attributes atts) { logger.log(LogService.LOG_DEBUG, "Here is OptionHandler:init()"); // $NON-NLS-1$ super.init(name, atts); _label_val = atts.getValue(LABEL); if (_label_val == null) { _isParsedDataValid = false; logger.log( LogService.LOG_ERROR, NLS.bind( MetaTypeMsg.MISSING_ATTRIBUTE, new Object[] { LABEL, name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName() })); return; } _value_val = atts.getValue(VALUE); if (_value_val == null) { _isParsedDataValid = false; logger.log( LogService.LOG_ERROR, NLS.bind( MetaTypeMsg.MISSING_ATTRIBUTE, new Object[] { VALUE, name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName() })); return; } }
public void init(String name, Attributes atts) { logger.log(LogService.LOG_DEBUG, "Here is AttributeHandler():init()"); // $NON-NLS-1$ super.init(name, atts); _adref_val = atts.getValue(ADREF); if (_adref_val == null) { _isParsedDataValid = false; logger.log( LogService.LOG_ERROR, NLS.bind( MetaTypeMsg.MISSING_ATTRIBUTE, new Object[] { ADREF, name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName() })); return; } _content_val = atts.getValue(CONTENT); if (_content_val == null) { _isParsedDataValid = false; logger.log( LogService.LOG_ERROR, NLS.bind( MetaTypeMsg.MISSING_ATTRIBUTE, new Object[] { CONTENT, name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName() })); return; } }
/** * This method is called when the start of an XML element is encountered. Instantiates new objects * when necessary and lets the characters method know what kind of action to take. * * @param name Name of the element that is encountered. * @param atts The attributes encountered. * @throws SAXException Exception thrown if is wrong type of XML file. */ public void startElement(String namespace, String name, String qName, Attributes atts) throws SAXException { // Make sure is correct file type if (count == 0) if (!name.equals("feature_vector_file") && !qName.equals("feature_vector_file")) throw new SAXException("\n\nIt is in reality of the type " + name + "."); count++; // Identify the type of tag tag_identifier = 0; if (name.equals("data_set") || qName.equals("data_set")) { // Create a new Dataset and add it to root_datasets. current_root_dataset = new DataSet(); root_datasets.add(current_root_dataset); } else if (name.equals("section") || qName.equals("section")) { // Create a new set of sub-sets of a data set if subset_datasets is null if (subset_datasets == null) subset_datasets = new LinkedList<DataSet>(); // Create a new sub-set DataSet. Place this DataSet in the list of // sub-set DataSets and gives it a reference to it's parent root // DataSet. current_subset_dataset = new DataSet(); current_subset_dataset.parent = current_root_dataset; subset_datasets.add(current_subset_dataset); // Extract the name of the DataSet from the id attribute current_subset_dataset.start = Double.parseDouble(atts.getValue(0)); current_subset_dataset.stop = Double.parseDouble(atts.getValue(1)); } else if (name.equals("feature") || qName.equals("feature")) { // Prepare the linked lists to store feature values if (feature_name_list == null) { feature_name_list = new LinkedList<String>(); feature_values_list = new LinkedList<double[]>(); } feature_indidual_values_list = new LinkedList<String>(); } else if (name.equals("data_set_id") || qName.equals("data_set_id")) tag_identifier = 1; else if (name.equals("name") || qName.equals("name")) tag_identifier = 2; else if (name.equals("v") || qName.equals("v")) tag_identifier = 3; }
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { throw new SAXException( NLS.bind( MetaTypeMsg.UNEXPECTED_ELEMENT, new Object[] { qName, attributes.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName() })); }
/** * @param attributes source attributes * @return new AttributesImpl containing all attributes that were in src attributes and that were * in the default name space. */ public static AttributesImpl getAttributesFromDefaultNamespace(final Attributes attributes) { final AttributesImpl ret = new AttributesImpl(); final int size = attributes.getLength(); for (int i = 0; i < size; i++) { final String ns = attributes.getURI(i); if (!"".equals(ns)) continue; final String lnam = attributes.getLocalName(i); final String qnam = attributes.getQName(i); final String typ = attributes.getType(i); final String val = attributes.getValue(i); ret.addAttribute(ns, lnam, qnam, typ, val); } return ret; }
public void cacheStartElement(String uri, String name, String tag, Attributes atts) { cached_events++; putByte((byte) 0); putString(uri); putString(name); putString(tag); if (atts != null) { putShort((short) atts.getLength()); for (int i = 0; i < atts.getLength(); i++) { putString(atts.getQName(i)); putString(atts.getValue(i)); } } else putShort((short) 0); }
@Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { curElem = true; // check for a known tag if (qName.equals("details")) { data = new HashMap<String, MissionInfo>(); mLoaded = false; } else if (qName.equals("mission")) { curName = attributes.getValue("id"); curMission = new MissionInfo(); curMission.setName(curName); } else if (qName.equals("reward")) { int level = Integer.parseInt(attributes.getValue("level")); int exp = Integer.parseInt(attributes.getValue("exp")); int gold = Integer.parseInt(attributes.getValue("gold")); curMission.setExp(level, exp); curMission.setGold(level, gold); // Log.v(tag, String.format("Diff: %d, %d, %d", level, exp, gold)); } }
/** * This method is called when the start of an XML element is encountered. Instantiates new objects * when necessary and lets the characters method know what kind of action to take. * * @param name Name of the element that is encountered. * @param atts The attributes encountered. * @throws SAXException Exception thrown if is wrong type of XML file. */ public void startElement(String namespace, String name, String qName, Attributes atts) throws SAXException { // Make sure is correct file type if (count == 0) if (!name.equals("classifications_file")) throw new SAXException("\n\nIt is in reality of the type " + name + "."); count++; // Identify the type of tag tag_identifier = 0; if (name.equals("data_set")) { // Create a new SegmentedClassification and add it to root_classifications. current_root_classification = new SegmentedClassification(); root_classifications.add(current_root_classification); } else if (name.equals("section")) { // Create a new set of sub-sets of a SegmentedClassificaiton if // subset_classifications is null if (subset_classifications == null) subset_classifications = new LinkedList<SegmentedClassification>(); // Create a new sub-set SegmentedClassificaiton. Place this // SegmentedClassificaiton in the list of sub-set SegmentedClassificaitons.. current_subset_classification = new SegmentedClassification(); subset_classifications.add(current_subset_classification); } else if (name.equals("class")) { // Create a new set of classes if classes is null if (classes == null) classes = new LinkedList<String>(); // Notify the characters method tag_identifier = 1; } else if (name.equals("misc_info")) { // Create a new set of meta_data_keys and meta_data_info // if meta_data_keys is null if (meta_data_keys == null) { meta_data_keys = new LinkedList<String>(); meta_data_info = new LinkedList<String>(); } // Extract the name of the meta-data key from the attribute // and store it meta_data_keys.add(atts.getValue(0)); // Notify the characters method tag_identifier = 2; } else if (name.equals("data_set_id")) tag_identifier = 3; else if (name.equals("role")) tag_identifier = 4; else if (name.equals("start")) tag_identifier = 5; else if (name.equals("stop")) tag_identifier = 6; }
protected void collectExtensionAttributes(Attributes attributes) { for (int i = 0; i < attributes.getLength(); i++) { String key = attributes.getURI(i); if (key.length() == 0 || key.startsWith("http://www.osgi.org/xmlns/metatype/v")) // $NON-NLS-1$ continue; Map<String, String> value = extensionAttributes.get(key); if (value == null) { value = new HashMap<String, String>(); extensionAttributes.put(key, value); } value.put( getName(attributes.getLocalName(i), attributes.getQName(i)), attributes.getValue(i)); } }