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());
}
}
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);
}
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;
}
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;
}
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));
}
Aggregations