/** * @since 1.4 */ public JDomReader(Document document, NameCoder nameCoder) { super(document.getRootElement(), nameCoder); }
/** * @since 1.2 * @deprecated As of 1.4, use {@link JDomReader#JDomReader(Document, NameCoder)} instead. */ public JDomReader(Document document, XmlFriendlyReplacer replacer) { this(document.getRootElement(), (NameCoder)replacer); }
public JDomReader(Document document) { super(document.getRootElement()); }
public List operate(Object node) { if (node instanceof Element) return((Element) node).getChildren(); else if (node instanceof Document) { Element root = ((Document) node).getRootElement(); return root == null ? Collections.EMPTY_LIST : Collections.singletonList(root); } // With 2.1 semantics it makes more sense to just return a null and let the core // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR) return null; /* else throw new TemplateModelException("_allChildren can not be applied on " + node.getClass()); */ } }
@NotNull private static Element rootElement(@NotNull File file) throws CannotConvertException { return JDomConvertingUtil.loadDocument(file).getRootElement(); }
@Override void getDescendants(Object node, List result) { if (node instanceof Document) { Element root = ((Document) node).getRootElement(); result.add(root); getDescendants(root, result); } else if (node instanceof Element) { getDescendants((Element) node, result); } }
private static SerializerDefinition parseSerializerDefinition(String serializerInfoXml, String elementName) { SAXBuilder builder = new SAXBuilder(); try { Document doc = builder.build(new StringReader(serializerInfoXml)); Element root = doc.getRootElement(); Element serializerElement = root.getChild(elementName); return StoreDefinitionsMapper.readSerializer(serializerElement); } catch(JDOMException e) { throw new MappingException(e); } catch(IOException e) { throw new MappingException(e); } }
public String writeCluster(Cluster cluster) { Document doc = new Document(new Element(CLUSTER_ELMT)); doc.getRootElement().addContent(new Element(CLUSTER_NAME_ELMT).setText(cluster.getName())); boolean displayZones = cluster.getZones().size() > 1; if(displayZones) { for(Zone n: cluster.getZones()) doc.getRootElement().addContent(mapZone(n)); } for(Node n: cluster.getNodes()) doc.getRootElement().addContent(mapServer(n, displayZones)); XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat()); return serializer.outputString(doc.getRootElement()); }
public static StoreDefinition readStore(Reader input) { SAXBuilder builder = new SAXBuilder(); try { Document doc = builder.build(input); Element root = doc.getRootElement(); return readStore(root); } catch(JDOMException e) { throw new MappingException(e); } catch(IOException e) { throw new MappingException(e); } }
public List operate(Object node) { LinkedList list = new LinkedList(); if (node instanceof Element) { addChildren((Element) node, list); } else if (node instanceof Document) { Element root = ((Document) node).getRootElement(); list.add(root); addChildren(root, list); } else // With 2.1 semantics it makes more sense to just return a null and let the core // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR) return null; // throw new TemplateModelException("_descendant can not be applied on " + node.getClass()); return list; }
public List operate(Object node, String localName, Namespace namespace) { if (node instanceof Element) { return((Element) node).getChildren(localName, namespace); } else if (node instanceof Document) { Element root = ((Document) node).getRootElement(); if (root != null && root.getName().equals(localName) && root.getNamespaceURI().equals(namespace.getURI())) { return Collections.singletonList(root); } else return Collections.EMPTY_LIST; } // With 2.1 semantics it makes more sense to just return a null and let the core // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR) return null; /* else throw new TemplateModelException("_namedChildren can not be applied on " + node.getClass()); */ } }
@Override void getChildren(Object node, String localName, String namespaceUri, List result) { if (node instanceof Element) { Element e = (Element) node; if (localName == null) { result.addAll(e.getChildren()); } else { result.addAll(e.getChildren(localName, Namespace.getNamespace("", namespaceUri))); } } else if (node instanceof Document) { Element root = ((Document) node).getRootElement(); if (localName == null || (equal(root.getName(), localName) && equal(root.getNamespaceURI(), namespaceUri))) { result.add(root); } } }
public List<StoreDefinition> readStoreList(Reader input, boolean verifySchema) { try { SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(input); if(verifySchema) { Validator validator = schema.newValidator(); validator.validate(new JDOMSource(doc)); } Element root = doc.getRootElement(); if(!root.getName().equals(STORES_ELMT)) throw new MappingException("Invalid root element: " + doc.getRootElement().getName()); List<StoreDefinition> stores = new ArrayList<StoreDefinition>(); for(Object store: root.getChildren(STORE_ELMT)) stores.add(readStore((Element) store)); for(Object view: root.getChildren(VIEW_ELMT)) stores.add(readView((Element) view, stores)); return stores; } catch(JDOMException e) { throw new MappingException(e); } catch(SAXException e) { throw new MappingException(e); } catch(IOException e) { throw new MappingException(e); } }
@Override public void preProcessingFinished() throws CannotConvertException { File oldSettingsFile = getGoBuildFlagsFile(); if (oldSettingsFile.exists()) { Element oldSettingsRoot = JDomConvertingUtil.loadDocument(oldSettingsFile).getRootElement(); Element buildFlagsSettings = JDomSerializationUtil.findComponent(oldSettingsRoot, "GoBuildFlags"); if (buildFlagsSettings != null) { newSettings = XmlSerializer.deserialize(buildFlagsSettings, GoBuildTargetSettings.class); buildFlagsSettings.detach(); //noinspection ResultOfMethodCallIgnored oldSettingsFile.delete(); } } }
@SuppressWarnings("unchecked") public Cluster readCluster(Reader input, boolean verifySchema) { try { SAXBuilder builder = new SAXBuilder(false); Document doc = builder.build(input); if(verifySchema) { Validator validator = this.schema.newValidator(); validator.validate(new JDOMSource(doc)); } Element root = doc.getRootElement(); if(!root.getName().equals(CLUSTER_ELMT)) throw new MappingException("Invalid root element: " + doc.getRootElement().getName()); String name = root.getChildText(CLUSTER_NAME_ELMT); List<Zone> zones = new ArrayList<Zone>(); for(Element node: (List<Element>) root.getChildren(ZONE_ELMT)) zones.add(readZone(node)); List<Node> servers = new ArrayList<Node>(); for(Element node: (List<Element>) root.getChildren(SERVER_ELMT)) servers.add(readServer(node)); return new Cluster(name, servers, zones); } catch(JDOMException e) { throw new MappingException(e); } catch(SAXException e) { throw new MappingException(e); } catch(IOException e) { throw new MappingException(e); } }
Document node = (Document) contextNode; Element el = node.getRootElement(); if (el.getName().equals(localName) == false) { return JaxenConstants.EMPTY_ITERATOR;
Element schedulingPeriodElement = document.getRootElement(); assertElementName(schedulingPeriodElement, "SchedulingPeriod"); NurseRoster nurseRoster = new NurseRoster();
try { final org.jdom.Document document = JDOMUtil.loadDocument(file.getInputStream()); Element element = document.getRootElement(); List<IgnoreSettings.UserTemplate> templates = IgnoreSettings.loadTemplates(element); for (IgnoreSettings.UserTemplate template : templates) {
private List<String> extractProperties(@Nullable final InputStream inputStream, @NotNull final ClassLoader checkstyleClassLoader) { if (inputStream != null) { try { final SAXBuilder saxBuilder = new SAXBuilder(); saxBuilder.setEntityResolver(new CheckStyleEntityResolver(this, checkstyleClassLoader)); final Document configDoc = saxBuilder.build(inputStream); return extractProperties(configDoc.getRootElement()); } catch (Exception e) { LOG.warn("CheckStyle file could not be parsed for properties.", e); } } return new ArrayList<>(); }
public Map load(String configFileName) { Map<String, TargetMetaDef> mps = new LinkedHashMap<String, TargetMetaDef>(); try { if (UtilValidate.isEmpty(configFileName)) return mps; Document doc = buildDocument(configFileName); if (doc == null) return mps; Element root = doc.getRootElement(); parse(root, mps); Debug.logVerbose("[JdonFramework]<!-- config load finished -->", module); } catch (Exception ex) { Debug.logError("[JdonFramework]configure FileName: " + configFileName + " parsed error: " + ex, module); } return mps; }