List of usage examples for org.jdom2.input SAXBuilder build
@Override public Document build(final String systemId) throws JDOMException, IOException
This builds a document from the supplied URI.
From source file:com.sun.syndication.io.impl.Atom10Parser.java
License:Open Source License
/** * Parse entry from reader./*from w ww . j av a2s . c o m*/ */ public static Entry parseEntry(Reader rd, String baseURI) throws JDOMException, IOException, IllegalArgumentException, FeedException { // Parse entry into JDOM tree SAXBuilder builder = new SAXBuilder(); Document entryDoc = builder.build(rd); Element fetchedEntryElement = entryDoc.getRootElement(); fetchedEntryElement.detach(); // Put entry into a JDOM document with 'feed' root so that Rome can handle it Feed feed = new Feed(); feed.setFeedType("atom_1.0"); WireFeedOutput wireFeedOutput = new WireFeedOutput(); Document feedDoc = wireFeedOutput.outputJDom(feed); feedDoc.getRootElement().addContent(fetchedEntryElement); if (baseURI != null) { feedDoc.getRootElement().setAttribute("base", baseURI, Namespace.XML_NAMESPACE); } WireFeedInput input = new WireFeedInput(); Feed parsedFeed = (Feed) input.build(feedDoc); return (Entry) parsedFeed.getEntries().get(0); }
From source file:com.sun.syndication.io.WireFeedInput.java
License:Open Source License
/** * Builds an WireFeed (RSS or Atom) from an Reader. * <p>// ww w .j a v a 2s.c om * NOTE: This method delages to the 'AsbtractFeed WireFeedInput#build(org.jdom2.Document)'. * <p> * @param reader Reader to read to create the WireFeed. * @return the WireFeed read from the Reader. * @throws IllegalArgumentException thrown if feed type could not be understood by any of the underlying parsers. * @throws FeedException if the feed could not be parsed * */ public WireFeed build(Reader reader) throws IllegalArgumentException, FeedException { SAXBuilder saxBuilder = createSAXBuilder(); try { if (_xmlHealerOn) { reader = new XmlFixerReader(reader); } Document document = saxBuilder.build(reader); return build(document); } catch (JDOMParseException ex) { throw new ParsingFeedException("Invalid XML: " + ex.getMessage(), ex); } catch (IllegalArgumentException ex) { throw ex; } catch (Exception ex) { throw new ParsingFeedException("Invalid XML", ex); } }
From source file:com.sun.syndication.io.WireFeedInput.java
License:Open Source License
/** * Builds an WireFeed (RSS or Atom) from an W3C SAX InputSource. * <p>//from w w w. j a va 2s . co m * NOTE: This method delages to the 'AsbtractFeed WireFeedInput#build(org.jdom2.Document)'. * <p> * @param is W3C SAX InputSource to read to create the WireFeed. * @return the WireFeed read from the W3C SAX InputSource. * @throws IllegalArgumentException thrown if feed type could not be understood by any of the underlying parsers. * @throws FeedException if the feed could not be parsed * */ public WireFeed build(InputSource is) throws IllegalArgumentException, FeedException { SAXBuilder saxBuilder = createSAXBuilder(); try { Document document = saxBuilder.build(is); return build(document); } catch (JDOMParseException ex) { throw new ParsingFeedException("Invalid XML: " + ex.getMessage(), ex); } catch (IllegalArgumentException ex) { throw ex; } catch (Exception ex) { throw new ParsingFeedException("Invalid XML", ex); } }
From source file:com.swordlord.gozer.components.csv.GCsvReport.java
License:Open Source License
/** * //ww w . ja v a 2 s. co m * @param gfe * @param report * @param app * @param session */ public GCsvReport(IGozerFrameExtension gfe, GReport report, Application app, IGozerSessionInfo session) { super(gfe); try { _app = app; _session = session; // TODO fix this String strReportFile = UserPrefs.APP_REPORT_GOZER_FILES_FOLDER + report.getDefiniton(); DefaultReportPanelExtension ext = new DefaultReportPanelExtension(session, strReportFile, gfe.getDataBindingContext()); SAXBuilder sb = new SAXBuilder(); Document document = sb.build(ResourceLoader.loadResource(_app, strReportFile, getClass())); Parser parser = new Parser(ext.getDataBindingContext()); parser.createTree(document); _ot = parser.getTree(); _context = new GWReportContext(null, ext, GozerDisplayMode.PDF, _ot); } catch (Exception e) { LOG.warn(e.getLocalizedMessage()); } }
From source file:com.swordlord.gozer.components.fop.GFopReport.java
License:Open Source License
/** * /*from w w w . ja v a 2 s . c o m*/ * @param gfe * @param report * @param app * @param session */ public GFopReport(IGozerFrameExtension gfe, GReport report, Application app, IGozerSessionInfo session) { super(gfe); try { _app = app; _session = session; // TODO: fix this String strReportFile = UserPrefs.APP_REPORT_GOZER_FILES_FOLDER + report.getDefiniton(); DefaultReportPanelExtension ext = new DefaultReportPanelExtension(session, strReportFile, gfe.getDataBindingContext()); SAXBuilder sb = new SAXBuilder(); Document document = sb.build(ResourceLoader.loadResource(_app, strReportFile, getClass())); Parser parser = new Parser(ext.getDataBindingContext()); parser.createTree(document); _ot = parser.getTree(); _context = new GWReportContext(null, ext, GozerDisplayMode.PDF, _ot); } catch (Exception e) { e.printStackTrace(); System.out.println(e); } }
From source file:com.swordlord.gozer.components.wicket.action.button.GWAbstractAction.java
License:Open Source License
/** * Loads the ObjectTree from the given GozerFrameExtension. Checks JCR first * and then loads from the HD afterwards. * /* w ww . ja va2 s . c o m*/ * @param gfe * GozerFrameExtension to load tree from. * @return Returns loaded ObjectTree */ protected ObjectTree getObjectTree(IGozerFrameExtension gfe) { try { String layoutFileName = gfe.getGozerLayoutFileName(); // Search the gozer configuration file first in the JCR Repository // then on the file system. InputStream inputStream = GozerFileLoader.getGozerLayout(getApplication(), layoutFileName); SAXBuilder sb = new SAXBuilder(); Document document = sb.build(inputStream); Parser parser = new Parser(gfe.getDataBindingContext()); parser.createTree(document); ObjectTree ot = parser.getTree(); return ot; } catch (JDOMException e) { String error = MessageFormat.format( "Error when rendering ObjectTree with GozerFile: {0}, Error: {1}, Cause: {2}", gfe.getGozerLayoutFileName(), e, e.getCause()); LOG.error(error); } catch (NullPointerException e) { String error = MessageFormat.format( "Error when rendering ObjectTree with GozerFile: {0}, Error: {1}, Cause: {2}", gfe.getGozerLayoutFileName(), e, e.getCause()); LOG.error(error); e.printStackTrace(); } catch (Exception e) { String error = MessageFormat.format( "Error when rendering ObjectTree with GozerFile: {0}, Error: {1}, Cause: {2}", gfe.getGozerLayoutFileName(), e, e.getCause()); LOG.error(error); } return null; }
From source file:com.swordlord.gozer.ui.gozerframe.WicketGozerPanel.java
License:Open Source License
protected ObjectTree getObjectTree(IGozerFrameExtension gfe) { try {//from www . j a va 2s . co m String layoutFileName = gfe.getGozerLayoutFileName(); //Search the gozer configuration file first in the JCR Repository then on the file system. InputStream inputStream = GozerFileLoader.getGozerLayout(getApplication(), layoutFileName); SAXBuilder sb = new SAXBuilder(); Document document = sb.build(inputStream); Parser parser = new Parser(gfe.getDataBindingContext()); parser.createTree(document); ObjectTree ot = parser.getTree(); return ot; } catch (JDOMException e) { String error = MessageFormat.format( "Error when rendering ObjectTree with GozerFile: {0}, Error: {1}, Cause: {2}", gfe.getGozerLayoutFileName(), e, e.getCause()); LOG.error(error); } catch (NullPointerException e) { String error = MessageFormat.format( "Error when rendering ObjectTree with GozerFile: {0}, Error: {1}, Cause: {2}", gfe.getGozerLayoutFileName(), e, e.getCause()); LOG.error(error); e.printStackTrace(); } catch (Exception e) { String error = MessageFormat.format( "Error when rendering ObjectTree with GozerFile: {0}, Error: {1}, Cause: {2}", gfe.getGozerLayoutFileName(), e, e.getCause()); LOG.error(error); } return null; }
From source file:com.swordlord.gozer.ui.gozerframe.WicketGozerReportPanel.java
License:Open Source License
protected ObjectTree getObjectTree(GozerReportExtension gfe) { try {//from w w w . java 2s .c o m String layoutFileName = gfe.getGozerLayoutFileName(); //Search the gozer configuration file first in the JCR Repository then on the file system. InputStream inputStream = GozerFileLoader.getGozerLayout(getApplication(), layoutFileName); SAXBuilder sb = new SAXBuilder(); Document document = sb.build(inputStream); Parser parser = new Parser(gfe.getDataBindingContext()); parser.createTree(document); ObjectTree ot = parser.getTree(); return ot; } catch (JDOMException eJDOM) { LOG.error(eJDOM); } catch (Exception e) { LOG.error(e); } return null; }
From source file:com.tactfactory.harmony.ProjectContext.java
License:Open Source License
/** * Extract Project NameSpace from AndroidManifest file. * * @param manifest Manifest File/*from w w w . j av a 2s. co m*/ * @return Project Name Space */ public static void loadNameSpaceFromManifest(final File manifest) { String result = null; SAXBuilder builder; Document doc; if (manifest.exists()) { // Make engine builder = new SAXBuilder(); try { // Load XML File doc = builder.build(manifest); // Load Root element final Element rootNode = doc.getRootElement(); // Get Name Space from package declaration result = rootNode.getAttributeValue("package"); result = result.replaceAll("\\.", HarmonyContext.DELIMITER); } catch (final JDOMException e) { ConsoleUtils.displayError(e); } catch (final IOException e) { ConsoleUtils.displayError(e); } } if (result != null) { ApplicationMetadata.INSTANCE.setProjectNameSpace(result.trim()); } }
From source file:com.tactfactory.harmony.ProjectContext.java
License:Open Source License
/** * Extract Project Name from configuration file. * * @param config Configuration file//from www . j a v a2 s . c o m * @return Project Name Space */ public static void loadProjectNameFromConfig(final File config) { String result = null; SAXBuilder builder; Document doc; if (config.exists()) { // Make engine builder = new SAXBuilder(); try { // Load XML File doc = builder.build(config); // Load Root element final Element rootNode = doc.getRootElement(); result = rootNode.getAttribute("name").getValue(); } catch (final JDOMException e) { ConsoleUtils.displayError(e); } catch (final IOException e) { ConsoleUtils.displayError(e); } } if (result != null) { ApplicationMetadata.INSTANCE.setName(result.trim()); } }