List of usage examples for org.jdom2.input SAXBuilder SAXBuilder
public SAXBuilder()
From source file:edu.co.usbcali.ir.util.ExtractReutersNews.java
public void extractNewsFromXml(String path) { SAXBuilder builder = new SAXBuilder(); File xmlFile = new File(path); String baseFileName = FilenameUtils.removeExtension(xmlFile.getName()); String lineSeparator = System.getProperty("line.separator"); try {/* w w w. ja va 2s .c o m*/ Document document = (Document) builder.build(xmlFile); Element rootNode = document.getRootElement(); List listReuters = rootNode.getChildren("REUTERS"); for (Object listElement : listReuters) { Element reuters = (Element) listElement; String newId = reuters.getAttributeValue("NEWID"); String date = reuters.getChildText("DATE"); List listText = reuters.getChildren("TEXT"); Element text = (Element) listText.get(0); String title = text.getChildText("TITLE"); String body = text.getChildText("BODY"); String reuterContent = title + lineSeparator + date + lineSeparator + lineSeparator + body; String reuterPath = "reuters/" + baseFileName + "-" + newId + ".txt"; WriteFile.writeFileContent(reuterContent, reuterPath); } } catch (JDOMException | IOException ex) { Logger.getLogger(ExtractReutersNews.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:edu.kit.iks.Cryptographics.Caesar.Demonstration.CryptoDemonstrationController.java
License:MIT License
/** * Constructor./* ww w. j av a2 s.c om*/ * * @param visualizationInfo */ public CryptoDemonstrationController(AbstractVisualizationInfo visualizationInfo) { super(visualizationInfo); SAXBuilder saxBuilder = new SAXBuilder(); // obtain file object InputStream is = this.getClass().getResourceAsStream("/caesar/CaesarResources.xml"); try { // converted file to document object Document document = saxBuilder.build(is); // get root node from xml this.cryptoResources = document.getRootElement(); } catch (JDOMException | IOException e) { Logger.error(e); } }
From source file:edu.kit.iks.Cryptographics.Caesar.Demonstration.IntroductionController.java
License:MIT License
/** * Constructor.//from ww w. j a va 2s. c o m * * @param visualizationInfo */ public IntroductionController(AbstractVisualizationInfo visualizationInfo) { super(visualizationInfo); SAXBuilder saxBuilder = new SAXBuilder(); // obtain file object InputStream is = this.getClass().getResourceAsStream("/caesar/CaesarResources.xml"); try { // converted file to document object Document document = saxBuilder.build(is); // get root node from xml this.caesarResources = document.getRootElement(); } catch (JDOMException | IOException e) { Logger.error(e); } }
From source file:edu.kit.iks.Cryptographics.Caesar.Experiment.CryptoExperimentController.java
License:MIT License
/** * Constructor./* w w w .ja va 2 s . c o m*/ * * @param visualizationInfo */ public CryptoExperimentController(AbstractVisualizationInfo visualizationInfo) { super(visualizationInfo); SAXBuilder saxBuilder = new SAXBuilder(); // obtain file object InputStream is = this.getClass().getResourceAsStream("/caesar/CaesarResources.xml"); try { // converted file to document object Document document = saxBuilder.build(is); // get root node from xml this.cryptoResources = document.getRootElement(); } catch (JDOMException | IOException e) { Logger.error(e); } }
From source file:edu.kit.iks.Cryptographics.StartController.java
License:MIT License
/** * Loads the view/*from w w w . j ava2s .c o m*/ */ @Override public void loadView() { this.view = new JPanel(new GridBagLayout()); this.view.setName("start-controller-view"); SAXBuilder saxBuilder = new SAXBuilder(); // obtain file object InputStream is = this.getClass().getResourceAsStream("/start/startResources.xml"); try { // converted file to document object Document document = saxBuilder.build(is); // get root node from xml this.startResources = document.getRootElement(); } catch (JDOMException | IOException e) { Logger.error(e); } // Add welcome view and its layout GridBagConstraints welcomeViewLayout = new GridBagConstraints(); welcomeViewLayout.fill = GridBagConstraints.HORIZONTAL; welcomeViewLayout.gridy = 0; welcomeViewLayout.weighty = 0.95f; this.welcomeView = new WelcomeView(); this.view.add(this.welcomeView, welcomeViewLayout); String path = startResources.getChild("welcomeImage").getAttributeValue("path"); GridBagConstraints imgConstraint = new GridBagConstraints(); imgConstraint.gridx = 0; imgConstraint.gridy = 1; imgConstraint.insets = new Insets(0, 0, 50, 0); ImageView imageToSet = new ImageView(path); this.view.add(imageToSet, imgConstraint); // Add timeline view and its layout GridBagConstraints timelineViewLayout = new GridBagConstraints(); timelineViewLayout.fill = GridBagConstraints.HORIZONTAL; timelineViewLayout.weightx = 1.0f; timelineViewLayout.weighty = 0.05f; timelineViewLayout.gridy = 2; this.timelineView = new TimelineView(visualizationInfos); this.view.add(this.timelineView, timelineViewLayout); // Add event handlers for (VisualizationButton button : this.timelineView.getButtons()) { button.addMouseListener(new MouseClickListener() { @Override public void clicked(MouseEvent event) { VisualizationButton button = (VisualizationButton) event.getSource(); presentPopoverAction(button.getVisualizationInfo(), button); } }); } this.view.validate(); }
From source file:edu.kit.iks.Cryptographics.Vigenere.VigenereVisualizationInfo.java
License:MIT License
/** * loads the resources which are bundled with the jar file *//*from w w w . j av a 2s. c om*/ private void loadResources() { SAXBuilder saxBuilder = new SAXBuilder(); InputStream is = this.getClass().getResourceAsStream("/vigenere/VigenereResources.xml"); try { // converted file to document object Document document = saxBuilder.build(is); // get root node from xml this.vigenereResources = document.getRootElement().getChild("vigenere"); } catch (JDOMException | IOException e) { Logger.error(e); } }
From source file:edu.kit.iks.cryptographicslib.common.view.InformationView.java
License:MIT License
/** * Helper to init the resources.//from ww w. j av a2 s . com */ private void initResources() { SAXBuilder saxBuilder = new SAXBuilder(); // obtain file object InputStream is = this.getClass().getResourceAsStream("/icons/IconResources.xml"); try { // converted file to document object Document document = saxBuilder.build(is); // get root node from xml this.resources = document.getRootElement().getChild("InformationView"); } catch (JDOMException | IOException e) { Logger.error(e); } }
From source file:edu.kit.iks.cryptographicslib.common.view.partial.KeyboardView.java
License:MIT License
/** * Helper to init the resources.//from w w w. ja v a2s. c o m */ private void initResources() { SAXBuilder saxBuilder = new SAXBuilder(); // obtain file object InputStream is = this.getClass().getResourceAsStream("/icons/IconResources.xml"); try { // converted file to document object Document document = saxBuilder.build(is); // get root node from xml this.resources = document.getRootElement().getChild("Keyboard"); } catch (JDOMException | IOException e) { Logger.error(e); } }
From source file:edu.kit.iks.cryptographicslib.common.view.partial.NumpadView.java
License:MIT License
private void initResources() { SAXBuilder saxBuilder = new SAXBuilder(); // obtain file object InputStream is = this.getClass().getResourceAsStream("/icons/IconResources.xml"); try {//www.j a va 2 s . c om // converted file to document object Document document = saxBuilder.build(is); // get root node from xml this.resources = document.getRootElement().getChild("Keyboard"); } catch (JDOMException | IOException e) { Logger.error(e); } }
From source file:edu.kit.iks.CryptographicsLib.Configuration.java
License:MIT License
/** * Marked as private to enforce singleton pattern. *//*from w ww . j a v a 2 s . co m*/ private Configuration(String path) { try { // Load document. SAXBuilder saxBuilder = new SAXBuilder(); Document document = saxBuilder.build(new File(path)); // Get root element. Element element = document.getRootElement(); for (Element child : element.getChildren()) { parseConfigElement(child); } } catch (JDOMException | IOException e) { // Could not read configuration. Use default values and print stack // trace. e.printStackTrace(); } }