當前位置: 首頁>>代碼示例>>Java>>正文


Java XMLStreamReader.getAttributeCount方法代碼示例

本文整理匯總了Java中javax.xml.stream.XMLStreamReader.getAttributeCount方法的典型用法代碼示例。如果您正苦於以下問題:Java XMLStreamReader.getAttributeCount方法的具體用法?Java XMLStreamReader.getAttributeCount怎麽用?Java XMLStreamReader.getAttributeCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.xml.stream.XMLStreamReader的用法示例。


在下文中一共展示了XMLStreamReader.getAttributeCount方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parseAttributes

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
/**
 * 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);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:24,代碼來源:OutboundStreamHeader.java

示例2: parseAttributes

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
/**
 * 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);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:31,代碼來源:OutboundReferenceParameterHeader.java

示例3: readPolicyReferenceElement

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
/**
 * Reads policy reference element <wsp:PolicyReference/> and returns referenced policy URI as String
 *
 * @param reader The XMLStreamReader should be in START_ELEMENT state and point to the PolicyReference element.
 * @return The URI contained in the PolicyReference
 */
public String readPolicyReferenceElement(final XMLStreamReader reader) {
    try {
        if (NamespaceVersion.resolveAsToken(reader.getName()) == XmlToken.PolicyReference) {     // "PolicyReference" element interests me
            for (int i = 0; i < reader.getAttributeCount(); i++) {
                if (XmlToken.resolveToken(reader.getAttributeName(i).getLocalPart()) == XmlToken.Uri) {
                    final String uriValue = reader.getAttributeValue(i);
                    reader.next();
                    return uriValue;
                }
            }
        }
        reader.next();
        return null;
    } catch(XMLStreamException e) {
        throw LOGGER.logSevereException(new WebServiceException(PolicyMessages.WSP_1001_XML_EXCEPTION_WHEN_PROCESSING_POLICY_REFERENCE(), e));
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:24,代碼來源:SafePolicyReader.java

示例4: readKey

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
@SuppressWarnings("unused")
private void readKey(XMLStreamReader xmlReader) {
	/*
	 * Currently, the attributes defined in GraphML for data types are not
	 * useful.
	 */
	String attrName, attrType, attrFor, attrId;

	for (int i = 0; i < xmlReader.getAttributeCount(); ++i) {
		String attr = xmlReader.getAttributeLocalName(i);

		if (attr.equalsIgnoreCase(ATTR_NAME)) {
			attrName = xmlReader.getAttributeValue(i);
		} else if (attr.equalsIgnoreCase(ATTR_TYPE)) {
			attrType = xmlReader.getAttributeValue(i);
		} else if (attr.equalsIgnoreCase(ATTR_FOR)) {
			attrFor = xmlReader.getAttributeValue(i);
		} else if (attr.equalsIgnoreCase(ATTR_ID)) {
			attrId = xmlReader.getAttributeValue(i);
		}
	}
}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:23,代碼來源:GraphMLImporter.java

示例5: testStartElement

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
@Test
public void testStartElement() {
    try {
        XMLInputFactory xif = XMLInputFactory.newInstance();
        XMLStreamReader xsr = xif.createXMLStreamReader(this.getClass().getResource(INPUT_FILE).toExternalForm(),
                this.getClass().getResourceAsStream(INPUT_FILE));

        while (xsr.hasNext()) {
            int event = xsr.next();
            if (event == XMLStreamReader.START_ELEMENT) {
                String localName = xsr.getLocalName();
                boolean print = "para".equals(localName);
                int nrOfAttr = xsr.getAttributeCount();
                if (print) {
                    Assert.assertTrue(nrOfAttr > 0, "Default attribute declared in DTD is missing");
                }

            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail("Exception occured: " + e.getMessage());
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:25,代碼來源:Bug6370703.java

示例6: readNodeData

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
private void readNodeData(XMLStreamReader xmlReader, Vertex v)
		throws XMLStreamException {
	String key = "", value = "";

	for (int i = 0; i < xmlReader.getAttributeCount(); ++i) {
		String attr = xmlReader.getAttributeLocalName(i);

		if (attr.equalsIgnoreCase(KEY)) {
			key = xmlReader.getAttributeValue(i);
		}
	}

	value = xmlReader.getElementText();
	double x = v.getPosition() != null ? v.getPosition().getX() : 0;
	double y = v.getPosition() != null ? v.getPosition().getY() : 0;
	int r = v.getFillColor().getRed(), g = v.getFillColor().getGreen(), b = v
			.getFillColor().getBlue();

	if (!value.isEmpty()) {
		if (key.equalsIgnoreCase(NODE_LABEL)) {
			v.setLabel(value);
		} else if (key.equalsIgnoreCase(NODE_X)) {
			v.setPosition(Double.parseDouble(value), y);
		} else if (key.equalsIgnoreCase(NODE_Y)) {
			v.setPosition(x, Double.parseDouble(value));
		} else if (key.equalsIgnoreCase(NODE_SIZE)) {
			v.setSize(Double.parseDouble(value));
		} else if (key.equalsIgnoreCase(NODE_R)) {
			r = Integer.parseInt(value);
			v.setFillColor(new Color(r, g, b));
		} else if (key.equalsIgnoreCase(NODE_G)) {
			g = Integer.parseInt(value);
			v.setFillColor(new Color(r, g, b));
		} else if (key.equalsIgnoreCase(NODE_B)) {
			b = Integer.parseInt(value);
			v.setFillColor(new Color(r, g, b));
		}
	}
}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:40,代碼來源:GraphMLImporter.java

示例7: readEdgeData

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
private void readEdgeData(XMLStreamReader xmlReader, Edge e)
		throws XMLStreamException {
	String key = "", value = "";

	for (int i = 0; i < xmlReader.getAttributeCount(); ++i) {
		String attr = xmlReader.getAttributeLocalName(i);

		if (attr.equalsIgnoreCase(KEY)) {
			key = xmlReader.getAttributeValue(i);
		}
	}

	value = xmlReader.getElementText();
	int r = e.getColor().getRed(), g = e.getColor().getGreen(), b = e
			.getColor().getBlue();

	if (!value.isEmpty()) {
		if (key.equalsIgnoreCase(EDGE_LABEL)) {
			e.setLabel(value);
		} else if (key.equalsIgnoreCase(EDGE_WIDTH)) {
			e.setWidth(Double.parseDouble(value));
		} else if (key.equalsIgnoreCase(EDGE_WEIGHT)) {
			e.setWeight(Double.parseDouble(value));
		} else if (key.equalsIgnoreCase(EDGE_R)) {
			r = Integer.parseInt(value);
			e.setColor(new Color(r, g, b));
		} else if (key.equalsIgnoreCase(EDGE_G)) {
			g = Integer.parseInt(value);
			e.setColor(new Color(r, g, b));
		} else if (key.equalsIgnoreCase(EDGE_B)) {
			b = Integer.parseInt(value);
			e.setColor(new Color(r, g, b));
		}
	}

}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:37,代碼來源:GraphMLImporter.java

示例8: storeAttributes

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
private void storeAttributes(XMLStreamReader reader) {
    int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        storeAttribute(reader.getAttributePrefix(i), reader.getAttributeNamespace(i), reader.getAttributeLocalName(i),
                reader.getAttributeType(i), reader.getAttributeValue(i));
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:8,代碼來源:StreamReaderBufferCreator.java

示例9: processHeaderAttributes

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
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;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:29,代碼來源:StreamHeader11.java

示例10: addAttributes

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
protected void addAttributes(StartElementEvent event,XMLStreamReader streamReader){
    AttributeBase attr = null;
    for(int i=0; i<streamReader.getAttributeCount() ;i++){
        attr = (AttributeBase)factory.createAttribute(streamReader.getAttributeName(i),
                                streamReader.getAttributeValue(i));
        attr.setAttributeType(streamReader.getAttributeType(i));
        attr.setSpecified(streamReader.isAttributeSpecified(i));
        event.addAttribute(attr);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:StAXEventAllocatorBase.java

示例11: AttributesImpl

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
public AttributesImpl(XMLStreamReader reader) {
    if (reader == null) {

        // this is the case when we call getAttributes() on the
        // reader when it is not on a start tag
        atInfos = new AttributeInfo[0];
    } else {

        // this is the normal case
        int index = 0;
        int namespaceCount = reader.getNamespaceCount();
        int attributeCount = reader.getAttributeCount();
        atInfos = new AttributeInfo[namespaceCount + attributeCount];
        for (int i=0; i<namespaceCount; i++) {
            String namespacePrefix = reader.getNamespacePrefix(i);

            // will be null if default prefix. QName can't take null
            if (namespacePrefix == null) {
                namespacePrefix = "";
            }
            atInfos[index++] = new AttributeInfo(
                new QName(XMLNS_NAMESPACE_URI,
                    namespacePrefix,
                    "xmlns"),
                reader.getNamespaceURI(i));
        }
        for (int i=0; i<attributeCount; i++) {
            atInfos[index++] = new AttributeInfo(
                reader.getAttributeName(i),
                reader.getAttributeValue(i));
        }
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:34,代碼來源:XMLStreamReaderUtil.java

示例12: fillXMLAttributes

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
private void fillXMLAttributes(XMLStreamReader input) {
    fAttributes.removeAllAttributes();
    final int len = input.getAttributeCount();
    for (int i = 0; i < len; ++i) {
        fillQName(fAttributeQName, input.getAttributeNamespace(i),
            input.getAttributeLocalName(i), input.getAttributePrefix(i));
        String type = input.getAttributeType(i);
        fAttributes.addAttributeNS(fAttributeQName,
                (type != null) ? type : XMLSymbols.fCDATASymbol, input.getAttributeValue(i));
        fAttributes.setSpecified(i, input.isAttributeSpecified(i));
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:13,代碼來源:StAXSchemaParser.java

示例13: getRawGaze

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
public OldRawGaze getRawGaze(XMLStreamReader reader) {
	String file = reader.getAttributeValue(0);
	String type = reader.getAttributeValue(1);
	double x = Double.parseDouble(reader.getAttributeValue(2));
	double y = Double.parseDouble(reader.getAttributeValue(3));
	double leftValidity = Double.parseDouble(reader.getAttributeValue(4));
	double rightValidity = Double.parseDouble(reader.getAttributeValue(5));
	double leftPupilDiam = Double.parseDouble(reader.getAttributeValue(6));
	double rightPupilDiam = Double.parseDouble(reader.getAttributeValue(8));
	long trackerTime = Long.parseLong(reader.getAttributeValue(9));
	long systemTime = Long.parseLong(reader.getAttributeValue(10));
	long nanoTime = Long.parseLong(reader.getAttributeValue(11));
	int lineBaseX = Integer.parseInt(reader.getAttributeValue(12));
	int line = Integer.parseInt(reader.getAttributeValue(13));
	int col = Integer.parseInt(reader.getAttributeValue(14));
	String hows = new String();
	String types = new String();
	String fullyQualifiedNames = new String();
	int lineBaseY = -1;
	
	if (reader.getAttributeCount() == 19) {
		hows = reader.getAttributeValue(15);
		types = reader.getAttributeValue(16);
		fullyQualifiedNames = reader.getAttributeValue(17);
		lineBaseY = Integer.parseInt(reader.getAttributeValue(18));
	} else {
		lineBaseY = Integer.parseInt(reader.getAttributeValue(15));
	}
	
	return new OldRawGaze(file, type, x, y, leftValidity, rightValidity,
			leftPupilDiam, rightPupilDiam, trackerTime, systemTime,
			nanoTime, lineBaseX, line, col, hows, types, fullyQualifiedNames,
			lineBaseY);
}
 
開發者ID:SERESLab,項目名稱:iTrace-Archive,代碼行數:35,代碼來源:OldXMLBasicFixationFilter.java

示例14: storeElementWithInScopeNamespaces

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
private void storeElementWithInScopeNamespaces(XMLStreamReader reader) {
    storeQualifiedName(T_ELEMENT_LN,
            reader.getPrefix(), reader.getNamespaceURI(), reader.getLocalName());

    if (reader.getNamespaceCount() > 0) {
        storeNamespaceAttributes(reader);
    }

    if (reader.getAttributeCount() > 0) {
        storeAttributes(reader);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:13,代碼來源:StreamReaderBufferCreator.java

示例15: readEdge

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
private void readEdge(XMLStreamReader xmlReader) throws XMLStreamException {
	int src = 0, dest = 0;
	boolean directed = false;
	boolean elemEnd = false;
	Edge e = null;

	for (int i = 0; i < xmlReader.getAttributeCount(); ++i) {
		String attr = xmlReader.getAttributeLocalName(i);

		if (attr.equalsIgnoreCase(EDGE_SRC)) {
			src = Integer.parseInt(xmlReader.getAttributeValue(i));
		} else if (attr.equalsIgnoreCase(EDGE_DEST)) {
			dest = Integer.parseInt(xmlReader.getAttributeValue(i));
		} else if (attr.equalsIgnoreCase(EDGE_DIRECTED)) {
			directed = Boolean.parseBoolean(xmlReader.getAttributeValue(i));
		}
	}

	e = new Edge();
	Vertex vs = null, vt = null;

	for (Vertex v : network.getVertices()) {
		if (v.getId() == src)
			vs = v;
		if (v.getId() == dest)
			vt = v;

		if (vs != null && vt != null)
			break;
	}

	while (xmlReader.hasNext() && !elemEnd) {
		int event = xmlReader.next();

		if (event == XMLEvent.START_ELEMENT) {
			if (xmlReader.getLocalName().equalsIgnoreCase(DATA)) {
				readEdgeData(xmlReader, e);
			}

		} else if (event == XMLEvent.END_ELEMENT) {
			if (xmlReader.getLocalName().equalsIgnoreCase(EDGE)) {
				elemEnd = true;
			}
		}
	}

	network.addEdge(e, vs, vt, (directed ? EdgeType.DIRECTED
			: EdgeType.UNDIRECTED));
}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:50,代碼來源:GraphMLImporter.java


注:本文中的javax.xml.stream.XMLStreamReader.getAttributeCount方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。