本文整理汇总了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;
}
}
示例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().");
}
}
示例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));
}
}
示例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));
}
示例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);
}
示例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()." );
}
}
示例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");
}
示例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");
}
示例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.");
}
示例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 ;
}
示例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 ;
}
示例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;
}
示例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()." );
}
}
示例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);
}
示例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");
}