List of usage examples for org.w3c.dom Element getAttribute
public String getAttribute(String name);
From source file:com.glaf.jbpm.factory.JbpmActionHandlerTypes.java
static Map<String, Class<?>> initializeHandlerTypes() { Map<String, Class<?>> types = new java.util.HashMap<String, Class<?>>(); String resource = SystemProperties.getString("jbpm.actions"); if (StringUtils.isEmpty(resource)) { resource = DEFAULT_CONFIG;// ww w .j av a2s .co m } if (StringUtils.isNotEmpty(resource)) { InputStream actionTypesStream = PropertiesUtils.getInputStream(resource); Element actionHandlesElement = XmlUtils.parseXmlInputStream(actionTypesStream).getDocumentElement(); Iterator<?> nodeTypeIterator = XmlUtils.elementIterator(actionHandlesElement, "action-handler"); while (nodeTypeIterator.hasNext()) { Element nodeTypeElement = (Element) nodeTypeIterator.next(); String elementTag = nodeTypeElement.getAttribute("element"); String className = nodeTypeElement.getAttribute("class"); try { Class<?> clazz = com.glaf.core.util.ClassUtils.loadClass(className); types.put(elementTag, clazz); } catch (Exception ex) { if (LogUtils.isDebug()) { ex.printStackTrace(); } logger.error("node '" + elementTag + "' will not be available. class '" + className + "' couldn't be loaded"); } } } String ext_resource = CustomProperties.getString("jbpm.actions"); if (StringUtils.isNotEmpty(ext_resource)) { InputStream actionTypesStream = PropertiesUtils.getInputStream(resource); Element actionHandlesElement = XmlUtils.parseXmlInputStream(actionTypesStream).getDocumentElement(); Iterator<?> nodeTypeIterator = XmlUtils.elementIterator(actionHandlesElement, "action-handler"); while (nodeTypeIterator.hasNext()) { Element nodeTypeElement = (Element) nodeTypeIterator.next(); String elementTag = nodeTypeElement.getAttribute("element"); String className = nodeTypeElement.getAttribute("class"); try { Class<?> clazz = com.glaf.core.util.ClassUtils.loadClass(className); types.put(elementTag, clazz); } catch (Exception ex) { if (LogUtils.isDebug()) { ex.printStackTrace(); } logger.error("node '" + elementTag + "' will not be available. class '" + className + "' couldn't be loaded"); } } } return types; }
From source file:com.flipkart.phantom.runtime.impl.spring.utils.ConfigFileUtils.java
/** * Gets the task handler names from Config file * @param configFile job config file contents as a <code> ByteArrayResource </code> * @return List of task handler names, null if unable to find a TaskHandler name. *//*w w w . j ava 2 s . c o m*/ public static List<String> getHandlerNames(ByteArrayResource configFile) { List<String> jobNameList = new LinkedList<String>(); try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document dom = db.parse(configFile.getInputStream()); Element docEle = dom.getDocumentElement(); //get a nodelist of nodes with the name "ConfigFileUtils.BATCH_JOB_TAG" NodeList nl = docEle.getElementsByTagName(ConfigFileUtils.BATCH_JOB_TAG); //Loop over all found nodes if (nl != null && nl.getLength() > 0) { for (int i = 0; i < nl.getLength(); i++) { //get the element Element el = (Element) nl.item(i); if (el.hasAttribute(ConfigFileUtils.ID_PROP)) { jobNameList.add(el.getAttribute(ConfigFileUtils.ID_PROP)); } } } } catch (Exception e) { LOGGER.error("Unable to get the job name from the given Spring Batch configuration file", e); throw new PlatformException(e); } return jobNameList; }
From source file:org.xacml4j.spring.DecisionCombiningAlgorithmProvidersDefinitionParser.java
private static BeanDefinitionBuilder parseComponent(Element element) { BeanDefinitionBuilder component = BeanDefinitionBuilder .rootBeanDefinition(DecisionCombiningAlgorithmProviderBean.class); String clazz = element.getAttribute("class"); if (StringUtils.hasText(clazz)) { component.addPropertyValue("class", clazz); }//from w ww. j a v a2 s .com String ref = element.getAttribute("ref"); if (StringUtils.hasText(ref)) { component.addPropertyReference("ref", ref); } return component; }
From source file:org.trpr.platform.batch.common.utils.ConfigFileUtils.java
/** * Gets the job names from Config file/* w w w . j a v a2 s .c om*/ * @param configFile job config file contents as a <code> ByteArrayResource </code> * @return List of job names, null if unable to find a job name. */ public static List<String> getJobName(ByteArrayResource configFile) { List<String> jobNameList = new LinkedList<String>(); try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document dom = db.parse(configFile.getInputStream()); Element docEle = dom.getDocumentElement(); //get a nodelist of nodes with the name "ConfigFileUtils.BATCH_JOB_TAG" NodeList nl = docEle.getElementsByTagName(ConfigFileUtils.BATCH_JOB_TAG); //Loop over all found nodes if (nl != null && nl.getLength() > 0) { for (int i = 0; i < nl.getLength(); i++) { //get the element Element el = (Element) nl.item(i); if (el.hasAttribute(ConfigFileUtils.ID_PROP)) { jobNameList.add(el.getAttribute(ConfigFileUtils.ID_PROP)); } } } } catch (Exception e) { LOGGER.error("Unable to get the job name from the given Spring Batch configuration file", e); throw new PlatformException(e); } return jobNameList; }
From source file:com.glaf.activiti.executionlistener.factory.ExecutionListenerTypes.java
static Map<String, Class<?>> initializeExecutionListenerTypes() { Map<String, Class<?>> types = new java.util.HashMap<String, Class<?>>(); String resource = SystemProperties.getString("activiti.executionListeners"); if (StringUtils.isEmpty(resource)) { resource = DEFAULT_CONFIG;/*ww w. ja v a 2s . c om*/ } if (StringUtils.isNotEmpty(resource)) { InputStream actionTypesStream = PropertiesUtils.getInputStream(resource); Element executionListenersElement = XmlUtils.parseXmlInputStream(actionTypesStream) .getDocumentElement(); Iterator<?> nodeTypeIterator = XmlUtils.elementIterator(executionListenersElement, "executionListeners"); while (nodeTypeIterator.hasNext()) { Element nodeTypeElement = (Element) nodeTypeIterator.next(); String elementTag = nodeTypeElement.getAttribute("element"); String className = nodeTypeElement.getAttribute("class"); try { Class<?> clazz = com.glaf.core.util.ClassUtils.loadClass(className); types.put(elementTag, clazz); } catch (Exception ex) { if (LogUtils.isDebug()) { ex.printStackTrace(); } logger.error("node '" + elementTag + "' will not be available. class '" + className + "' couldn't be loaded"); } } } String ext_resource = CustomProperties.getString("activiti.executionListeners"); if (StringUtils.isNotEmpty(ext_resource)) { InputStream actionTypesStream = PropertiesUtils.getInputStream(resource); Element executionListenersElement = XmlUtils.parseXmlInputStream(actionTypesStream) .getDocumentElement(); Iterator<?> nodeTypeIterator = XmlUtils.elementIterator(executionListenersElement, "executionListener"); while (nodeTypeIterator.hasNext()) { Element nodeTypeElement = (Element) nodeTypeIterator.next(); String elementTag = nodeTypeElement.getAttribute("element"); String className = nodeTypeElement.getAttribute("class"); try { Class<?> clazz = com.glaf.core.util.ClassUtils.loadClass(className); types.put(elementTag, clazz); } catch (Exception ex) { if (LogUtils.isDebug()) { ex.printStackTrace(); } logger.error("node '" + elementTag + "' will not be available. class '" + className + "' couldn't be loaded"); } } } return types; }
From source file:ar.com.zauber.commons.conversion.spring.schema.ConfigurableConverterBeanDefinitionParser.java
/** * /* www. j a v a 2 s.c om*/ * Parses the ConfigurableJavaBeanConverter * to be set as the FactoryBean's object. * * @param element * @return */ private static BeanDefinitionBuilder parseComponent(final Element element) { BeanDefinitionBuilder component = BeanDefinitionBuilder .rootBeanDefinition(ConfigurableJavaBeanConverter.class); component.addConstructorArgValue(element.getAttribute("target-class")); return component; }
From source file:org.jdal.beans.BeanDefinitionUtils.java
/** * Add property reference to {@link BeanDefinitionBuilder} if needed, following the naming {@link Conventions} * @param bdb BeanDefintionBuilder to operate on. * @param element Element holding the attribute * @param attributeName the attribute name *//*www . ja v a2s. c om*/ public static void addPropertyReferenceIfNeeded(BeanDefinitionBuilder bdb, Element element, String attributeName) { if (element.hasAttribute(attributeName)) bdb.addPropertyReference(Conventions.attributeNameToPropertyName(attributeName), element.getAttribute(attributeName)); }
From source file:fr.aliasource.webmail.server.proxy.client.http.DOMUtils.java
public static Element findElementWithUniqueAttribute(Element root, String elementName, String attribute, String attributeValue) {/*from w w w . jav a2 s . co m*/ NodeList list = root.getElementsByTagName(elementName); for (int i = 0; i < list.getLength(); i++) { Element tmp = (Element) list.item(i); if (tmp.getAttribute(attribute).equals(attributeValue)) { return tmp; } } return null; }
From source file:Main.java
/** * Returns {@code true} if the element matches the filters. * * @param elem/*from ww w. j a va2 s. co m*/ * @param filters * @return */ private static boolean matchesFilters(Element elem, String... filters) { for (String filter : filters) { final String attribute = extractFilterName(filter); final String value = extractFilterValue(filter); if (!elem.getAttribute(attribute).equals(value)) { return false; } } return true; }
From source file:Main.java
/** * Method to check difference between actual time and saved time in xml file. * //from w ww. j a va2 s. c om * @param target document * @return time difference as integer * @throws ParseException */ public static int checkDateDifference(Document target) throws ParseException { int diff = 0; NodeList parents = target.getElementsByTagName("g:options"); Element parent = (Element) parents.item(0); //g:options - only 1 element DateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.ENGLISH); //date xml String time = parent.getAttribute("time"); Date oldT = format.parse(time); //date now Date newT = new Date(); //compare diff = (int) ((newT.getTime() - oldT.getTime()) / 1000); return diff; }