o Need a way to transform the nodes if there is no user interaction.

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@112886 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
jvanzyl 2003-02-11 01:00:55 +00:00
parent 9506694e04
commit f9906f9f3b
2 changed files with 34 additions and 1 deletions

View File

@ -82,7 +82,7 @@ import java.util.Properties;
*
* @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
*
* @version $Id: AbstractPomTransformer.java,v 1.3 2003/02/11 00:56:36 jvanzyl Exp $
* @version $Id: AbstractPomTransformer.java,v 1.4 2003/02/11 01:00:55 jvanzyl Exp $
*/
public abstract class AbstractPomTransformer
implements PomTransformer
@ -250,6 +250,26 @@ public abstract class AbstractPomTransformer
}
}
/**
* This is the automated way of transforming the nodes if there is
* no user interaction involved.
*
* @throws Exception If an error occurs while transforming the nodes.
*/
public void transformNodes()
throws Exception
{
for ( Iterator i = getSelectedNodes().iterator(); i.hasNext(); )
{
Object o = i.next();
if ( o instanceof Node )
{
transformNode( (Node) o );
}
}
}
// ----------------------------------------------------------------------
// Implementation
// ----------------------------------------------------------------------

View File

@ -97,4 +97,17 @@ public class DummySnapshotResolver
Node version = node.selectSingleNode( selectNodeXPath() );
version.setText( getNodeContent( node ) );
}
public Node getTransformedNode( Node node )
throws Exception
{
// Now with our xpath expression we have the whole <dependency/>
// element and we want to alter the <version/> element.
Node version = node.selectSingleNode( selectNodeXPath() );
Node transformedNode = (Node) version.clone();
transformedNode.setText( getNodeContent( node ) );
return transformedNode;
}
}