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:edu.kit.iks.Cryptographics.Caesar.Demonstration.IntroductionController.java
License:MIT License
/** * Constructor./*from ww w . j av a 2s . c om*/ * * @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./* ww w . j av a 2s .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 ww. j a va2 s .c om */ @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 . jav a2 s. c o m*/ 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 w w w. j a v a 2 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 .j a v a 2 s . 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 {//ww w . j a v a 2 s.co m // 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 w w . j a va 2s . 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(); } }
From source file:edu.kit.iks.cryptographicslib.framework.controller.StartController.java
License:MIT License
@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 {/* ww w .j av a 2 s . c o m*/ // 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 (VisualizationButtonView button : this.timelineView.getButtons()) { button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { VisualizationButtonView button = (VisualizationButtonView) e.getSource(); StartController.this.presentPopoverAction(button.getVisualizationInfo(), button); } }); } this.view.validate(); }
From source file:edu.kit.trufflehog.model.configdata.SettingsDataModel.java
License:Open Source License
/** * <p>//ww w. ja v a 2 s. co m * Loads all settings found on the hard drive into memory. * </p> */ public void load() { settingsMap.clear(); try { // Set up the XML parser SAXBuilder saxBuilder = new SAXBuilder(); Document document = saxBuilder.build(settingsFile); Element rootElement = document.getRootElement(); if (!checkHead(rootElement.getChild("head"))) { logger.error("Settings file does not match specified type"); return; } // Get the "data" elements of the xml file Element data = rootElement.getChild("data"); // Parse through all entries and add them to the map List<Element> entries = data.getChildren(); entries.stream().forEach(entry -> { // Get the type, key and value. The type has to be specified as the whole class name, otherwise // it is set to java.lang.Object String type = entry.getAttribute("type").getValue(); Class typeClass; try { typeClass = Class.forName(type); } catch (ClassNotFoundException e) { logger.error("Specified type class does not exist, setting the type class to java.lang.Object", e); typeClass = Object.class; } String key = entry.getChild("key").getValue(); String value = entry.getChild("value").getValue(); // Finally add the data to the map addToMap(typeClass, key, value); }); } catch (JDOMException | IOException e) { logger.error("Error while parsing the " + CONFIG_FILE_NAME + " file", e); } }