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


Java XMLEvent.END_ELEMENT屬性代碼示例

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


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

示例1: handleEvent

private void handleEvent(XMLStreamReader xmlr, int eventType) {
    switch (eventType) {
        case XMLEvent.START_ELEMENT:
            handleStartElement(xmlr);
            break;
        case XMLEvent.END_ELEMENT:
            handleEndElement(xmlr);
            break;
        case XMLEvent.CHARACTERS:
            handleCharacters(xmlr);
            break;
        case XMLEvent.COMMENT:
            handleComment(xmlr);
            break;
        case XMLEvent.ENTITY_REFERENCE:
            break;
        case XMLEvent.ATTRIBUTE:
            break;
        case XMLEvent.DTD:
            break;
        case XMLEvent.CDATA:
            break;
        default:
            break;
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:26,代碼來源:EntityTest.java

示例2: getNamespaceURI

/**
 * Returns the uri for the namespace declared at the index.
 *
 * @param index the position of the namespace declaration
 * @return returns the namespace uri
 * @throws IllegalStateException if this is not a START_ELEMENT, END_ELEMENT
 * or NAMESPACE
 */
public String getNamespaceURI(int index) {
    if (fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.END_ELEMENT
            || fEventType == XMLEvent.NAMESPACE) {
        //namespaceContext is dynamic object.
        return fScanner.getNamespaceContext().getURI(fScanner.getNamespaceContext()
                .getDeclaredPrefixAt(index));
    } else {
        throw new IllegalStateException("Current state " + getEventTypeString(fEventType)
                + " is not among the states " + getEventTypeString(XMLEvent.START_ELEMENT)
                + ", " + getEventTypeString(XMLEvent.END_ELEMENT) + ", "
                + getEventTypeString(XMLEvent.NAMESPACE)
                + " valid for getNamespaceURI().");
    }

}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:XMLStreamReaderImpl.java

示例3: getName

/**
 * Returns a QName for the current START_ELEMENT or END_ELEMENT event
 *
 * @return the QName for the current START_ELEMENT or END_ELEMENT event
 */
public javax.xml.namespace.QName getName() {
    if (fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.END_ELEMENT) {
        return convertXNIQNametoJavaxQName(fScanner.getElementQName());
    } else {
        throw new java.lang.IllegalStateException("Illegal to call getName() "
                + "when event type is " + getEventTypeString(fEventType) + "."
                + " Valid states are " + getEventTypeString(XMLEvent.START_ELEMENT) + ", "
                + getEventTypeString(XMLEvent.END_ELEMENT));
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:15,代碼來源:XMLStreamReaderImpl.java

示例4: getName

/** Returns a QName for the current START_ELEMENT or END_ELEMENT event
 * @return the QName for the current START_ELEMENT or END_ELEMENT event
 */
public javax.xml.namespace.QName getName() {
    if(fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.END_ELEMENT)
        return convertXNIQNametoJavaxQName(fScanner.getElementQName());
    else
        throw new java.lang.IllegalStateException("Illegal to call getName() "+
        "when event type is "+ getEventTypeString(fEventType) + "."
                 + " Valid states are " + getEventTypeString(XMLEvent.START_ELEMENT) + ", "
                 + getEventTypeString(XMLEvent.END_ELEMENT));
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:12,代碼來源:XMLStreamReaderImpl.java

示例5: readNode

private void readNode(XMLStreamReader xmlReader) throws XMLStreamException {
	int attrId = 0;
	Vertex v = null;

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

		if (attr.equalsIgnoreCase(NODE_ID)) {
			attrId = Integer.parseInt(xmlReader.getAttributeValue(i));
		}
	}

	v = new Vertex(attrId);

	boolean elemEnd = false;

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

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

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

	network.addVertex(v);
}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:33,代碼來源:GraphMLImporter.java

示例6: getNamespaceCount

/** Returns the count of namespaces declared on this START_ELEMENT or END_ELEMENT,
 * this method is only valid on a START_ELEMENT, END_ELEMENT or NAMESPACE. On
 * an END_ELEMENT the count is of the namespaces that are about to go
 * out of scope.  This is the equivalent of the information reported
 * by SAX callback for an end element event.
 * @return returns the number of namespace declarations on this specific element
 * @throws IllegalStateException if this is not a START_ELEMENT, END_ELEMENT or NAMESPACE
 */
public int getNamespaceCount() {
    //namespaceContext is dynamic object.
    //REVISIT: check if it specifies all conditions mentioned in the javadoc
    if(fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.END_ELEMENT || fEventType == XMLEvent.NAMESPACE){
        return fScanner.getNamespaceContext().getDeclaredPrefixCount() ;
    } else{
        throw new IllegalStateException("Current event state is " + getEventTypeString(fEventType)
         + " is not among the states " + getEventTypeString(XMLEvent.START_ELEMENT)
         + ", " + getEventTypeString(XMLEvent.END_ELEMENT) + ", "
                 + getEventTypeString(XMLEvent.NAMESPACE)
         + " valid for getNamespaceCount()." );
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:21,代碼來源:XMLStreamReaderImpl.java

示例7: fromXml

public static TsoDisconnectedGenerator fromXml(String contingencyId, XMLStreamReader xmlsr) throws XMLStreamException {
    String text = null;
    Map<String, Float> disconnectedGenerators = new HashMap<>();
    String id = null;
    while (xmlsr.hasNext()) {
        int eventType = xmlsr.next();
        switch (eventType) {
            case XMLEvent.CHARACTERS:
                text = xmlsr.getText();
                break;

            case XMLEvent.START_ELEMENT:
                if ("generator".equals(xmlsr.getLocalName())) {
                    id = xmlsr.getAttributeValue(null, "id");
                }
                break;

            case XMLEvent.END_ELEMENT:
                switch (xmlsr.getLocalName()) {
                    case "generator":
                        if (id == null) {
                            throw new AssertionError();
                        }
                        float p = Float.parseFloat(text);
                        disconnectedGenerators.put(id, p);
                        id = null;
                        break;
                    case "index":
                        return new TsoDisconnectedGenerator(contingencyId, disconnectedGenerators);
                    default:
                        throw new AssertionError("Unexpected element: " + xmlsr.getLocalName());
                }
                break;

            default:
                break;
        }
    }
    throw new AssertionError("Should not happen");
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:40,代碼來源:TsoDisconnectedGenerator.java

示例8: testNextTag

private static void testNextTag(int max)
        throws IOException, XMLStreamException {
    System.out.println("\nTest nextTag (" + max + ")...");
    XMLEventReader reader = createXmlReader(max);
    XMLEvent event;
    do {
        event = reader.nextTag();
        System.out.println(event);
        if (event.getEventType() == XMLEvent.END_ELEMENT
            && event.asEndElement().getName().getLocalPart().equals(ROOT)) {
            break;
        }
    } while (true);
    System.out.println("nextTag passed\n");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:15,代碼來源:EventFilterSupportTest.java

示例9: getLocalName

public String getLocalName() {
    if(fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.END_ELEMENT){
        //xxx check whats the value of fCurrentElement
        return fScanner.getElementQName().localpart ;
    }
    else if(fEventType == XMLEvent.ENTITY_REFERENCE){
        return fScanner.getEntityName();
    }
    throw new IllegalStateException("Method getLocalName() cannot be called for " +
        getEventTypeString(fEventType) + " event.");
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:11,代碼來源:XMLStreamReaderImpl.java

示例10: getNamespaceURI

/**
 * @return
 */
public String getNamespaceURI() {
    //doesn't take care of Attribute as separte event
    if(fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.END_ELEMENT){
        return fScanner.getElementQName().uri ;
    }
    return null ;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:10,代碼來源:XMLStreamReaderImpl.java

示例11: getPrefix

/**
* @return the prefix of the current event, or null if the event does
* not have a prefix. For START_ELEMENT and END_ELEMENT, return
* XMLConstants.DEFAULT_NS_PREFIX when no prefix is available.
*/
public String getPrefix() {
    if(fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.END_ELEMENT){
        String prefix = fScanner.getElementQName().prefix;
        return prefix == null ? XMLConstants.DEFAULT_NS_PREFIX : prefix;
    }
    return null ;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:12,代碼來源:XMLStreamReaderImpl.java

示例12: getValue

/**
 * @return
 */
public String getValue() {
    if(fEventType == XMLEvent.PROCESSING_INSTRUCTION){
        return fScanner.getPIData().toString();
    } else if(fEventType == XMLEvent.COMMENT){
        return fScanner.getComment();
    } else if(fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.END_ELEMENT){
        return fScanner.getElementQName().localpart ;
    } else if(fEventType == XMLEvent.CHARACTERS){
        return fScanner.getCharacterData().toString();
    }
    return null;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:15,代碼來源:XMLStreamReaderImpl.java

示例13: getNamespacePrefix

/** Returns the prefix for the namespace declared at the
 * index.  Returns null if this is the default namespace
 * declaration
 *
 * @param index the position of the namespace declaration
 * @return returns the namespace prefix
 * @throws IllegalStateException if this is not a START_ELEMENT, END_ELEMENT or NAMESPACE
 */
public String getNamespacePrefix(int index) {
    if(fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.END_ELEMENT || fEventType == XMLEvent.NAMESPACE){
        //namespaceContext is dynamic object.
        String prefix = fScanner.getNamespaceContext().getDeclaredPrefixAt(index) ;
        return prefix.equals("") ? null : prefix ;
    }
    else{
        throw new IllegalStateException("Current state " + getEventTypeString(fEventType)
         + " is not among the states " + getEventTypeString(XMLEvent.START_ELEMENT)
         + ", " + getEventTypeString(XMLEvent.END_ELEMENT) + ", "
                 + getEventTypeString(XMLEvent.NAMESPACE)
         + " valid for getNamespacePrefix()." );
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:22,代碼來源:XMLStreamReaderImpl.java

示例14: readEdge

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));
		}
	}

	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;
	}

	if (vs != null && vt != null) {
		e = new Edge(vs, vt, 1, directed);
	}

	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);
}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:51,代碼來源:GraphMLImporter.java

示例15: fromXml

public static MultiCriteriaVoltageStabilityIndex fromXml(String contingencyId, XMLStreamReader xmlsr) throws XMLStreamException {
    String text = null;
    Map<String, Float> lockedTapChangerLoads = new LinkedHashMap<>();
    Map<String, Float> stoppedTapChangerLoads = new LinkedHashMap<>();
    Map<String, Float> underVoltageAutomatonGenerators = new LinkedHashMap<>();
    Set<String> underVoltageBuses = new LinkedHashSet<>();
    String id = null;
    while (xmlsr.hasNext()) {
        int eventType = xmlsr.next();
        switch (eventType) {
            case XMLEvent.CHARACTERS:
                text = xmlsr.getText();
                break;
            case XMLEvent.START_ELEMENT:
                switch (xmlsr.getLocalName()) {
                    case TAG_LOCKED_TAP_CHANGER_LOAD:
                    case TAG_STOPPED_TAP_CHANGER_LOAD:
                    case TAG_UNDER_VOLTAGE_AUTOMATON_GENERATOR:
                        id = xmlsr.getAttributeValue(null, TAG_ID);
                        break;
                    case TAG_UNDER_BUS_VOLTAGE:
                    case TAG_INDEX:
                        // nothing to do
                        break;
                    default:
                        throw new AssertionError("Unexpected element: " + xmlsr.getLocalName());
                }
                break;

            case XMLEvent.END_ELEMENT:
                switch (xmlsr.getLocalName()) {
                    case TAG_LOCKED_TAP_CHANGER_LOAD:
                        if (id == null) {
                            throw new AssertionError();
                        }
                        lockedTapChangerLoads.put(id, Float.parseFloat(text));
                        id = null;
                        break;
                    case TAG_STOPPED_TAP_CHANGER_LOAD:
                        if (id == null) {
                            throw new AssertionError();
                        }
                        stoppedTapChangerLoads.put(id, Float.parseFloat(text));
                        id = null;
                        break;
                    case TAG_UNDER_VOLTAGE_AUTOMATON_GENERATOR:
                        if (id == null) {
                            throw new AssertionError();
                        }
                        underVoltageAutomatonGenerators.put(id, Float.parseFloat(text));
                        id = null;
                        break;
                    case TAG_UNDER_BUS_VOLTAGE:
                        underVoltageBuses.add(text);
                        break;
                    case TAG_INDEX:
                        return new MultiCriteriaVoltageStabilityIndex(contingencyId, lockedTapChangerLoads, stoppedTapChangerLoads,
                                                                      underVoltageAutomatonGenerators, underVoltageBuses);
                    default:
                        throw new AssertionError("Unexpected element: " + xmlsr.getLocalName());
                }
                break;

            default:
                break;
        }
    }
    throw new AssertionError("Should not happen");
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:69,代碼來源:MultiCriteriaVoltageStabilityIndex.java


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