[use case] Format Java

Description

The Format Java use case illustrates the txt task in a set2set usage : formatting java source code to unify spaces / tabs.

Sample

ant file - build.xml

<project name="usages" xmlns:bj="antlib:org.bidji.taskdefs">
  <target name="format-java">
    <bj:txtt todir="." overwrite="true" preservepath="true">
      <fileset dir=".">
        <include name="**/*.java"/>
      </fileset>
      <template><![CDATA[[#foreach line in txt?api.lines()]
[#-- or preserve_white_spaces to remove tabs --]
${line?api.preserve_tabs_and_white_spaces()}
[/#foreach]
]]>			
      </template>
    </bj:txtt>
  </target>
</project>

input file - MyFile.java

public class MyFile {

    private String str1; // 4 spaces
	private String str2; // 1 tab    
}

ouput file - MyFile.java

public class MyFile {

	private String str1; // 1 tab
	private String str2; // 1 tab    
}