List of usage examples for org.jdom2 Attribute getValue
public String getValue()
Attribute
. From source file:AIR.ResourceBundler.Xml.FileSet.java
License:Open Source License
public void parse(Element resourcesEl) throws ResourcesException { Attribute fileSetAttrib = null; // parse main attributes fileSetAttrib = resourcesEl.getAttribute("name"); _name = (fileSetAttrib != null) ? fileSetAttrib.getValue() : null; fileSetAttrib = resourcesEl.getAttribute("output"); setOutput((fileSetAttrib != null) ? fileSetAttrib.getValue() : null); // parse setting attributes fileSetAttrib = resourcesEl.getAttribute("compress"); if (fileSetAttrib != null) _compress = (fileSetAttrib.getValue() == "true"); fileSetAttrib = resourcesEl.getAttribute("removeLines"); if (fileSetAttrib != null) _removeEmptyLines = (fileSetAttrib.getValue() == "true"); fileSetAttrib = resourcesEl.getAttribute("removeComments"); if (fileSetAttrib != null) _removeComments = (fileSetAttrib.getValue() == "true"); fileSetAttrib = resourcesEl.getAttribute("removeSpaces"); if (fileSetAttrib != null) removeSpaces = (fileSetAttrib.getValue() == "true"); for (Element childEl : resourcesEl.getChildren()) { String childName = childEl.getName(); if ("input".equalsIgnoreCase(childName)) { parseFileInput(childEl);/*from w w w . ja va2 s.co m*/ } else if ("reference".equalsIgnoreCase(childName)) { parseReference(childEl); } else if ("exclude".equalsIgnoreCase(childName)) { parseExclude(childEl); } else if ("replace".equalsIgnoreCase(childName)) { parseReplace(childEl); } } }
From source file:AIR.ResourceBundler.Xml.FileSet.java
License:Open Source License
private void parseReference(Element dependencyEl) throws ResourcesException { // lookup dependency Attribute setAttrib = dependencyEl.getAttribute("set"); String setName = (setAttrib != null) ? setAttrib.getValue() : null; // Replacing tts by tts2 if ("tts".equals(setName)) setName = "tts2"; // add files/*from www . j av a2s .c o m*/ FileSet fileSet = _parentResources.getFileSet(setName); if (fileSet != null) { _entries.add(fileSet); } }
From source file:AIR.ResourceBundler.Xml.FileSet.java
License:Open Source License
private void parseExclude(Element excludeEl) { Attribute setAttrib = excludeEl.getAttribute("set"); String setName = (setAttrib != null) ? setAttrib.getValue() : null; // add files//from w w w .j a v a2 s. c o m FileSet fileSet = _parentResources.getFileSet(setName); if (fileSet != null) { _excludedSets.add(fileSet); } }
From source file:AIR.ResourceBundler.Xml.FileSet.java
License:Open Source License
private void parseReplace(Element replaceEl) { // get source fileset Attribute setAttrib = replaceEl.getAttribute("set"); String fileSetName = (setAttrib != null) ? setAttrib.getValue() : null; FileSet fileSet = _parentResources.getFileSet(fileSetName); // get desintation fileset Attribute newAttrib = replaceEl.getAttribute("new"); String newFileSetName = (newAttrib != null) ? newAttrib.getValue() : null; FileSet newFileSet = _parentResources.getFileSet(newFileSetName); _replaceSets.put(fileSet, newFileSet); }
From source file:AIR.ResourceBundler.Xml.FileSetInput.java
License:Open Source License
public void parse(Element fileEl) { // get file path setPath(_fileSet.resolveFile(fileEl.getValue())); Attribute attrib = null; attrib = fileEl.getAttribute("prepend"); _prepend = (attrib != null) ? attrib.getValue() : null; attrib = fileEl.getAttribute("append"); _append = (attrib != null) ? attrib.getValue() : null; }
From source file:AIR.ResourceBundler.Xml.Resources.java
License:Open Source License
private void parseRemove(Element excludeEl) { Attribute setAttrib = excludeEl.getAttribute("set"); String setName = (setAttrib != null) ? setAttrib.getValue() : null; // remove fileset globally if (!StringUtils.isEmpty(setName)) { _fileSets.remove(setName);/* ww w.j a va 2 s . c om*/ } }
From source file:backtesting.BackTesterNinety.java
public static boolean CheckBacktestSettingsInCache(LocalDate startDate, LocalDate endDate) { try {/* w w w . j ava2 s . c o m*/ File inputFile = new File("backtest/cache/_settings.xml"); if (!inputFile.exists()) { return false; } SAXBuilder saxBuilder = new SAXBuilder(); Document document = saxBuilder.build(inputFile); Element rootElement = document.getRootElement(); Attribute attStart = rootElement.getAttribute("start"); LocalDate start = LocalDate.parse(attStart.getValue()); Attribute attEnd = rootElement.getAttribute("end"); LocalDate end = LocalDate.parse(attEnd.getValue()); return startDate.isEqual(start) && endDate.isEqual(end); } catch (JDOMException e) { e.printStackTrace(); logger.severe("Error in loading from XML: JDOMException.\r\n" + e); } catch (IOException ioe) { ioe.printStackTrace(); logger.severe("Error in loading from XML: IOException.\r\n" + ioe); } return false; }
From source file:ca.mcgill.cs.swevo.jayfx.model.Category.java
License:Open Source License
public static Category valueOf(Element elem) { Attribute typeAttribute = elem.getAttribute(TYPE); return valueOf(typeAttribute.getValue()); }
From source file:ca.mcgill.cs.swevo.jayfx.model.Relation.java
License:Open Source License
public static Relation valueOf(Element elem) { Attribute typeAttribute = elem.getAttribute(TYPE); String typeString = typeAttribute.getValue(); return valueOf(typeString); }
From source file:ca.nrc.cadc.caom2.xml.ObservationReader.java
License:Open Source License
/** * Construct an Observation from a Reader. * * @param reader//from ww w . ja va 2 s . co m * A Reader. * @return An Observation. * @throws ObservationParsingException * if there is an error parsing the XML. */ public Observation read(Reader reader) throws ObservationParsingException, IOException { if (reader == null) { throw new IllegalArgumentException("reader must not be null"); } init(); Document document; try { document = XmlUtil.buildDocument(reader, schemaMap); } catch (JDOMException jde) { String error = "XML failed schema validation: " + jde.getMessage(); throw new ObservationParsingException(error, jde); } // Root element and namespace of the Document Element root = document.getRootElement(); Namespace namespace = root.getNamespace(); log.debug("obs namespace uri: " + namespace.getURI()); log.debug("obs namespace prefix: " + namespace.getPrefix()); ReadContext rc = new ReadContext(); if (XmlConstants.CAOM2_0_NAMESPACE.equals(namespace.getURI())) { rc.docVersion = 20; } else if (XmlConstants.CAOM2_1_NAMESPACE.equals(namespace.getURI())) { rc.docVersion = 21; } else if (XmlConstants.CAOM2_2_NAMESPACE.equals(namespace.getURI())) { rc.docVersion = 22; } // Simple or Composite Attribute type = root.getAttribute("type", xsiNamespace); String tval = type.getValue(); String collection = getChildText("collection", root, namespace, false); String observationID = getChildText("observationID", root, namespace, false); // Algorithm. Algorithm algorithm = getAlgorithm(root, namespace, rc); // Create the Observation. Observation obs; String simple = namespace.getPrefix() + ":" + SimpleObservation.class.getSimpleName(); String comp = namespace.getPrefix() + ":" + CompositeObservation.class.getSimpleName(); if (simple.equals(tval)) { obs = new SimpleObservation(collection, observationID); obs.setAlgorithm(algorithm); } else if (comp.equals(tval)) { obs = new CompositeObservation(collection, observationID, algorithm); } else { throw new ObservationParsingException("unexpected observation type: " + tval); } // Observation children. String intent = getChildText("intent", root, namespace, false); if (intent != null) { obs.intent = ObservationIntentType.toValue(intent); } obs.type = getChildText("type", root, namespace, false); obs.metaRelease = getChildTextAsDate("metaRelease", root, namespace, false, rc.dateFormat); obs.sequenceNumber = getChildTextAsInteger("sequenceNumber", root, namespace, false); obs.proposal = getProposal(root, namespace, rc); obs.target = getTarget(root, namespace, rc); obs.targetPosition = getTargetPosition(root, namespace, rc); obs.requirements = getRequirements(root, namespace, rc); obs.telescope = getTelescope(root, namespace, rc); obs.instrument = getInstrument(root, namespace, rc); obs.environment = getEnvironment(root, namespace, rc); addPlanes(obs.getPlanes(), root, namespace, rc); if (obs instanceof CompositeObservation) { addMembers(((CompositeObservation) obs).getMembers(), root, namespace, rc); } assignEntityAttributes(root, obs, rc); return obs; }