List of usage examples for org.dom4j Element attributeIterator
Iterator<Attribute> attributeIterator();
From source file:org.codehaus.aspectwerkz.definition.DocumentParser.java
License:Open Source License
/** * Retrieves and returns the package.//from w w w . java 2 s . c o m * * @param packageElement the package element * @return the package as a string ending with DOT, or empty string */ private static String getPackage(final Element packageElement) { String packageName = ""; for (Iterator it2 = packageElement.attributeIterator(); it2.hasNext();) { Attribute attribute = (Attribute) it2.next(); if (attribute.getName().trim().equalsIgnoreCase("name")) { packageName = attribute.getValue().trim(); if (packageName.endsWith(".*")) { packageName = packageName.substring(0, packageName.length() - 1); } else if (packageName.endsWith(".")) { ; // skip } else { packageName += "."; } break; } else { continue; } } return packageName; }
From source file:org.codehaus.aspectwerkz.definition.DocumentParser.java
License:Open Source License
/** * Parses the <tt>include</tt> elements. * * @param root the root element//from ww w .ja v a2 s . c o m * @param definition the definition object * @param packageName the package name */ private static void parseIncludePackageElements(final Element root, final SystemDefinition definition, final String packageName) { for (Iterator it1 = root.elementIterator("include"); it1.hasNext();) { String includePackage = ""; Element includeElement = (Element) it1.next(); for (Iterator it2 = includeElement.attributeIterator(); it2.hasNext();) { Attribute attribute = (Attribute) it2.next(); if (attribute.getName().trim().equalsIgnoreCase("package")) { // handle base package if (packageName.endsWith(".*")) { includePackage = packageName.substring(0, packageName.length() - 2); } else if (packageName.endsWith(".")) { includePackage = packageName.substring(0, packageName.length() - 1); } // handle exclude package includePackage = packageName + attribute.getValue().trim(); if (includePackage.endsWith(".*")) { includePackage = includePackage.substring(0, includePackage.length() - 2); } else if (includePackage.endsWith(".")) { includePackage = includePackage.substring(0, includePackage.length() - 1); } break; } else { continue; } } if (includePackage.length() != 0) { definition.addIncludePackage(includePackage); } } }
From source file:org.codehaus.aspectwerkz.definition.DocumentParser.java
License:Open Source License
/** * Parses the <tt>exclude</tt> elements. * * @param root the root element//w w w.j a va 2 s.com * @param definition the definition object * @param packageName the package name */ private static void parseExcludePackageElements(final Element root, final SystemDefinition definition, final String packageName) { for (Iterator it1 = root.elementIterator("exclude"); it1.hasNext();) { String excludePackage = ""; Element excludeElement = (Element) it1.next(); for (Iterator it2 = excludeElement.attributeIterator(); it2.hasNext();) { Attribute attribute = (Attribute) it2.next(); if (attribute.getName().trim().equalsIgnoreCase("package")) { // handle base package if (packageName.endsWith(".*")) { excludePackage = packageName.substring(0, packageName.length() - 2); } else if (packageName.endsWith(".")) { excludePackage = packageName.substring(0, packageName.length() - 1); } // handle exclude package excludePackage = packageName + attribute.getValue().trim(); if (excludePackage.endsWith(".*")) { excludePackage = excludePackage.substring(0, excludePackage.length() - 2); } else if (excludePackage.endsWith(".")) { excludePackage = excludePackage.substring(0, excludePackage.length() - 1); } break; } else { continue; } } if (excludePackage.length() != 0) { definition.addExcludePackage(excludePackage); } } }
From source file:org.codehaus.aspectwerkz.definition.DocumentParser.java
License:Open Source License
/** * Parses the <tt>prepare</tt> elements. * * @param root the root element//from w w w . j a v a 2s . c o m * @param definition the definition object * @param packageName the base package name */ public static void parsePrepareElements(final Element root, final SystemDefinition definition, final String packageName) { for (Iterator it1 = root.elementIterator("prepare"); it1.hasNext();) { String preparePackage = ""; Element prepareElement = (Element) it1.next(); for (Iterator it2 = prepareElement.attributeIterator(); it2.hasNext();) { Attribute attribute = (Attribute) it2.next(); if (attribute.getName().trim().equals("package")) { // handle base package if (packageName.endsWith(".*")) { preparePackage = packageName.substring(0, packageName.length() - 2); } else if (packageName.endsWith(".")) { preparePackage = packageName.substring(0, packageName.length() - 1); } // handle prepare package preparePackage = packageName + attribute.getValue().trim(); if (preparePackage.endsWith(".*")) { preparePackage = preparePackage.substring(0, preparePackage.length() - 2); } else if (preparePackage.endsWith(".")) { preparePackage = preparePackage.substring(0, preparePackage.length() - 1); } break; } else { continue; } } if (preparePackage.length() != 0) { definition.addPreparePackage(preparePackage); } } }
From source file:org.codehaus.aspectwerkz.definition.DocumentParser.java
License:Open Source License
/** * Retrieves and returns the base package for a system element * * @param system a system element/*from w w w . j av a 2 s.co m*/ * @return the base package */ private static String getBasePackage(final Element system) { String basePackage = ""; for (Iterator it2 = system.attributeIterator(); it2.hasNext();) { Attribute attribute = (Attribute) it2.next(); if (attribute.getName().trim().equalsIgnoreCase("base-package")) { basePackage = attribute.getValue().trim(); if (basePackage.endsWith(".*")) { basePackage = basePackage.substring(0, basePackage.length() - 1); } else if (basePackage.endsWith(".")) { ; // skip } else { basePackage += "."; } break; } else { continue; } } return basePackage; }
From source file:org.codehaus.aspectwerkz.extension.persistence.PersistenceDefinitionParser.java
License:Open Source License
/** * Parses the <tt>index</tt> elements. * * @param root the root element// w w w . j av a 2s. c o m * @param definition the definition object */ private static void parseIndexElements(final Element root, final PersistenceDefinition definition) { for (Iterator it1 = root.elementIterator("index"); it1.hasNext();) { IndexDefinition indexDef = new IndexDefinition(); Element introduction = (Element) it1.next(); for (Iterator it2 = introduction.attributeIterator(); it2.hasNext();) { Attribute attribute = (Attribute) it2.next(); String name = attribute.getName().trim(); String value = attribute.getValue().trim(); if (name.equals("name")) { indexDef.setName(value); continue; } else if (name.equals("type")) { indexDef.setType(value); continue; } } definition.addIndex(indexDef); } }
From source file:org.codehaus.aspectwerkz.extension.persistence.PersistenceDefinitionParser.java
License:Open Source License
/** * Parses the <tt>peristence-manager</tt> elements. * * @param root the root element//from w w w. j a v a 2s . c o m * @param definition the definition object */ private static void parsePersistenceManagerElements(final Element root, final PersistenceDefinition definition) { for (Iterator it1 = root.elementIterator("persistence-manager"); it1.hasNext();) { PersistenceManagerDefinition pmDef = new PersistenceManagerDefinition(); final Element pm = (Element) it1.next(); for (Iterator it2 = pm.attributeIterator(); it2.hasNext();) { Attribute attribute = (Attribute) it2.next(); String name = attribute.getName().trim(); String value = attribute.getValue().trim(); if (name.equals("class")) { pmDef.setClassName(value); } else if (name.equals("active")) { pmDef.setActive(value); } } for (Iterator it2 = pm.elementIterator(); it2.hasNext();) { Element nestedAdviceElement = (Element) it2.next(); if (nestedAdviceElement.getName().trim().equals("index-ref")) { IndexRefDefinition indexDef = new IndexRefDefinition(); indexDef.setName(nestedAdviceElement.attributeValue("name")); pmDef.addIndexRef(indexDef); } else if (nestedAdviceElement.getName().trim().equals("param")) { ParameterDefinition paramDef = new ParameterDefinition(); paramDef.setName(nestedAdviceElement.attributeValue("name")); paramDef.setValue(nestedAdviceElement.getText()); pmDef.addParameter(paramDef); } } definition.addPersistenceManager(pmDef); } }
From source file:org.codehaus.aspectwerkz.extension.persistence.PersistenceDefinitionParser.java
License:Open Source License
/** * Parses the <tt>persistent</tt> elements. * * @param root the root element//from w w w . j a va 2 s. co m * @param definition the definition object */ private static void parsePersistentElements(final Element root, final PersistenceDefinition definition) { for (Iterator it1 = root.elementIterator("persistent"); it1.hasNext();) { final PersistentObjectDefinition persistentDef = new PersistentObjectDefinition(); final Element persistent = (Element) it1.next(); for (Iterator it2 = persistent.attributeIterator(); it2.hasNext();) { Attribute attribute = (Attribute) it2.next(); String name = attribute.getName().trim(); String value = attribute.getValue().trim(); if (name.equals("class")) { persistentDef.setClassName(value); continue; } } for (Iterator it2 = persistent.elementIterator(); it2.hasNext();) { Element nestedAdviceElement = (Element) it2.next(); if (nestedAdviceElement.getName().trim().equals("index-ref")) { IndexRefDefinition indexDef = new IndexRefDefinition(); indexDef.setName(nestedAdviceElement.attributeValue("name")); indexDef.setMethod(nestedAdviceElement.attributeValue("method")); persistentDef.addIndexRef(indexDef); } } definition.addPersistentObject(persistentDef); } }
From source file:org.codehaus.aspectwerkz.xmldef.definition.DocumentParser.java
License:Open Source License
/** * Parses the <tt>introduction</tt> elements. * * @param root the root element//from w w w . j a v a 2 s . c om * @param definition the definition object * @param packageName the package name * @return flag that says if we have a definition of this kind or not */ private static boolean parseIntroductionElements(final Element root, final AspectWerkzDefinitionImpl definition, final String packageName) { boolean hasDef = false; for (Iterator it1 = root.elementIterator("introduction-def"); it1.hasNext();) { final IntroductionDefinition introDef = new IntroductionDefinition(); Element introduction = (Element) it1.next(); for (Iterator it2 = introduction.attributeIterator(); it2.hasNext();) { Attribute attribute = (Attribute) it2.next(); final String name = attribute.getName().trim(); final String value = attribute.getValue().trim(); if (name.equals("name")) { introDef.setName(value); } else if (name.equals("interface")) { introDef.setInterface(packageName + value); } else if (name.equals("implementation")) { introDef.setImplementation(packageName + value); } else if (name.equals("deployment-model")) { introDef.setDeploymentModel(value); } else if (name.equals("attribute")) { introDef.setAttribute(value); } } definition.addIntroduction(introDef); hasDef = true; } return hasDef; }
From source file:org.codehaus.aspectwerkz.xmldef.definition.DocumentParser.java
License:Open Source License
/** * Parses the <tt>advice</tt> elements. * * @param root the root element//w ww . j a va 2 s . c o m * @param definition the definition object * @param packageName the package name * @return flag that says if we have a definition of this kind or not */ private static boolean parseAdviceElements(final Element root, final AspectWerkzDefinitionImpl definition, final String packageName) { boolean hasDef = false; for (Iterator it1 = root.elementIterator("advice-def"); it1.hasNext();) { final AdviceDefinition adviceDef = new AdviceDefinition(); Element advice = (Element) it1.next(); for (Iterator it2 = advice.attributeIterator(); it2.hasNext();) { Attribute attribute = (Attribute) it2.next(); final String name = attribute.getName().trim(); final String value = attribute.getValue().trim(); if (name.equals("name")) { adviceDef.setName(value); } else if (name.equals("class")) { adviceDef.setAdviceClassName(packageName + value); } else if (name.equals("deployment-model")) { adviceDef.setDeploymentModel(value); } else if (name.equals("attribute")) { adviceDef.setAttribute(value); } } for (Iterator it2 = advice.elementIterator(); it2.hasNext();) { Element nestedAdviceElement = (Element) it2.next(); if (nestedAdviceElement.getName().trim().equals("param")) { adviceDef.addParameter(nestedAdviceElement.attributeValue("name"), nestedAdviceElement.attributeValue("value")); } } definition.addAdvice(adviceDef); hasDef = true; } return hasDef; }