edu.sc.seis.seisFile.fdsnws.stationxml.ExternalReference Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of seisFile Show documentation
Show all versions of seisFile Show documentation
A library for reading and writing seismic file formats in java.
The newest version!
package edu.sc.seis.seisFile.fdsnws.stationxml;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
import edu.sc.seis.seisFile.fdsnws.StaxUtil;
public class ExternalReference {
public ExternalReference(String uri, String description) {
this.uri = uri;
this.description = description;
}
public ExternalReference(XMLEventReader reader, String tagName) throws XMLStreamException, StationXMLException {
StartElement startE = StaxUtil.expectStartElement(tagName, reader);
while (reader.hasNext()) {
XMLEvent e = reader.peek();
if (e.isStartElement()) {
String elName = e.asStartElement().getName().getLocalPart();
if (parseSubElement(elName, reader)) {
// super handled it
} else {
StaxUtil.skipToMatchingEnd(reader);
}
} else if (e.isEndElement()) {
reader.nextEvent();
return;
} else {
e = reader.nextEvent();
}
}
}
boolean parseSubElement(String elName, final XMLEventReader reader) throws StationXMLException, XMLStreamException {
if (elName.equals(StationXMLTagNames.URI)) {
uri = StaxUtil.pullText(reader, StationXMLTagNames.URI);
return true;
} else if (elName.equals(StationXMLTagNames.DESCRIPTION)) {
description = StaxUtil.pullText(reader, StationXMLTagNames.DESCRIPTION);
return true;
} else {
return false;
}
}
void parseAttributes(StartElement startE) throws StationXMLException {
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
String uri;
String description;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy