use of org.jkiss.utils.xml.SAXListener in project dbeaver by dbeaver.
the class MavenArtifact method parseMetadata.
private void parseMetadata(InputStream mdStream) throws IOException, XMLException {
SAXReader reader = new SAXReader(mdStream);
reader.parse(new SAXListener() {
public String lastTag;
@Override
public void saxStartElement(SAXReader reader, String namespaceURI, String localName, Attributes atts) throws XMLException {
lastTag = localName;
}
@Override
public void saxText(SAXReader reader, String data) throws XMLException {
if ("version".equals(lastTag)) {
versions.add(data);
} else if ("latest".equals(lastTag)) {
latestVersion = data;
} else if ("release".equals(lastTag)) {
releaseVersion = data;
} else if ("lastUpdate".equals(lastTag)) {
try {
lastUpdate = new Date(Long.parseLong(data));
} catch (NumberFormatException e) {
log.warn(e);
}
}
}
@Override
public void saxEndElement(SAXReader reader, String namespaceURI, String localName) throws XMLException {
lastTag = null;
}
});
}
use of org.jkiss.utils.xml.SAXListener in project dbeaver by serge-rider.
the class MavenArtifact method parseMetadata.
private void parseMetadata(InputStream mdStream) throws IOException, XMLException {
SAXReader reader = new SAXReader(mdStream);
reader.parse(new SAXListener() {
public String lastTag;
@Override
public void saxStartElement(SAXReader reader, String namespaceURI, String localName, Attributes atts) throws XMLException {
lastTag = localName;
}
@Override
public void saxText(SAXReader reader, String data) throws XMLException {
if ("version".equals(lastTag)) {
versions.add(data);
} else if ("latest".equals(lastTag)) {
latestVersion = data;
} else if ("release".equals(lastTag)) {
releaseVersion = data;
} else if ("lastUpdate".equals(lastTag)) {
try {
lastUpdate = new Date(Long.parseLong(data));
} catch (NumberFormatException e) {
log.warn(e);
}
}
}
@Override
public void saxEndElement(SAXReader reader, String namespaceURI, String localName) throws XMLException {
lastTag = null;
}
});
}
use of org.jkiss.utils.xml.SAXListener in project dbeaver by dbeaver.
the class VersionDescriptor method parseVersionInfo.
private void parseVersionInfo(InputStream inputStream) throws IOException, XMLException {
SAXReader parser = new SAXReader(inputStream);
SAXListener dsp = new SAXListener() {
private String lastTag;
private StringBuilder textBuffer = new StringBuilder();
@Override
public void saxStartElement(SAXReader reader, String namespaceURI, String localName, Attributes atts) throws XMLException {
lastTag = localName;
textBuffer.setLength(0);
}
@Override
public void saxText(SAXReader reader, String data) throws XMLException {
textBuffer.append(data);
}
@Override
public void saxEndElement(SAXReader reader, String namespaceURI, String localName) throws XMLException {
final String text = textBuffer.toString();
switch(lastTag) {
case "name":
programName = text;
break;
case "number":
programVersion = Version.parseVersion(text);
break;
case "date":
updateTime = text;
break;
case "base-url":
baseURL = text;
break;
case "release-notes":
releaseNotes = text;
break;
}
textBuffer.setLength(0);
}
};
parser.parse(dsp);
}
use of org.jkiss.utils.xml.SAXListener in project dbeaver by serge-rider.
the class VersionDescriptor method parseVersionInfo.
private void parseVersionInfo(InputStream inputStream) throws IOException, XMLException {
SAXReader parser = new SAXReader(inputStream);
SAXListener dsp = new SAXListener() {
private String lastTag;
private StringBuilder textBuffer = new StringBuilder();
@Override
public void saxStartElement(SAXReader reader, String namespaceURI, String localName, Attributes atts) throws XMLException {
lastTag = localName;
textBuffer.setLength(0);
}
@Override
public void saxText(SAXReader reader, String data) throws XMLException {
textBuffer.append(data);
}
@Override
public void saxEndElement(SAXReader reader, String namespaceURI, String localName) throws XMLException {
final String text = textBuffer.toString();
switch(lastTag) {
case "name":
programName = text;
break;
case "number":
programVersion = Version.parseVersion(text);
break;
case "date":
updateTime = text;
break;
case "base-url":
baseURL = text;
break;
case "release-notes":
releaseNotes = text;
break;
}
textBuffer.setLength(0);
}
};
parser.parse(dsp);
}
Aggregations