Java Code Examples for org.dom4j.Attribute#getValue()
The following examples show how to use
org.dom4j.Attribute#getValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HbmBinder.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
private static int getOptimisticLockMode(Attribute olAtt) throws MappingException { if ( olAtt == null ) return Versioning.OPTIMISTIC_LOCK_VERSION; String olMode = olAtt.getValue(); if ( olMode == null || "version".equals( olMode ) ) { return Versioning.OPTIMISTIC_LOCK_VERSION; } else if ( "dirty".equals( olMode ) ) { return Versioning.OPTIMISTIC_LOCK_DIRTY; } else if ( "all".equals( olMode ) ) { return Versioning.OPTIMISTIC_LOCK_ALL; } else if ( "none".equals( olMode ) ) { return Versioning.OPTIMISTIC_LOCK_NONE; } else { throw new MappingException( "Unsupported optimistic-lock style: " + olMode ); } }
Example 2
Source File: ManifestFileUtils.java From atlas with Apache License 2.0 | 6 votes |
public static String getVersionCode(File androidManifestFile) throws IOException, DocumentException { SAXReader reader = new SAXReader(); String versionCode = ""; if (androidManifestFile.exists()) { Document document = reader.read(androidManifestFile);// Read the XML file Element root = document.getRootElement();// Get the root node if ("manifest".equalsIgnoreCase(root.getName())) { List<Attribute> attributes = root.attributes(); for (Attribute attr : attributes) { if (StringUtils.equalsIgnoreCase(attr.getName(), "versionCode")) { versionCode = attr.getValue(); } } } } return versionCode; }
Example 3
Source File: UnittypeXML.java From freeacs with MIT License | 5 votes |
public static String getAttr(Node node, String attrName) throws Exception { Attribute attr = (Attribute) node.selectSingleNode("@" + attrName); if (attr != null) { return attr.getValue(); } else { return ""; } }
Example 4
Source File: QTIHelper.java From olat with Apache License 2.0 | 5 votes |
public static float attributeToFloat(final Attribute att) { float val = -1; if (att != null) { String sval = att.getValue(); sval = sval.trim(); // assume int value, even so dtd cannot enforce it val = Integer.parseInt(sval); } return val; }
Example 5
Source File: HbmBinder.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
public static void bindUnionSubclass(Element node, UnionSubclass unionSubclass, Mappings mappings, java.util.Map inheritedMetas) throws MappingException { bindClass( node, unionSubclass, mappings, inheritedMetas ); inheritedMetas = getMetas( node, inheritedMetas, true ); // get meta's from <subclass> if ( unionSubclass.getEntityPersisterClass() == null ) { unionSubclass.getRootClass().setEntityPersisterClass( UnionSubclassEntityPersister.class ); } Attribute schemaNode = node.attribute( "schema" ); String schema = schemaNode == null ? mappings.getSchemaName() : schemaNode.getValue(); Attribute catalogNode = node.attribute( "catalog" ); String catalog = catalogNode == null ? mappings.getCatalogName() : catalogNode.getValue(); Table denormalizedSuperTable = unionSubclass.getSuperclass().getTable(); Table mytable = mappings.addDenormalizedTable( schema, catalog, getClassTableName(unionSubclass, node, schema, catalog, denormalizedSuperTable, mappings ), unionSubclass.isAbstract() != null && unionSubclass.isAbstract().booleanValue(), getSubselect( node ), denormalizedSuperTable ); unionSubclass.setTable( mytable ); log.info( "Mapping union-subclass: " + unionSubclass.getEntityName() + " -> " + unionSubclass.getTable().getName() ); createClassProperties( node, unionSubclass, mappings, inheritedMetas ); }
Example 6
Source File: HbmBinder.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
private static void bindNamedQuery(Element queryElem, String path, Mappings mappings) { String queryName = queryElem.attributeValue( "name" ); if (path!=null) queryName = path + '.' + queryName; String query = queryElem.getText(); log.debug( "Named query: " + queryName + " -> " + query ); boolean cacheable = "true".equals( queryElem.attributeValue( "cacheable" ) ); String region = queryElem.attributeValue( "cache-region" ); Attribute tAtt = queryElem.attribute( "timeout" ); Integer timeout = tAtt == null ? null : new Integer( tAtt.getValue() ); Attribute fsAtt = queryElem.attribute( "fetch-size" ); Integer fetchSize = fsAtt == null ? null : new Integer( fsAtt.getValue() ); Attribute roAttr = queryElem.attribute( "read-only" ); boolean readOnly = roAttr != null && "true".equals( roAttr.getValue() ); Attribute cacheModeAtt = queryElem.attribute( "cache-mode" ); String cacheMode = cacheModeAtt == null ? null : cacheModeAtt.getValue(); Attribute cmAtt = queryElem.attribute( "comment" ); String comment = cmAtt == null ? null : cmAtt.getValue(); NamedQueryDefinition namedQuery = new NamedQueryDefinition( query, cacheable, region, timeout, fetchSize, getFlushMode( queryElem.attributeValue( "flush-mode" ) ) , getCacheMode( cacheMode ), readOnly, comment, getParameterTypes(queryElem) ); mappings.addQuery( queryName, namedQuery ); }
Example 7
Source File: HbmBinder.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
private static void bindImport(Element importNode, Mappings mappings) { String className = getClassName( importNode.attribute( "class" ), mappings ); Attribute renameNode = importNode.attribute( "rename" ); String rename = ( renameNode == null ) ? StringHelper.unqualify( className ) : renameNode.getValue(); log.debug( "Import: " + rename + " -> " + className ); mappings.addImport( className, rename ); }
Example 8
Source File: HbmBinder.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
private static void bindIndex(Attribute indexAttribute, Table table, Column column, Mappings mappings) { if ( indexAttribute != null && table != null ) { StringTokenizer tokens = new StringTokenizer( indexAttribute.getValue(), ", " ); while ( tokens.hasMoreTokens() ) { table.getOrCreateIndex( tokens.nextToken() ).addColumn( column ); } } }
Example 9
Source File: JPAOverriddenAnnotationReader.java From lams with GNU General Public License v2.0 | 5 votes |
private IdClass getIdClass(Element tree, XMLContext.Default defaults) { Element element = tree == null ? null : tree.element( "id-class" ); if ( element != null ) { Attribute attr = element.attribute( "class" ); if ( attr != null ) { AnnotationDescriptor ad = new AnnotationDescriptor( IdClass.class ); Class clazz; try { clazz = classLoaderAccess.classForName( XMLContext.buildSafeClassName( attr.getValue(), defaults ) ); } catch ( ClassLoadingException e ) { throw new AnnotationException( "Unable to find id-class: " + attr.getValue(), e ); } ad.setValue( "value", clazz ); return AnnotationFactory.create( ad ); } else { throw new AnnotationException( "id-class without class. " + SCHEMA_VALIDATION ); } } else if ( defaults.canUseJavaAnnotations() ) { return getPhysicalAnnotation( IdClass.class ); } else { return null; } }
Example 10
Source File: JPAOverriddenAnnotationReader.java From lams with GNU General Public License v2.0 | 5 votes |
private Inheritance getInheritance(Element tree, XMLContext.Default defaults) { Element element = tree != null ? tree.element( "inheritance" ) : null; if ( element != null ) { AnnotationDescriptor ad = new AnnotationDescriptor( Inheritance.class ); Attribute attr = element.attribute( "strategy" ); InheritanceType strategy = InheritanceType.SINGLE_TABLE; if ( attr != null ) { String value = attr.getValue(); if ( "SINGLE_TABLE".equals( value ) ) { strategy = InheritanceType.SINGLE_TABLE; } else if ( "JOINED".equals( value ) ) { strategy = InheritanceType.JOINED; } else if ( "TABLE_PER_CLASS".equals( value ) ) { strategy = InheritanceType.TABLE_PER_CLASS; } else { throw new AnnotationException( "Unknown InheritanceType in XML: " + value + " (" + SCHEMA_VALIDATION + ")" ); } } ad.setValue( "strategy", strategy ); return AnnotationFactory.create( ad ); } else if ( defaults.canUseJavaAnnotations() ) { return getPhysicalAnnotation( Inheritance.class ); } else { return null; } }
Example 11
Source File: HbmBinder.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
private static void bindSimpleValueType(Element node, SimpleValue simpleValue, Mappings mappings) throws MappingException { String typeName = null; Properties parameters = new Properties(); Attribute typeNode = node.attribute( "type" ); if ( typeNode == null ) typeNode = node.attribute( "id-type" ); // for an any if ( typeNode != null ) typeName = typeNode.getValue(); Element typeChild = node.element( "type" ); if ( typeName == null && typeChild != null ) { typeName = typeChild.attribute( "name" ).getValue(); Iterator typeParameters = typeChild.elementIterator( "param" ); while ( typeParameters.hasNext() ) { Element paramElement = (Element) typeParameters.next(); parameters.setProperty( paramElement.attributeValue( "name" ), paramElement.getTextTrim() ); } } TypeDef typeDef = mappings.getTypeDef( typeName ); if ( typeDef != null ) { typeName = typeDef.getTypeClass(); // parameters on the property mapping should // override parameters in the typedef Properties allParameters = new Properties(); allParameters.putAll( typeDef.getParameters() ); allParameters.putAll( parameters ); parameters = allParameters; } if ( !parameters.isEmpty() ) simpleValue.setTypeParameters( parameters ); if ( typeName != null ) simpleValue.setTypeName( typeName ); }
Example 12
Source File: HbmBinder.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
private static void bindUniqueKey(Attribute uniqueKeyAttribute, Table table, Column column, Mappings mappings) { if ( uniqueKeyAttribute != null && table != null ) { StringTokenizer tokens = new StringTokenizer( uniqueKeyAttribute.getValue(), ", " ); while ( tokens.hasMoreTokens() ) { table.getOrCreateUniqueKey( tokens.nextToken() ).addColumn( column ); } } }
Example 13
Source File: NamedSQLQuerySecondPass.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
public void doSecondPass(Map persistentClasses) throws MappingException { String queryName = queryElem.attribute( "name" ).getValue(); if (path!=null) queryName = path + '.' + queryName; boolean cacheable = "true".equals( queryElem.attributeValue( "cacheable" ) ); String region = queryElem.attributeValue( "cache-region" ); Attribute tAtt = queryElem.attribute( "timeout" ); Integer timeout = tAtt == null ? null : new Integer( tAtt.getValue() ); Attribute fsAtt = queryElem.attribute( "fetch-size" ); Integer fetchSize = fsAtt == null ? null : new Integer( fsAtt.getValue() ); Attribute roAttr = queryElem.attribute( "read-only" ); boolean readOnly = roAttr != null && "true".equals( roAttr.getValue() ); Attribute cacheModeAtt = queryElem.attribute( "cache-mode" ); String cacheMode = cacheModeAtt == null ? null : cacheModeAtt.getValue(); Attribute cmAtt = queryElem.attribute( "comment" ); String comment = cmAtt == null ? null : cmAtt.getValue(); java.util.List synchronizedTables = new ArrayList(); Iterator tables = queryElem.elementIterator( "synchronize" ); while ( tables.hasNext() ) { synchronizedTables.add( ( (Element) tables.next() ).attributeValue( "table" ) ); } boolean callable = "true".equals( queryElem.attributeValue( "callable" ) ); NamedSQLQueryDefinition namedQuery; Attribute ref = queryElem.attribute( "resultset-ref" ); String resultSetRef = ref == null ? null : ref.getValue(); if ( StringHelper.isNotEmpty( resultSetRef ) ) { namedQuery = new NamedSQLQueryDefinition( queryElem.getText(), resultSetRef, synchronizedTables, cacheable, region, timeout, fetchSize, HbmBinder.getFlushMode( queryElem.attributeValue( "flush-mode" ) ), HbmBinder.getCacheMode( cacheMode ), readOnly, comment, HbmBinder.getParameterTypes( queryElem ), callable ); //TODO check there is no actual definition elemnents when a ref is defined } else { ResultSetMappingDefinition definition = buildResultSetMappingDefinition( queryElem, path, mappings ); namedQuery = new NamedSQLQueryDefinition( queryElem.getText(), definition.getQueryReturns(), synchronizedTables, cacheable, region, timeout, fetchSize, HbmBinder.getFlushMode( queryElem.attributeValue( "flush-mode" ) ), HbmBinder.getCacheMode( cacheMode ), readOnly, comment, HbmBinder.getParameterTypes( queryElem ), callable ); } log.debug( "Named SQL query: " + queryName + " -> " + namedQuery.getQueryString() ); mappings.addSQLQuery( queryName, namedQuery ); }
Example 14
Source File: CommonAbstractAttributeParser.java From SVG-Android with Apache License 2.0 | 4 votes |
protected String parseString(Element element, String name, String defaultValue) { Attribute attribute = element.attribute(name); String value = attribute == null ? null : attribute.getValue(); return value == null || value.trim().length() == 0 ? defaultValue : value; }
Example 15
Source File: XmlUtil.java From fixflow with Apache License 2.0 | 4 votes |
public static String getAttributeValue(Attribute attribute){ String result = null; if(attribute!=null) result = attribute.getValue(); return result; }
Example 16
Source File: HbmBinder.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
private static void bindManyToManySubelements( Collection collection, Element manyToManyNode, Mappings model) throws MappingException { // Bind the where Attribute where = manyToManyNode.attribute( "where" ); String whereCondition = where == null ? null : where.getValue(); collection.setManyToManyWhere( whereCondition ); // Bind the order-by Attribute order = manyToManyNode.attribute( "order-by" ); String orderFragment = order == null ? null : order.getValue(); collection.setManyToManyOrdering( orderFragment ); // Bind the filters Iterator filters = manyToManyNode.elementIterator( "filter" ); if ( ( filters.hasNext() || whereCondition != null ) && collection.getFetchMode() == FetchMode.JOIN && collection.getElement().getFetchMode() != FetchMode.JOIN ) { throw new MappingException( "many-to-many defining filter or where without join fetching " + "not valid within collection using join fetching [" + collection.getRole() + "]" ); } while ( filters.hasNext() ) { final Element filterElement = ( Element ) filters.next(); final String name = filterElement.attributeValue( "name" ); String condition = filterElement.getTextTrim(); if ( StringHelper.isEmpty(condition) ) condition = filterElement.attributeValue( "condition" ); if ( StringHelper.isEmpty(condition) ) { condition = model.getFilterDefinition(name).getDefaultFilterCondition(); } if ( condition==null) { throw new MappingException("no filter condition found for filter: " + name); } log.debug( "Applying many-to-many filter [" + name + "] as [" + condition + "] to role [" + collection.getRole() + "]" ); collection.addManyToManyFilter( name, condition ); } }
Example 17
Source File: HbmBinder.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
private static void bindPersistentClassCommonValues(Element node, PersistentClass entity, Mappings mappings, java.util.Map inheritedMetas) throws MappingException { // DISCRIMINATOR Attribute discriminatorNode = node.attribute( "discriminator-value" ); entity.setDiscriminatorValue( ( discriminatorNode == null ) ? entity.getEntityName() : discriminatorNode.getValue() ); // DYNAMIC UPDATE Attribute dynamicNode = node.attribute( "dynamic-update" ); entity.setDynamicUpdate( dynamicNode != null && "true".equals( dynamicNode.getValue() ) ); // DYNAMIC INSERT Attribute insertNode = node.attribute( "dynamic-insert" ); entity.setDynamicInsert( insertNode != null && "true".equals( insertNode.getValue() ) ); // IMPORT mappings.addImport( entity.getEntityName(), entity.getEntityName() ); if ( mappings.isAutoImport() && entity.getEntityName().indexOf( '.' ) > 0 ) { mappings.addImport( entity.getEntityName(), StringHelper.unqualify( entity.getEntityName() ) ); } // BATCH SIZE Attribute batchNode = node.attribute( "batch-size" ); if ( batchNode != null ) entity.setBatchSize( Integer.parseInt( batchNode.getValue() ) ); // SELECT BEFORE UPDATE Attribute sbuNode = node.attribute( "select-before-update" ); if ( sbuNode != null ) entity.setSelectBeforeUpdate( "true".equals( sbuNode.getValue() ) ); // OPTIMISTIC LOCK MODE Attribute olNode = node.attribute( "optimistic-lock" ); entity.setOptimisticLockMode( getOptimisticLockMode( olNode ) ); entity.setMetaAttributes( getMetas( node, inheritedMetas ) ); // PERSISTER Attribute persisterNode = node.attribute( "persister" ); if ( persisterNode == null ) { // persister = SingleTableEntityPersister.class; } else { try { entity.setEntityPersisterClass( ReflectHelper.classForName( persisterNode .getValue() ) ); } catch (ClassNotFoundException cnfe) { throw new MappingException( "Could not find persister class: " + persisterNode.getValue() ); } } // CUSTOM SQL handleCustomSQL( node, entity ); Iterator tables = node.elementIterator( "synchronize" ); while ( tables.hasNext() ) { entity.addSynchronizedTable( ( (Element) tables.next() ).attributeValue( "table" ) ); } Attribute abstractNode = node.attribute( "abstract" ); Boolean isAbstract = abstractNode == null ? null : "true".equals( abstractNode.getValue() ) ? Boolean.TRUE : "false".equals( abstractNode.getValue() ) ? Boolean.FALSE : null; entity.setAbstract( isAbstract ); }
Example 18
Source File: SkipXmlNodeMatcher.java From ats-framework with Apache License 2.0 | 4 votes |
List<Element> getMatchingNodes( String snapshot, XmlNode xmlNode ) { // cycle all nodes that come for this XPath List<Element> matchedNodes = new ArrayList<>(); List foundNodeObjects = xmlNode.getnode().selectNodes(this.xpath); if (foundNodeObjects != null) { for (Object foundNodeObject : foundNodeObjects) { Element node = (Element) foundNodeObject; String message = null; Attribute attribute = node.attribute(attributeKey); if (attribute != null) { String attributeValue = attribute.getValue(); if (matchType == MATCH_TYPE.TEXT && attributeValue.equalsIgnoreCase(this.attributeValue)) { // equals text message = "equals ignoring case '" + attributeValue + "'"; } else if (matchType == MATCH_TYPE.CONTAINS_TEXT && attributeValue.toLowerCase() .contains(this.attributeValue.toLowerCase())) { // contains text message = "contains ignoring case '" + attributeValue + "'"; } else if (attributeValue.matches(this.attributeValue)) { // matches regex message = "matches the '" + attributeValue + "' regular expression"; } if (message != null) { if (log.isDebugEnabled()) { log.debug("[" + snapshot + "] File " + filePath + ": Removing XML node " + new XmlNode(xmlNode, node).getSignature("") + " as its attribute '" + this.attributeKey + "=" + this.attributeValue + "' has a value that " + message); } matchedNodes.add(node); } } } } return matchedNodes; }
Example 19
Source File: IosNativePageSourceHandler.java From agent with MIT License | 4 votes |
/** * android / ios 复用一套前端inspector组件,将ios的布局转成android格式 * * @param element */ @Override public void handleElement(Element element) { if (element == null) { return; } String elementName = element.getName(); if (StringUtils.isEmpty(elementName)) { return; } if ("AppiumAUT".equals(elementName)) { element.setName("hierarchy"); } else { element.setName("node"); Attribute xAttr = element.attribute("x"); String startX = xAttr.getValue(); element.remove(xAttr); Attribute yAttr = element.attribute("y"); String startY = yAttr.getValue(); element.remove(yAttr); Attribute widthAttr = element.attribute("width"); String width = widthAttr.getValue(); element.remove(widthAttr); Attribute heightAttr = element.attribute("height"); String height = heightAttr.getValue(); element.remove(heightAttr); Integer endX = Integer.parseInt(startX) + Integer.parseInt(width); Integer endY = Integer.parseInt(startY) + Integer.parseInt(height); String bounds = String.format("[%s,%s][%d,%d]", startX, startY, endX, endY); element.addAttribute("bounds", bounds); // 前端el-tree // defaultProps: { // children: 'nodes', // label: 'class' // } element.addAttribute("class", elementName); } List<Element> elements = element.elements(); elements.forEach(e -> handleElement(e)); }
Example 20
Source File: HbmBinder.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
public static void bindJoinedSubclass(Element node, JoinedSubclass joinedSubclass, Mappings mappings, java.util.Map inheritedMetas) throws MappingException { bindClass( node, joinedSubclass, mappings, inheritedMetas ); inheritedMetas = getMetas( node, inheritedMetas, true ); // get meta's from // <joined-subclass> // joined subclasses if ( joinedSubclass.getEntityPersisterClass() == null ) { joinedSubclass.getRootClass() .setEntityPersisterClass( JoinedSubclassEntityPersister.class ); } Attribute schemaNode = node.attribute( "schema" ); String schema = schemaNode == null ? mappings.getSchemaName() : schemaNode.getValue(); Attribute catalogNode = node.attribute( "catalog" ); String catalog = catalogNode == null ? mappings.getCatalogName() : catalogNode.getValue(); Table mytable = mappings.addTable( schema, catalog, getClassTableName( joinedSubclass, node, schema, catalog, null, mappings ), getSubselect( node ), false ); joinedSubclass.setTable( mytable ); bindComment(mytable, node); log.info( "Mapping joined-subclass: " + joinedSubclass.getEntityName() + " -> " + joinedSubclass.getTable().getName() ); // KEY Element keyNode = node.element( "key" ); SimpleValue key = new DependantValue( mytable, joinedSubclass.getIdentifier() ); joinedSubclass.setKey( key ); key.setCascadeDeleteEnabled( "cascade".equals( keyNode.attributeValue( "on-delete" ) ) ); bindSimpleValue( keyNode, key, false, joinedSubclass.getEntityName(), mappings ); // model.getKey().setType( new Type( model.getIdentifier() ) ); joinedSubclass.createPrimaryKey(); joinedSubclass.createForeignKey(); // CHECK Attribute chNode = node.attribute( "check" ); if ( chNode != null ) mytable.addCheckConstraint( chNode.getValue() ); // properties createClassProperties( node, joinedSubclass, mappings, inheritedMetas ); }