o Adding a way to get hold of the selected node count so it can be

displayed to the user.


git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@112882 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
jvanzyl 2003-02-10 16:43:41 +00:00
parent 2a7d688042
commit 68fff41e79
2 changed files with 44 additions and 4 deletions

View File

@ -94,6 +94,8 @@ public abstract class AbstractPomTransformer
/** Properties used in transformNode */
private Properties properties;
private List selectedNodes;
// -------------------------------------------------------------------------
// Accessors
// -------------------------------------------------------------------------
@ -170,6 +172,44 @@ public abstract class AbstractPomTransformer
this.outputFile = outputFile;
}
/**
*
* @return
*/
public List getSelectedNodes()
{
if ( selectedNodes == null )
{
try
{
selectNodes();
}
catch ( Exception e )
{
// do nothing.
}
}
return selectedNodes;
}
/**
*
* @param selectedNodes
*/
public void setSelectedNodes( List selectedNodes )
{
this.selectedNodes = selectedNodes;
}
/**
*
* @return
*/
public int getSelectedNodeCount()
{
return getSelectedNodes().size();
}
// ----------------------------------------------------------------------
// Implementation
// ----------------------------------------------------------------------
@ -195,7 +235,7 @@ public abstract class AbstractPomTransformer
public void transformNodes()
throws Exception
{
for ( Iterator i = selectNodes().iterator(); i.hasNext(); )
for ( Iterator i = getSelectedNodes().iterator(); i.hasNext(); )
{
Object o = i.next();
@ -212,7 +252,7 @@ public abstract class AbstractPomTransformer
*
* @throws Exception
*/
public List selectNodes()
public void selectNodes()
throws Exception
{
SAXReader reader = new SAXReader();
@ -223,7 +263,7 @@ public abstract class AbstractPomTransformer
// So we can get any information we need, and alter anything we need to before writing
// the dom4j document back out.
XPath xpath = new Dom4jXPath( createXPathExpression() );
return xpath.selectNodes( getDocument() );
setSelectedNodes( xpath.selectNodes( getDocument() ) );
}
/**

View File

@ -68,7 +68,7 @@ import java.io.File;
*
* @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
*
* @version $Id: SnapshotResolver.java,v 1.3 2003/02/10 15:57:06 jvanzyl Exp $
* @version $Id: SnapshotResolver.java,v 1.4 2003/02/10 16:43:41 jvanzyl Exp $
*/
public class SnapshotResolver
extends AbstractPomTransformer