use of org.jdom2.Element in project gocd by gocd.
the class GoConfigFieldWriter method parseCollection.
@SuppressWarnings("unchecked")
private Collection parseCollection(Element e, Class<?> collectionType) {
ConfigCollection collection = collectionType.getAnnotation(ConfigCollection.class);
Class<?> type = collection.value();
Object o = newInstance(collectionType);
bombUnless(o instanceof Collection, "Must be some sort of list. Was: " + collectionType.getName());
Collection baseCollection = (Collection) o;
for (Element childElement : (List<Element>) e.getChildren()) {
if (isInCollection(childElement, type)) {
baseCollection.add(parseType(childElement, type));
}
}
bombIf(baseCollection.size() < collection.minimum(), "Required at least " + collection.minimum() + " subelements to '" + e.getName() + "'. " + "Found " + baseCollection.size() + ".");
return baseCollection;
}
use of org.jdom2.Element in project gocd by gocd.
the class SvnLogXmlParser method parseLogEntry.
private Modification parseLogEntry(Element logEntry, String path) throws ParseException {
Element logEntryPaths = logEntry.getChild("paths");
if (logEntryPaths == null) {
/* Path-based access control forbids us from learning
* details of this log entry, so skip it. */
return null;
}
Date modifiedTime = convertDate(logEntry.getChildText("date"));
String author = logEntry.getChildText("author");
String comment = logEntry.getChildText("msg");
String revision = logEntry.getAttributeValue("revision");
Modification modification = new Modification(author, comment, null, modifiedTime, revision);
List paths = logEntryPaths.getChildren("path");
for (Iterator iterator = paths.iterator(); iterator.hasNext(); ) {
Element node = (Element) iterator.next();
if (underPath(path, node.getText())) {
ModifiedAction action = convertAction(node.getAttributeValue("action"));
modification.createModifiedFile(node.getText(), null, action);
}
}
return modification;
}
use of org.jdom2.Element in project gocd by gocd.
the class SvnLogXmlParser method parseDOMTree.
private List<Modification> parseDOMTree(Document document, String path) throws ParseException {
List<Modification> modifications = new ArrayList<>();
Element rootElement = document.getRootElement();
List logEntries = rootElement.getChildren("logentry");
for (Iterator iterator = logEntries.iterator(); iterator.hasNext(); ) {
Element logEntry = (Element) iterator.next();
Modification modification = parseLogEntry(logEntry, path);
if (modification != null) {
modifications.add(modification);
}
}
return modifications;
}
use of org.jdom2.Element in project gocd by gocd.
the class HgModificationSplitter method parseDOMTree.
private List<Modification> parseDOMTree(Document document) throws ParseException {
List<Modification> modifications = new ArrayList<>();
Element rootElement = document.getRootElement();
List logEntries = rootElement.getChildren("changeset");
for (Iterator iterator = logEntries.iterator(); iterator.hasNext(); ) {
Element changeset = (Element) iterator.next();
modifications.add(parseChangeset(changeset));
}
return modifications;
}
use of org.jdom2.Element in project gocd by gocd.
the class HgModificationSplitter method parseChangeset.
private Modification parseChangeset(Element changeset) throws ParseException {
Date modifiedTime = DateUtils.parseRFC822(changeset.getChildText("date"));
String author = org.apache.commons.lang.StringEscapeUtils.unescapeXml(changeset.getChildText("author"));
String comment = org.apache.commons.lang.StringEscapeUtils.unescapeXml(changeset.getChildText("desc"));
String revision = changeset.getChildText("node");
Modification modification = new Modification(author, comment, null, modifiedTime, revision);
Element files = changeset.getChild("files");
List<File> modifiedFiles = parseFiles(files, "modified");
List<File> addedFiles = parseFiles(files, "added");
List<File> deletedFiles = parseFiles(files, "deleted");
modifiedFiles.removeAll(addedFiles);
modifiedFiles.removeAll(deletedFiles);
addModificationFiles(modification, ModifiedAction.added, addedFiles);
addModificationFiles(modification, ModifiedAction.deleted, deletedFiles);
addModificationFiles(modification, ModifiedAction.modified, modifiedFiles);
return modification;
}
Aggregations