Java Doc for ModifiedSelector.java in  » Build » ANT » org » apache » tools » ant » types » selectors » modifiedselector » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Build » ANT » org.apache.tools.ant.types.selectors.modifiedselector 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.apache.tools.ant.types.selectors.BaseExtendSelector
   org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector

ModifiedSelector
public class ModifiedSelector extends BaseExtendSelector implements BuildListener,ResourceSelector(Code)

Selector class that uses Algorithm, Cache and Comparator for its work. The Algorithm is used for computing a hashvalue for a file. The Comparator decides whether to select or not. The Cache stores the other value for comparison by the Comparator in a persistent manner.

The ModifiedSelector is implemented as a CoreSelector and uses default values for all its attributes therefore the simpliest example is

 <copy todir="dest">
 <filelist dir="src">
 <modified/>
 </filelist>
 </copy>
 

The same example rewritten as CoreSelector with setting the all values (same as defaults are) would be

 <copy todir="dest">
 <filelist dir="src">
 <modified update="true"
 cache="propertyfile"
 algorithm="digest"
 comparator="equal">
 <param name="cache.cachefile"     value="cache.properties"/>
 <param name="algorithm.algorithm" value="MD5"/>
 </modified>
 </filelist>
 </copy>
 

And the same rewritten as CustomSelector would be

 <copy todir="dest">
 <filelist dir="src">
 <custom class="org.apache.tools.ant.type.selectors.ModifiedSelector">
 <param name="update"     value="true"/>
 <param name="cache"      value="propertyfile"/>
 <param name="algorithm"  value="digest"/>
 <param name="comparator" value="equal"/>
 <param name="cache.cachefile"     value="cache.properties"/>
 <param name="algorithm.algorithm" value="MD5"/>
 </custom>
 </filelist>
 </copy>
 

If you want to provide your own interface implementation you can do that via the *classname attributes. If the classes are not on Ant's core classpath, you will have to provide the path via nested <classpath> element, so that the selector can find the classes.

 <modified cacheclassname="com.mycompany.MyCache">
 <classpath>
 <pathelement location="lib/mycompony-antutil.jar"/>
 </classpath>
 </modified>
 

All these three examples copy the files from src to dest using the ModifiedSelector. The ModifiedSelector uses the PropertyfileCache , the DigestAlgorithm and the EqualComparator for its work. The PropertyfileCache stores key-value-pairs in a simple java properties file. The filename is cache.properties. The update flag lets the selector update the values in the cache (and on first call creates the cache). The DigestAlgorithm computes a hashvalue using the java.security.MessageDigest class with its MD5-Algorithm and its standard provider. The new computed hashvalue and the stored one are compared by the EqualComparator which returns 'true' (more correct a value not equals zero (1)) if the values are not the same using simple String comparison.

A useful scenario for this selector is inside a build environment for homepage generation (e.g. with Apache Forrest).

 <target name="generate-and-upload-site">
 <echo> generate the site using forrest </echo>
 <antcall target="site"/>
 <echo> upload the changed files </echo>
 <ftp server="${ftp.server}" userid="${ftp.user}" password="${ftp.pwd}">
 <fileset dir="htdocs/manual">
 <modified/>
 </fileset>
 </ftp>
 </target>
 
Here all changed files are uploaded to the server. The ModifiedSelector saves therefore much upload time.

This selector uses reflection for setting the values of its three interfaces (using org.apache.tools.ant.IntrospectionHelper) therefore no special 'configuration interfaces' has to be implemented by new caches, algorithms or comparators. All present setXX methods can be used. E.g. the DigestAlgorithm can use a specified provider for computing its value. For selecting this there is a setProvider(String providername) method. So you can use a nested <param name="algorithm.provider" value="MyProvider"/>.
since:
   Ant 1.6


Inner Class :public static class CacheName extends EnumeratedAttribute
Inner Class :public static class AlgorithmName extends EnumeratedAttribute
Inner Class :public static class ComparatorName extends EnumeratedAttribute


Constructor Summary
public  ModifiedSelector()
     Bean-Constructor.

Method Summary
public  voidaddClasspath(Path path)
     Add the classpath.
public  voidaddParam(String key, Object value)
     Support for nested <param> tags.
public  voidaddParam(Parameter parameter)
     Support for nested <param> tags.
public  voidbuildFinished(BuildEvent event)
     Signals that the last target has finished.
public  voidbuildStarted(BuildEvent event)
     Signals that a build has started.
public  voidconfigure()
     Configures this Selector. Does this work only once per Selector object.

Because some problems while configuring from Selector the configuration is done in the following order:

  1. collect the configuration data
  2. wait for the first isSelected() call
  3. set the default values
  4. set values for name pattern '*': update, cache, algorithm, comparator
  5. set values for name pattern '*.*: cache.cachefile, ...
