Package org.fontysvenlo.codestripper

Package Codestripper

See:
          Description

Class Summary
CodeStripper CodeStripper acts as a filter and removes code between start and end tag.
Parents Creates File with directory parents for a file
 

Package org.fontysvenlo.codestripper Description

Package Codestripper

The package codestripper provides one ant task, codestripper. The initial purpose of codestripper is to remove code (solutions) form exam questions, such that tried and tested solutions code could be stripped and used as initial code for exam questions.
As CodeStripper extends the ant MatchingTask, it supports includes and excludes with filename patterns such as "**/*.java" and the like.
The codestripper supports a number of properties to define start and end tags, whether to remove the lines or replaces them with empty lines and to replace start an end tags with in code replacements, mainly to keep the compiler happy with the remaining code.
Properties:
propertyDescriptiondefault value
deletelinesdeletes lines if set. Otherwise replaces original lines with newline-characters in output file. false
dirinput directory"."
todiroutput dir."out"
starttag start stripping token.^\\s∗//Start Solution
endtagend stripping token.^\\s∗//End Solution.
dryRundryRun to test to test ant task.false
replaceTagThis allows means to replace the start and end lines with some other text, typically with //TODO for start and return 0; for end.
Any leading white space (indentation) is preserved.
::replacewith::
A typical usage example:
The ant task:
        <target name="strip">
                <codestripper todir="../examproject" 
                        dir="src" 
                        deletelines="true"
                        includes="**/*.java" 
                        excludes="**/Parents.java"
                        />
        </target>
The tags in the code (using the defaults) could look like this (the strikethrough is not in the code or in the result, but rather shows what code would be removed):

    private File makeOutputFile(String arg) {
        //Start Solution::replacewith:://TODO
File f = new File(arg); String parent = f.getParent(); System.out.println(f.getName()); String fullOutPath = "out/" + arg; if (parent != null) { System.out.println(parent); File outDir = new File("out/" + parent); outDir.mkdirs(); } File result = new File(fullOutPath); return result;
//End Solution::replacewith::return null; }
Authors: Pieter van den Hombergh, Ferd van Odenhoven