org.barracudamvc.taskdefs
Class Localize

java.lang.Object
  extended byorg.apache.tools.ant.ProjectComponent
      extended byorg.apache.tools.ant.Task
          extended byorg.apache.tools.ant.taskdefs.MatchingTask
              extended byorg.enhydra.xml.xmlc.taskdef.Xmlc
                  extended byorg.barracudamvc.taskdefs.Localize
All Implemented Interfaces:
org.apache.tools.ant.types.selectors.SelectorContainer

public class Localize
extends org.enhydra.xml.xmlc.taskdef.Xmlc

Ant task to invoke the localize HTML template files. Supports all the attributes found in the Xmlc taskdef. This is a reworking of the original Localize taskdef--the taskdef reads the master templates, generates locale templates from it using straight text substitution (previously we actually compiled the master template via XMLC and then parsed the resulting DOM object, which caused all kinds of problems because of Tidy bugs/quirks). At any rate, once the templates are generated, and then we invoke XMLC on everything. There is probably room to improve the performance of this thing (I haven't done any optimization)

Author:
christian.cryder@gmail.com

Nested Class Summary
 
Nested classes inherited from class org.enhydra.xml.xmlc.taskdef.Xmlc
org.enhydra.xml.xmlc.taskdef.Xmlc.BooleanAttribute
 
Field Summary
static String[] countryCodes
           
 File masterDir
           
 File masterFile
           
protected  boolean tidy
           
 
Fields inherited from class org.enhydra.xml.xmlc.taskdef.Xmlc
classPath, cmdl, compile, destDir, forceBuild, keep, logHdr, logLevel, ML, options, packageDir, packageName, performExec, srcDir, srcDirName, srcOutDir, srcOutDirName, upToDate, verbose, xmlcArgs
 
Fields inherited from class org.apache.tools.ant.taskdefs.MatchingTask
fileset
 
Fields inherited from class org.apache.tools.ant.Task
description, location, target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
project
 
Constructor Summary
Localize()
           
 
Method Summary
protected  boolean embeddedInToken(String str, int fpos, String stoken, String etoken)
           
 void execute()
          Execute the task.
protected  boolean isQualified(String str, int fpos)
           
static void main(String[] args)
           
protected  String qualifiedStrReplace(String str, String str1, String str2)
          Replace occurrences of str1 in string str with str2, but only if the str1 is qualified (ie. not embedded in an 'id=""' or 'class=""' attribute)
 void setMasterlocaledir(String masterDir)
          Set the Master Locale Directory by accesssing the build.xml file
 void setMasterlocalefile(String masterFile)
          Set the Master Locale File Name by accessing the build.xml file
 void setTidy(org.enhydra.xml.xmlc.taskdef.Xmlc.BooleanAttribute itidy)
          Run tidy on the localized templates
protected  String strReplace(String str, String str1, String str2)
          Replace occurrences of str1 in string str with str2
 
Methods inherited from class org.enhydra.xml.xmlc.taskdef.Xmlc
createArg, setArgs, setClasspath, setCompile, setDestdir, setForce, setKeep, setMarkup, setOptions, setPackagedir, setPackagename, setPerformexec, setSourceout, setSrcdir, setVerbose
 
Methods inherited from class org.apache.tools.ant.taskdefs.MatchingTask
add, addAnd, addContains, addContainsRegexp, addCustom, addDate, addDepend, addDepth, addDifferent, addFilename, addMajority, addModified, addNone, addNot, addOr, addPresent, addSelector, addSize, addType, appendSelector, createExclude, createExcludesFile, createInclude, createIncludesFile, createPatternSet, getDirectoryScanner, getImplicitFileSet, getSelectors, hasSelectors, selectorCount, selectorElements, setCaseSensitive, setDefaultexcludes, setExcludes, setExcludesfile, setFollowSymlinks, setIncludes, setIncludesfile, setProject, XsetIgnore, XsetItems
 
Methods inherited from class org.apache.tools.ant.Task
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, reconfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tidy

protected boolean tidy

masterFile

public File masterFile

masterDir

public File masterDir

countryCodes

public static final String[] countryCodes
Constructor Detail

Localize

public Localize()
Method Detail

setTidy

public void setTidy(org.enhydra.xml.xmlc.taskdef.Xmlc.BooleanAttribute itidy)
Run tidy on the localized templates

Parameters:
itidy - Set "true" for tidy

setMasterlocaledir

public void setMasterlocaledir(String masterDir)
Set the Master Locale Directory by accesssing the build.xml file

Parameters:
masterDir - the location of the Master Localization File

setMasterlocalefile

public void setMasterlocalefile(String masterFile)
Set the Master Locale File Name by accessing the build.xml file

Parameters:
masterFile - the given name of the Master Localization File

execute

public void execute()
             throws org.apache.tools.ant.BuildException
Execute the task. The basic flow here is: invoke xmlc to generate template classes, invoke the java compiler to compile those classes, then use those compiled DOM structures to create localized versions of the XML templates. Finally, reinvoke xmlc and javac to recompile the newly created localized templates.

Throws:
org.apache.tools.ant.BuildException

qualifiedStrReplace

protected String qualifiedStrReplace(String str,
                                     String str1,
                                     String str2)
Replace occurrences of str1 in string str with str2, but only if the str1 is qualified (ie. not embedded in an 'id=""' or 'class=""' attribute)


strReplace

protected String strReplace(String str,
                            String str1,
                            String str2)
Replace occurrences of str1 in string str with str2


isQualified

protected boolean isQualified(String str,
                              int fpos)

embeddedInToken

protected boolean embeddedInToken(String str,
                                  int fpos,
                                  String stoken,
                                  String etoken)

main

public static void main(String[] args)


Copyright © 2004 BarracudaMVC.org All Rights Reserved.