it.haefelinger.flaka
Class DotClassPath

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by it.haefelinger.flaka.Task
              extended by it.haefelinger.flaka.DotClassPath
All Implemented Interfaces:
Cloneable

public class DotClassPath
extends Task

A task to execute operations on a .classpath loc. This task implements opertations like append, remove and query on a .classpath loc.

Since:
1.0
Author:
merzedes

Nested Class Summary
 class DotClassPath.ClassPathEntry
          A class representing a "real" classpathentry element.
 class DotClassPath.FileSetEntry
          To be used to create a list of 'lib->path' entries
static interface DotClassPath.LogicalClassPathEntry
          Interface representing a logical classpath entry.
 
Field Summary
static int AND
           
protected  File base
          my base folder
protected  boolean echo
          dump content
protected  File file
          the loc to operate on
protected  List list
          internal list of (logical) classpath entries
protected  int logic
          query logic
protected  char opc
          operation
static int OR
           
protected  String qvar
          query result var
protected  String refid
          dependencies to be used
protected  boolean sort
          sort content
protected  File wsfolder
          Eclipse's workspace
 
Fields inherited from class it.haefelinger.flaka.Task
debug, el
 
Fields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
DotClassPath()
           
 
Method Summary
 void addFileSet(FileSet item)
           
protected static void attr2buf(StringBuffer buf, String v, String name)
          A helper function to add an XML like attribute to a string buffer.
protected  File basedir()
          Returns current base folder given by property basedir.
protected  void collect(Element root, List bucket)
          Iterates of each child element of root, turing each into a classpath entry and adding such an entry to bucket.
protected  boolean contains(List Q, DotClassPath.ClassPathEntry c)
           
 DotClassPath.ClassPathEntry createClassPathEntry()
           
protected  void eval(List bucket)
          Iterates over each logical classpath entries and evaluates each entry into a physical entries.
 void execute()
           
protected  boolean good(DotClassPath.ClassPathEntry c)
          Check whether this classpath entry is acceptable for Eclipse.
protected  void opQuery(List clazzpath)
           
protected  void opRemove(List clazzpath)
           
protected  void opUpdate(List clazzpath)
          * Update XML element by adding classpath entries.
 void setBase(File file)
          Use this attribute to specify the base directory.
 void setEcho(boolean b)
          Use this attribute to dump the content of the .classpath loc on stdout.
 void setFile(File file)
          Use this attribute to set the loc to operate on.
 void setFlush(boolean b)
          Deprecated.  
 void setLogic(String s)
          Use this attribute to specify the query logic.
 void setOp(String s)
          Use this attribute to specify the operation to execute.
 void setRefId(String s)
          Use attribute refid to specify another variable holding an array of Dependencies.
 void setResDir(String s)
           
 void setSort(boolean b)
          Use this attribute to sort the final .classpath.
 void setSrcDir(String s)
           
 void setUnique(boolean b)
          Deprecated.  
 void setValidate(boolean b)
          Deprecated.  
 void setVar(String s)
          This attribute will be set if a query evaluates to true.
 void setWsFolder(File file)
          Use this attribute to specify the workspace folder of Eclipse.
 String toString()
          This method will render a string representation of all physical classpath entries.
protected  void update(DotClassPath.ClassPathEntry c, Element e)
           
 
Methods inherited from class it.haefelinger.flaka.Task
debug, debug, error, error, getProperty, getref, info, log, setDebug, setEl, throwbx, throwbx, toFile, verbose, warn, warn
 
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

list

protected List list
internal list of (logical) classpath entries


file

protected File file
the loc to operate on


base

protected File base
my base folder


wsfolder

protected File wsfolder
Eclipse's workspace


sort

protected boolean sort
sort content


opc

protected char opc
operation


echo

protected boolean echo
dump content


qvar

protected String qvar
query result var


refid

protected String refid
dependencies to be used


logic

protected int logic
query logic


AND

public static final int AND
See Also:
Constant Field Values

OR

public static final int OR
See Also:
Constant Field Values
Constructor Detail

DotClassPath

public DotClassPath()
Method Detail

setLogic

