Search in sources :

Example 16 with Element

use of com.zhan_dui.utils.m3u8.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;
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) Element(org.jdom2.Element) Iterator(java.util.Iterator) ModifiedAction(com.thoughtworks.go.domain.materials.ModifiedAction) ArrayList(java.util.ArrayList) List(java.util.List) Date(java.util.Date)

Example 17 with Element

use of com.zhan_dui.utils.m3u8.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;
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) Element(org.jdom2.Element) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List)

Example 18 with Element

use of com.zhan_dui.utils.m3u8.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;
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) Element(org.jdom2.Element) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List)

Example 19 with Element

use of com.zhan_dui.utils.m3u8.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;
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) Element(org.jdom2.Element) File(java.io.File) Date(java.util.Date)

Example 20 with Element

use of com.zhan_dui.utils.m3u8.Element in project gocd by gocd.

the class HgModificationSplitter method parseFiles.

private List<File> parseFiles(Element filesElement, String fileType) {
    List files = filesElement.getChild(fileType).getChildren("file");
    List<File> modifiedFiles = new ArrayList<>();
    for (Iterator iterator = files.iterator(); iterator.hasNext(); ) {
        Element node = (Element) iterator.next();
        modifiedFiles.add(new File(org.apache.commons.lang.StringEscapeUtils.unescapeXml(node.getText())));
    }
    return modifiedFiles;
}
Also used : Element(org.jdom2.Element) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File)

Aggregations

Element (org.jdom2.Element)673 Attribute (org.jdom2.Attribute)73 Document (org.jdom2.Document)58 File (java.io.File)49 ArrayList (java.util.ArrayList)36 NamedIcon (jmri.jmrit.catalog.NamedIcon)27 IOException (java.io.IOException)26 JDOMException (org.jdom2.JDOMException)26 XmlFile (jmri.jmrit.XmlFile)24 Test (org.junit.Test)24 Turnout (jmri.Turnout)20 DataConversionException (org.jdom2.DataConversionException)20 DocType (org.jdom2.DocType)19 Editor (jmri.jmrit.display.Editor)18 Point (java.awt.Point)15 HashMap (java.util.HashMap)15 Dimension (java.awt.Dimension)14 FileNotFoundException (java.io.FileNotFoundException)13 SignalHead (jmri.SignalHead)13 List (java.util.List)12