com.samskivert.jdbc.depot.tools
Class GenRecordTask

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by com.samskivert.jdbc.depot.tools.GenRecordTask
All Implemented Interfaces:
Cloneable

public class GenRecordTask
extends org.apache.tools.ant.Task

An ant task that updates the column constants for a persistent record.


Field Summary
protected  ClassLoader _cloader
          Used to do our own classpath business.
protected  ArrayList<org.apache.tools.ant.types.FileSet> _filesets
          A list of filesets that contain tile images.
protected  Class<?> _prclass
          PersistentRecord resolved with the proper classloader so that we can compare it to loaded derived classes.
protected  org.apache.velocity.app.VelocityEngine _velocity
          Used to generate source files from templates.
protected static String COL_TMPL
          Specifies the path to the column code template.
protected static String FIELDS_END
           
protected static String FIELDS_START
           
protected static String KEY_TMPL
          Specifies the path to the key code template.
protected static String MARKER
           
protected static String METHODS_END
           
protected static String METHODS_START
           
protected static Pattern NAME_PATTERN
          A regular expression for matching the class or interface declaration.
protected static String NAME_TMPL
          Specifies the path to the name code template.
protected static Pattern PACKAGE_PATTERN
          A regular expression for matching the package declaration.
 
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
GenRecordTask()
           
 
Method Summary
 void addFileset(org.apache.tools.ant.types.FileSet set)
          Adds a nested fileset element which enumerates record source files.
protected  boolean check(File source, String mname, int mline, String fname, int fline)
          Helper function for sanity checking marker existence.
 void execute()
           
protected  String get(String[] lines, int index)
          Safely gets the indexth line, returning the empty string if we exceed the length of the array.
protected static boolean hasAnnotation(Field field, Class<?> annotation)
           
protected  boolean isPersistentField(Field field)
          Returns true if the supplied field is part of a persistent record (is a public, non-static, non-transient field).
protected  String mergeTemplate(String tmpl, org.apache.velocity.VelocityContext ctx)
          Helper function for generating our boilerplate code.
protected  void processRecord(File source)
          Processes a distributed object source file.
protected  void processRecord(File source, Class<?> rclass)
          Processes a resolved persistent record class instance.
protected static String readClassName(File source)
          Reads in the supplied source file and locates the package and class or interface name and returns a fully qualified class name.
 void setClasspathref(org.apache.tools.ant.types.Reference pathref)
          Configures that classpath that we'll use to load record classes.
protected  void writeln(BufferedWriter bout, String line)
          Helper function for writing a string and a newline to a writer.
 
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, 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, toString, wait, wait, wait
 

Field Detail

_filesets

protected ArrayList<org.apache.tools.ant.types.FileSet> _filesets
A list of filesets that contain tile images.


_cloader

protected ClassLoader _cloader
Used to do our own classpath business.


_velocity

protected org.apache.velocity.app.VelocityEngine _velocity
Used to generate source files from templates.


_prclass

protected Class<?> _prclass
PersistentRecord resolved with the proper classloader so that we can compare it to loaded derived classes.


NAME_TMPL

protected static final String NAME_TMPL
Specifies the path to the name code template.

See Also:
Constant Field Values

COL_TMPL

protected static final String COL_TMPL
Specifies the path to the column code template.

See Also:
Constant Field Values

KEY_TMPL

protected static final String KEY_TMPL
Specifies the path to the key code template.

See Also:
Constant Field Values

MARKER

protected static final String MARKER
See Also:
Constant Field Values

FIELDS_START

protected static final String FIELDS_START
See Also:
Constant Field Values

FIELDS_END

protected static final String FIELDS_END
See Also:
Constant Field Values

METHODS_START

protected static final String METHODS_START
See Also:
Constant Field Values

METHODS_END

protected static final String METHODS_END
See Also:
Constant Field Values

PACKAGE_PATTERN

protected static final Pattern PACKAGE_PATTERN
A regular expression for matching the package declaration.


NAME_PATTERN

protected static final Pattern NAME_PATTERN
A regular expression for matching the class or interface declaration.

Constructor Detail

GenRecordTask

public GenRecordTask()
Method Detail

addFileset

public void addFileset(org.apache.tools.ant.types.FileSet set)
Adds a nested fileset element which enumerates record source files.


setClasspathref

public void setClasspathref(org.apache.tools.ant.types.Reference pathref)
Configures that classpath that we'll use to load record classes.


execute

public void execute()
             throws org.apache.tools.ant.BuildException
Overrides:
execute in class org.apache.tools.ant.Task
Throws:
org.apache.tools.ant.BuildException

processRecord

protected void processRecord(File source)
Processes a distributed object source file.


processRecord

protected void processRecord(File source,
                             Class<?> rclass)
Processes a resolved persistent record class instance.


isPersistentField

protected boolean isPersistentField(Field field)
Returns true if the supplied field is part of a persistent record (is a public, non-static, non-transient field).


get

protected String get(String[] lines,
                     int index)
Safely gets the indexth line, returning the empty string if we exceed the length of the array.


check

protected boolean check(File source,
                        String mname,
                        int mline,
                        String fname,
                        int fline)
Helper function for sanity checking marker existence.


writeln

protected void writeln(BufferedWriter bout,
                       String line)
                throws IOException
Helper function for writing a string and a newline to a writer.

Throws:
IOException

mergeTemplate

protected String mergeTemplate(String tmpl,
                               org.apache.velocity.VelocityContext ctx)
Helper function for generating our boilerplate code.


hasAnnotation

protected static boolean hasAnnotation(Field field,
                                       Class<?> annotation)

readClassName

protected static String readClassName(File source)
                               throws IOException
Reads in the supplied source file and locates the package and class or interface name and returns a fully qualified class name.

Throws:
IOException


Copyright © 2000-2008 Michael Bayne. All Rights Reserved.