public void setLogic(String s)
Use this attribute to specify the query logic. By default each entry must match. When changing to "or", it is sufficient that one entry matches.

Parameters:
s - Shall not be null. The string value will be normalized, then tested for the following values in a case insensitive manner: "and", "&" and "&&" equals to logical and, while "or","|" or "||" gives the logical or. If the given values does not match, the default value gets applied.

setRefId

public void setRefId(String s)
Use attribute refid to specify another variable holding an array of Dependencies. This dependencies are used to figure out the project ( if known) of a lib entry. Default: project.dependencies.

Parameters:
s - null allowed

setVar

public void setVar(String s)
This attribute will be set if a query evaluates to true. If a name is given, property ${name} is set to true. Note that the property is not set if already defined. There is no default value.

Parameters:
s - The name of the property to set if a query evaluates to true.

setEcho

public void setEcho(boolean b)
Use this attribute to dump the content of the .classpath loc on stdout. By default, content is not dumped.

Parameters:
b - If true, dump the content of .classpath.

setOp

public void setOp(String s)
Use this attribute to specify the operation to execute. Use 'a' or 'u' to execute an update command, use 'r' for removal and use 'q' for an query. Default value is 'a'.

Parameters:
s -

setFile

public void setFile(File file)
Use this attribute to set the loc to operate on. By default, .classpath is used.


setBase

public void setBase(File file)
Use this attribute to specify the base directory. By default, the base directory is the folder containing the build loc.


setWsFolder

public void setWsFolder(File file)
Use this attribute to specify the workspace folder of Eclipse. If not given, then the workspace folder will be the parent of base directory.


setSort

public void setSort(boolean b)
Use this attribute to sort the final .classpath. This attribute has no effect when executing a query.


setUnique

public void setUnique(boolean b)
Deprecated. 

This attribute is kept for legacy reasons.

Parameters:
b -

setValidate

public void setValidate(boolean b)
Deprecated. 

This attribute is kept for legacy reasons.

Parameters:
b -

setFlush

public void setFlush(boolean b)
Deprecated. 

This attribute is kept for legacy reasons.

Parameters:
b -

setSrcDir

public void setSrcDir(String s)
Parameters:
s -

setResDir

public void setResDir(String s)
Parameters:
s -

attr2buf

protected static void attr2buf(StringBuffer buf,
                               String v,
                               String name)
A helper function to add an XML like attribute to a string buffer.

Parameters:
buf - not null
name - (attribute name)
v - (attribute value)

createClassPathEntry

public DotClassPath.ClassPathEntry createClassPathEntry()
                                                 throws BuildException
Throws:
BuildException

basedir

protected File basedir()
Returns current base folder given by property basedir. This property is set by Ant on starting up and is the folder containing the build script being executed.


addFileSet

public void addFileSet(FileSet item)
                throws BuildException
Throws:
BuildException

eval

protected void eval(List bucket)
Iterates over each logical classpath entries and evaluates each entry into a physical entries. Those physical entries are appended to given bucket list.


toString

public String toString()
This method will render a string representation of all physical classpath entries. It will not render a .classpath loc nor does it update or touch any loc. It's main purpose is for debugging.

Overrides:
toString in class Object

collect

protected void collect(Element root,
                       List bucket)
Iterates of each child element of root, turing each into a classpath entry and adding such an entry to bucket.


update

protected void update(DotClassPath.ClassPathEntry c,
                      Element e)

good

protected boolean good(DotClassPath.ClassPathEntry c)
Check whether this classpath entry is acceptable for Eclipse. Eclipse is rather fuzzy about entries listed.

Parameters:
c - not null
Returns:
true if well formed.

contains

protected boolean contains(List Q,
                           DotClassPath.ClassPathEntry c)

opUpdate

protected void opUpdate(List clazzpath)
                 throws BuildException
* Update XML element by adding classpath entries. * *

Throws:
BuildException

opQuery

protected void opQuery(List clazzpath)
                throws BuildException
Throws:
BuildException

opRemove

protected void opRemove(List clazzpath)
                 throws BuildException
Throws:
BuildException

execute

public void execute()
             throws BuildException
Overrides:
execute in class Task
Throws:
BuildException