Java Code Examples for javax.xml.stream.XMLStreamReader#getAttributeLocalName()
The following examples show how to use
javax.xml.stream.XMLStreamReader#getAttributeLocalName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OutboundReferenceParameterHeader.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * We don't really expect this to be used, but just to satisfy * the {@link Header} contract. * * So this is rather slow. */ private void parseAttributes() { try { XMLStreamReader reader = readHeader(); reader.nextTag(); // move to the first element, which is the header element attributes = new FinalArrayList<Attribute>(); boolean refParamAttrWritten = false; for (int i = 0; i < reader.getAttributeCount(); i++) { final String attrLocalName = reader.getAttributeLocalName(i); final String namespaceURI = reader.getAttributeNamespace(i); final String value = reader.getAttributeValue(i); if (namespaceURI.equals(AddressingVersion.W3C.nsUri)&& attrLocalName.equals("IS_REFERENCE_PARAMETER")) { refParamAttrWritten = true; } attributes.add(new Attribute(namespaceURI,attrLocalName,value)); } // we are adding one more attribute "wsa:IsReferenceParameter", if its not alrady there if (!refParamAttrWritten) { attributes.add(new Attribute(AddressingVersion.W3C.nsUri,IS_REFERENCE_PARAMETER,TRUE_VALUE)); } } catch (XMLStreamException e) { throw new WebServiceException("Unable to read the attributes for {"+nsUri+"}"+localName+" header",e); } }
Example 2
Source File: OutboundReferenceParameterHeader.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * We don't really expect this to be used, but just to satisfy * the {@link Header} contract. * * So this is rather slow. */ private void parseAttributes() { try { XMLStreamReader reader = readHeader(); reader.nextTag(); // move to the first element, which is the header element attributes = new FinalArrayList<Attribute>(); boolean refParamAttrWritten = false; for (int i = 0; i < reader.getAttributeCount(); i++) { final String attrLocalName = reader.getAttributeLocalName(i); final String namespaceURI = reader.getAttributeNamespace(i); final String value = reader.getAttributeValue(i); if (namespaceURI.equals(AddressingVersion.W3C.nsUri)&& attrLocalName.equals("IS_REFERENCE_PARAMETER")) { refParamAttrWritten = true; } attributes.add(new Attribute(namespaceURI,attrLocalName,value)); } // we are adding one more attribute "wsa:IsReferenceParameter", if its not alrady there if (!refParamAttrWritten) { attributes.add(new Attribute(AddressingVersion.W3C.nsUri,IS_REFERENCE_PARAMETER,TRUE_VALUE)); } } catch (XMLStreamException e) { throw new WebServiceException("Unable to read the attributes for {"+nsUri+"}"+localName+" header",e); } }
Example 3
Source File: OutboundStreamHeader.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * We don't really expect this to be used, but just to satisfy * the {@link Header} contract. * * So this is rather slow. */ private void parseAttributes() { try { XMLStreamReader reader = readHeader(); attributes = new FinalArrayList<Attribute>(); for (int i = 0; i < reader.getAttributeCount(); i++) { final String localName = reader.getAttributeLocalName(i); final String namespaceURI = reader.getAttributeNamespace(i); final String value = reader.getAttributeValue(i); attributes.add(new Attribute(namespaceURI,localName,value)); } } catch (XMLStreamException e) { throw new WebServiceException("Unable to read the attributes for {"+nsUri+"}"+localName+" header",e); } }
Example 4
Source File: OutboundStreamHeader.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * We don't really expect this to be used, but just to satisfy * the {@link Header} contract. * * So this is rather slow. */ private void parseAttributes() { try { XMLStreamReader reader = readHeader(); attributes = new FinalArrayList<Attribute>(); for (int i = 0; i < reader.getAttributeCount(); i++) { final String localName = reader.getAttributeLocalName(i); final String namespaceURI = reader.getAttributeNamespace(i); final String value = reader.getAttributeValue(i); attributes.add(new Attribute(namespaceURI,localName,value)); } } catch (XMLStreamException e) { throw new WebServiceException("Unable to read the attributes for {"+nsUri+"}"+localName+" header",e); } }
Example 5
Source File: DatabaseIO.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
/** * Returns the value of the indicated attribute of the current element as a boolean. * If the value is not a valid boolean, then an exception is thrown. * * @param xmlReader The xml reader * @param attributeIdx The index of the attribute * @return The attribute's value as a boolean */ private boolean getAttributeValueAsBoolean(XMLStreamReader xmlReader, int attributeIdx) throws DdlUtilsXMLException { String value = xmlReader.getAttributeValue(attributeIdx); if ("true".equalsIgnoreCase(value)) { return true; } else if ("false".equalsIgnoreCase(value)) { return false; } else { throw new DdlUtilsXMLException("Illegal boolean value '" + value +"' for attribute " + xmlReader.getAttributeLocalName(attributeIdx)); } }
Example 6
Source File: OutboundStreamHeader.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * We don't really expect this to be used, but just to satisfy * the {@link Header} contract. * * So this is rather slow. */ private void parseAttributes() { try { XMLStreamReader reader = readHeader(); attributes = new FinalArrayList<Attribute>(); for (int i = 0; i < reader.getAttributeCount(); i++) { final String localName = reader.getAttributeLocalName(i); final String namespaceURI = reader.getAttributeNamespace(i); final String value = reader.getAttributeValue(i); attributes.add(new Attribute(namespaceURI,localName,value)); } } catch (XMLStreamException e) { throw new WebServiceException("Unable to read the attributes for {"+nsUri+"}"+localName+" header",e); } }
Example 7
Source File: OutboundReferenceParameterHeader.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * We don't really expect this to be used, but just to satisfy * the {@link Header} contract. * * So this is rather slow. */ private void parseAttributes() { try { XMLStreamReader reader = readHeader(); reader.nextTag(); // move to the first element, which is the header element attributes = new FinalArrayList<Attribute>(); boolean refParamAttrWritten = false; for (int i = 0; i < reader.getAttributeCount(); i++) { final String attrLocalName = reader.getAttributeLocalName(i); final String namespaceURI = reader.getAttributeNamespace(i); final String value = reader.getAttributeValue(i); if (namespaceURI.equals(AddressingVersion.W3C.nsUri)&& attrLocalName.equals("IS_REFERENCE_PARAMETER")) { refParamAttrWritten = true; } attributes.add(new Attribute(namespaceURI,attrLocalName,value)); } // we are adding one more attribute "wsa:IsReferenceParameter", if its not alrady there if (!refParamAttrWritten) { attributes.add(new Attribute(AddressingVersion.W3C.nsUri,IS_REFERENCE_PARAMETER,TRUE_VALUE)); } } catch (XMLStreamException e) { throw new WebServiceException("Unable to read the attributes for {"+nsUri+"}"+localName+" header",e); } }
Example 8
Source File: XlsUtils.java From data-prep with Apache License 2.0 | 6 votes |
/** * transform all attributes to a Map (key: att name, value: att value) * * @param streamReader * @return */ private static Map<String, String> getAttributesNameValue(XMLStreamReader streamReader) { int size = streamReader.getAttributeCount(); if (size > 0) { Map<String, String> attributesValues = new HashMap<>(size); for (int i = 0; i < size; i++) { String attributeName = streamReader.getAttributeLocalName(i); String attributeValue = streamReader.getAttributeValue(i); if (StringUtils.isNotEmpty(attributeName)) { attributesValues.put(attributeName, attributeValue); } } return attributesValues; } return Collections.emptyMap(); }
Example 9
Source File: StreamHeader12.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
protected final FinalArrayList<Attribute> processHeaderAttributes(XMLStreamReader reader) { FinalArrayList<Attribute> atts = null; _role = SOAPConstants.URI_SOAP_1_2_ROLE_ULTIMATE_RECEIVER; for (int i = 0; i < reader.getAttributeCount(); i++) { final String localName = reader.getAttributeLocalName(i); final String namespaceURI = reader.getAttributeNamespace(i); final String value = reader.getAttributeValue(i); if (SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE.equals(namespaceURI)) { if (SOAP_1_2_MUST_UNDERSTAND.equals(localName)) { _isMustUnderstand = Util.parseBool(value); } else if (SOAP_1_2_ROLE.equals(localName)) { if (value != null && value.length() > 0) { _role = value; } } else if (SOAP_1_2_RELAY.equals(localName)) { _isRelay = Util.parseBool(value); } } if(atts==null) { atts = new FinalArrayList<Attribute>(); } atts.add(new Attribute(namespaceURI,localName,value)); } return atts; }
Example 10
Source File: StreamWriterFacade.java From yangtools with Eclipse Public License 1.0 | 5 votes |
private void forwardAttributes(final XMLStreamReader reader) throws XMLStreamException { for (int i = 0, count = reader.getAttributeCount(); i < count; ++i) { final String localName = reader.getAttributeLocalName(i); final String value = reader.getAttributeValue(i); final String prefix = reader.getAttributePrefix(i); if (prefix != null) { writer.writeAttribute(prefix, reader.getAttributeNamespace(i), localName, value); } else { writer.writeAttribute(localName, value); } } }
Example 11
Source File: StreamHeader12.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
protected final FinalArrayList<Attribute> processHeaderAttributes(XMLStreamReader reader) { FinalArrayList<Attribute> atts = null; _role = SOAPConstants.URI_SOAP_1_2_ROLE_ULTIMATE_RECEIVER; for (int i = 0; i < reader.getAttributeCount(); i++) { final String localName = reader.getAttributeLocalName(i); final String namespaceURI = reader.getAttributeNamespace(i); final String value = reader.getAttributeValue(i); if (SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE.equals(namespaceURI)) { if (SOAP_1_2_MUST_UNDERSTAND.equals(localName)) { _isMustUnderstand = Util.parseBool(value); } else if (SOAP_1_2_ROLE.equals(localName)) { if (value != null && value.length() > 0) { _role = value; } } else if (SOAP_1_2_RELAY.equals(localName)) { _isRelay = Util.parseBool(value); } } if(atts==null) { atts = new FinalArrayList<Attribute>(); } atts.add(new Attribute(namespaceURI,localName,value)); } return atts; }
Example 12
Source File: StreamHeader11.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
protected final FinalArrayList<Attribute> processHeaderAttributes(XMLStreamReader reader) { FinalArrayList<Attribute> atts = null; _role = SOAPConstants.URI_SOAP_ACTOR_NEXT; for (int i = 0; i < reader.getAttributeCount(); i++) { final String localName = reader.getAttributeLocalName(i); final String namespaceURI = reader.getAttributeNamespace(i); final String value = reader.getAttributeValue(i); if (SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE.equals(namespaceURI)) { if (SOAP_1_1_MUST_UNDERSTAND.equals(localName)) { _isMustUnderstand = Util.parseBool(value); } else if (SOAP_1_1_ROLE.equals(localName)) { if (value != null && value.length() > 0) { _role = value; } } } if(atts==null) { atts = new FinalArrayList<Attribute>(); } atts.add(new Attribute(namespaceURI,localName,value)); } return atts; }
Example 13
Source File: StreamHeader11.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
protected final FinalArrayList<Attribute> processHeaderAttributes(XMLStreamReader reader) { FinalArrayList<Attribute> atts = null; _role = SOAPConstants.URI_SOAP_ACTOR_NEXT; for (int i = 0; i < reader.getAttributeCount(); i++) { final String localName = reader.getAttributeLocalName(i); final String namespaceURI = reader.getAttributeNamespace(i); final String value = reader.getAttributeValue(i); if (SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE.equals(namespaceURI)) { if (SOAP_1_1_MUST_UNDERSTAND.equals(localName)) { _isMustUnderstand = Util.parseBool(value); } else if (SOAP_1_1_ROLE.equals(localName)) { if (value != null && value.length() > 0) { _role = value; } } } if(atts==null) { atts = new FinalArrayList<Attribute>(); } atts.add(new Attribute(namespaceURI,localName,value)); } return atts; }
Example 14
Source File: StreamHeader12.java From hottub with GNU General Public License v2.0 | 5 votes |
protected final FinalArrayList<Attribute> processHeaderAttributes(XMLStreamReader reader) { FinalArrayList<Attribute> atts = null; _role = SOAPConstants.URI_SOAP_1_2_ROLE_ULTIMATE_RECEIVER; for (int i = 0; i < reader.getAttributeCount(); i++) { final String localName = reader.getAttributeLocalName(i); final String namespaceURI = reader.getAttributeNamespace(i); final String value = reader.getAttributeValue(i); if (SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE.equals(namespaceURI)) { if (SOAP_1_2_MUST_UNDERSTAND.equals(localName)) { _isMustUnderstand = Util.parseBool(value); } else if (SOAP_1_2_ROLE.equals(localName)) { if (value != null && value.length() > 0) { _role = value; } } else if (SOAP_1_2_RELAY.equals(localName)) { _isRelay = Util.parseBool(value); } } if(atts==null) { atts = new FinalArrayList<Attribute>(); } atts.add(new Attribute(namespaceURI,localName,value)); } return atts; }
Example 15
Source File: StreamHeader11.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
protected final FinalArrayList<Attribute> processHeaderAttributes(XMLStreamReader reader) { FinalArrayList<Attribute> atts = null; _role = SOAPConstants.URI_SOAP_ACTOR_NEXT; for (int i = 0; i < reader.getAttributeCount(); i++) { final String localName = reader.getAttributeLocalName(i); final String namespaceURI = reader.getAttributeNamespace(i); final String value = reader.getAttributeValue(i); if (SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE.equals(namespaceURI)) { if (SOAP_1_1_MUST_UNDERSTAND.equals(localName)) { _isMustUnderstand = Util.parseBool(value); } else if (SOAP_1_1_ROLE.equals(localName)) { if (value != null && value.length() > 0) { _role = value; } } } if(atts==null) { atts = new FinalArrayList<Attribute>(); } atts.add(new Attribute(namespaceURI,localName,value)); } return atts; }
Example 16
Source File: MetricsDefManager.java From mysql_perf_analyzer with Apache License 2.0 | 4 votes |
/** * Parse metricsGroup attributes * @param reader * @return */ private MetricsGroup parseMetricsGroupAttribute(XMLStreamReader reader) { int attrCount2 = reader.getAttributeCount(); HashMap<String, String> pairs = new HashMap<String, String>(11); for(int i=0;i<attrCount2;i++) { String attrName = reader.getAttributeLocalName(i); String attrValue = reader.getAttributeValue(i); pairs.put(attrName, attrValue); } //group name, cannot be blank or missing String name = pairs.get("name"); if (name == null || name.isEmpty())return null; name = name.trim().toUpperCase(); String sql = pairs.get("sql"); String singleRow = pairs.get("multipleMetricsPerRow"); String nameColumn = pairs.get("nameColumn"); String valueColumn = pairs.get("valueColumn"); String storeInCommonTable = pairs.get("storeInCommonTable"); String targetTable = pairs.get("targetTable"); String isAuto = pairs.get("auto"); String keyColumn = pairs.get("keyColumn"); logger.info("Parsing metric group: "+ name); MetricsGroup mg = new MetricsGroup(name); mg.setMetricNameColumn(nameColumn); mg.setMetricValueColumn(valueColumn); mg.setMultipleMetricsPerRow("y".equalsIgnoreCase(singleRow)); mg.setSql(sql); mg.setStoreInCommonTable("y".equalsIgnoreCase(storeInCommonTable)); mg.setTargetTable(targetTable); if("n".equalsIgnoreCase(isAuto)) mg.setAuto(false); else mg.setAuto(true); if(keyColumn != null && !keyColumn.isEmpty()) mg.setKeyColumn(keyColumn); return mg; }
Example 17
Source File: DsParser.java From ironjacamar with Eclipse Public License 1.0 | 4 votes |
/** * * Parse recovery tag * * @param reader reader * @return the parsed recovery object * @throws XMLStreamException in case of error * @throws ParserException in case of error * @throws ValidateException in case of error */ @Override protected Recovery parseRecovery(XMLStreamReader reader) throws XMLStreamException, ParserException, ValidateException { Boolean noRecovery = Defaults.NO_RECOVERY; Credential security = null; Extension plugin = null; Map<String, String> expressions = new HashMap<String, String>(); for (int i = 0; i < reader.getAttributeCount(); i++) { switch (reader.getAttributeLocalName(i)) { case XML.ATTRIBUTE_NO_RECOVERY : { noRecovery = attributeAsBoolean(reader, XML.ATTRIBUTE_NO_RECOVERY, Boolean.FALSE, expressions); break; } default : break; } } while (reader.hasNext()) { switch (reader.nextTag()) { case END_ELEMENT : { switch (reader.getLocalName()) { case XML.ELEMENT_RECOVERY : return new RecoveryImpl(security, plugin, noRecovery, !expressions.isEmpty() ? expressions : null); case XML.ELEMENT_RECOVERY_CREDENTIAL : case XML.ELEMENT_RECOVERY_PLUGIN : break; default : throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName())); } } case START_ELEMENT : { switch (reader.getLocalName()) { case XML.ELEMENT_RECOVERY_CREDENTIAL : { security = parseCredential(reader); break; } case XML.ELEMENT_RECOVERY_PLUGIN : { plugin = parseExtension(reader, XML.ELEMENT_RECOVERY_PLUGIN); break; } default : throw new ParserException(bundle.unexpectedElement(reader.getLocalName())); } break; } } } throw new ParserException(bundle.unexpectedEndOfDocument()); }
Example 18
Source File: AbstractParser.java From ironjacamar with Eclipse Public License 1.0 | 4 votes |
/** * * Parse recovery tag * * @param reader reader * @return the parsed recovery object * @throws XMLStreamException in case of error * @throws ParserException in case of error * @throws ValidateException in case of error */ protected Recovery parseRecovery(XMLStreamReader reader) throws XMLStreamException, ParserException, ValidateException { Boolean noRecovery = Defaults.NO_RECOVERY; Credential security = null; Extension plugin = null; Map<String, String> expressions = new HashMap<String, String>(); for (int i = 0; i < reader.getAttributeCount(); i++) { switch (reader.getAttributeLocalName(i)) { case CommonXML.ATTRIBUTE_NO_RECOVERY : { noRecovery = attributeAsBoolean(reader, CommonXML.ATTRIBUTE_NO_RECOVERY, Boolean.FALSE, expressions); break; } default : break; } } while (reader.hasNext()) { switch (reader.nextTag()) { case END_ELEMENT : { switch (reader.getLocalName()) { case CommonXML.ELEMENT_RECOVERY : return new RecoveryImpl(security, plugin, noRecovery, !expressions.isEmpty() ? expressions : null); case CommonXML.ELEMENT_RECOVERY_CREDENTIAL : case CommonXML.ELEMENT_RECOVERY_PLUGIN : break; default : throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName())); } } case START_ELEMENT : { switch (reader.getLocalName()) { case CommonXML.ELEMENT_RECOVERY_CREDENTIAL : { security = parseCredential(reader); break; } case CommonXML.ELEMENT_RECOVERY_PLUGIN : { plugin = parseExtension(reader, CommonXML.ELEMENT_RECOVERY_PLUGIN); break; } default : throw new ParserException(bundle.unexpectedElement(reader.getLocalName())); } break; } } } throw new ParserException(bundle.unexpectedEndOfDocument()); }
Example 19
Source File: ResultListUtil.java From mysql_perf_analyzer with Apache License 2.0 | 4 votes |
private static List<BindVariable> parseBinds(String binds, XMLInputFactory inputFactory) { if(binds==null)return null; List<BindVariable> vars = new java.util.ArrayList<BindVariable>(); //<binds><bind name=":1" pos="1" dty="1" dtystr="VARCHAR2(2000)" maxlen="2000" csid="873" len="15">Billing Contact</bind></binds> java.io.CharArrayReader in = new java.io.CharArrayReader(binds.toCharArray()); XMLStreamReader reader = null; try { reader = inputFactory.createXMLStreamReader(in); while(reader.hasNext()) { //loop till one sql tag is found int evtType = reader.next(); if(evtType!=XMLStreamConstants.START_ELEMENT)continue; String tagName = reader.getLocalName(); if(!"bind".equals(tagName))continue; BindVariable var = new BindVariable(); int attrCount = reader.getAttributeCount(); for(int i=0;i<attrCount;i++) { String attrName = reader.getAttributeLocalName(i); String attrValue = reader.getAttributeValue(i); if("name".equals(attrName)) var.name = attrValue; else if("pos".equals(attrName)) var.pos = attrValue; else if("dtystr".equalsIgnoreCase(attrName)) var.dtystr = attrValue; else if("maxlen".equalsIgnoreCase(attrName)) { var.maxLen = attrValue; }else if("len".equalsIgnoreCase(attrName)) { var.len = attrValue; } } var.value = reader.getElementText(); vars.add(var); } }catch(Exception ex) { } finally { if(reader!=null)try{reader.close(); reader=null;}catch(Exception iex){} } return vars; }
Example 20
Source File: MetricsDefManager.java From mysql_perf_analyzer with Apache License 2.0 | 4 votes |
private Metric parseMetric(XMLStreamReader reader) { //assume current tag is metric int attrCount2 = reader.getAttributeCount(); HashMap<String, String> pairs = new HashMap<String, String>(11); for(int i=0;i<attrCount2;i++) { String attrName = reader.getAttributeLocalName(i); String attrValue = reader.getAttributeValue(i); pairs.put(attrName, attrValue); } String mname = pairs.get("name"); if(mname == null || mname.isEmpty()) { logger.warning("METRICS column has no name, ignore it."); return null; } mname = mname.trim().toUpperCase(); //if cannot be retrieved by both sourceName and mnane, try altname String mdbname = pairs.get("sourceName"); if (mdbname == null || mdbname.isEmpty()) mdbname = pairs.get("name"); String altName = pairs.get("altName"); String mdesc = pairs.get("description"); String mdataType = pairs.get("dataType"); MetricDataType md = MetricDataType.INT; if("float".equalsIgnoreCase(mdataType))md = MetricDataType.FLOAT; else if("double".equalsIgnoreCase(mdataType))md = MetricDataType.DOUBLE; else if("long".equalsIgnoreCase(mdataType))md = MetricDataType.LONG; else if("byte".equalsIgnoreCase(mdataType))md = MetricDataType.BYTE; else if("short".equalsIgnoreCase(mdataType))md = MetricDataType.SHORT; String munit = pairs.get("unit"); String mincremental = pairs.get("incremental"); String madj = pairs.get("adjustment"); String mavg = pairs.get("averageTimeUnit"); String mdisplay = pairs.get("chartDisplayUnit"); Metric m = new Metric(mname, mdbname, md, munit, mdesc, "y".equalsIgnoreCase(mincremental)); if(altName != null) m.setAltName(altName); if(mavg!=null)m.setAverageTimeUnit(mavg); if(madj!=null)m.setAdjustment(madj); if(mdisplay!=null)m.setChartDisplayUnit(mdisplay); return m; }