Search in sources :

Example 1 with SAXBuilder

use of org.jdom2.input.SAXBuilder in project pcgen by PCGen.

the class NameGenPanel method loadData.

private void loadData(File path) {
    if (path.isDirectory()) {
        File[] dataFiles = path.listFiles(new XMLFilter());
        SAXBuilder builder = new SAXBuilder();
        GeneratorDtdResolver resolver = new GeneratorDtdResolver(path);
        builder.setEntityResolver(resolver);
        for (File dataFile : dataFiles) {
            try {
                URL url = dataFile.toURI().toURL();
                Document nameSet = builder.build(url);
                DocType dt = nameSet.getDocType();
                if (dt.getElementName().equals("GENERATOR")) {
                    loadFromDocument(nameSet);
                }
            } catch (Exception e) {
                Logging.errorPrint(e.getMessage(), e);
                JOptionPane.showMessageDialog(this, "XML Error with file " + dataFile.getName());
            }
        }
        loadDropdowns();
    } else {
        JOptionPane.showMessageDialog(this, "No data files in directory " + path.getPath());
    }
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) Document(org.jdom2.Document) File(java.io.File) URL(java.net.URL) DocType(org.jdom2.DocType) FileNotFoundException(java.io.FileNotFoundException) DataConversionException(org.jdom2.DataConversionException)

Example 2 with SAXBuilder

use of org.jdom2.input.SAXBuilder in project pcgen by PCGen.

the class RoomBoardFactory method load.

public static RoomBoard load(File dataDir) {
    //Create a new list for the room and board
    PairList<RBCost> inns = new PairList<>();
    PairList<RBCost> foods = new PairList<>();
    PairList<RBCost> animals = new PairList<>();
    File path = new File(dataDir, DIR_RNBPRICE);
    if (path.isDirectory()) {
        File[] dataFiles = path.listFiles(new XMLFilter());
        SAXBuilder builder = new SAXBuilder();
        for (int i = 0; i < dataFiles.length; i++) {
            try {
                Document methodSet = builder.build(dataFiles[i]);
                DocType dt = methodSet.getDocType();
                if (//$NON-NLS-1$
                dt.getElementName().equals("RNBPRICE")) {
                    //Do work here
                    loadRBData(methodSet, inns, foods, animals);
                }
                methodSet = null;
                dt = null;
            } catch (Exception e) {
                Logging.errorPrintLocalised("XML Error with file {0}", dataFiles[i].getName());
                Logging.errorPrint(e.getMessage(), e);
            }
        }
    } else {
        //$NON-NLS-1$
        Logging.errorPrintLocalised("in_plugin_overland_noDatafile", path.getPath());
    }
    return new RoomBoardImplementation(inns, foods, animals);
}
Also used : RBCost(plugin.overland.util.RBCost) SAXBuilder(org.jdom2.input.SAXBuilder) XMLFilter(plugin.overland.gui.XMLFilter) PairList(plugin.overland.util.PairList) Document(org.jdom2.Document) File(java.io.File) DocType(org.jdom2.DocType) ParseException(java.text.ParseException)

Example 3 with SAXBuilder

use of org.jdom2.input.SAXBuilder in project gocd by gocd.

the class SvnCommand method getAllExternalURLs.

public List<SvnExternal> getAllExternalURLs() {
    CommandLine svnExternalCommand = svn(true).withArgs("propget", "--non-interactive", "svn:externals", "-R").withArg(repositoryUrl);
    ConsoleResult result = executeCommand(svnExternalCommand);
    String svnExternalConsoleOut = result.outputAsString();
    SvnInfo remoteInfo = remoteInfo(new SAXBuilder());
    String repoUrl = remoteInfo.getUrl();
    String repoRoot = remoteInfo.getRoot();
    List<SvnExternal> svnExternalList = null;
    try {
        svnExternalList = new SvnExternalParser().parse(svnExternalConsoleOut, repoUrl, repoRoot);
    } catch (RuntimeException e) {
        throw (RuntimeException) result.smudgedException(e);
    }
    return svnExternalList;
}
Also used : CommandLine.createCommandLine(com.thoughtworks.go.util.command.CommandLine.createCommandLine) SAXBuilder(org.jdom2.input.SAXBuilder)

Example 4 with SAXBuilder

use of org.jdom2.input.SAXBuilder in project gocd by gocd.

the class SvnCommand method getBuilder.

private SAXBuilder getBuilder() {
    SAXBuilder saxBuilder = saxBuilderThreadLocal.get();
    if (saxBuilder == null) {
        saxBuilder = new SAXBuilder();
        saxBuilderThreadLocal.set(saxBuilder);
    }
    return saxBuilder;
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder)

Example 5 with SAXBuilder

use of org.jdom2.input.SAXBuilder in project gocd by gocd.

the class SvnLogXmlParserTest method shouldGetAllModifiedFilesUnderRootPath.

@Test
public void shouldGetAllModifiedFilesUnderRootPath() {
    SvnLogXmlParser parser = new SvnLogXmlParser();
    List<Modification> materialRevisions = parser.parse(MULTIPLE_FILES, "", new SAXBuilder());
    Modification mod = materialRevisions.get(0);
    List<ModifiedFile> files = mod.getModifiedFiles();
    assertThat(files.size(), is(2));
    ModifiedFile file = files.get(0);
    assertThat(file.getFileName(), is("/trunk/revision3.txt"));
    assertThat(file.getAction(), is(ModifiedAction.added));
    file = files.get(1);
    assertThat(file.getFileName(), is("/branch/1.1/readme.txt"));
    assertThat(file.getAction(), is(ModifiedAction.deleted));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) SAXBuilder(org.jdom2.input.SAXBuilder) ModifiedFile(com.thoughtworks.go.domain.materials.ModifiedFile) Test(org.junit.Test)

Aggregations

SAXBuilder (org.jdom2.input.SAXBuilder)121 Document (org.jdom2.Document)84 Element (org.jdom2.Element)51 IOException (java.io.IOException)34 Test (org.junit.Test)29 JDOMException (org.jdom2.JDOMException)27 File (java.io.File)20 StringReader (java.io.StringReader)15 InputStream (java.io.InputStream)14 ArrayList (java.util.ArrayList)12 URL (java.net.URL)9 XMLOutputter (org.jdom2.output.XMLOutputter)8 Modification (com.thoughtworks.go.domain.materials.Modification)7 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)7 List (java.util.List)6 ParseException (java.text.ParseException)5 MCRPath (org.mycore.datamodel.niofs.MCRPath)5 BufferedInputStream (java.io.BufferedInputStream)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 FileInputStream (java.io.FileInputStream)4