本文整理汇总了Java中org.jdom.input.SAXBuilder.build方法的典型用法代码示例。如果您正苦于以下问题:Java SAXBuilder.build方法的具体用法?Java SAXBuilder.build怎么用?Java SAXBuilder.build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jdom.input.SAXBuilder
的用法示例。
在下文中一共展示了SAXBuilder.build方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadRecent
import org.jdom.input.SAXBuilder; //导入方法依赖的package包/类
private void loadRecent(Path recentFile) throws FileNotFoundException,
IOException, JDOMException {
SAXBuilder builder = new SAXBuilder();
@SuppressWarnings("unused")
Document document;
try (InputStream fileInputStream = Files.newInputStream(recentFile)) {
document = builder.build(fileInputStream);
}
synchronized (recents) {
recents.clear();
// TAVERNA-65 - temporarily disabled
//RecentDeserializer deserialiser = new RecentDeserializer();
try {
// recents.addAll(deserialiser.deserializeRecent(document
// .getRootElement()));
} catch (Exception e) {
logger.warn("Could not read recent workflows from file "
+ recentFile, e);
}
}
}
示例2: parseSearchResult
import org.jdom.input.SAXBuilder; //导入方法依赖的package包/类
private LyricsInfo parseSearchResult(String xml) throws Exception {
SAXBuilder builder = new SAXBuilder();
Document document = builder.build(new StringReader(xml));
Element root = document.getRootElement();
Namespace ns = root.getNamespace();
String lyric = StringUtils.trimToNull(root.getChildText("Lyric", ns));
String song = root.getChildText("LyricSong", ns);
String artist = root.getChildText("LyricArtist", ns);
return new LyricsInfo(lyric, artist, song);
}
示例3: readComponent
import org.jdom.input.SAXBuilder; //导入方法依赖的package包/类
@Nullable
private static Element readComponent(@NotNull SAXBuilder parser, @NotNull String projectPath) {
Element component = null;
try {
String studyProjectXML = projectPath + STUDY_PROJECT_XML_PATH;
Document xmlDoc = parser.build(new File(studyProjectXML));
Element root = xmlDoc.getRootElement();
component = root.getChild("component");
}
catch (JDOMException | IOException ignored) {
}
return component;
}
示例4: constructDocumentFromXml
import org.jdom.input.SAXBuilder; //导入方法依赖的package包/类
/**
* Construct document from xml string.
*
* @param xmlString the xml string
* @return the document
*/
public static Document constructDocumentFromXml(final String xmlString) {
try {
final SAXBuilder builder = new SAXBuilder();
builder.setFeature("http://xml.org/sax/features/external-general-entities", false);
builder.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
return builder
.build(new ByteArrayInputStream(xmlString.getBytes(Charset.defaultCharset())));
} catch (final Exception e) {
return null;
}
}
示例5: initialise
import org.jdom.input.SAXBuilder; //导入方法依赖的package包/类
@Override
public boolean initialise() {
try {
super.imgName=manifestFile.getParentFile().getName();
SAXBuilder builder = new SAXBuilder();
setFile(manifestFile);
doc = builder.build(productxml);
tiffImages = getImages();
if(tiffImages==null) return false;
IReader image = tiffImages.values().iterator().next();
this.displayName=super.imgName;//+ " " +image.getImageFile().getName();
parseProductXML(productxml);
bounds = new Rectangle(0, 0, image.getxSize(), image.getySize());
readPixel(0,0,0);
} catch (Exception ex) {
dispose();
logger.error(ex.getMessage(),ex);
return false;
}
return true;
}
示例6: fromXSchema
import org.jdom.input.SAXBuilder; //导入方法依赖的package包/类
/** Creates an AnnotationSchema object from an XSchema file
* @param anXSchemaURL the URL where to find the XSchema file
*/
public void fromXSchema(URL anXSchemaURL)
throws ResourceInstantiationException {
org.jdom.Document jDom = null;
SAXBuilder saxBuilder = new SAXBuilder(false);
try {
try{
jDom = saxBuilder.build(anXSchemaURL);
}catch(JDOMException je){
throw new ResourceInstantiationException(je);
}
} catch (java.io.IOException ex) {
throw new ResourceInstantiationException(ex);
}
workWithJDom(jDom);
}
示例7: main
import org.jdom.input.SAXBuilder; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
URL input = (new File(
"/home/mark/gate-top/externals/gate-svn/plugins/Lang_French/french.gapp"))
.toURI().toURL();
SAXBuilder builder = new SAXBuilder(false);
Document doc = builder.build(input);
List<UpgradePath> upgrades = suggest(doc);
for(UpgradePath upgrade : upgrades) {
System.out.println(upgrade);
}
upgrade(doc, upgrades);
outputter.output(doc, System.out);
}
示例8: getAlertsFromFile
import org.jdom.input.SAXBuilder; //导入方法依赖的package包/类
public static List<Alert> getAlertsFromFile(File file, String alertType) throws JDOMException, IOException {
List<Alert> alerts = new ArrayList<>();
SAXBuilder parser = new SAXBuilder();
Document alertsDoc = parser.build(file);
@SuppressWarnings("unchecked")
List<Element> alertElements = alertsDoc.getRootElement().getChildren(alertType);
for (Element element: alertElements){
Alert alert = new Alert(
element.getAttributeValue("alert"),
element.getAttributeValue("url"),
element.getAttributeValue("risk"),
element.getAttributeValue("confidence"),
element.getAttributeValue("param"),
element.getAttributeValue("other"));
alerts.add(alert);
}
return alerts;
}
示例9: Properties
import org.jdom.input.SAXBuilder; //导入方法依赖的package包/类
public Properties() {
try {
String encodedApplicationFolder = (new File(Properties.class
.getProtectionDomain()
.getCodeSource()
.getLocation()
.getPath())).getParentFile().getAbsolutePath();
applicationFolder = URLDecoder.decode(encodedApplicationFolder, "UTF-8");
File file = new File(applicationFolder, "properties.xml");
if (!file.exists()) {
file = new File("properties.xml");
}
SAXBuilder builder = new SAXBuilder();
configurationFile = builder.build(file);
parseXML();
} catch (Exception e) {
e.printStackTrace(System.err);
}
}
示例10: updateAliasInPARs
import org.jdom.input.SAXBuilder; //导入方法依赖的package包/类
private void updateAliasInPARs(String includeOrigin, String includeDestination, File ear) throws IOException, JDOMException {
TrueZipFileSet pars = new TrueZipFileSet();
pars.setDirectory(ear.getAbsolutePath());
pars.addInclude("*.par");
List<TFile> parsXML = truezip.list(pars);
for (TFile parXML : parsXML) {
TFile xmlTIBCO = new TFile(parXML, "TIBCO.xml");
String tempPath = ear.getParentFile().getAbsolutePath() + File.separator + "TIBCO.xml";
TFile xmlTIBCOTemp = new TFile(tempPath);
truezip.copyFile(xmlTIBCO, xmlTIBCOTemp);
File xmlTIBCOFile = new File(tempPath);
SAXBuilder sxb = new SAXBuilder();
Document document = sxb.build(xmlTIBCOFile);
XPath xpa = XPath.newInstance("//dd:NameValuePairs/dd:NameValuePair[dd:name='EXTERNAL_JAR_DEPENDENCY']/dd:value");
xpa.addNamespace("dd", "http://www.tibco.com/xmlns/dd");
Element singleNode = (Element) xpa.selectSingleNode(document);
if (singleNode != null) {
String value = singleNode.getText().replace(includeOrigin, includeDestination);
singleNode.setText(value);
XMLOutputter xmlOutput = new XMLOutputter();
xmlOutput.setFormat(Format.getPrettyFormat().setIndent(" "));
xmlOutput.output(document, new FileWriter(xmlTIBCOFile));
truezip.copyFile(xmlTIBCOTemp, xmlTIBCO);
}
}
}
示例11: getToStringOnRootElementWrapper
import org.jdom.input.SAXBuilder; //导入方法依赖的package包/类
private String getToStringOnRootElementWrapper(String inputFileName) throws IOException, JDOMException {
PluginParameters pluginParameters = PluginParameters.builder()
.setPomFile(null).setFileOutput(false, ".bak", null)
.setEncoding("UTF-8")
.setFormatting("\r\n", true, true)
.setIndent(2, false)
.setSortOrder("default_0_4_0.xml", null)
.setSortEntities("scope,groupId,artifactId", "groupId,artifactId", true, true).build();
FileUtil fileUtil = new FileUtil();
fileUtil.setup(pluginParameters);
String xml = IOUtils.toString(new FileInputStream("src/test/resources/" + inputFileName), UTF_8);
SAXBuilder parser = new SAXBuilder();
Document document = parser.build(new ByteArrayInputStream(xml.getBytes(UTF_8)));
WrapperFactoryImpl wrapperFactory = new WrapperFactoryImpl(fileUtil);
wrapperFactory.setup(pluginParameters);
HierarchyRootWrapper rootWrapper = wrapperFactory.createFromRootElement(document.getRootElement());
rootWrapper.createWrappedStructure(wrapperFactory);
return rootWrapper.toString();
}
示例12: BeastImporter
import org.jdom.input.SAXBuilder; //导入方法依赖的package包/类
public BeastImporter(Reader reader) throws IOException, JDOMException, Importer.ImportException {
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(reader);
root = doc.getRootElement();
if (!root.getName().equalsIgnoreCase("beast")) {
throw new Importer.ImportException("Unrecognized root element in XML file");
}
dateFormat = DateFormat.getDateInstance(java.text.DateFormat.SHORT, Locale.UK);
dateFormat.setLenient(true);
Calendar cal = Calendar.getInstance(Locale.getDefault());
// set uses a zero based month (Jan = 0):
cal.set(0000, 00, 01);
// origin = cal.getTime();
cal.setTimeInMillis(0);
origin = cal.getTime();
}
示例13: getTemplateListFromXml
import org.jdom.input.SAXBuilder; //导入方法依赖的package包/类
private ArrayList<TrivialnameTemplate> getTemplateListFromXml(URL xmlUrl) throws ResourcesDbException {
ArrayList<TrivialnameTemplate> tmplList = new ArrayList<TrivialnameTemplate>();
SAXBuilder parser = new SAXBuilder();
try {
Document doc = parser.build(xmlUrl);
org.jdom.Element root = doc.getRootElement();
List<?> templateTagsList = root.getChildren();
Iterator<?> templatesIter = templateTagsList.iterator();
while(templatesIter.hasNext()) {
org.jdom.Element xmlTemplate = (org.jdom.Element) templatesIter.next();
TrivialnameTemplate template = getTemplateFromXmlTree(xmlTemplate);
if(template != null) {
tmplList.add(template);
}
}
} catch (JDOMException je) {
throw new ResourcesDbException("Exception in reading TrivialnameTemplate XML file.", je);
} catch (IOException ie) {
throw new ResourcesDbException("Exception in reading TrivialnameTemplate XML file.", ie);
}
return tmplList;
}
示例14: testConvertFull
import org.jdom.input.SAXBuilder; //导入方法依赖的package包/类
@Test
public void testConvertFull() throws Exception {
SAXBuilder builder = new SAXBuilder();
builder.setValidation(false);
builder.setFeature("http://xml.org/sax/features/validation", false);
builder.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
builder.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
InputStreamReader testIS = new InputStreamReader(ClassLoader.class.getResourceAsStream(testXML), "UTF-8");
Document document = builder.build(testIS);
Element sourceDocument = document.getRootElement();
String testText = NlmToDocumentTextConverter.getDocumentText(sourceDocument, null);
testIS.close();
InputStream expectedIS = ClassLoader.class.getResourceAsStream(testTXT);
String expectedText = IOUtils.toString(expectedIS, "UTF-8").replaceAll(System.getProperty("line.separator"), "\n");
expectedIS.close();
assertEquals(expectedText, testText);
}
示例15: parseJobProperties
import org.jdom.input.SAXBuilder; //导入方法依赖的package包/类
/**
* Returns oozie job parsed properties
*/
public Properties parseJobProperties(String jobPropertiesString) {
Properties jobProperties = new Properties();
try {
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(new StringReader(jobPropertiesString));
for (Object o : doc.getRootElement().getChildren()) {
Element propertyElement = (Element) o;
String propertyName = propertyElement.getChildText("name");
String propertyValue = propertyElement.getChildText("value");
jobProperties.put(propertyName, propertyValue);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return jobProperties;
}