List of usage examples for org.dom4j Attribute getValue
String getValue();
From source file:org.foxbpm.engine.impl.util.FoxBPMCfgParseUtil.java
License:Apache License
private void doAttributes(Element element, Object paramObj) { // ?element// w ww . j a va2s. c o m Method method = null; Attribute attribute = null; Map<String, Method> methodMap = getSetMethods(GENERAL_M_PREFIX, paramObj); for (int i = 0, length = element.attributeCount(); i < length; i++) { attribute = element.attribute(i); method = methodMap.get(generateMethodName(GENERAL_M_PREFIX, attribute.getName())); if (null != method) { doAttributeValue(paramObj, method, attribute.getValue(), method.getParameterTypes()[0]); } } }
From source file:org.foxbpm.engine.impl.util.XMLToObject.java
License:Apache License
/** * ?// w w w .ja v a 2 s . c o m * * @param element * @param paramObj * @param temp * @throws InvocationTargetException * @throws IllegalAccessException * @throws IllegalArgumentException */ private void doAttributes(Element element, Object paramObj, Map<String, Method> methods) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { // ?element Method method = null; Attribute attribute = null; for (int i = 0, length = element.attributeCount(); i < length; i++) { attribute = element.attribute(i); method = methods.get(generateMethodName(GENERAL_M_PREFIX, attribute.getName())); if (null != method && method.getParameterTypes().length == 1) { doAttributeValue(paramObj, method, attribute.getValue(), method.getParameterTypes()[0]); } } }
From source file:org.geolatte.mapserver.config.Configuration.java
License:Open Source License
/** * Lists the titles of all {@code TileMap}s in the configuration file. * * @return list of {@code TileMap} titles. *//*from www . j a v a 2 s. c o m*/ public List<String> getTileMaps() { List titles = configDoc.selectNodes("//TileMap/@title"); List<String> result = new ArrayList<String>(); for (Object o : titles) { Attribute title = (Attribute) o; result.add(title.getValue()); } return result; }
From source file:org.geolatte.mapserver.config.Configuration.java
License:Open Source License
private String getAttribute(String tileMapName, String attribute) throws ConfigurationException { Attribute attr = (Attribute) configDoc .selectSingleNode("//TileMap[@title='" + tileMapName + "']/@" + attribute); if (attr == null) { throw new ConfigurationException( String.format("Configuration for TileMap \"%s\" has no %s attribute.", tileMapName, attribute)); }/*from w w w. j ava 2 s . co m*/ return attr.getValue(); }
From source file:org.geolatte.mapserver.tms.TileMapBuilder.java
License:Open Source License
private String extractAttribute(String xpath) { Attribute attr = (Attribute) xmlDoc.selectSingleNode(xpath); String str = attr.getValue(); return str;// w w w . j a v a 2 s . c o m }
From source file:org.gradle.gradleplugin.foundation.Dom4JUtility.java
License:Apache License
public static boolean getAttributeAsBoolean(Element element, String attributeName, boolean defaultValue) { Attribute attribute = element.attribute(attributeName); if (attribute == null) { return defaultValue; }// w w w . j ava 2 s .com return "true".equals(attribute.getValue()); }
From source file:org.hibernate.cfg.AnnotationConfiguration.java
License:Open Source License
@Override protected void parseMappingElement(Element subelement, String name) { Attribute rsrc = subelement.attribute("resource"); Attribute file = subelement.attribute("file"); Attribute jar = subelement.attribute("jar"); Attribute pckg = subelement.attribute("package"); Attribute clazz = subelement.attribute("class"); if (rsrc != null) { log.debug("{} <- {}", name, rsrc); addResource(rsrc.getValue()); } else if (jar != null) { log.debug("{} <- {}", name, jar); addJar(new File(jar.getValue())); } else if (file != null) { log.debug("{} <- {}", name, file); addFile(file.getValue());/*w w w . j ava 2 s.com*/ } else if (pckg != null) { log.debug("{} <- {}", name, pckg); addPackage(pckg.getValue()); } else if (clazz != null) { log.debug("{} <- {}", name, clazz); Class loadedClass; try { loadedClass = ReflectHelper.classForName(clazz.getValue()); } catch (ClassNotFoundException cnf) { throw new MappingException("Unable to load class declared as <mapping class=\"" + clazz.getValue() + "\"/> in the configuration:", cnf); } catch (NoClassDefFoundError ncdf) { throw new MappingException("Unable to load class declared as <mapping class=\"" + clazz.getValue() + "\"/> in the configuration:", ncdf); } addAnnotatedClass(loadedClass); } else { throw new MappingException("<mapping> element in configuration specifies no attributes"); } }
From source file:org.hibernate.cfg.AnnotationConfiguration.java
License:Open Source License
@Override protected void add(org.dom4j.Document doc) throws MappingException { boolean ejb3Xml = "entity-mappings".equals(doc.getRootElement().getName()); if (inSecondPass) { //if in second pass bypass the queueing, getExtendedQueue reuse this method if (!ejb3Xml) { super.add(doc); }//from w ww . ja v a2s. co m } else { if (!ejb3Xml) { final Element hmNode = doc.getRootElement(); Attribute packNode = hmNode.attribute("package"); String defaultPackage = packNode != null ? packNode.getValue() : ""; Set<String> entityNames = new HashSet<String>(); findClassNames(defaultPackage, hmNode, entityNames); for (String entity : entityNames) { hbmEntities.put(entity, doc); } hbmDocuments.add(doc); } else { final MetadataProvider metadataProvider = ((MetadataProviderInjector) reflectionManager) .getMetadataProvider(); JPAMetadataProvider jpaMetadataProvider = (JPAMetadataProvider) metadataProvider; List<String> classnames = jpaMetadataProvider.getXMLContext().addDocument(doc); for (String classname : classnames) { try { annotatedClasses.add(reflectionManager.classForName(classname, this.getClass())); } catch (ClassNotFoundException e) { throw new AnnotationException("Unable to load class defined in XML: " + classname, e); } } } } }
From source file:org.hibernate.cfg.AnnotationConfiguration.java
License:Open Source License
private static String getClassName(Attribute name, String defaultPackage) { if (name == null) { return null; }/*from ww w . j a v a 2s.co m*/ String unqualifiedName = name.getValue(); if (unqualifiedName == null) { return null; } if (unqualifiedName.indexOf('.') < 0 && defaultPackage != null) { return defaultPackage + '.' + unqualifiedName; } return unqualifiedName; }
From source file:org.hibernate.cfg.annotations.reflection.JPAOverriddenAnnotationReader.java
License:LGPL
private void applyXmlDefinedConverts(Element containingElement, XMLContext.Default defaults, String attributeNamePrefix, Map<String, Convert> convertAnnotationsMap) { final List<Element> convertElements = containingElement.elements("convert"); for (Element convertElement : convertElements) { final AnnotationDescriptor convertAnnotationDescriptor = new AnnotationDescriptor(Convert.class); copyStringAttribute(convertAnnotationDescriptor, convertElement, "attribute-name", false); copyBooleanAttribute(convertAnnotationDescriptor, convertElement, "disable-conversion"); final Attribute converterClassAttr = convertElement.attribute("converter"); if (converterClassAttr != null) { final String converterClassName = XMLContext.buildSafeClassName(converterClassAttr.getValue(), defaults);// w ww . j av a 2 s .com try { final Class converterClass = ReflectHelper.classForName(converterClassName, this.getClass()); convertAnnotationDescriptor.setValue("converter", converterClass); } catch (ClassNotFoundException e) { throw new AnnotationException( "Unable to find specified converter class id-class: " + converterClassName, e); } } final Convert convertAnnotation = AnnotationFactory.create(convertAnnotationDescriptor); final String qualifiedAttributeName = qualifyConverterAttributeName(attributeNamePrefix, convertAnnotation.attributeName()); convertAnnotationsMap.put(qualifiedAttributeName, convertAnnotation); } }