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


Java XMLStreamReader.getAttributeValue方法代碼示例

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


在下文中一共展示了XMLStreamReader.getAttributeValue方法的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:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:24,代碼來源:OutboundStreamHeader.java

示例2: 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

示例3: 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

示例4: readGraph

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
private void readGraph(XMLStreamReader xmlReader) {
	String edgeDefault = "";

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

		if (attr.equalsIgnoreCase(GRAPH_EDGEDEFAULT)) {
			edgeDefault = xmlReader.getAttributeValue(i);
		}
	}

	network.setDirected(edgeDefault.equalsIgnoreCase(EDGE_DIRECTED));
}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:14,代碼來源:GraphMLImporter.java

示例5: 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

示例6: 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:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:29,代碼來源:StreamHeader11.java

示例7: 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

示例8: addressibleElement

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
private boolean addressibleElement(XMLStreamReader reader, WSDLFeaturedObject binding) {
    QName ua = reader.getName();
    if (ua.equals(AddressingVersion.W3C.wsdlExtensionTag)) {
        String required = reader.getAttributeValue(WSDLConstants.NS_WSDL, "required");
        binding.addFeature(new AddressingFeature(true, Boolean.parseBoolean(required)));
        XMLStreamReaderUtil.skipElement(reader);
        return true;        // UsingAddressing is consumed
    }

    return false;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:12,代碼來源:W3CAddressingWSDLParserExtension.java

示例9: readOptionalIntegerAttribute

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
public static Integer readOptionalIntegerAttribute(XMLStreamReader reader, String attributeName) {
    String attributeValue = reader.getAttributeValue(null, attributeName);
    return attributeValue != null ? Integer.valueOf(attributeValue) : null;
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:5,代碼來源:XmlUtil.java

示例10: readOptionalFloatAttribute

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
public static float readOptionalFloatAttribute(XMLStreamReader reader, String attributeName, float defaultValue) {
    String attributeValue = reader.getAttributeValue(null, attributeName);
    return attributeValue != null ? Float.valueOf(attributeValue) : defaultValue;
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:5,代碼來源:XmlUtil.java

示例11: fromXml

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
public static List<SecurityIndex> fromXml(String contingencyId, Reader reader) {
    List<SecurityIndex> indexes = new ArrayList<>();
    try {
        XMLStreamReader xmlsr = XML_INPUT_FACTORY_SUPPLIER.get().createXMLStreamReader(reader);
        while (xmlsr.hasNext()) {
            int eventType = xmlsr.next();
            switch (eventType) {
                case XMLEvent.START_ELEMENT:
                    switch (xmlsr.getLocalName()) {
                        case "index":
                            switch (xmlsr.getAttributeValue(null, "name")) {
                                case OverloadSecurityIndex.XML_NAME:
                                    indexes.add(OverloadSecurityIndex.fromXml(contingencyId, xmlsr));
                                    break;
                                case UnderOverVoltageSecurityIndex.XML_NAME:
                                    indexes.add(UnderOverVoltageSecurityIndex.fromXml(contingencyId, xmlsr));
                                    break;
                                case SmallSignalSecurityIndex.XML_NAME:
                                    indexes.add(SmallSignalSecurityIndex.fromXml(contingencyId, xmlsr));
                                    break;
                                case TransientSecurityIndex.XML_NAME:
                                    indexes.add(TransientSecurityIndex.fromXml(contingencyId, xmlsr));
                                    break;
                                case TsoOverloadSecurityIndex.XML_NAME:
                                    indexes.add(TsoOverloadSecurityIndex.fromXml(contingencyId, xmlsr));
                                    break;
                                case TsoOvervoltageSecurityIndex.XML_NAME:
                                    indexes.add(TsoOvervoltageSecurityIndex.fromXml(contingencyId, xmlsr));
                                    break;
                                case TsoUndervoltageSecurityIndex.XML_NAME:
                                    indexes.add(TsoUndervoltageSecurityIndex.fromXml(contingencyId, xmlsr));
                                    break;
                                case TsoFrequencySecurityIndex.XML_NAME:
                                    indexes.add(TsoFrequencySecurityIndex.fromXml(contingencyId, xmlsr));
                                    break;
                                case TsoSynchroLossSecurityIndex.XML_NAME:
                                    indexes.add(TsoSynchroLossSecurityIndex.fromXml(contingencyId, xmlsr));
                                    break;
                                case TsoGeneratorVoltageAutomaton.XML_NAME:
                                    indexes.add(TsoGeneratorVoltageAutomaton.fromXml(contingencyId, xmlsr));
                                    break;
                                case TsoGeneratorSpeedAutomaton.XML_NAME:
                                    indexes.add(TsoGeneratorSpeedAutomaton.fromXml(contingencyId, xmlsr));
                                    break;
                                case TsoDisconnectedGenerator.XML_NAME:
                                    indexes.add(TsoDisconnectedGenerator.fromXml(contingencyId, xmlsr));
                                    break;
                                case MultiCriteriaVoltageStabilityIndex.XML_NAME:
                                    indexes.add(MultiCriteriaVoltageStabilityIndex.fromXml(contingencyId, xmlsr));
                                    break;
                                case MultiCriteriaVoltageStabilityIndex2.XML_NAME:
                                    indexes.add(MultiCriteriaVoltageStabilityIndex2.fromXml(contingencyId, xmlsr));
                                    break;
                                default:
                                    throw new AssertionError("Unexpected attribute value: " + xmlsr.getAttributeValue(null, "name"));
                            }
                            break;

                        default:
                            throw new AssertionError("Unexpected element: " + xmlsr.getLocalName());
                    }
                    break;

                default:
                    break;
            }
        }
    } catch (XMLStreamException e) {
        throw new UncheckedXmlStreamException(e);
    }
    return indexes;
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:73,代碼來源:SecurityIndexParser.java

示例12: getRawGaze

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
public NewRawGaze getRawGaze(XMLStreamReader reader) throws XMLStreamException {
	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(7));
	long trackerTime = Long.parseLong(reader.getAttributeValue(8));
	long systemTime = Long.parseLong(reader.getAttributeValue(9));
	long nanoTime = Long.parseLong(reader.getAttributeValue(10));
	String path = reader.getAttributeValue(11);
	int lineHeight = Integer.parseInt(reader.getAttributeValue(12));
	int fontHeight = Integer.parseInt(reader.getAttributeValue(13));
	int line = Integer.parseInt(reader.getAttributeValue(14));
	int col = Integer.parseInt(reader.getAttributeValue(15));
	int lineBaseX = Integer.parseInt(reader.getAttributeValue(16));
	int lineBaseY = Integer.parseInt(reader.getAttributeValue(17));
	ArrayList<SourceCodeEntity> sces = new ArrayList<SourceCodeEntity>();
	
	reader.next();
	reader.next();
	while(!reader.isEndElement()) {
		String name = reader.getAttributeValue(0);
		String Type = reader.getAttributeValue(1);
		String how = reader.getAttributeValue(2);
		int length = Integer.parseInt(reader.getAttributeValue(3));
		int startLine = Integer.parseInt(reader.getAttributeValue(4));
		int endLine = Integer.parseInt(reader.getAttributeValue(5));
		int startCol = Integer.parseInt(reader.getAttributeValue(6));
		int endCol = Integer.parseInt(reader.getAttributeValue(7));
		
		sces.add(new SourceCodeEntity(name, Type, how, length,
				startLine, endLine, startCol, endCol));
		reader.next();
		reader.next();
	}
	
	return new NewRawGaze(file, type, x, y, leftValidity, rightValidity,
			leftPupilDiam, rightPupilDiam, trackerTime, systemTime,
			nanoTime, path, lineHeight, fontHeight, lineBaseX, line,
			col, lineBaseY, sces);
}
 
開發者ID:SERESLab,項目名稱:iTrace-Archive,代碼行數:45,代碼來源:XMLBasicFixationFilter.java

示例13: getAttribute

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
public static String getAttribute(XMLStreamReader reader, String name) {
    return reader.getAttributeValue(null, name);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:4,代碼來源:ParserUtil.java

示例14: getAttribute

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
public static String getAttribute(XMLStreamReader reader, QName name) {
    return reader.getAttributeValue(name.getNamespaceURI(), name.getLocalPart());
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:4,代碼來源:ParserUtil.java

示例15: SpectrumIndexer

import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
public SpectrumIndexer(XMLStreamReader xr) {
	this.name = xr.getAttributeValue(null, "name");
	this.idToOffsets = new HashMap<String, Long>();
	this.offsets = new ArrayList<Long>();
}
 
開發者ID:digitalproteomics,項目名稱:dp-mzml,代碼行數:6,代碼來源:SpectrumIndexer.java


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