public  AlgorithmgetAlgorithm()
     Get the algorithm type to use.
public  CachegetCache()
     Get the cache type to use.
public  ClassLoadergetClassLoader()
     Returns and initializes the classloader for this class.
public  ComparatorgetComparator()
     Get the comparator type to use.
public  booleangetDelayUpdate()
    
public  intgetModified()
    
public  booleanisSelected(Resource resource)
     Implementation of ResourceSelector.isSelected().
public  booleanisSelected(File basedir, String filename, File file)
     Implementation of BaseExtendSelector.isSelected().
protected  ObjectloadClass(String classname, String msg, Class type)
     Loads the specified class and initializes an object of that class.
public  voidmessageLogged(BuildEvent event)
     Signals a message logging event.
protected  voidsaveCache()
    
public  voidsetAlgorithm(AlgorithmName name)
     Set the algorithm type to use.
public  voidsetAlgorithmClass(String classname)
     Setter for algorithmClass.
public  voidsetCache(CacheName name)
     Set the cache type to use.
public  voidsetCacheClass(String classname)
     Setter for cacheClass.
public  voidsetClassLoader(ClassLoader loader)
     Set the used ClassLoader. If you invoke this selector by API (e.g.
public  voidsetComparator(ComparatorName name)
     Set the comparator type to use.
public  voidsetComparatorClass(String classname)
     Setter for comparatorClass.
public  voidsetDelayUpdate(boolean delayUpdate)
    
public  voidsetModified(int modified)
    
public  voidsetParameters(Parameter[] parameters)
     Defined in org.apache.tools.ant.types.Parameterizable.
public  voidsetSeldirs(boolean seldirs)
     Support for seldirs attribute.
public  voidsetSelres(boolean newValue)
     Support for selres attribute.
public  voidsetUpdate(boolean update)
     Support for update attribute.
public  voidtargetFinished(BuildEvent event)
     Signals that a target has finished.
public  voidtargetStarted(BuildEvent event)
     Signals that a target is starting.
public  voidtaskFinished(BuildEvent event)
     Signals that a task has finished.
public  voidtaskStarted(BuildEvent event)
     Signals that a task is starting.
public  StringtoString()
     Override Object.toString().
protected  voidtryToSetAParameter(Object obj, String name, String value)
     Try to set a value on an object using reflection.
public  voiduseParameter(Parameter parameter)
     Support for nested tags.
public  voidverifySettings()
     Overrides BaseSelector.verifySettings().


Constructor Detail
ModifiedSelector
public ModifiedSelector()(Code)
Bean-Constructor.




Method Detail
addClasspath
public void addClasspath(Path path)(Code)
Add the classpath.
Parameters:
  path - the classpath



addParam
public void addParam(String key, Object value)(Code)
Support for nested <param> tags.
Parameters:
  key - the key of the parameter
Parameters:
  value - the value of the parameter



addParam
public void addParam(Parameter parameter)(Code)
Support for nested <param> tags.
Parameters:
  parameter - the parameter object



buildFinished
public void buildFinished(BuildEvent event)(Code)
Signals that the last target has finished.
Parameters:
  event - recieved BuildEvent



buildStarted
public void buildStarted(BuildEvent event)(Code)
Signals that a build has started.
Parameters:
  event - recieved BuildEvent



configure
public void configure()(Code)
Configures this Selector. Does this work only once per Selector object.

Because some problems while configuring from Selector the configuration is done in the following order:

  1. collect the configuration data
  2. wait for the first isSelected() call
  3. set the default values
  4. set values for name pattern '*': update, cache, algorithm, comparator
  5. set values for name pattern '*.*: cache.cachefile, ...

This configuration algorithm is needed because you don't know the order of arriving config-data. E.g. if you first set the cache.cachefilename and after that the cache itself, the default value for cachefilename is used, because setting the cache implies creating a new Cache instance - with its defaults.




getAlgorithm
public Algorithm getAlgorithm()(Code)
Get the algorithm type to use. the enumerated algorithm type



getCache
public Cache getCache()(Code)
Get the cache type to use. the enumerated cache type



getClassLoader
public ClassLoader getClassLoader()(Code)
Returns and initializes the classloader for this class. the classloader



getComparator
public Comparator getComparator()(Code)
Get the comparator type to use. the enumerated comparator type



getDelayUpdate
public boolean getDelayUpdate()(Code)
Getter for the delay update true if we should delay for performance



getModified
public int getModified()(Code)
Getter for the modified count modified count



isSelected
public boolean isSelected(Resource resource)(Code)
Implementation of ResourceSelector.isSelected().
Parameters:
  resource - The resource to check whether the resource is selected
See Also:   ResourceSelector.isSelected(Resource)



isSelected
public boolean isSelected(File basedir, String filename, File file)(Code)
Implementation of BaseExtendSelector.isSelected().
Parameters:
  basedir - as described in BaseExtendSelector
Parameters:
  filename - as described in BaseExtendSelector
Parameters:
  file - as described in BaseExtendSelector as described in BaseExtendSelector



loadClass
protected Object loadClass(String classname, String msg, Class type)(Code)
Loads the specified class and initializes an object of that class. Throws a BuildException using the given message if an error occurs during loading/instantiation or if the object is not from the given type.
Parameters:
  classname - the classname
Parameters:
  msg - the message-part for the BuildException
Parameters:
  type - the type to check against a castable object



messageLogged
public void messageLogged(BuildEvent event)(Code)
Signals a message logging event.
Parameters:
  event - recieved BuildEvent



saveCache
protected void saveCache()(Code)
save the cache file



setAlgorithm
public void setAlgorithm(AlgorithmName name)(Code)
Set the algorithm type to use.
Parameters:
  name - an enumerated algorithm type.



setAlgorithmClass
public void setAlgorithmClass(String classname)(Code)
Setter for algorithmClass.
Parameters:
  classname - new value



setCache
public void setCache(CacheName name)(Code)
Set the cache type to use.
Parameters:
  name - an enumerated cache type.



setCacheClass
public void setCacheClass(String classname)(Code)
Setter for cacheClass.
Parameters:
  classname - new value



setClassLoader
public void setClassLoader(ClassLoader loader)(Code)
Set the used ClassLoader. If you invoke this selector by API (e.g. inside some testcases) the selector will use a different classloader for loading the interface implementations than the caller. Therefore you will get a ClassCastException if you get the implementations from the selector and cast them.
Parameters:
  loader - the ClassLoader to use



setComparator
public void setComparator(ComparatorName name)(Code)
Set the comparator type to use.
Parameters:
  name - an enumerated comparator type.



setComparatorClass
public void setComparatorClass(String classname)(Code)
Setter for comparatorClass.
Parameters:
  classname - new value



setDelayUpdate
public void setDelayUpdate(boolean delayUpdate)(Code)
Setter for the delay update
Parameters:
  delayUpdate - true if we should delay for performance



setModified
public void setModified(int modified)(Code)
Setter for the modified count
Parameters:
  modified - count



setParameters
public void setParameters(Parameter[] parameters)(Code)
Defined in org.apache.tools.ant.types.Parameterizable. Overwrite implementation in superclass because only special parameters are valid.
See Also:    #addParam(String,Object).
Parameters:
  parameters - the parameters to set.



setSeldirs
public void setSeldirs(boolean seldirs)(Code)
Support for seldirs attribute.
Parameters:
  seldirs - new value



setSelres
public void setSelres(boolean newValue)(Code)
Support for selres attribute.
Parameters:
  newValue - the new value



setUpdate
public void setUpdate(boolean update)(Code)
Support for update attribute.
Parameters:
  update - new value



targetFinished
public void targetFinished(BuildEvent event)(Code)
Signals that a target has finished.
Parameters:
  event - recieved BuildEvent



targetStarted
public void targetStarted(BuildEvent event)(Code)
Signals that a target is starting.
Parameters:
  event - received BuildEvent



taskFinished
public void taskFinished(BuildEvent event)(Code)
Signals that a task has finished.
Parameters:
  event - recieved BuildEvent



taskStarted
public void taskStarted(BuildEvent event)(Code)
Signals that a task is starting.
Parameters:
  event - recieved BuildEvent



toString
public String toString()(Code)
Override Object.toString(). information about this selector



tryToSetAParameter
protected void tryToSetAParameter(Object obj, String name, String value)(Code)
Try to set a value on an object using reflection. Helper method for easier access to IntrospectionHelper.setAttribute().
Parameters:
  obj - the object on which the attribute should be set
Parameters:
  name - the attributename
Parameters:
  value - the new value



useParameter
public void useParameter(Parameter parameter)(Code)
Support for nested tags. Parameter named cache, algorithm, comparator or update are mapped to the respective set-Method. Parameter which names starts with cache. or algorithm. or comparator. are tried to set on the appropriate object via its set-methods. Other parameters are invalid and an BuildException will be thrown.
Parameters:
  parameter - Key and value as parameter object



verifySettings
public void verifySettings()(Code)
Overrides BaseSelector.verifySettings().



Fields inherited from org.apache.tools.ant.types.selectors.BaseExtendSelector
protected Parameter[] parameters(Code)(Java Doc)

Methods inherited from org.apache.tools.ant.types.selectors.BaseExtendSelector
protected Parameter[] getParameters()(Code)(Java Doc)
abstract public boolean isSelected(File basedir, String filename, File file) throws BuildException(Code)(Java Doc)
public void setParameters(Parameter[] parameters)(Code)(Java Doc)

w_ww___.___j___a___v___a_2_s___._c___om_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.