@Override protected String getBeanClassName(Element element) { if (element.hasAttribute(WEAVER_CLASS_ATTRIBUTE)) { return element.getAttribute(WEAVER_CLASS_ATTRIBUTE); } return DEFAULT_LOAD_TIME_WEAVER_CLASS_NAME; }
private void readPackageConfigFromXml(Node node) throws IOException { NodeList childNodes = node.getChildNodes(); if (childNodes.getLength() > 0) { for (int j = 0, n = childNodes.getLength(); j < n; j++) { Node child = childNodes.item(j); if (child.getNodeType() == Node.ELEMENT_NODE) { Element check = (Element) child; String tagName = check.getTagName(); String value = check.getAttribute(ATTR_VALUE); String name = check.getAttribute(ATTR_NAME); if (tagName.equals(ATTR_CONFIG_FIELD)) { mPackageFields.put(name, value); } else { System.err.println("unknown package config tag " + tagName); } } } } }
/** * @param xmlDescription * xmlDescription * @throws NullPointerException * NullPointerException * @throws MalformedURLException * MalformedURLException */ public VoiceComponentDescription(Element xmlDescription) throws NullPointerException, MalformedURLException { super(xmlDescription); this.gender = xmlDescription.getAttribute("gender"); this.type = xmlDescription.getAttribute("type"); Element dependsElement = (Element) xmlDescription.getElementsByTagName("depends").item(0); this.dependsLanguage = dependsElement.getAttribute("language"); this.dependsVersion = dependsElement.getAttribute("version"); }
private static void parseProperties(NodeList nodeList, RootBeanDefinition beanDefinition) { if (nodeList != null && nodeList.getLength() > 0) { for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (node instanceof Element) { if ("property".equals(node.getNodeName()) || "property".equals(node.getLocalName())) { String name = ((Element) node).getAttribute("name"); if (name != null && name.length() > 0) { String value = ((Element) node).getAttribute("value"); String ref = ((Element) node).getAttribute("ref"); if (value != null && value.length() > 0) { beanDefinition.getPropertyValues().addPropertyValue(name, value); } else if (ref != null && ref.length() > 0) { beanDefinition.getPropertyValues().addPropertyValue(name, new RuntimeBeanReference(ref)); } else { throw new UnsupportedOperationException("Unsupported <property name=\"" + name + "\"> sub tag, Only supported <property name=\"" + name + "\" ref=\"...\" /> or <property name=\"" + name + "\" value=\"...\" />"); } } } } } } }
/** * Parse a list element. */ public List<Object> parseListElement(Element collectionEle, @Nullable BeanDefinition bd) { String defaultElementType = collectionEle.getAttribute(VALUE_TYPE_ATTRIBUTE); NodeList nl = collectionEle.getChildNodes(); ManagedList<Object> target = new ManagedList<>(nl.getLength()); target.setSource(extractSource(collectionEle)); target.setElementTypeName(defaultElementType); target.setMergeEnabled(parseMergeAttribute(collectionEle)); parseCollectionElements(nl, target, bd, defaultElementType); return target; }
public static String getLanguage(Document document) { return document.getDocumentElement().getAttribute("xml:lang"); }
/** * Try to determine the locale of a document by looking at the xml:lang attribute of the document element. * * @param doc * the document in which to look for a locale. * @return the locale set for the document, or null if no locale is set. */ public static Locale getLocale(Document doc) { if (doc.getDocumentElement().hasAttribute("xml:lang")) return MaryUtils.string2locale(doc.getDocumentElement().getAttribute("xml:lang")); return null; }
private static Element findPropertyByName(Element bean, String name) { NodeList propertyList = bean.getElementsByTagName("property"); for (int j = 0, m = propertyList.getLength(); j < m; ++j) { Node node = propertyList.item(j); if (node instanceof Element) { Element p = (Element) node; if (name.equals(p.getAttribute("name"))) { return p; } } } return null; }
private static void parseProperties(NodeList nodeList, RootBeanDefinition beanDefinition) { if (nodeList != null && nodeList.getLength() > 0) { for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (node instanceof Element) { if ("property".equals(node.getNodeName()) || "property".equals(node.getLocalName())) { String name = ((Element) node).getAttribute("name"); if (name != null && name.length() > 0) { String value = ((Element) node).getAttribute("value"); String ref = ((Element) node).getAttribute("ref"); if (value != null && value.length() > 0) { beanDefinition.getPropertyValues().addPropertyValue(name, value); } else if (ref != null && ref.length() > 0) { beanDefinition.getPropertyValues().addPropertyValue(name, new RuntimeBeanReference(ref)); } else { throw new UnsupportedOperationException("Unsupported <property name=\"" + name + "\"> sub tag, Only supported <property name=\"" + name + "\" ref=\"...\" /> or <property name=\"" + name + "\" value=\"...\" />"); } } } } } } }
/** * Parse an array element. */ public Object parseArrayElement(Element arrayEle, @Nullable BeanDefinition bd) { String elementType = arrayEle.getAttribute(VALUE_TYPE_ATTRIBUTE); NodeList nl = arrayEle.getChildNodes(); ManagedArray target = new ManagedArray(elementType, nl.getLength()); target.setSource(extractSource(arrayEle)); target.setElementTypeName(elementType); target.setMergeEnabled(parseMergeAttribute(arrayEle)); parseCollectionElements(nl, target, bd, elementType); return target; }
public DOMInputCapsule(Document doc, XMLImporter importer) { this.doc = doc; this.importer = importer; currentElem = doc.getDocumentElement(); String version = currentElem.getAttribute("format_version"); importer.formatVersion = version.equals("") ? 0 : Integer.parseInt(version); }
static String extractCacheManager(Element element) { return (element.hasAttribute(CacheNamespaceHandler.CACHE_MANAGER_ATTRIBUTE) ? element.getAttribute(CacheNamespaceHandler.CACHE_MANAGER_ATTRIBUTE) : CacheNamespaceHandler.DEFAULT_CACHE_MANAGER_BEAN_NAME); }
/** * @param xmlDescription * xmlDescription * @throws NullPointerException * NullPointerException * @throws MalformedURLException * MalformedURLException */ public VoiceComponentDescription(Element xmlDescription) throws NullPointerException, MalformedURLException { super(xmlDescription); this.gender = xmlDescription.getAttribute("gender"); this.type = xmlDescription.getAttribute("type"); Element dependsElement = (Element) xmlDescription.getElementsByTagName("depends").item(0); this.dependsLanguage = dependsElement.getAttribute("language"); this.dependsVersion = dependsElement.getAttribute("version"); }
/** * Try to determine the locale of a document by looking at the xml:lang attribute of the document element. * * @param doc * the document in which to look for a locale. * @return the locale set for the document, or null if no locale is set. */ public static Locale getLocale(Document doc) { if (doc.getDocumentElement().hasAttribute("xml:lang")) return MaryUtils.string2locale(doc.getDocumentElement().getAttribute("xml:lang")); return null; }
private void readLibPatternsFromXml(Node node) throws IOException { NodeList childNodes = node.getChildNodes(); if (childNodes.getLength() > 0) { for (int j = 0, n = childNodes.getLength(); j < n; j++) { Node child = childNodes.item(j); if (child.getNodeType() == Node.ELEMENT_NODE) { Element check = (Element) child; String tagName = check.getTagName(); String value = check.getAttribute(ATTR_VALUE); if (tagName.equals(ATTR_PATTERN)) { addToPatterns(value, mSoFilePattern); } else { System.err.println("unknown dex tag " + tagName); } } } } }
@SuppressWarnings("unchecked") private static ManagedMap parseParameters(NodeList nodeList, RootBeanDefinition beanDefinition) { if (nodeList != null && nodeList.getLength() > 0) { ManagedMap parameters = null; for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (node instanceof Element) { if ("parameter".equals(node.getNodeName()) || "parameter".equals(node.getLocalName())) { if (parameters == null) { parameters = new ManagedMap(); } String key = ((Element) node).getAttribute("key"); String value = ((Element) node).getAttribute("value"); boolean hide = "true".equals(((Element) node).getAttribute("hide")); if (hide) { key = Constants.HIDE_KEY_PREFIX + key; } parameters.put(key, new TypedStringValue(value, String.class)); } } } return parameters; } return null; }
/** * Parse a set element. */ public Set<Object> parseSetElement(Element collectionEle, @Nullable BeanDefinition bd) { String defaultElementType = collectionEle.getAttribute(VALUE_TYPE_ATTRIBUTE); NodeList nl = collectionEle.getChildNodes(); ManagedSet<Object> target = new ManagedSet<>(nl.getLength()); target.setSource(extractSource(collectionEle)); target.setElementTypeName(defaultElementType); target.setMergeEnabled(parseMergeAttribute(collectionEle)); parseCollectionElements(nl, target, bd, defaultElementType); return target; }
/** * Parse the validated document and add entries to the given unit info list. */ protected List<SpringPersistenceUnitInfo> parseDocument( Resource resource, Document document, List<SpringPersistenceUnitInfo> infos) throws IOException { Element persistence = document.getDocumentElement(); String version = persistence.getAttribute(PERSISTENCE_VERSION); URL rootUrl = determinePersistenceUnitRootUrl(resource); List<Element> units = DomUtils.getChildElementsByTagName(persistence, PERSISTENCE_UNIT); for (Element unit : units) { infos.add(parsePersistenceUnitInfo(unit, version, rootUrl)); } return infos; }
static String getTransactionManagerName(Element element) { return (element.hasAttribute(TRANSACTION_MANAGER_ATTRIBUTE) ? element.getAttribute(TRANSACTION_MANAGER_ATTRIBUTE) : DEFAULT_TRANSACTION_MANAGER_BEAN_NAME); }
@ExpectWarning("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE") public String getFirstChildName(Element e) { NodeList list = e.getElementsByTagName("child"); if(list != null) { return ((Element)list.item(0)).getAttribute("name"); } return null; } }