List of usage examples for org.dom4j Node valueOf
String valueOf(String xpathExpression);
valueOf
evaluates an XPath expression and returns the textual representation of the results the XPath string-value of this node.
From source file:com.adobe.ac.maven.ncss.NcssReportGenerator.java
License:Apache License
private void doFunctionAnalysis(final Document document) { subtitleHelper(getResourceBundle().getString("report.javancss.top") + " " + lineThreshold + " " + getResourceBundle().getString("report.javancss.function.byncss")); getSink().paragraph();/*from ww w . jav a 2 s .c o m*/ getSink().table(); getSink().tableRow(); headerCellHelper(getResourceBundle().getString("report.javancss.header.function")); headerCellHelper(getResourceBundle().getString("report.javancss.header.ncss")); headerCellHelper(getResourceBundle().getString("report.javancss.header.ccn")); headerCellHelper(getResourceBundle().getString("report.javancss.header.javadoc")); getSink().tableRow_(); final List list = document.selectNodes("//javancss/functions/function"); Collections.sort(list, new NumericNodeComparator("ncss")); final Iterator nodeIterator = list.iterator(); int i = 0; while (nodeIterator.hasNext() && (i++ < lineThreshold)) { final Node node = (Node) nodeIterator.next(); getSink().tableRow(); getSink().tableCell(); getSink().tableCell_(); tableCellHelper(node.valueOf("ncss")); tableCellHelper(node.valueOf("ccn")); tableCellHelper(node.valueOf("javadocs")); getSink().tableRow_(); } getSink().table_(); getSink().paragraph_(); }
From source file:com.adobe.ac.maven.ncss.NcssReportGenerator.java
License:Apache License
private void doFunctionAverage(final Document document) { subtitleHelper(getResourceBundle().getString("report.javancss.averages")); getSink().paragraph();/*from ww w . ja va 2 s.co m*/ getSink().table(); getSink().tableRow(); headerCellHelper(getResourceBundle().getString("report.javancss.header.programncss")); headerCellHelper(getResourceBundle().getString("report.javancss.header.ncssaverage")); headerCellHelper(getResourceBundle().getString("report.javancss.header.ccnaverage")); headerCellHelper(getResourceBundle().getString("report.javancss.header.javadocaverage")); getSink().tableRow_(); final Node node = document.selectSingleNode("//javancss/functions/function_averages"); final String totalNcss = document.selectSingleNode("//javancss/functions/ncss").getText(); getSink().tableRow(); tableCellHelper(totalNcss); tableCellHelper(node.valueOf("ncss")); tableCellHelper(node.valueOf("ccn")); tableCellHelper(node.valueOf("javadocs")); getSink().tableRow_(); getSink().table_(); getSink().paragraph_(); }
From source file:com.adobe.ac.maven.ncss.NcssViolationCheckMojo.java
License:Apache License
public void execute() throws MojoExecutionException, MojoFailureException { final Set<String> ccnViolation = new HashSet<String>(); final Set<String> ncssViolation = new HashSet<String>(); final List methodList = loadDocument().selectNodes("//javancss/functions/function"); // Count ccn & ncss violations final Iterator nodeIterator = methodList.iterator(); while (nodeIterator.hasNext()) { final Node node = (Node) nodeIterator.next(); // count ccn violation final int ccn = Integer.valueOf(node.valueOf("ccn")); if (ccn > ccnLimit) { ccnViolation.add(node.valueOf("name")); }/*from w ww . j a va2 s.c om*/ // count ncss violation final int ncss = Integer.valueOf(node.valueOf("ncss")); if (ncss > ncssLimit) { ncssViolation.add(node.valueOf("name")); } } // crappy.... reportViolation("ccn", ccnViolation, ccnLimit); reportViolation("ncss", ncssViolation, ncssLimit); }
From source file:com.adobe.ac.pmd.metrics.maven.FlexMetricsMojo.java
License:Apache License
@SuppressWarnings("unchecked") public void execute() throws MojoExecutionException, MojoFailureException { new LoggerUtils().loadConfiguration(); if (sourceDirectory != null && sourceDirectory.exists()) { final Set<String> ccnViolation = new HashSet<String>(); final Set<String> ncssViolation = new HashSet<String>(); final List<Node> methodList = loadDocument().selectNodes("//javancss/functions/function"); for (final Node node : methodList) { if (Integer.valueOf(node.valueOf("ccn")) > ccnLimit) { ccnViolation.add(node.valueOf("name")); }/*from w ww. j a va2 s . c om*/ if (Integer.valueOf(node.valueOf("ncss")) > ncssLimit) { ncssViolation.add(node.valueOf("name")); } } reportViolation("ccn", ccnViolation, ccnLimit); reportViolation("ncss", ncssViolation, ncssLimit); } }
From source file:com.adobe.ac.pmd.metrics.maven.generators.NcssAggregateReportGenerator.java
License:Apache License
private void doModuleAnalysis(final List<ModuleReport> reports) { doModuleAnalysisHeader();/*from w ww . j a v a 2s.co m*/ int packages = 0; int classes = 0; int methods = 0; int ncss = 0; int javadocs = 0; int jdlines = 0; int single = 0; int multi = 0; for (final ModuleReport moduleReport : reports) { final ModuleReport report = moduleReport; final Document document = report.getJavancssDocument(); getSink().tableRow(); getLog().debug("Aggregating " + report.getModule().getArtifactId()); tableCellHelper(report.getModule().getArtifactId()); final int packageSize = document.selectNodes("//javancss/packages/package").size(); packages += packageSize; tableCellHelper(String.valueOf(packageSize)); final Node node = document.selectSingleNode("//javancss/packages/total"); tableCellHelper(node.valueOf("classes")); classes += Integer.parseInt(node.valueOf("classes")); tableCellHelper(node.valueOf("functions")); methods += Integer.parseInt(node.valueOf("functions")); tableCellHelper(node.valueOf("ncss")); ncss += Integer.parseInt(node.valueOf("ncss")); tableCellHelper(node.valueOf("javadocs")); javadocs += Integer.parseInt(node.valueOf("javadocs")); tableCellHelper(node.valueOf("javadoc_lines")); jdlines += Integer.parseInt(node.valueOf("javadoc_lines")); tableCellHelper(node.valueOf("single_comment_lines")); single += Integer.parseInt(node.valueOf("single_comment_lines")); tableCellHelper(node.valueOf("multi_comment_lines")); multi += Integer.parseInt(node.valueOf("multi_comment_lines")); getSink().tableRow_(); } doModuleAnalysisTotals(packages, classes, methods, ncss, javadocs, jdlines, single, multi); }
From source file:com.adobe.ac.pmd.metrics.maven.generators.NcssReportGenerator.java
License:Apache License
@SuppressWarnings("unchecked") private void doFunctionAnalysis(final Document document) { subtitleHelper(getResourceBundle().getString("report.javancss.top") + " " + lineThreshold + " " + getResourceBundle().getString("report.javancss.function.byncss")); getSink().paragraph();/*from w w w. j av a 2 s .c o m*/ getSink().table(); getSink().tableRow(); headerCellHelper(getResourceBundle().getString("report.javancss.header.function")); headerCellHelper(getResourceBundle().getString("report.javancss.header.ncss")); headerCellHelper(getResourceBundle().getString("report.javancss.header.ccn")); getSink().tableRow_(); final List<Node> list = document.selectNodes("//javancss/functions/function"); Collections.sort(list, new NumericNodeComparator(NCSS)); final Iterator<Node> nodeIterator = list.iterator(); int currentIndex = 0; while (nodeIterator.hasNext() && currentIndex++ < lineThreshold) { final Node node = nodeIterator.next(); getSink().tableRow(); // getSink().tableCell(); // getSink().tableCell_(); tableCellHelper(node.valueOf("name")); tableCellHelper(node.valueOf(NCSS)); tableCellHelper(node.valueOf("ccn")); getSink().tableRow_(); } getSink().table_(); getSink().paragraph_(); }
From source file:com.adobe.ac.pmd.metrics.maven.generators.NcssReportGenerator.java
License:Apache License
private void doFunctionAverage(final Document document) { subtitleHelper(getResourceBundle().getString("report.javancss.averages")); getSink().paragraph();/*w ww. ja v a 2 s. c o m*/ getSink().table(); getSink().tableRow(); headerCellHelper(getResourceBundle().getString("report.javancss.header.programncss")); headerCellHelper(getResourceBundle().getString("report.javancss.header.ncssaverage")); headerCellHelper(getResourceBundle().getString("report.javancss.header.ccnaverage")); getSink().tableRow_(); final Node node = document.selectSingleNode("//javancss/functions/function_averages"); final String totalNcss = document.selectSingleNode("//javancss/functions/ncss").getText(); getSink().tableRow(); tableCellHelper(totalNcss); tableCellHelper(node.valueOf(NCSS)); tableCellHelper(node.valueOf("ccn")); getSink().tableRow_(); getSink().table_(); getSink().paragraph_(); }
From source file:com.adobe.ac.pmd.metrics.maven.generators.NcssReportGenerator.java
License:Apache License
@SuppressWarnings("unchecked") private void doMainPackageAnalysis(final Document document) { subtitleHelper(getResourceBundle().getString("report.javancss.package.text")); getSink().table();/* w w w . j a v a 2s . c o m*/ getSink().tableRow(); // HEADER headerCellHelper(getResourceBundle().getString("report.javancss.header.package")); headerCellHelper(getResourceBundle().getString("report.javancss.header.classe")); headerCellHelper(getResourceBundle().getString("report.javancss.header.function")); headerCellHelper(getResourceBundle().getString("report.javancss.header.ncss")); getSink().tableRow_(); // DATA final List<Node> list = document.selectNodes("//javancss/packages/package"); Collections.sort(list, new NumericNodeComparator(NCSS)); for (final Node node : list) { getSink().tableRow(); tableCellHelper(node.valueOf(NAME)); tableCellHelper(node.valueOf(CLASSES)); tableCellHelper(node.valueOf(FUNCTIONS)); tableCellHelper(node.valueOf(NCSS)); getSink().tableRow_(); } getSink().table_(); }
From source file:com.adobe.ac.pmd.metrics.maven.generators.NcssReportGenerator.java
License:Apache License
private void doObjectAverage(final Document document) { subtitleHelper(getResourceBundle().getString("report.javancss.averages")); getSink().table();/* w w w .j a v a 2 s. c o m*/ getSink().tableRow(); headerCellHelper(getResourceBundle().getString("report.javancss.header.ncssaverage")); headerCellHelper(getResourceBundle().getString("report.javancss.header.classeaverage")); headerCellHelper(getResourceBundle().getString("report.javancss.header.functionaverage")); getSink().tableRow_(); final Node node = document.selectSingleNode("//javancss/objects/averages"); getSink().tableRow(); tableCellHelper(node.valueOf(NCSS)); tableCellHelper(node.valueOf(CLASSES)); tableCellHelper(node.valueOf(FUNCTIONS)); getSink().tableRow_(); getSink().table_(); }
From source file:com.adobe.ac.pmd.metrics.maven.generators.NcssReportGenerator.java
License:Apache License
private void doTopObjectGeneric(final List<Node> nodeList) { getSink().table();//from w w w . j a va 2 s .co m getSink().tableRow(); headerCellHelper(getResourceBundle().getString("report.javancss.header.object")); headerCellHelper(getResourceBundle().getString("report.javancss.header.ncss")); headerCellHelper(getResourceBundle().getString("report.javancss.header.function")); getSink().tableRow_(); final Iterator<Node> nodeIterator = nodeList.iterator(); int currentIndex = 0; while (nodeIterator.hasNext() && currentIndex++ < lineThreshold) { final Node node = nodeIterator.next(); getSink().tableRow(); tableCellHelper(node.valueOf(NAME)); tableCellHelper(node.valueOf(NCSS)); tableCellHelper(node.valueOf(FUNCTIONS)); getSink().tableRow_(); } getSink().table_(); }