List of usage examples for org.w3c.dom Element getAttribute
public String getAttribute(String name);
From source file:Main.java
/** * Returns true if the element has all the specified attributes with all the specified values * @param element/*from ww w . jav a2s .com*/ * @param identifyingAttributes * @param identifyingValues * @return */ private static boolean hasTheseAttributeValues(Element element, String[] identifyingAttributes, String[] identifyingValues) { for (int i = 0; i < identifyingAttributes.length; i++) { if (!element.getAttribute(identifyingAttributes[i]).equals(identifyingValues[i])) { return false; } } return true; }
From source file:eu.eidas.configuration.ConfigurationReader.java
/** * Generate parameters.//from w w w .ja v a2s. c o m * * @param configurationNode the configuration node * * @return the map< string, string> */ private static Map<String, String> generateParam(final Element configurationNode) { final Map<String, String> parameters = new HashMap<String, String>(); final NodeList parameterNodes = configurationNode.getElementsByTagName(NODE_PARAMETER); String parameterName; String parameterValue; for (int k = 0; k < parameterNodes.getLength(); ++k) { // for every parameter find, process. final Element parameterNode = (Element) parameterNodes.item(k); parameterName = parameterNode.getAttribute(NODE_PARAM_NAME); parameterValue = parameterNode.getAttribute(NODE_PARAM_VALUE); // verified the content. if (StringUtils.isBlank(parameterName) || StringUtils.isBlank(parameterValue)) { throw new EIDASSAMLEngineRuntimeException("Error reader parameters (name - value)."); } else { parameters.put(parameterName.trim(), parameterValue.trim()); } } return parameters; }
From source file:DomUtil.java
/** * Determines whether a specific boolean flag is set on an element. * /*from ww w. jav a 2s.c o m*/ * @param element The element to analyze. * @param attributeName The name of the boolean 'flag' attribute. * @return True if the value of the attribute is 'true', false if it is * not or if the attribute does not exist. */ public static boolean getBooleanAttribute(Element element, String attributeName) { String value = element.getAttribute(attributeName); if (value == null) { return false; } else if (value.equals("true")) { return true; } else { return false; } }
From source file:com.cloud.hypervisor.kvm.resource.LibvirtDomainXMLParser.java
private static String getAttrValue(String tag, String attr, Element eElement) { NodeList tagNode = eElement.getElementsByTagName(tag); if (tagNode.getLength() == 0) { return null; }/*from w w w . j av a 2 s . com*/ Element node = (Element) tagNode.item(0); return node.getAttribute(attr); }
From source file:org.apache.smscserver.config.spring.SpringUtil.java
/** * Return an attribute value after checking it is a valid {@link InetAddress} * //from w w w. j a va 2 s .co m * @param parent * The element * @param attrName * The attribute name * @return The attribute string value. */ public static String parseStringFromInetAddress(final Element parent, final String attrName) { if (SpringUtil.parseInetAddress(parent, attrName) != null) { return parent.getAttribute(attrName); } return null; }
From source file:fll.xml.XMLUtils.java
/** * Get the winner criteria for a particular element. *//*from w w w . ja va 2 s. com*/ public static WinnerType getWinnerCriteria(final Element element) { if (element.hasAttribute("winner")) { final String str = element.getAttribute("winner"); final String sortStr; if (!str.isEmpty()) { sortStr = str.toUpperCase(); } else { sortStr = "HIGH"; } return Enum.valueOf(WinnerType.class, sortStr); } else { return WinnerType.HIGH; } }
From source file:fll.xml.XMLUtils.java
/** * Get the score type for a particular element. *//*from w w w . java 2s . co m*/ public static ScoreType getScoreType(final Element element) { if (element.hasAttribute("scoreType")) { final String str = element.getAttribute("scoreType"); final String sortStr; if (!str.isEmpty()) { sortStr = str.toUpperCase(); } else { sortStr = "INTEGER"; } return Enum.valueOf(ScoreType.class, sortStr); } else { return ScoreType.INTEGER; } }
From source file:Main.java
/** * Find an element//from w w w . j a v a 2 s.co m * @param doc XML document * @param tagName Tag name * @param props Properties corresponding to attributes in tag * @return Element or null if not found */ public static Element findElement(Document doc, String tagName, Properties props) { Element elmt = null; NodeList nlist = doc.getElementsByTagName(tagName); for (int i = 0; i < nlist.getLength() && elmt == null; i++) { Node node = nlist.item(i); if (node instanceof Element) { Element temp = (Element) node; boolean matches = true; for (Enumeration en = props.keys(); en.hasMoreElements() && matches;) { String name = (String) en.nextElement(); String value = props.getProperty(name); String attValue = temp.getAttribute(name); if (attValue == null) matches = false; else if (!value.equals(attValue)) matches = false; } if (matches) elmt = temp; } } return elmt; }
From source file:com.nridge.core.base.std.XMLUtl.java
public static boolean isAttrBoolTrue(Element anElement, String aName) { String valueString;/*from ww w.j av a2s . c o m*/ if (StringUtils.isNotEmpty(aName)) { valueString = anElement.getAttribute(aName); if (StringUtils.isNotEmpty(valueString)) { if ((valueString.equalsIgnoreCase(XML_UPPER_YES)) || (valueString.equalsIgnoreCase(XML_UPPER_TRUE))) return true; } } return false; }
From source file:com.mirth.connect.server.launcher.MirthLauncher.java
private static void addExtensionsToClasspath(List<URL> urls, String currentVersion) throws Exception { FileFilter extensionFileFilter = new NameFileFilter( new String[] { "plugin.xml", "source.xml", "destination.xml" }, IOCase.INSENSITIVE); FileFilter directoryFilter = FileFilterUtils.directoryFileFilter(); File extensionPath = new File(EXTENSIONS_DIR); Properties extensionProperties = new Properties(); File extensionPropertiesFile = new File(appDataDir, EXTENSION_PROPERTIES); /*// ww w . j a v a2 s .c om * If the file does not exist yet, an empty Properties object will be used, returning the * default of true for all extensions. */ if (extensionPropertiesFile.exists()) { extensionProperties.load(new FileInputStream(extensionPropertiesFile)); } if (extensionPath.exists() && extensionPath.isDirectory()) { File[] directories = extensionPath.listFiles(directoryFilter); for (File directory : directories) { File[] extensionFiles = directory.listFiles(extensionFileFilter); for (File extensionFile : extensionFiles) { try { Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder() .parse(extensionFile); Element rootElement = document.getDocumentElement(); boolean enabled = extensionProperties .getProperty(rootElement.getElementsByTagName("name").item(0).getTextContent(), "true") .equalsIgnoreCase("true"); boolean compatible = isExtensionCompatible( rootElement.getElementsByTagName("mirthVersion").item(0).getTextContent(), currentVersion); // Only add libraries from extensions that are not disabled and are compatible with the current version if (enabled && compatible) { NodeList libraries = rootElement.getElementsByTagName("library"); for (int i = 0; i < libraries.getLength(); i++) { Element libraryElement = (Element) libraries.item(i); String type = libraryElement.getAttribute("type"); if (type.equalsIgnoreCase("server") || type.equalsIgnoreCase("shared")) { File pathFile = new File(directory, libraryElement.getAttribute("path")); if (pathFile.exists()) { logger.trace("adding library to classpath: " + pathFile.getAbsolutePath()); urls.add(pathFile.toURI().toURL()); } else { logger.error("could not locate library: " + pathFile.getAbsolutePath()); } } } } } catch (Exception e) { logger.error("failed to parse extension metadata: " + extensionFile.getAbsolutePath(), e); } } } } else { logger.warn("no extensions found"); } }