JeeWiz Home  
The Model-Driven System Builder

JeeWiz Architect's Guide
 
Contents  >   8.  Templates and Velocity Features
 


8.11 Helper Methods

The methods listed here are available via the base class of all meta-classes. This means they can all be used from any meta-model Java method, or from Velocity ($object.helperMethod()), whether in a template or pattern.

For helper methods that are of the 'getX()' format, you can access the value for

  • the current model object by '${x}'. This format works from Ant too.
  • another model object by '${mo.x}'. This format doesn't work from Ant, because Ant conventions treat the '.' as part of the name.
For other helper methods, the Velocity syntax requires that you access the method via an object, even if it is a static method. If you need to access a static method and don't want to think about which object to use to access it, the simplest approach is to use 'this' as the object name, e.g. '$this.helperMethod()'. Again, because of the way Ant treats '.', these methods are not available from Ant.

You can add to the helper methods listed here by creating a class called 'ExtraHelperMethods', e.g.
package uk.co.nte.jw.engine;

import java.util.*;
import java.io.*;

public class ExtraHelperMethods
{
	// add your own methods here
}
If you add this class to the classpath of JeeWiz in front of the jeewiz-engine.jar (for example, see the 'user.classpath' property in bin/jwrun.xml), the additional methods will be available. They must be public, and use parameters that are accessible via Velocity - in particular, 'char' parameters are not accessible via Velocity.

 8.11.1  addErrorMessage
 8.11.2  addPatternErrorMessage
 8.11.3  addPatternRootElement
 8.11.4  addSourcePattern
 8.11.5  addTemplateErrorMessage
 8.11.6  addText
 8.11.7  addURIByPrefix
 8.11.8  addUniqueCSStrings
 8.11.9  appendToUniqueCSString
 8.11.10  arrayListToCsv
 8.11.11  buildCSString
 8.11.12  callPattern( String patternFileName )
 8.11.13  callPattern( String patternFileName, Object patternRootObject )
 8.11.14  capitalise
 8.11.15  capitalize
 8.11.16  checkXsdDate
 8.11.17  checkXsdDateTime
 8.11.18  checkXsdTime
 8.11.19  compareStringNumbers
 8.11.20  containsKey
 8.11.21  createChild
 8.11.22  createModelObject
 8.11.23  createRootModelObject
 8.11.24  csvToArrayList( String csv )
 8.11.25  csvToArrayList( String csv, String separator, String delimiter )
 8.11.26  decapitalize
 8.11.27  doingLogsForLevel
 8.11.28  dumpObject( Object objectToDump )
 8.11.29  dumpObject( Object objectToDump, String initialIndent, String indentIncrement )
 8.11.30  dumpStringWithControlChars
 8.11.31  exciseString
 8.11.32  exit( String errorMessage )
 8.11.33  exit( int exitStatus )
 8.11.34  exit( long exitStatus )
 8.11.35  exit()
 8.11.36  extraInitialiseComponent
 8.11.37  fatal
 8.11.38  fatalErrorMessage
 8.11.39  fatalPatternErrorMessage
 8.11.40  fatalTemplateErrorMessage
 8.11.41  fileIsAbsolute
 8.11.42  firstIndexOf
 8.11.43  firstLetterCaps
 8.11.44  firstValue( String s1, String s2 )
 8.11.45  firstValue( String s1, String s2, String s3 )
 8.11.46  formatNumericString( String str )
 8.11.47  formatNumericString( String str, Locale locale )
 8.11.48  formatXML( String inputString )
 8.11.49  formatXML( String inputString, int initialIndent , int attributeTabPosition)
 8.11.50  get
 8.11.51  getAbsolutePath( File f )
 8.11.52  getAbsolutePath( String s )
 8.11.53  getAllAntProperties
 8.11.54  getAllPrefixToURIMappings
 8.11.55  getAllProperties
 8.11.56  getAttributeOrProperty
 8.11.57  getAvailableMethods()
 8.11.58  getAvailableMethods( Object o )
 8.11.59  getBasename
 8.11.60  getBooleanFalse
 8.11.61  getBooleanTrue
 8.11.62  getCanonicalPath( File f )
 8.11.63  getCanonicalPath( String fileName )
 8.11.64  getCapsAndSeparatorName
 8.11.65  getCapsAndSpacesName
 8.11.66  getCapsAndUnderscoreName
 8.11.67  getCharacterCount
 8.11.68  getChildren
 8.11.69  getClassInstance(ArrayList typeNames, String fullyQualifiedClassName, Object p1 )
 8.11.70  getClassInstance(String fullyQualifiedClassName)
 8.11.71  getClassInstance(String fullyQualifiedClassName, Object p1 )
 8.11.72  getClassInstance(String fullyQualifiedClassName, Object p1, Object p2 )
 8.11.73  getClassInstance(String fullyQualifiedClassName, Object p1, Object p2, Object p3 )
 8.11.74  getClassObject
 8.11.75  getContainingBCByType
 8.11.76  getCurrentAntProject
 8.11.77  getCurrentAntProperties
 8.11.78  getCurrentScript
 8.11.79  getCurrentTimeMillis
 8.11.80  getDelegatedProperty
 8.11.81  getDelegatedPropertyFromAbove
 8.11.82  getDirname
 8.11.83  getEOLString
 8.11.84  getFile( File dir, String fileName )
 8.11.85  getFile( String path )
 8.11.86  getFileSeparator
 8.11.87  getFinalElementTag
 8.11.88  getFirstPieceOf
 8.11.89  getIdentifyingString
 8.11.90  getIsDOS
 8.11.91  getIsUNIX
 8.11.92  getIsWindows
 8.11.93  getJWControlManager
 8.11.94  getJavaClassComponentType
 8.11.95  getJavaClassName()
 8.11.96  getJavaClassName( String inputName )
 8.11.97  getJavaName
 8.11.98  getJavaVarComponentType
 8.11.99  getJavaVarName()
 8.11.100  getJavaVarName( String inputName )
 8.11.101  getJaxbAttributeName
 8.11.102  getLastPieceOf
 8.11.103  getLineSeparator
 8.11.104  getLocalName
 8.11.105  getLocalPrefixToURIMappings
 8.11.106  getMyXmlURI
 8.11.107  getName
 8.11.108  getNameCapitalised
 8.11.109  getNameCapitalized
 8.11.110  getNewArrayList( Collection c )
 8.11.111  getNewArrayList( int n )
 8.11.112  getNewArrayList()
 8.11.113  getNewControl( String templateName )
 8.11.114  getNewControl( String xmlTemplateName, Map map )
 8.11.115  getNewControl( String xmlTemplateName, String propertiesString )
 8.11.116  getNewControl()
 8.11.117  getNewHashMap( Map m )
 8.11.118  getNewHashMap()
 8.11.119  getNewListMap
 8.11.120  getNewTreeMap( Map m )
 8.11.121  getNewTreeMap()
 8.11.122  getNull
 8.11.123  getOriginalElementTag
 8.11.124  getParentBC
 8.11.125  getPathSeparator
 8.11.126  getPatternXmlDeclaration
 8.11.127  getPieceOf( String inputString, String leftSeparator, String rightSeparator )
 8.11.128  getPieceOf( String inputString, String separator, int pieceNumber )
 8.11.129  getPieces( String inputString, String separator )
 8.11.130  getPieces( String inputString, String separator, boolean removeEmptyPieces )
 8.11.131  getPlatformPath( File f )
 8.11.132  getPlatformPath( String fileName )
 8.11.133  getPreLastPieceOf
 8.11.134  getPrefix
 8.11.135  getProperties
 8.11.136  getRelativePath( String path, String baseDirectory )
 8.11.137  getRelativePath( String path, String baseDirectory, int nLevels )
 8.11.138  getRelativePathBS( String path, String baseDirectory )
 8.11.139  getRelativePathBS( String path, String baseDirectory, int nLevels )
 8.11.140  getRenderedText
 8.11.141  getResolvedPathFrom
 8.11.142  getSetAttributes
 8.11.143  getShortID
 8.11.144  getSingleLineDescription
 8.11.145  getSingleLineText
 8.11.146  getSuperclasses
 8.11.147  getSystemProperties
 8.11.148  getTemplate
 8.11.149  getTemplateStack
 8.11.150  getText
 8.11.151  getTopComponent
 8.11.152  getURIByPrefix
 8.11.153  getURIByQName
 8.11.154  getUUID( String hostName )
 8.11.155  getUUID()
 8.11.156  getUniqueKey( String baseKey, Map map )
 8.11.157  getUniqueKey( String baseKey, Map map, Object entryValue )
 8.11.158  getUnixPath( File f )
 8.11.159  getUnixPath( String fileName )
 8.11.160  getVersionNumber
 8.11.161  getWindowsPath( File f )
 8.11.162  getWindowsPath( String fileName )
 8.11.163  getXMLComponentType
 8.11.164  getXMLName
 8.11.165  getXmlDump( String indent )
 8.11.166  getXmlDump()
 8.11.167  getXmlLocalPart
 8.11.168  getXmlName()
 8.11.169  getXmlName( String inputName )
 8.11.170  getXmlPrefix( String s )
 8.11.171  getXmlPrefix()
 8.11.172  getXmlns
 8.11.173  getXsdDateAsCalendar
 8.11.174  getXsdDateTimeAsCalendar
 8.11.175  getXsdTimeAsCalendar
 8.11.176  initialiseComponent
 8.11.177  isDirectory
 8.11.178  isFile
 8.11.179  isInstanceOf
 8.11.180  leftJustify
 8.11.181  list
 8.11.182  log( String indentation, String stringToLog )
 8.11.183  log( String indentation, String stringToLog, int logLevel )
 8.11.184  log( String s )
 8.11.185  log( String s, boolean messageOnlyFlag )
 8.11.186  log( String s, int logLevel )
 8.11.187  logError( String indentation, String s )
 8.11.188  logError( String s )
 8.11.189  logObject( Object objectToDump )
 8.11.190  logObject( String label, Object objectToDump )
 8.11.191  logObject( Object objectToDump, String initialIndent, String indentIncrement )
 8.11.192  lowerCaseOnSecond
 8.11.193  multiplyString
 8.11.194  onInstantiation
 8.11.195  parseFormat
 8.11.196  preInitialiseComponent
 8.11.197  processSpecialCharacters
 8.11.198  put
 8.11.199  readFileAsLines( File file )
 8.11.200  readFileAsLines( String fileName )
 8.11.201  readFileAsString( File file )
 8.11.202  readFileAsString( String fileName )
 8.11.203  readFileAsXml( File file, String propertyName )
 8.11.204  readFileAsXml( String fileName, String propertyName )
 8.11.205  readPropertiesFile( File file )
 8.11.206  readPropertiesFile( String fileName )
 8.11.207  removeCSListDuplicates
 8.11.208  removeChars
 8.11.209  removePunctuationAndCapitalise
 8.11.210  removeSpaces
 8.11.211  removeSpacesCapitalise
 8.11.212  removeSpacesProperCase
 8.11.213  removeString
 8.11.214  removeStringNoCapital
 8.11.215  renderString
 8.11.216  reportAllPrefixToURIMappings
 8.11.217  resetPatternErrorMessages
 8.11.218  rightJustify
 8.11.219  separateByCapitals
 8.11.220  setCurrentScript
 8.11.221  setNextPattern
 8.11.222  setPatternRootObject
 8.11.223  setPatternXmlDeclaration
 8.11.224  setSourcePattern
 8.11.225  setText
 8.11.226  setX( String key, String value )
 8.11.227  setX( String key, boolean value )
 8.11.228  sleep
 8.11.229  spaces( String s )
 8.11.230  spaces( int n )
 8.11.231  spaces1
 8.11.232  splitCSString
 8.11.233  splitCSStringWithoutDuplicates
 8.11.234  splitSeparatorString( String stringToSplit, String delimiters )
 8.11.235  splitSeparatorString( String stringToSplit, String delimiters, boolean returnDelims )
 8.11.236  splitStringIntoTwo
 8.11.237  stopBuild
 8.11.238  stringNumberEqual
 8.11.239  stringNumberGreater
 8.11.240  stringNumberGreaterOrEqual
 8.11.241  stringNumberLess
 8.11.242  stringNumberLessOrEqual
 8.11.243  stringToCDATAsection
 8.11.244  stringToXMLAttr
 8.11.245  stringToXMLAttrWithoutQuotes
 8.11.246  stringToXMLCharacterData
 8.11.247  stringWithinCData
 8.11.248  toHTML
 8.11.249  uncapitalise
 8.11.250  uncapitaliseInitialGroup
 8.11.251  uncapitaliseSecond
 8.11.252  uncapitalize
 8.11.253  writeStringToFile( File file, String stringToWrite )
 8.11.254  writeStringToFile( File file, String stringToWrite, String encoding )
 8.11.255  writeStringToFile( String fileName, String stringToWrite )
 8.11.256  writeStringToFile( String fileName, String stringToWrite, String encoding )

8.11.1  addErrorMessage
Signaturestatic void addErrorMessage( String errmsg )
DescriptionError messages can be added via this method during method processing - which may be invoked during pattern or template processing. This is a synonym for addTemplateErrorMessage or addPatternErrorMessage as appropriate.

8.11.2  addPatternErrorMessage
Signaturestatic void addPatternErrorMessage( String errmsg )
DescriptionExtra error messages can be added via this method during pattern firing. They must be added via a meta-class object - such as $this, although any meta-class object will do. So, in patterns, you must say $this.addPatternErrorMessage( "pattern error..." )

They are recognised by the engine after each pattern firing sequence.

They are treated as fatal.

'addTemplateErrorMessage()' does the same sort of thing for templates.

See also fatalPatternErrorMessage which additionally stops the build immediately.

8.11.3  addPatternRootElement
Signature void addPatternRootElement( String newRootElementTag )
DescriptionCauses a root element to be added to the current pattern and sets the XML element tag for the new root.

The newRootElementTag is the XML tag of the added root element. It can be 'this' or 'parent'.

The newRootElementTag is used at the end of each pattern and then reset.

This method can be called twice, but subsequent calls must pass the same value as the first call.

8.11.4  addSourcePattern
Signature String addSourcePattern()
Description'addSourcePattern()' is a convenience method, equivalent to

    $this.setSourcePattern( $currentScript )

from Velocity.

It is typically used via '$this.addSourcePattern()' in a preIncludeSpec or extraIncludeSpec to log the source pattern in the xmlDump.

See setSourcePattern for an overview of the 'sourcePattern' property.

8.11.5  addTemplateErrorMessage
Signaturestatic void addTemplateErrorMessage( String errmsg )
DescriptionError messages can be added via this method during template processing. They must be added via a meta-class object - such as $this, although any meta-class object will do. So, in templates, you normally say $this.addPatternErrorMessage( "template error..." )

They are recognised by the engine after each template has been processed.

They are treated as fatal.

'addPatternErrorMessage()' does the same sort of thing for patterns.

See also fatalTemplateErrorMessage which additionally stops the build immediately.

8.11.6  addText
Signature void addText(String text)
DescriptionaddText adds more text to the 'text' attribute. For a model object, this is normally called when a SAX 'characters' event occurs.

8.11.7  addURIByPrefix
Signature void addURIByPrefix( String prefix, String URI )
DescriptionPuts a prefix->URI entry into this element's mapping (as returned by getLocalPrefixToURIMappings() ).

8.11.8  addUniqueCSStrings
Signaturestatic String addUniqueCSStrings( String string1, String string2 )
DescriptionAdd two unique comma-separated strings, and ensures that the result has unique entries - i.e. has no duplicate values.

This method is optimised assuming that the two input strings are already unique. In other words, if one or the other has no value, the other string is returned.

8.11.9  appendToUniqueCSString
Signaturestatic String appendToUniqueCSString( List uniqueList, String extraCSItems )
DescriptionAppend a comma-separated string to a List of Unique strings, and ensures that the result has unique entries - i.e. has no duplicate values.

This method assumes that the uniqueList is already unique, but the extraCSItems may duplicate values either within itself or with the entries in uniqueList In other words, if one or the other has no value, the other string is returned.

8.11.10  arrayListToCsv
Signaturestatic String arrayListToCsv( ArrayList alIn, String separator, String delimiter )
DescriptionarrayListToCsv produces a single string in CSV format from some fields, represented as an ArrayList of Strings.

The format of the CSV string will be individual strings, separated by a separator and optionally delimited.

If a field contains a separator or leading/trailing blank spaces, or if it starts with a delimiter, it will be delimited in the output string.

If a delimited field contains the delimiter as part of the data, that delimiter will be represented by two adjacent delimiters.

A null entry in the ArrayList is converted into an empty value; it is therefore equivalent to "".

8.11.11  buildCSString
Signaturestatic String buildCSString( List stringList )
DescriptionBuilds a comma separated string from a List containing either Strings or CDataAttribute objects (one CDataAttribute object is created by JeeWiz to read each <description> element.

The comma-separated list does not have unique entries (i.e. duplicates are not removed).

Leading and trailing spaces are significant in the items in 'stringList'; they are not trimmed.

8.11.12  callPattern( String patternFileName )
Signature void callPattern( String patternFileName )
DescriptionCall a pattern, using 'this' as the context for evaluation. See the two-parameter version of this call for details

8.11.13  callPattern( String patternFileName, Object patternRootObject )
Signature void callPattern( String patternFileName, Object patternRootObject )
DescriptionCall a pattern, using 'this' as the context for evaluation.
parameterspatternFileNamethe name of the file containing the pattern to fire. This is looked up in the usual way.
patternRootObjectthe root object for the output of this pattern. i.e. if the pattern has as its root element, then the pattern creates objects underneath the pattern root object. if the pattern has , then the pattern creates peers of the pattern root object. If this is null, the build component that this method is called on is used as the pattern root object. Note that this parameter is given as an 'Object' rather than as a BuildComponent so that, if the programmer calls this method on the wrong type of object, Velocity will still call it and the programmer will get an error message. (If this parameter were a BaseBuildComponent, then Velocity would give an unresolved error; an error message will be easier to diagnose.)


8.11.14  capitalise
Signaturestatic String capitalise( String inputString )
DescriptionReturns the input string as is, except that if the first letter is lower-case, it is converted to upper case.

8.11.15  capitalize
Signaturestatic String capitalize( String inputString )
DescriptionSynonym for capitalise.

8.11.16  checkXsdDate
Signature static String checkXsdDate( String s )
DescriptionChecks that a string, supposedly a valid XML Date, can be converted into a Calendar object.
parameterssThe date string to be validated.
returnsThe exception's error message on failure, otherwise null


8.11.17  checkXsdDateTime
Signature static String checkXsdDateTime( String s )
DescriptionChecks that a string, supposedly a valid XML DateTime, can be converted into a Calendar object.
parameterssThe dateTime string to be validated.
returnsThe exception's error message on failure, otherwise null


8.11.18  checkXsdTime
Signature static String checkXsdTime( String s )
DescriptionChecks that a string, supposedly a valid XML Time, can be converted into a Calendar object.
parameterssThe time string to be validated.
returnsThe exception's error message on failure, otherwise null


8.11.19  compareStringNumbers
Signaturestatic int compareStringNumbers( String s1, String s2 )
DescriptionCalls BigInteger.compareTo for BigIntegers constructed from s1 and s2

8.11.20  containsKey
Signature boolean containsKey( Object key )
Descriptionreturns true if the local properties contains the key

8.11.21  createChild
Signature BaseBuildComponent createChild( String className, String elementTag )
DescriptioncreateChild is a way to create child components for meta-model objects specifying the class to be used. This does not implement all the features of createModelObject(), but does allow specific classes to be defined. (createModelObject() picks up the class for the new object automatically, in the same way as XML spec read-in and patterns do.)

It makes the current object the parent of the new child and sets various other pointers correctly so that tracing works.

'className' must be the fully-qualified className (as for Class.getNewInstance). This can be left null or empty ("") to get the ExtraBuildComponent - the default. 'elementTag' is the XML element tag.

If the specified className doesn't exist, a null value is returned (rather than an excepction being thrown).

If an instance is created, it is present as a child of the creating class, but it is on no other lists.

8.11.22  createModelObject
Signature BaseBuildComponent createModelObject( String elementTag )
DescriptionCreate a model object using the 'element tag' like we do from a pattern.

In other words, this does all the management and linkages that are done when reading the object from a file.

This differs from 'createChild()' in that the class of the object to be created is not specified explicitly. Instead, it is derived from the tag name: if this matches the name of a list for this meta-class, then an instance of the meta-class for objects in the list is created; if not, an ExtraBuildComponent instance is created.

This method supports renaming via a system.properties 'convert(...)', but not deletion of nodes (convert...=- or *)

8.11.23  createRootModelObject
Signature BaseBuildComponent createRootModelObject( String className, String elementTag )
DescriptioncreateRootModelObject is the recommended way to create a top-level model object (unattached to a parent). The parameters are the same as for createChild().

8.11.24  csvToArrayList( String csv )
Signaturestatic ArrayList csvToArrayList( String csv )
DescriptionTakes a CSV string, with ',' as the separator and " as the string delimiter and converts it into an ArrayList

8.11.25  csvToArrayList( String csv, String separator, String delimiter )
Signaturestatic ArrayList csvToArrayList( String csv, String separator, String delimiter )
DescriptionThis takes as input a string in CSV (Comma-Separated Value) format and turns it an ArrayList of the Strings it contains.

The format of the CSV string must be individual strings separated by a separator and optionally delimited by a delimiter. In this form of the method, the separator and delimiter are explicitly specified.

The separator separates the values, and is usually ",".

The delimiter delimits valid values (i.e. so they can contain the separator), and is usually the " character.

If a field contains a separator or leading/trailing blank spaces, it will must be delimited.

If a delimited field contains the delimiter as part of the data, it must be represented by two adjacent delimiters. Any field whose first non-blank character is a delimiter is deemed to be delimited (so two adjacent delimiters as the first non-blank characters are treated as an empty string, not as a string containing a single delimiter).

8.11.26  decapitalize
Signaturestatic String decapitalize( String inputString )
DescriptionThis method implements the JavaBeans 'decapitalize' method, which is
  • if the first two letters of a variable name are upper case, leave them unchanged (e.g. URL remains as URL)
  • otherwise ensure the first character becomes lower-case.

8.11.27  doingLogsForLevel
Signature static boolean doingLogsForLevel( int logLevel )
DescriptiondoingLogsForLevel returns true if the specified logLevel is being output by Ant.

The underlying value is pulled from the special JeeWiz launcher for Ant. If this is not used, "INFO" level logging is assumed (because there is no way, with standard Ant, to get the actual logging level used).

Ant filters out logs depending on their priority. The priority is defined in Ant and, in decreasing priority order, is: Project.MSG_ERR = 0; Project.MSG_WARN = 1; Project.MSG_INFO = 2; Project.MSG_VERBOSE = 3; Project.MSG_DEBUG = 4;

The reason for exposing this level is that standard log's in JeeWiz are done at WARN level, so a meta-model implementation class needs to get some log at VERBOSE level for instance (and only at that level), it should check this level first.

(There is a slight deficiency here: if the level is artificially set at e.g. "WARN", then it is possible to check that logging is available ... but then the Ant filtering will remove the logs. The deficiency is slight because the higher levels of filtering (i.e. removing info and higher priority) is not available via the command line. )

Meta-model class implementations should use e.g. the following sequence for verbose logs: if( doingLogsForLevel( Project.MSG_VERBOSE ) log( s );

See also the log, method.

8.11.28  dumpObject( Object objectToDump )
Signaturestatic String dumpObject( Object objectToDump )
DescriptionThis is a variant of the 'dumpObject' method, which has no initial indentation and three spaces for each nested level of objects.

8.11.29  dumpObject( Object objectToDump, String initialIndent, String indentIncrement )
Signaturestatic String dumpObject( Object objectToDump, String initialIndent, String indentIncrement )
DescriptionThis method dumps the object in a "nice format" - that takes account of the Java Collections Framework, particularly objects that implement Map and List - adding newLines and key/value separation, to aid readability.

The initialIndent parameter should be the number of spaces to indent the first list of sub-objects. The indentIncrement parameter should be the number of spaces to additionaly indent further lists of sub-objects. (Note that the very first line is not indented at all).

There is an anti-recursion stopper at a depth of 20 nested objects.

8.11.30  dumpStringWithControlChars
Signature static String dumpStringWithControlChars( String s )
DescriptionDumps a string with JeeWiz-specific control character names. The special characters are: CR - carriage return LF - line feed TAB - tab ADS - JeeWiz start of additional indent text ( == [0001] ) END - JeeWiz end of additional indent text, and start of text to be indented by that amount ( == [0002] ) UNI - JeeWiz end of additional indent sequence ( == [0003] ) NLD - Null line deleter ( == [0004] ) NL2 - Delete two null lines ( == [0005] ) [nnnn] - Other ISO control characters. Any other characters are printed out as themselves

8.11.31  exciseString
Signature static String exciseString( String input, String toExcise )
DescriptionRemoves all occurrences of 'toExcise' from the 'input' string. If 'toExcise' is null or the empty string, the 'input' string is returned unchanged.

The algorithm works left-to-right, so overlaps are not recognised. For example, exciseString( "ababa", "aba" ) returns "ba".

8.11.32  exit( String errorMessage )
Signaturestatic void exit( String errorMessage )
Descriptionexit( String errorMessage ) writes the errorMessage to the error log and then exits (i.e. System.exit) with a return status of 1, indicating failure.

8.11.33  exit( int exitStatus )
Signaturestatic void exit( int exitStatus )
Descriptionexit( int ) calls System.exit() with the exitStatus parameter

8.11.34  exit( long exitStatus )
Signaturestatic void exit( long exitStatus )
Descriptionexit( long ) calls System.exit() with the exitStatus parameter, throwing away any high-order bits

8.11.35  exit()
Signaturestatic void exit()
Descriptionexit() calls System.exit() with a 0 exitStatus parameter - which indicates successful execution.

8.11.36  extraInitialiseComponent
Signature boolean extraInitialiseComponent( ArrayList alErrmsgStrings )
DescriptionextraInitialiseComponent() is like initialiseComponent, except it is called at the end of the pre-phase, just before any extraIncludeSpecs patterns are run. See the 'Patterns' chapter for the exact timing of the call to this method.

Apart from timing, rest of the spec is the same as for preInitialiseComponent.

8.11.37  fatal
Signaturestatic void fatal( String errmsg )
DescriptionThis method is a synonym for fatalErrorMessage, for the lazy.

8.11.38  fatalErrorMessage
Signaturestatic void fatalErrorMessage( String errmsg )
DescriptionThis method is like addErrorMessage, but it also stops any more Velocity processing immediately. See also "fatal".

8.11.39  fatalPatternErrorMessage
Signaturestatic void fatalPatternErrorMessage( String errmsg )
DescriptionThis method is like addPatternErrorMessage, but it also stops any more Velocity processing immediately

8.11.40  fatalTemplateErrorMessage
Signaturestatic void fatalTemplateErrorMessage( String errmsg )
DescriptionThis method is like addTemplateErrorMessage, but it also stops any more Velocity processing immediately

8.11.41  fileIsAbsolute
Signaturestatic boolean fileIsAbsolute( String path )
DescriptionReturns true if the input path represents an absolute.file. This also

8.11.42  firstIndexOf
Signaturestatic int firstIndexOf( String source, String findChars )
DescriptionSearch for the first occurrence of one of the characters in findChars in source string.

If found, return the index of the earliest character. Otherwise, return -1.

For example, firstIndexOf( "The quick, brown fox", "qk" ) = 4

8.11.43  firstLetterCaps
Signaturestatic String firstLetterCaps( String inputString )
DescriptionSynonym for capitalise.

8.11.44  firstValue( String s1, String s2 )
Signaturestatic String firstValue( String s1, String s2 )
DescriptionReturns the first 'real value' of the two inputs.

In detail this means, the returned value is s1 if that is a non-empty string (i.e. length>0); otherwise it is s2. This can be used to construct a default.

8.11.45  firstValue( String s1, String s2, String s3 )
Signaturestatic String firstValue( String s1, String s2, String s3 )
DescriptionReturns the first 'real value' of the three inputs.

In detail this means, the returned value is
  • s1 if that is a non-empty string (i.e. length>0);
  • otherwise it is s2 if that is a non-empty string .
  • otherwise it is s3. This can be used to construct a default.

8.11.46  formatNumericString( String str )
Signaturestatic String formatNumericString( String str )
DescriptionformatNumericString formats a string, presumed to be integral and a valid Long number, using the current locale's standards, and in groups.

For example, in the US, formatNumericString("1234") == "1,234". In a German system, "1.234" will be returned.

If the input string cannot be converted to a long, this method throws a NumberFormatException. (If there is any valid possibility that the input string is not a number, the method should be called inside a #try() block.)

8.11.47  formatNumericString( String str, Locale locale )
Signaturestatic String formatNumericString( String str, Locale locale )
DescriptionformatNumericString formats a string, presumed to be integral and a valid Long number, using the locale parameter's standards, and in groups.

If the input string cannot be converted to a long, this method throws a NumberFormatException. (If there is any valid possibility that the input string is not a number, the method should be called inside a #try() block.)

The locale can be created via getClassInstance, e.g. #set( $locale = $this.getClassInstance( "java.util.Locale", "de" ) ) #set( $y = $this.formatNumericString( "1234", $locale ) )

The 1-, 2- and 3-parameter constructor for Locale can be used in getClassInstance.

8.11.48  formatXML( String inputString )
Signature String formatXML( String inputString )
DescriptionformatXML formats an XML string, passed in the 'inputString' parameter. The XML string can contain multiple 'top-level' elements (so the input does not need to be a valid document). However, the XML string must not contain the "<?xml...?>>" header. This is because, to support multiple top-level elements, the string is wrapped in a root element.

This is the simple version of this call, and takes the default values, which are:
    • the initial indentation is 0 (which is appropriate for dumping a complete XML document, starting with the root element)
    • the column position of attributes - which is 36 as of this writing.
In addition, if there is an exception thrown by the processing of the XML string - e.g. because it is not a valid format
    • the original inputString is returned as the value of the method
    • in verbose logging level, a log will be made of the reason for the exception, but this will not abort the build.

8.11.49  formatXML( String inputString, int initialIndent , int attributeTabPosition)
Signature String formatXML( String inputString, int initialIndent , int attributeTabPosition)
DescriptionThis version of formatXML gives more control over the simple version. Both versions take the same first parameter, the 'inputString'. This version additionally allows you to specify the
    • what the initial indent of this sequence should be. This does not affect the attributeTabPosition - attributes will output in the specified column if possible.
    • the attribute tab position (i.e. the column position on which attributes are output)

8.11.50  get
Signature Object get( Object key )
DescriptionGet a property from the metaClass's extra properties HashMap.

Direct calls to this are normally unnecessary - you can use the ${object.property} format, or $property to get a property of the current object.

This method is equivalent to 'extraProperties.get( key )' - i.e. retrieving a value from the extra properties ListMap. The implementation just delegates down to this.

This is different from the delegated searching of normal, unqualified accesses. For example, '${j2eeVersion}' in scripts in the standard J2EE build will return the value '13', but this is because it is defined in the system properties (and found using the delegated search algorithm). However, '$this.get( "j2eeVersion" )' will return null because there is no extra property sete on the current object.

See also put.

8.11.51  getAbsolutePath( File f )
Signaturestatic String getAbsolutePath( File f )
DescriptionReturns Java's File.getAbsolutePath() value for the input file. If the input file is null, this returns null.

8.11.52  getAbsolutePath( String s )
Signaturestatic String getAbsolutePath( String s )
DescriptionUses the input file name as a constructor for a file and then calls Java's File.getAbsolutePath(). If the input file name is null, this returns null.

8.11.53  getAllAntProperties
Signature static TreeMap getAllAntProperties()
DescriptionGet all the properties visible in an Ant project at this level. This is an aggregation of all the properties in all the available Ant builds, starting with the current model object's build, if there is one, then the initial Ant project(s).

If a name has been defined twice, the value from the 'lower' Ant properties is used. For example, if a property has been defined in the current model object's Ant build Project, it will take precedence over other Ant properties. This defines what properties will be visible from the current Ant build.

8.11.54  getAllPrefixToURIMappings
Signature ListMap getAllPrefixToURIMappings()
DescriptiongetAllPrefixToURIMappings() returns the map of prefix names to URI as seen by this particular element. It pulls down all the higher-level prefix->URI mappings into the aggregate for this element. This is the map that should be used in interpreting prefixes on the current element.

8.11.55  getAllProperties
Signature Map getAllProperties()
DescriptionThis returns a map that consists of the union of getSetAttributes() and getProperties().

Note that if a property is set using #set( $this.property = "value" ) and there is a public Java Method 'setProperty(value)' on the object, then this will not get reported here. (So 'getAllProperties' is not strictly true!). However, it will get all properties read in from XML or patterns, set using #set if there is no Java setter, or if the setX() method is used.

8.11.56  getAttributeOrProperty
Signature Object getAttributeOrProperty( String name )
DescriptiongetAttributeOrProperty gets the attribute (i.e. from a 'getter' method on the Java metaClass) or property (i.e. an unmodelled property set on the metaClass).

For a given name, $this.getAttributeOrProperty( $name ) is exactly equivalent to $this.$name
  • if only we could write this syntax in Velocity. For example, $this.getAttributeOrProperty( "description" ) is the same as $this.description.
Therefore, the only reason a programmer should find it necessary to call this function is when looping through all the set attributes. In this case, the attribute or property name will not be constant, so the '$this.description' syntax cannot be used.

8.11.57  getAvailableMethods()
Signature ArrayList getAvailableMethods()
DescriptionGets an ArrayList of the signatures all available methods defined for this object. The earliest items in the list reflect the class of the object itself; the latest items are from the Object class.

This is intended for diagnostics. It can be used on any class. For model object, it is best to use getAvailableMethods() in conjunction with dumpObject(), because there will be over 350 items in the list. For example, to dump the methods available from $this use

$this.dumpObject( $availableMethods )

The format is not exactly the same as the Java dump of a method signature; we change the layout slightly for ease of reading. For example, the string for this methods is

BaseBuildComponent: ArrayList getAvailableMethods()

8.11.58  getAvailableMethods( Object o )
Signature static ArrayList getAvailableMethods( Object o )
DescriptionGets an ArrayList of the signatures all available methods defined for the input parameter object. See the previous definition of getAvailableMethods() for further details.

8.11.59  getBasename
Signaturestatic String getBasename( String path )
DescriptionGet the filename part - after the last '/' or '\' - from a path string. If the path is null or doesn't contain '/' or '\', then the path is returned

8.11.60  getBooleanFalse
Signaturestatic Boolean getBooleanFalse()
Descriptionreturns a Boolean false value, which is the same as "false" in Velocity. This can be used to initialise variales in system.properties and component.properties with "booleanFalse".

8.11.61  getBooleanTrue
Signaturestatic Boolean getBooleanTrue()
Descriptionreturns a Boolean true value, which is the same as "true" in Velocity. This can be used to initialise variales in system.properties and component.properties with "booleanTrue".

8.11.62  getCanonicalPath( File f )
Signaturestatic String getCanonicalPath( File f )
DescriptionReturns Java's File.getCanonicalPath. If the input file is null or getCanonicalPath throws an exception, this returns null.

8.11.63  getCanonicalPath( String fileName )
Signaturestatic String getCanonicalPath( String fileName )
DescriptionReturns the Java File canonical path, using '/' as the path separator If the input file name is null or getCanonicalPath throws an exception, this returns null.

8.11.64  getCapsAndSeparatorName
Signature static String getCapsAndSeparatorName( String externalName, String separator )
DescriptiongetCapsAndSeparatorName converts 'externalName' to Java Class format, then adds 'separator' before each capital letter in the external name if
  • it is preceded by a lower-case or numeric letter, or
  • it is the last in the sequence of capital letters and followed by a lower-case letter.
For example,
  • getCapsAndSeparatorName( "boy-band", "_" )="Boy_Band" // JavaClass form="BoyBand"
  • getCapsAndSeparatorName( "XYZCorp", " " )="XYZ Corp" // "C" is last in sequence of capital letters
  • getCapsAndSeparatorName( "XYZ.Corp", "/" )="XYZ.Corp" // no change - last in sequence not followed by letter
Normally 'separator' is a single-character string, but it does not need to be

8.11.65  getCapsAndSpacesName
Signature static String getCapsAndSpacesName( String externalName )
DescriptiongetCapsAndSpacesName is a wrapper for getCapsAndSeparatorName, using space as the separator.

This is used to construct user-visible labels, e.g. labels on screen controls.

8.11.66  getCapsAndUnderscoreName
Signature static String getCapsAndUnderscoreName( String externalName )
DescriptiongetCapsAndUnderscoreName is a wrapper for getCapsAndSeparatorName, using underscore as the separator.

This is used, for example, to construct database table names from the entity java-style name.

8.11.67  getCharacterCount
Signaturestatic int getCharacterCount( String s, String c )
DescriptionGets the number of occurrences of the first character of 'c' in the string 's'. This allows 'c' to be a string; only the first charater is used.

If c or s is null, the returned value is 0.

8.11.68  getChildren
Signature ArrayList getChildren()
DescriptionGet the children, of whatever eventual type, of this node.

This will have MetaClasses in the list. Initially objects in this list are in the order inserted, but after patterns are fired any reordering done on the children will be reflected in this list. Therefore, if order is important, do any processing related to the order in the preIncludeSpec's.

8.11.69  getClassInstance(ArrayList typeNames, String fullyQualifiedClassName, Object p1 )
Signature static Object getClassInstance(ArrayList typeNames, String fullyQualifiedClassName, Object p1 )
DescriptionConstruct an instance of the given class name using a constructor to match the input variable. The ArrayList typeNames holds a list of string that define the signature specifies the class of the constructor parameter, rather than p1.getClass().

For example, if you want to get a StringWriter object for an OutputStreamWrite using a FileOutputStream as the constructore parameter, you would have to do say something like this.

#set( $fos = $this.getClassInstance( "java.io.FileOutputStream", "${fileName}-massaged" ) ) #set( $asl = $newArrayList ) #set( $dummy = $asl.add( "java.io.OutputStream" ) ) #set( $osw = $this.getClassInstance( $asl, "java.io.OutputStreamWriter", $fos ) )

The relevant constructor for the OutputStreamWriter takes an OutputStream rather than the OutputStreamWriter, so saying

#set( $osw = $this.getClassInstance( $asl, "java.io.OutputStreamWriter", $fos ) )

would get a NoSuchMethodException because there is no construct that takes a FileOutputStream parameter.

The fullyQualifiedClassName parameter must not be null and must correctly identify a loadable class.

See the one-parameter version of getClassInstance() for details on the class name.

8.11.70  getClassInstance(String fullyQualifiedClassName)
Signature static Object getClassInstance(String fullyQualifiedClassName)
DescriptionConstruct an instance of the given class name.

The fullyQualifiedClassName must be the fully qualified classname (e.g. "java.util.StringTokenizer").

The call '$this.getClassInstance("x.y.z")' is broadly equivalent to '$this.class.forName("x.y.z").newInstance(), except the former gives you a nicer error message if it fails.

There are fast versions of this for common new object instances, accessed by

8.11.71  getClassInstance(String fullyQualifiedClassName, Object p1 )
Signature static Object getClassInstance(String fullyQualifiedClassName, Object p1 )
DescriptionConstruct an instance of the given class name using a constructor to match the input variable. Note that this technique only supports an object for the p1 parameter - it cannot pick out different constructs based on the types of the parameter.

The fullyQualifiedClassName parameter must not be null and must correctly identify a loadable class.

See the one-parameter version of getClassInstance() for details on the class name.

8.11.72  getClassInstance(String fullyQualifiedClassName, Object p1, Object p2 )
Signature static Object getClassInstance(String fullyQualifiedClassName, Object p1, Object p2 )
DescriptionConstruct an instance of the given class name using a constructor to match the input variables. Note that this technique only supports an object for the 'p' parameters - it cannot pick out different constructs based on the types of the parameters.

The fullyQualifiedClassName parameter must not be null and must correctly identify a loadable class.

See the one-parameter version of getClassInstance() for details on the class name.

8.11.73  getClassInstance(String fullyQualifiedClassName, Object p1, Object p2, Object p3 )
Signature static Object getClassInstance(String fullyQualifiedClassName, Object p1, Object p2, Object p3 )
DescriptionConstruct an instance of the given class name using a constructor to match the input variables. Note that this technique only supports an object for the 'p' parameters - it cannot pick out different constructs based on the types of the parameters.

The fullyQualifiedClassName parameter must not be null and must correctly identify a loadable class.

See the one-parameter version of getClassInstance() for details on the class name.

8.11.74  getClassObject
Signature static Class getClassObject( String fullyQualifiedClassName )
DescriptionReturns the Java class object for the given class name.

The fullyQualifiedClassName must be the fully qualified Java class name (e.g. "java.lang.Character").

If there is a problem, this method throws a BuildException.

8.11.75  getContainingBCByType
Signature BaseBuildComponent getContainingBCByType( String classToFind )
DescriptiongetContainingBCByType looks for a containing buildcomponent object that is of the passed-in type, or inherits from it.
parametersclassToFindcan be either of:
    • the fully-qualified class name (i.e. with the package), e.g. "uk.co.nte.jw.components.businessObject.Jar"
    • the final (last '.' piece) of the class name e.g. "Jar"
The second alternative is preferred because it works correctly when additional meta-models have been defined in different packages.


8.11.76  getCurrentAntProject
Signature static Project getCurrentAntProject()
DescriptionGet the current Ant project. See class Project in Ant - org.apache.tools.ant.Project. See also getCurrentAntProperties().

8.11.77  getCurrentAntProperties
Signature static Hashtable getCurrentAntProperties()
DescriptionGet the properties from the current Ant project. This is a Hashtable.

This allows you for example to read values read as properties in Ant - e.g.

Note that this is the only way to get at Ant's properties from Velocity. As described in the 'Finding and Using Properties' chapter, a $property variable accessed in Velocity does not look at the Ant properties. So to access such a property in Ant, use

$currentAntProperties.get( "property" )

Note that for reading a properties file direct from Velocity, you can use $this.readPropertiesFile( "filePath" ) which returns a property object.

8.11.78  getCurrentScript
Signature String getCurrentScript()
Description'$currentScript' can be accessed from Velocity scripts (i.e. both templates and patterns) to get the filename of the current script.

The returned value is the complete path for the script file, in platform-specific form (e.g. "C:\myscripts\pattern.vm" in Windows) so that it can be copied and pasted for opening in an editor.

This method is useful for debugging patterns, where there is a particular problem: by the time the patterns have been resolved into objects, any #parse'd patterns have finished and gone away, so it is not possible to automatically deduce the exact script that created an object. This means that the 'tracePatterns' feature can only a first approximation - it reports the (pre, or extra) includeSpec, but not any #parse'd files called from the patterns.

Therefore some of the standard patterns use '$currentScript' to set the sourcePattern attribute of the object being created. The way you do this is to include a sourcePattern attribute (which will invoke this method) in the pattern, i.e.

    sourcePattern="$currentScript"

This approach correctly reports the exact file where the pattern is being executed.

See also setSourcePattern, which is useful for reporting the scripts that embellish a pre-created metaClass.

8.11.79  getCurrentTimeMillis
Signaturestatic long getCurrentTimeMillis()
DescriptiongetCurrentTimeMillis() is equivalent to System.currentTimeMillis(). It can (unless someone has redefined this) be referenced as $currentTimeMillis

8.11.80  getDelegatedProperty
Signature Object getDelegatedProperty( String propertyName )
DescriptiongetDelegatedProperty first checks properties on the current object. This first search works whether or not the attribute is defined on the Java metaClass, or comes out of the 'properties' hashmap.

If this yields a null value, this continues looking for a non-null value of the same name
  • in the parent chain
  • in 'system.properties' for the applicable meta-models
  • in the build properties (e.g. build.jwp).
The first non-null value found in this search is the value returned. If all possibilities are exhausted, then null is returned.

The effect of this method for Velocity script is slightly different from using '$propertyName', because this method continues searching for a non-null value (even if there are getters on parent objects that return null), whereas '$propertyName' will return null if a parent is enountered with a getter that returns null.

8.11.81  getDelegatedPropertyFromAbove
Signature Object getDelegatedPropertyFromAbove( String name )
DescriptiongetDelegatedPropertyFromAbove follows the same algorithm as 'getDelegatedProperty'.

The only difference is that, whereas the search on getDelegatedProperty starts with the current (context) metaClass that method is being run on, with getDelegatedPropertyFromAbove the current metaClass is skipped (presumably because the caller already knows that the value of the attribute on the current metaClass is null).

8.11.82  getDirname
Signaturestatic String getDirname( String path )
DescriptionGet the directory part - up to but not including the last '/' or '\' - from a path string. If the path is null or empty, the path value is returned. If the path doesn't contain '/' or '\', then ".." is returned (on the assumption that name is a relative reference to the current directory and so the desired directory is the parent of the current directory).

8.11.83  getEOLString
Signaturestatic String getEOLString( String inputString )
DescriptiongetEOLString gets the first EOL (end of line) string in the input string. An end-of-line string is one of the following: CR-LF CR LF If there is no end-of-line sequence, then null is returned

8.11.84  getFile( File dir, String fileName )
Signaturestatic File getFile( File dir, String fileName )
DescriptionReturns a Java File from the fileName, i.e. 'new File( dir, fileName )'.

8.11.85  getFile( String path )
Signaturestatic File getFile( String path )
DescriptionReturns a Java File from the path, i.e. 'new File( path )'.

8.11.86  getFileSeparator
Signaturestatic String getFileSeparator()
DescriptionReturns the file separator, either '/' for UNIX or '\' for Windows.

8.11.87  getFinalElementTag
Signature String getFinalElementTag()
DescriptionReturns the element name from the XML specification as read in, after renaming and with any prefixes removed, and in javaVarName format.

8.11.88  getFirstPieceOf
Signaturestatic String getFirstPieceOf( String inputString, String separator )
DescriptiongetFirstPieceOf gets the first piece of the inputString - this variant takes a string to delimit the pieces rather than a character.
parametersinputStringthe string to be broken apart
separatorthe separator that defines the pieces. The separator can be any non-empty string, although normally it is a single character of punctuation.
returnsthe substring of inputString before the first occurrence of a single-character separator, or, if there is none, the input string


8.11.89  getIdentifyingString
Signature String getIdentifyingString()
DescriptionGets a formatted name for the current meta-objects in its XML element representation. Use this in your own error messages or logs. In debugging, it is better to use this than to just dump the object - this gives more information.

The identifyingString may change if the object gets a name ... maybe we should always calculate the name... but we don't because in verbose mode it would add significantly to the overhead.

8.11.90  getIsDOS
Signaturestatic boolean getIsDOS()
DescriptionReturns true if on DOS (Windows)

8.11.91  getIsUNIX
Signaturestatic boolean getIsUNIX()
DescriptionReturns true if on UNIX or Linux.

8.11.92  getIsWindows
Signaturestatic boolean getIsWindows()
DescriptionReturns true if on Windows

8.11.93  getJWControlManager
Signature JWControlManager getJWControlManager()
DescriptionReturns the JeeWiz Control manager - $JWControlManager

To support dyslexics, there are some alternate spellings too: 'jwcontrolManager', 'jwControlManager'.

This method is present to support JeeWiz V4 controls. It is deprecated since JeeWiz V5: use Velocity-based JeeWiz controls instead.

8.11.94  getJavaClassComponentType
Signature String getJavaClassComponentType()
DescriptionReturns the metaClass's type as a single name, in Java class format (e.g. 'BusinessObject').

8.11.95  getJavaClassName()
Signature String getJavaClassName()
DescriptionReturns the name as set in Java class format. This allows the name to be set in lower-case-XML-dashes format and still return a Java class name.

For example, if the name as set was "business-object", this returns "BusinessObject".

8.11.96  getJavaClassName( String inputName )
Signaturestatic String getJavaClassName( String inputName )
DescriptionConverts from an XML name to a Java class-style name. The Java class-style name is as you would expect: a leading uppercase letter, followed by alphanumerics with capitals signalling the start of new logical 'words'. The details of the steps involved are:
  1. capitalise the first character of the name
  2. find disallowed characters - XML characters that are not allowed in Java ('.', ':' and '-')
  3. remove these characters and capitalise the next character, if any
  4. leave the case of characters within the body of the name that do not follow a separator unchanged
The '_' character, which is allowed in XML and in Java, is passed through and the case of the following letter is unchanged.

8.11.97  getJavaName
Signaturestatic String getJavaName( String inputName, boolean capitaliseFirstCharacter )
DescriptionConverts from an XML name to a Java class or variable name, depending on the setting of capitaliseFirstCharacter. If capitaliseFirstCharacter is set, this is equivalent to getJavaClassName. If capitaliseFirstCharacter is not set, this is equivalent to getJavaVarName.

The '.', '-' and ':' are allowed name characters in XML but not in Java. (Although ':' is used in the XML prefix syntax, you can run JeeWiz with 'processPrefixes=false', and the ':' character is processed by this algorithm.) There characters are used as 'capitalization' triggers - the next character if any is capitalized - and the character itself is discarded.

8.11.98  getJavaVarComponentType
Signature String getJavaVarComponentType()
DescriptionReturns the metaClass's type as a single name, in Java variable format (e.g. 'businessObject')

8.11.99  getJavaVarName()
Signature String getJavaVarName()
DescriptionReturns the name as set in Java variable format. This allows the name to be set in lower-case-XML-dashes format and still return a Java variable name.

For example, if the name as set was "business-object", this returns "businessObject".

8.11.100  getJavaVarName( String inputName )
Signaturestatic String getJavaVarName( String inputName )
DescriptionConverts from an XML name to a Java variable-style name. In other words, this is the same as getJavaClassName, except the first character will be lower-case.

8.11.101  getJaxbAttributeName
Signature String getJaxbAttributeName( String xmlName )
Descriptionget the Jaxb attribute name in Java from the xml name. This
  • removes punctuation characters
  • capitalises the letter following a word break (which is either punctuation or numerics) For example, "n.A-s_t2y" becomes "nAST2Y"

8.11.102  getLastPieceOf
Signaturestatic String getLastPieceOf( String inputString, String separator )
DescriptiongetLastPieceOf gets the last piece of the inputString
parametersinputStringthe string to be broken apart
separatorthe separator character that defines the pieces. The separator can be any non-empty string, although normally it is a single character of punctuation.
returnsthe substring of inputString after the last occurrence of separator, of, if there is none, the input string


8.11.103  getLineSeparator
Signaturestatic String getLineSeparator()
DescriptionReturns the appropriate line separator for UNIX (\n) or Windows (\r\n).

8.11.104  getLocalName
Signaturestatic String getLocalName( String qName )
DescriptionReturns the local-part name from an XML Qname.

The syntax for an XML Qname is:

    QName ::= (Prefix ':')? LocalPart

In other words, the prefix is optional and separated from the local part of the name by ':'.

So getLocalName returns the qName as input, less the prefix and ':', if present.

8.11.105  getLocalPrefixToURIMappings
Signature ListMap getLocalPrefixToURIMappings()
DescriptionThis returns a ListMap containing the mapping from prefix strings to URIs, as defined by 'xmlns:prefix="URI"' attributes on this element.

8.11.106  getMyXmlURI
Signature String getMyXmlURI()
DescriptionGets the URI for this XML element. If there is a prefix, this will be the namespace associated with that prefix. For example, assume the governing namespace definition is xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" then for the element <wsdl:documentation'> getMyXmlURI() will return "http://schemas.xmlsoap.org/wsdl/" If there is no prefix, then the namespace will be the default namespace for the element.

8.11.107  getName
Signature String getName()
DescriptiongetName() is the name as set.

There are derivatives, which are set as a function of the name as set:

8.11.108  getNameCapitalised
Signature String getNameCapitalised()
DescriptionReturns the name as set, in capitalised format - first character is uppercased if it is lowercase.

For example, if the name as set was "businessObject", this returns "BusinessObject".

However, no dashes removal is done, so if the name set was 'a-b', the value returned will be 'A-b'. If you intend to use the result in source code, use one of the other 'getName...()'.

See also capitalise().

8.11.109  getNameCapitalized
Signature String getNameCapitalized()
DescriptionA synonym for getNameCapitalised().

8.11.110  getNewArrayList( Collection c )
Signaturestatic ArrayList getNewArrayList( Collection c )
DescriptionReturns a new ArrayList (i.e. a short-hand for using 'getClassInstance( "java.util.ArrayList" )') populated by the values in the input collection parameter.

Note that you must use the full name 'getNewArrayList(...)' to call this method (unlike the 0-parameter version, which can be referenced without the 'get' - e.g. '$this.newArrayList').

8.11.111  getNewArrayList( int n )
Signaturestatic ArrayList getNewArrayList( int n )
DescriptionReturns a new ArrayList with an initial capacity of n.

Note that you must use the full name 'getNewArrayList(...)' to call this method (unlike the 0-parameter version, which can be referenced without the 'get' - e.g. '$this.newArrayList').

8.11.112  getNewArrayList()
Signaturestatic ArrayList getNewArrayList()
DescriptionReturns a new ArrayList (i.e. a short-hand for using 'getClassInstance( "java.util.ArrayList" )').

8.11.113  getNewControl( String templateName )
Signaturestatic Jwcontrol getNewControl( String templateName )
DescriptionReturns a new Jwcontrol, specifically for getting an object that can invoke methods.
parameterstemplateNamethe name of the control. This must exactly match the basename of the .control file which defined the control.
throwsRuntimeExceptionIf the construction of the control caused an exception. The stack trace is automatically printed and the exception will then cause execution to stop.


8.11.114  getNewControl( String xmlTemplateName, Map map )
Signaturestatic Jwcontrol getNewControl( String xmlTemplateName, Map map )
DescriptionReturns a new Jwcontrol, specifically for getting an object that can invoke methods.
parameterstemplateNamethe name of the control. This must exactly match the basename of the .control file which defined the control.
mapThe map of key-value's to initialise the control with (after component.properties are added). The keys in the map must be Strings and must not be null. The values in the map may be of any type or value including null. Specifically values may be references to other Jwcontrols or model objects.
throwsRuntimeExceptionIf the construction of the control caused an exception. The stack trace is automatically printed and the exception will then cause execution to stop.


8.11.115  getNewControl( String xmlTemplateName, String propertiesString )
Signaturestatic Jwcontrol getNewControl( String xmlTemplateName, String propertiesString )
DescriptionReturns a new Jwcontrol, specifically for getting an object that can invoke methods.
parameterstemplateNamethe name of the control. This must exactly match the basename of the .control file which defined the control.
propertiesStringA list of initialisation properties, which should be in the form key=value [, key=value ]... For example, propertiesString="a=A,b=B" is equivalent to putProperty( "a", "A" ); putProperty( "b", "B" ); Leading and trailing spaces around the keys and the values are significant. For example, propertiesString=" a = A " is equivalent to putProperty( " a ", " A " ); There is no escape mechanism for ','. If a value may contain ',', the constructor that initialises using a Map must be used.
throwsRuntimeExceptionIf the construction of the control caused an exception. The stack trace is automatically printed and the exception will then cause execution to stop.


8.11.116  getNewControl()
Signaturestatic Jwcontrol getNewControl()
DescriptionThis constructor is not allowed and throws a BuildException, which will stop the current build.

To create an instance of a control, you must also specify the xmlTemplateName

8.11.117  getNewHashMap( Map m )
Signaturestatic HashMap getNewHashMap( Map m )
DescriptionReturns a new HashMap with the same mappings as the Map parameter.

Note that you must use the full name 'getNewHashMap(...)' to call this method (unlike the 0-parameter version, which can be referenced without the 'get' - e.g. '$this.newHashMap').

8.11.118  getNewHashMap()
Signaturestatic HashMap getNewHashMap()
DescriptionReturns a new HashMap (i.e. a short-hand for using 'getClassInstance( "java.util.HashMap" )').

8.11.119  getNewListMap
Signaturestatic ListMap getNewListMap()
DescriptionReturns a new ListMap.

The ListMap is a JeeWiz utility class that at the first level is an ArrayList, whose values are unique keys. Then at the second level it is a HashMap, mapping from the unique keys to values.

These two are combined so that the ListMap can be accessed

  • as a HashMap, with 'put(Object,Object)' to insert key/value pairs, and 'get(Object)' to retrieve them
  • as an ArrayList. By iterating through the ArrayList, the keys can be accessed in the order in which they were put in. Given an entry from the this ArrayList, the value must be accessed via 'get( key )'.

8.11.120  getNewTreeMap( Map m )
Signaturestatic TreeMap getNewTreeMap( Map m )
DescriptionReturns a new TreeMap with the same mappings as the Map parameter. This uses the 'TreeMap( Map )' constructor. A ClassCastException is thrown if the objects in the map are not mutually comparable.

Note that you must use the full name 'getNewTreeMap(...)' to call this method (unlike the 0-parameter version, which can be referenced without the 'get' - e.g. '$this.newTreeMap').

8.11.121  getNewTreeMap()
Signaturestatic TreeMap getNewTreeMap()
DescriptionReturns a new TreeMap (i.e. a short-hand for using 'getClassInstance( "java.util.TreeMap" )').

8.11.122  getNull
Signaturestatic String getNull()
DescriptionThis returns a null, as an easy way to get a null value in Velocity - use $null.

8.11.123  getOriginalElementTag
Signature String getOriginalElementTag()
DescriptionReturns the XML element tag for the model object, before any renaming or prefix handling. So this gives the original fully-qualified name.

8.11.124  getParentBC
Signature BaseBuildComponent getParentBC()
DescriptiongetParentBC returns our parent buildcomponent. For the very top of the specification, it returns null.

This is useful in Java. In Velocity, saying '$parent' is easier, faster to execute and equivalent.

8.11.125  getPathSeparator
Signaturestatic String getPathSeparator()
DescriptionReturns the path separator, either ':' for UNIX or ';' for Windows.

8.11.126  getPatternXmlDeclaration
Signature String getPatternXmlDeclaration()
DescriptionThis method gets the XML Declaration for the current pattern. (The XML declaration is the one at the top of an XML file, along the lines of "<?xml version='1.0' encoding='ISO-8859-1'?>".) If this is executed outside the execution of a pattern, the value returned is undefined.

This method should only be used to verify the XML declaration coded between multiple parts.

8.11.127  getPieceOf( String inputString, String leftSeparator, String rightSeparator )
Signaturestatic String getPieceOf( String inputString, String leftSeparator, String rightSeparator )
DescriptiongetPieceOf gets a piece of the inputString, separated by delimiters. This variant takes a left separator, to mark the LHS of the result, and a right separator, to mark the end of the result.
parametersinputStringthe string to be broken apart
leftSeparatorthe separator character that defines the pieces. In fact, this can be any non-empty string, although normally it is a single-character punctuation.
returnsthe substring of inputString after the leftSeparator and before the rightSeparator. The empty string "" is returned in all the 'degenerate' cases, i.e. if
    • any of the input parameters are null
    • there is no occurence of the leftSeparator in the inputString
    • there is no occurence of the rightSeparator after the leftSeparator.



8.11.128  getPieceOf( String inputString, String separator, int pieceNumber )
Signaturestatic String getPieceOf( String inputString, String separator, int pieceNumber )
DescriptiongetPieceOf in this form gets a numbered piece of a string. For example getPieceOf( "a,b,c", ",", 2 ) returns "b".
parametersinputStringthe string to be broken apart
separatorthe separator character that defines the pieces. In the method where separator is a character, this can be any character - it doesn't have to be punctuation In the method where separator is a string.
pieceNumberthe piece number: if pieceNumber is 0, the inputString is returned. If there is no such piece - i.e. the number is out of range, then the empty string "" is returned. For pieceNumbers greater than 0, the 'first' piece runs from the start of the string to the character before the first separator or the end of the string, so getFirstPieceOf( x, "," ) == getPieceOf( x, "," 1 ) The second piece runs from after the first separator to just before the second separator or the end of the string; and so on. If pieceNumber is less than 0, then -1 is the "last" occurrence, -2 is the second last occurrence, and so on.
returnsthe substring of inputString before the pieceNumber'th occurrence of the separator, but after the previous occurrence. So getPieceOf( "a,b,c", ",", 1 ) returns "a", i.e. the same as getFirstPieceOf( "a,b,c", "," ) getPieceOf( "a,b,c", ",", 2 ) returns "b" getPieceOf( "a,b,c", ",", 3 ) returns "c" - there are two occurrences of the separator, so the third piece is the remainder of the string getPieceOf( "a,b,c", ",", 4 ) returns "" - there aren't enough separator characters This method returns "" in all degenerate cases, i.e. where
    • the input string is null or the empty string
    • the piece number is less than 1
    • the separator string is null or the empty string
    • there are not enough separator strings (i.e. there are less than 'pieceNumber-1' occurrences of the separator string.



8.11.129  getPieces( String inputString, String separator )
Signaturestatic ArrayList getPieces( String inputString, String separator )
DescriptiongetPieces gets the pieces of the inputString before the last. The separator is the string that separates the pieces. The separator can be any non-empty string: in particular, it can be more than a single character in length.
returnsnull if the inputString or separator are null, or if the separator is empty, otherwise an ArrayList whose elements are the pieces of the input string separated by the separator string. Note that empty strings are removed from the result list if they are encountered. e.g. getPieces( "x - y - z - ", " - " ) = { "x", "y", "z", "" } getPieces( "", " - " ) = { "" } getPieces( "", "" ) = null getPieces( "a b", " " ) = { "a", "", "", "b" }


8.11.130  getPieces( String inputString, String separator, boolean removeEmptyPieces )
Signaturestatic ArrayList getPieces( String inputString, String separator, boolean removeEmptyPieces )
DescriptiongetPieces gets the pieces of the inputString before the last. The separator is the string that separates the pieces. The separator can be any non-empty string: in particular, it can be more than a single character in length. The 'removeEmptyPieces' flag tells whether empty strings should be removed from the output list.
returnsnull if the inputString or separator are null, or if the separator is empty, otherwise an ArrayList whose elements are the pieces of the input string separated by the separator string. Note that empty strings are possible as elements of the returned ArrayList if 'removeEmptyPieces' is false. e.g. getPieces( "a b", " ", true ) = { "a", "b" } getPieces( "a b", " ", false ) = { "a", "", "", "b" }


8.11.131  getPlatformPath( File f )
Signaturestatic String getPlatformPath( File f )
DescriptionReturns the input file as a path in a standard, absolute format for the input file, suitable for error messages and for specifying to other tools on this platform. On Windows, this uses '\' path separators; on UNIX, it uses '/'.

Use getUnixPath for ant scripts.

If the input file name is null, this returns null.

8.11.132  getPlatformPath( String fileName )
Signaturestatic String getPlatformPath( String fileName )
DescriptionReturns the input file name as a path in a standard, absolute format for the indicated file, suitable for error messages and for specifying to other tools on this platform.

Use getUnixPath for ant scripts.

On Windows, this uses '\' path separators; on UNIX, it uses '/'. If the input file name is null, this returns null.

8.11.133  getPreLastPieceOf
Signaturestatic String getPreLastPieceOf( String inputString, String separator )
DescriptiongetPreLastPieceOf gets the pieces of the inputString before the last.
parametersinputStringthe string to be broken apart
separatorthe separator character that defines the pieces. The separator can be any non-empty string, although normally it is a single character of punctuation.
returnsnull if the inputString or separator are null, otherwise the substring of inputString preceding the last occurrence of separator, of, if there is none, "". e.g. getLastPieceOf( "x.y", "." ) = "x"


8.11.134  getPrefix
Signaturestatic String getPrefix( String qName )
DescriptionReturn the prefix from an XML QName.

For example, if qName="pfx:elt", then this method returns "pfx".

If there is no prefix on the QName, this method returns "".

8.11.135  getProperties
Signature ListMap getProperties()
DescriptionReturns the extra properties ListMap (attached to every model object). This is where $object.put() goes. All un-meta-modelled attributes set on a model object (e.g. #set( $mo.ummAttribute = "value") ) gets set here.

8.11.136  getRelativePath( String path, String baseDirectory )
Signaturestatic String getRelativePath( String path, String baseDirectory )
DescriptiongetRelativePath returns a path, relative to a base directory, if possible. The input 'path' can be either a single path, or multiple paths separated by the current platform's path separator (';' or ':'). Each individual path is resolved to a directory relative to the current one, by moving up the parents to find a common directory with the baseDirectory. If a common directory is found, the path relative via that directory is returned, with forward '/' for the file separator.

However this process stops when four levels have been examined unsuccessfully; at this point, the original path in Unix format is returned.

8.11.137  getRelativePath( String path, String baseDirectory, int nLevels )
Signaturestatic String getRelativePath( String path, String baseDirectory, int nLevels )
DescriptiongetRelativePath returns a path, relative to a base directory, if possible. The input 'path' can be either a single path, or multiple paths separated by the current platform's path separator (';' or ':'). Each individual path is resolved to a directory relative to the current one, by moving up the parents to find a common directory with the baseDirectory. If a common directory is found, the path relative via that directory is returned, with forward '/' for the file separator.

In this variant of getRelativePath, the number of levels examined for a common directory is specified by 'nLevels'; at this point, the original path in Unix format is returned.

8.11.138  getRelativePathBS( String path, String baseDirectory )
Signaturestatic String getRelativePathBS( String path, String baseDirectory )
DescriptionReturns the same as getRelativePath, but with any '/' changed to '\' (for Windows). The number of parent directory levels searched for a common directory is 4 in this version.

8.11.139  getRelativePathBS( String path, String baseDirectory, int nLevels )
Signaturestatic String getRelativePathBS( String path, String baseDirectory, int nLevels )
DescriptionReturns the same as getRelativePath, but with any '/' changed to '\' (for Windows). The number of parent directory levels searched for a common directory is specified by 'nLevels' in this version.

8.11.140  getRenderedText
Signature String getRenderedText()
DescriptionTakes the 'text' property and renders it using Velocity and the current model object as context.

As of JeeWiz V5, this method silently ignores '#' as a special character, which means that

    • you can use the '#' character as a literal
    • calls to macros are ignored during the rendering.
This is often used in renderings in the following way:

    if( $text)
         $renderedText

8.11.141  getResolvedPathFrom
Signaturestatic String getResolvedPathFrom( String path, String baseDir )
DescriptionThe input path is one or more path elements separated by the platform path separator (';' or ':') or ",". The path elements can optionally have leading or trainling whitespace (e.g. newlines), which will be trimmed before use The baseDir is the base to resolve from. The returned value is the input string, but where a path element is relative, it is resolved into an absolute path. Empty path elements (i.e. a zero-length string) are discarded in this process. For example, on Windows getResolvedPathFrom( "C:\jw\myproject;../subdir", "C:\jw\top" ) = "C:\jw\myproject;C:\jw\subdir"

8.11.142  getSetAttributes
Signature ListMap getSetAttributes()
DescriptionThis is a list of the attributes of the model object that have been set *from XML*.

In order that the reported list of attributes is not cluttered with temporary variables from the rendering, the setAttributes list does not include component.properties or attributes set via Velocity's #set directive (e.g. '#set( $mo.attr = "value" )' ).

If you want to set an attribute so that it appears in the xml dump or the setAttributes list, use setX()

8.11.143  getShortID
Signature String getShortID()
DescriptionGets a formatted name for the current model object. Use this in your own error messages or logs. In debugging, it is better to use this than to just dump the object - this gives more information. This is a similar concept to getIdentifyingString(), but yields a shorter and possibly non-unique value.

8.11.144  getSingleLineDescription
Signature String getSingleLineDescription( )
DescriptionConverts the description so that it can be used as the contents of a single Java string in a Java program. So in generating a Java program you could write

    String d = "$singleLineDescription";

This converts \n, \r, ", ', and \. It does not affect any of the XML-meta-characters (like '&').

8.11.145  getSingleLineText
Signaturestatic String getSingleLineText( String description )
DescriptionThis method converts from an internal String value (e.g. read in from XML character data) into a string suitable for creating a single-line String constant in a Java program.

8.11.146  getSuperclasses
Signature ArrayList getSuperclasses()
DescriptionGet the list of names for the superclasses of this particular object (which can of course be a sub-class of BaseBuildComponent). N.B. The 0'th item will be the name of the class of the object itself - which is not strictly a superclass!; the last item will be "java.lang.Object".

This method is typically used for diagnostics, in which case it is easier to read if 'dumpObject()' is also used:

$this.log( $this.dumpObject( $superclasses ) )

8.11.147  getSystemProperties
Signature static Properties getSystemProperties()
Descriptionreturns the system properties, i.e. System.getProperties() from the java.lang.System class.

Note that because the property names have '.' in them, you cannot say e.g. $systemProperties.user.name to get the user name.

Instead, you should use the Properties class's 'get' method: $systemProperties.get( "user.name" )

8.11.148  getTemplate
Signature String getTemplate()
DescriptiongetTemplate() returns the template name for this metaClass. The value determines the initial metaClass directory that the engine searches for templates. getTemplate() is normally used only by the engine during rendering.

There is a public setter for this property (i.e. you can use 'setTemplate("newTemplateName")') but it is for expert use only.

8.11.149  getTemplateStack
Signature String getTemplateStack()
Descriptionreturns the current template stack one line per template, with the current template as the first line This can be accessed from Velocity using '$templateStack' (or $this.templateStack if necessary).

8.11.150  getText
Signature String getText()
DescriptiongetText gets the 'text' attribute. For a model object, this is normally set by reading character data (CDATA) from the XML specification. However, it can also be set by via 'addText' or 'setText'

8.11.151  getTopComponent
Signature BaseBuildComponent getTopComponent()
DescriptionReturns the top (i.e. root) metaClass of the main spec.

For example, for a J2EE build, this will be the application or jar object (whichever is top).

8.11.152  getURIByPrefix
Signature String getURIByPrefix( String prefix )
DescriptionLooks up the URI by prefix for the metaClass, This delegates up the parent chain to find the first relevant prefix->URI mapping, if the prefix->URI mapping is not found locally (i.e. on this metaClass).

8.11.153  getURIByQName
Signature String getURIByQName( String QName )
DescriptionLooks up the URI using the prefix implied by the QName, for a given metaClass, This delegates up the parent chain to find the first relevant prefix->URI mapping, if the prefix->URI mapping is not found locally (i.e. on this metaClass).

A QName with no prefix is valid: the prefix is the zero-length string, and will find the first default namespace defined in the metaClass or its parent chain. (The default namespace is defined by the xmlns attribute, i.e. 'xmlns="DefaultNamespaceURI"'.)

8.11.154  getUUID( String hostName )
Signature static String getUUID( String hostName )
DescriptionThis is a very simple implementation of UUIDs, intended for creating XMI IDs in generated UML models. It is not machine-specific in any way.

This variant allows you to pass in the host-name part, which must be a correct UID string (e.g. 12 hex digits).

8.11.155  getUUID()
Signature static String getUUID()
DescriptionThis is a very simple implementation of UUIDs, intended for creating XMI IDs in generated UML models. It is not machine-specific in any way.

This version uses all '0's as the hostname.

8.11.156  getUniqueKey( String baseKey, Map map )
Signature static String getUniqueKey( String baseKey, Map map )
DescriptiongetUniqueKey with two parameters is a variant of the three-parameter method. It puts a zero-length string "" as the entry in the HashMap.

8.11.157  getUniqueKey( String baseKey, Map map, Object entryValue )
Signature static String getUniqueKey( String baseKey, Map map, Object entryValue )
DescriptiongetUniqueKey gets a unique key for a map, starting with the baseKey string. If the baseKey already has an entry in the map, '2', '3' and so on are suffixed onto baseKey until a unique key is produced.

An entry is created in the map, using the returned value as the key and entryValue as the value.

If baseKey is null, "" is used. map may not be null. entryValue may be null, and will result in a null value being put into the map.

The returned value is the unique key

8.11.158  getUnixPath( File f )
Signaturestatic String getUnixPath( File f )
DescriptionReturns Java's File.getCanonicalPath for the input file, but using '/' as the path separator.

[ We use the 'Unix' in the name to reflect the '/' separator, but on Windows this will have the 'drive:' at the start so it is not strictly a Unix path.]

If the input file is null or File.getCanonicalPath throws an exception, getUnixPath() returns null.

Use this method to write file paths into Ant scripts and into properties files (in properties files, the '\' character of a Windows path will be interpreted as an escape character). Use getPlatformPath() for creating files for input to local-platform tools.

8.11.159  getUnixPath( String fileName )
Signaturestatic String getUnixPath( String fileName )
DescriptionCreates a File using the input file name in the constructor, then returns Java's File.getCanonicalPath for the file, but using '/' as the path separator.

[ We use the 'Unix' in the name to reflect the '/' separator, but on Windows this will have the 'drive:' at the start so it is not strictly a Unix path.]

If the input file name is null or File.getCanonicalPath throws an exception, getUnixPath() returns null.

Use this method to write file paths into Ant scripts and into properties files (in properties files, the '\' character of a Windows path will be interpreted as an escape character). Use getPlatformPath() for creating files for input to local-platform tools.

8.11.160  getVersionNumber
Signature static String getVersionNumber()
DescriptionThis method returns the version number marker of the engine only. There is another version number, for the standard renderings, defined in jeewiz/resources/version.properties The engine version number consists of three or four components - x.y.z[.h]:
  • the 'x' component is the major engine version level - 1,2,3,... This is changed when (and if) a major new feature is introduced into the engine. Version 3 introduced patterns and the original version of controls based on Java. Version 4 introduced Java/Velocity controls and object-oriented features (such as methods on objects) into Velocity.
  • the 'y' component is the minor engine version level, starting with 0. At this level, a change in the 'y' component implies the introduction of, or change in, minor features. The '0' minor level is the first distributed build of a major version.
  • the 'z' component is the distributed build number within the major/minor level, starting with 0.
  • the optional 'h' component is present if there is a problem with the x.y.z distribution and identifies hot fixes, starting with 1.

8.11.161  getWindowsPath( File f )
Signaturestatic String getWindowsPath( File f )
DescriptionReturns Java's File.getCanonicalPath for the input file, but using '\' as the path separator.

If the input file is null or File.getCanonicalPath throws an exception, getWindowsPath() returns null.

Use this method for creating files for input to Windows commands.

8.11.162  getWindowsPath( String fileName )
Signaturestatic String getWindowsPath( String fileName )
DescriptionCreates a File using the input file name in the constructor, then returns Java's File.getCanonicalPath for the file, but using '\' as the path separator.

If the input file name is null or File.getCanonicalPath throws an exception, getWindowsPath() returns null.

Use this method for creating files for input to Windows commands.

8.11.163  getXMLComponentType
Signature String getXMLComponentType()
DescriptionReturns the metaClass's type as a single name, in XML element format (e.g. 'business-object')

8.11.164  getXMLName
Signaturestatic String getXMLName( String inputName )
DescriptionSynonym for 'getXmlName'

8.11.165  getXmlDump( String indent )
Signature String getXmlDump( String indent )
DescriptionAs per getXmlDump() but indented by the 'indent' string, which should be whitespace

8.11.166  getXmlDump()
Signature String getXmlDump()
DescriptionReturns a string representation of this node, including the set attributes and character data, plus the same dump of all nested elements recursively.

This uses the original element tags (before any renaming) and only outputs those items set from the specification, or specially marked using setX.

The character data (i.e. the 'text()' method on the model object) is first trimmed (java.lang.String.trim()). Then, it is either put out as a single CDATA section if it contains a line-feed or, if not, as character data. The intent is to preserve significant whitespace within the text, at the expense of the leading and trailing whitespace (which is trimmed away).

8.11.167  getXmlLocalPart
Signature String getXmlLocalPart( String s )
DescriptiongetXmlLocalPart gets the xml local part from the input string. For example, if the input string is "prefix:localpart", the return value is "localpart".

If there is no prefix, the return value is the input string.

If the input string is null, the return value is null.

8.11.168  getXmlName()
Signature String getXmlName()
DescriptionReturns the name as set in format

For example, if the name as set was "BusinessObject", this returns "business-object"

8.11.169  getXmlName( String inputName )
Signaturestatic String getXmlName( String inputName )
DescriptionConverts the input name into 'standard XML' format. This means:

  • initial capital letters are made lower cases
  • capital letters in the remainder of the input name are also made lower case, but a '-; is inserted before them ... unless there is already a '-' there, in which case this is omitted - to avoid synthetic double '-'s.
For example, getXmlName( "EjbJar" ) = "ejb-jar" getXmlName( "Ejb-Jar" ) = "ejb-jar"

Note that the double-'-' rule means that the Xml and JavaVar names are not completely associative - getXmlName( getJavaVarName( x ) ) == x is not always true - when there is a '-' before an upper case.

8.11.170  getXmlPrefix( String s )
Signature String getXmlPrefix( String s )
DescriptiongetXmlPrefix gets the xml prefix from the input string. For example, if the input string is "prefix:localpart", the return value is "prefix".

If there is no prefix, the return value is "".

If the input string is null, the return value is null.

8.11.171  getXmlPrefix()
Signature String getXmlPrefix()
DescriptionGets the XML prefix specified in defining this element. For example, if the current metaModel element's XML is '<pfx:cmo', the getXmlPrefix="pfx".

This is ignored in most JeeWiz models, but is required when reading designs based on XML Schema, such as WSDL, FPML etc.

8.11.172  getXmlns
Signature String getXmlns()
DescriptionGets the 'xmlns' attribute - i.e. the default namespace defined at this XML element.

This does *not* delegate: if there is no 'xmlns' attribute defined on the current metaClass, then this returns null.

8.11.173  getXsdDateAsCalendar
Signature static Calendar getXsdDateAsCalendar( String s )
DescriptionGets an XML Schema date string into a calendar object.
parameterssThe date, in YYYY-MM-DD format, optionally followed by a timezone specification.
throwsIllegalArgumentExceptionif the input string is not a timezone format, or empty
returnsThe Calendar object with the Year/Month/Day fields set. The timezone will be set to the input timezone if one is present, otherwise to the current default timezone.


8.11.174  getXsdDateTimeAsCalendar
Signature static Calendar getXsdDateTimeAsCalendar( String s )
DescriptionGets an XML Schema dateTime string into a calendar object.
parameterssThe dateTime, in YYYY-MM-DDTHH:MM:SS[.sss] format, optionally followed by a timezone specification.
throwsIllegalArgumentExceptionif the input string is not a valid dateTime.
returnsThe Calendar object with all fields set.


8.11.175  getXsdTimeAsCalendar
Signature static Calendar getXsdTimeAsCalendar( String sIn )
DescriptionGets an XML Schema time string into a calendar object.
parameterssThe total 'time' (without the date part) in HH:MM:SS[.sss]format, optionally followed by a timezone specification. There can be a timezone specification on the end of the string - but only 'Z' is allowed. Any number of 'sub-seconds' (after the '.') can be specified as per the spec, but only 3 are used.
throwsIllegalArgumentExceptionif the input string is not a timezone format, or empty
returnsThe Calendar object with the Year/Month/Day fields set. The timezone will be set to the input timezone if one is present, otherwise to the current default timezone.


8.11.176  initialiseComponent
Signature boolean initialiseComponent( ArrayList alErrmsgStrings )
DescriptioninitialiseComponent() does non-pre-phase initialisation.

This should only be used in writing meta-models, and is provided by the metaModel coder to initialise the component. It is called into by the engine.

Do not call this yourself, either in Java or from Velocity.

See the 'Patterns' chapter for the exact timing of the call to this method.

It can
  • perform additional initialisation
  • do more complex validation checks than is possible with the expressions.
Add error messages onto alErrmsgStrings.

Return true to quit now (and stop further tests being made). If any indexes are kept manually, they should be set up here

If you return false, but add error messages, the build will stop after the current round of validation.

8.11.177  isDirectory
Signature static boolean isDirectory( String fileName )
DescriptionReturns true if the fileName represents a directory. This uses Java's 'File.isDirectory()' method, but catches any thrown exception (i.e. the SecurityException in Java 1.4) and returns false. In other words, a true result means that fileName is a directory and is accessible.

If fileName is a relative file, it will be interpreted in Velocity as relative to the build.xml file calling Velocity. As this can change with different renderings, it is best to only use absolute fileName's from Velocity.

8.11.178  isFile
Signature static boolean isFile( String fileName )
DescriptionReturns true if the fileName represents a normal file. This uses Java's 'File.isFile()' method, but catches any thrown exception (i.e. the SecurityException in Java 1.4) and returns false. In other words, a true result means that the file exists and is readable.

If fileName is a relative file, it will be interpreted in Velocity as relative to the build.xml file calling Velocity. As this can change with different renderings, it is best to only use absolute fileName's from Velocity.

8.11.179  isInstanceOf
Signature boolean isInstanceOf( final String className )
DescriptionisInstanceOf checks whether the context object (the object the method is executed on) is an instance of the named type. ( This method is necessary, even in Java, because you can't in Java say "o instanceof c", where c is of type class.)

The 'classToFind' parameter can be either of:
    • the fully-qualified class name (i.e. with the package), e.g. "uk.co.nte.jw.components.businessObject.DataView"
    • the final (last '.' piece) of the class name e.g. "DataView"
The second alternative is preferred because it works correctly when additional meta-models have been defined in different packages.

For example, to check if the context object is a DataView, in Velocity say $this.isInstanceOf( "uk.co.nte.jw.components.screen.DataView" ) or the alternate $this.isInstanceOf( "DataView" )

8.11.180  leftJustify
Signaturestatic String leftJustify( String s, int n )
DescriptionReturns a string 'n' spaces long, up to a maximum of 600 or so.

8.11.181  list
Signaturestatic String list( String input, String separator, String addon )
DescriptionReturns a concatenated list.  The returned value is

  • 'addon' if 'inputCSList' is empty (i.e. null or "")
  • 'inputCSList' if 'addon' is empty
  • otherwise, the concatenation of 'inputCSList', 'separator' and 'addon'.
This is useful for building lists in Velocity. The following will create a list, with the properties separated by ', '.
    #set( $result = "" )
    #foreach( $whatever )
        #set( $result = $this.list( $result, ", ", $whatever.property ) )
    #end

8.11.182  log( String indentation, String stringToLog )
Signaturestatic String log( String indentation, String stringToLog )
DescriptionLogs a warning message to the standard logging stream (normally the console).

This variant explicitly sets the indentation in the first parameter

8.11.183  log( String indentation, String stringToLog, int logLevel )
Signaturestatic String log( String indentation, String stringToLog, int logLevel )
DescriptionLogs a message to the standard logging stream, explicitly specifying the indentation and logging level.

8.11.184  log( String s )
Signaturestatic String log( String s )
DescriptionLogs a warning message to the standard logging stream (normally the console).

For the first message from a particular Velocity template file, or at each change of source template file, this method also displays the source template's file path.

Use this method anywhere in the code. If the line it appears on is empty or only has whitespace, the line will be removed from the output.

This method filters warnings at the Ant "Project.MSG_WARN" level, which means that in most situations they will appear (unless the call takes extra-special measures).

There is a default indentation of 5 characters.

8.11.185  log( String s, boolean messageOnlyFlag )
Signaturestatic String log( String s, boolean messageOnlyFlag )
DescriptionLogs a warning message to the standard logging stream (normally the console).

This is a wrapper for the single-parameter version of log. The second parameter 'messageOnlyFlag' if true will log the message only - no source file. If 'messageOnlyFlag' is false, then the source file is listed - i.e. just like the single-parameter version of the method.

8.11.186  log( String s, int logLevel )
Signaturestatic String log( String s, int logLevel )
DescriptionLogs a message to the standard logging stream (normally the console) at the specified log level as long as we are doing logs for the requested level.

For the first message from a particular Velocity template file, or at each change of source template file, this method also displays the source template's file path.

Use this method anywhere in the code. If the line it appears on is empty or only has whitespace, the line will be removed from the output.

This method logs at the supplied log level, which derive from the org.apache.tools.ant.Project values:
    1. = error
    2. = warning
    3. = info
    4. = verbose
    5. = debug These values are also defined in antLogLevel* properties in resources/base/control/system.properties

8.11.187  logError( String indentation, String s )
Signaturestatic String logError( String indentation, String s )
DescriptionLogs an error message explicitly specifying the left-hand indentation (which defaults to 5 spaces).

8.11.188  logError( String s )
Signaturestatic String logError( String s )
DescriptionLogs an error message including location information to the standard logging stream, but without stopping the build. (fatalErrorMessage gives the location information but also stops the build; other logs don't give the location information).

8.11.189  logObject( Object objectToDump )
Signature String logObject( Object objectToDump )
DescriptionThis method dumps the object using 'dumpObject' and then logs it using 'log'.

8.11.190  logObject( String label, Object objectToDump )
Signature String logObject( String label, Object objectToDump )
DescriptionThis method dumps the object using 'dumpObject' and then logs it using the 'log()', with the specified label as a header.

8.11.191  logObject( Object objectToDump, String initialIndent, String indentIncrement )
Signaturestatic String logObject( Object objectToDump, String initialIndent, String indentIncrement )
DescriptionThis method dumps the object using 'dumpObject' and then logs it using 'log'.

8.11.192  lowerCaseOnSecond
Signaturestatic String lowerCaseOnSecond( String inputString )
DescriptionReturns the input string as is, except that if the *second* letter is upper-case, ALL characters are converted to lower case.

8.11.193  multiplyString
Signature static String multiplyString( String value, int multiplier )
Descriptionreturns the value string, multiplied by 'multiplier'. For example, multiplyString( "123", 3 ) == "123123123"

If value is null, or multiplier is <= 0, then "" is returned.

8.11.194  onInstantiation
Signature void onInstantiation()
DescriptiononInstantiation() is called immediately after the object is create and hooked up to its parent and has attributes set.

MetaModel implementors can override this method to use as a "surrogate constructor". The reason that the actual constructor cannot be used realistically is that nothing has been set on the object.

8.11.195  parseFormat
Signature String parseFormat(String format, String fControl, String fTerm)
DescriptionparseFormat - Similar to parseFormat in the uiBase jwControl, this is to make the same functionality available for .vms
parametersformat,the raw format String, containing 0 to many format terms.
fControl,the characters starting the format, usually @followed by the type, eg@w or@i.
fTerm,the terminating character, usually
returnsString returns the value of the relevant format term.


8.11.196  preInitialiseComponent
Signature boolean preInitialiseComponent( ArrayList alErrmsgStrings )
DescriptionpreInitialiseComponent() is like initialiseComponent, except it is called during the pre-phase. See the 'Patterns' chapter for the exact timing of the call to this method.

If you want to do something before preInitialisedComponent (which in general happens after other objects have been initialised), then use onInstantiation.

It can
  • perform additional initialisation
  • do more complex validation checks than is possible with the expressions.
Add error messages onto alErrmsgStrings.

Return true to quit now (and stop further tests being made). If any indexes are kept manually, they should be set up here

If you return false, but add error messages, the build will stop after the current round of validation.

8.11.197  processSpecialCharacters
Signaturestatic String processSpecialCharacters( String resultString )
DescriptionProcesses the JeeWiz special characters INDENTSTART etc. See jeewiz\resources\base\control\system.properties for symbolic names - $indentStartHeader etc. See also following short-hand names $i, $u, $b, $e.

8.11.198  put
Signature void put(Object key, Object value)
DescriptionPuts a property and its value into the extra properties Map.

Note that both the key and the object are Objects: any non-primitive value can be put in here.

From Velocity, it is easier and safer to use

    #set( $this.key = $value )

The above form will also correctly use a meta-modelled setter on the metaClass if one exists, which is probably what is intended. Using 'put' avoids a meta-modelled setter, which means that the value can only be retrieved using 'get'.

See also get.

8.11.199  readFileAsLines( File file )
Signature static ArrayList readFileAsLines( File file )
DescriptionReads 'file' as an ArrayList of lines.

If the file does not exist, is not a file or cannot be read due to an IO error, logs an error and return null. Otherwise, returns the contents of the file as a single string.

This method uses the default input encoding to read the string, as defined by the 'inputEncoding' "Engine Configuration Value" - see the Architect Guide chapter on "Running And Configuring JeeWiz".

8.11.200  readFileAsLines( String fileName )
Signature static ArrayList readFileAsLines( String fileName )
DescriptionreadFileAsLines returns the contents of a file as a String. 'fileName' is interpreted as a file name, and used to call readFileAsLines(file).

This method uses the default input encoding to read the string, as defined by the 'inputEncoding' "Engine Configuration Value" - see the Architect Guide chapter on "Running And Configuring JeeWiz".

8.11.201  readFileAsString( File file )
Signature static String readFileAsString( File file )
DescriptionReads 'file' as a String.

If the file does not exist, is not a file or cannot be read due to an IO error, logs an error and return null. Otherwise, returns the contents of the file as a single string.

This method uses the default input encoding to read the string, as defined by the 'inputEncoding' "Engine Configuration Value" - see the Architect Guide chapter on "Running And Configuring JeeWiz".

8.11.202  readFileAsString( String fileName )
Signature static String readFileAsString( String fileName )
DescriptionreadFileAsString returns the contents of a file as a String. 'fileName' is interpreted as a file name, and used to call readFileAsString(file).

This method uses the default input encoding to read the string, as defined by the 'inputEncoding' "Engine Configuration Value" - see the Architect Guide chapter on "Running And Configuring JeeWiz".

8.11.203  readFileAsXml( File file, String propertyName )
Signature BaseBuildComponent readFileAsXml( File file, String propertyName )
DescriptionReads a file as XML into a model object as a property under the calling model object. Neither the fileName nor the propertyName parameters can be null or empty.

If the filename does not exist, or if the the filename is not valid XML, an exception is thrown.

8.11.204  readFileAsXml( String fileName, String propertyName )
Signature BaseBuildComponent readFileAsXml( String fileName, String propertyName )
DescriptionReads a file as XML into a model object as a property under the calling model object. Neither the fileName nor the propertyName parameters can be null or empty.

If the filename does not exist, or if the the filename is not valid XML, an exception is thrown.

8.11.205  readPropertiesFile( File file )
Signature static Properties readPropertiesFile( File file )
DescriptionreadPropertiesFile returns the contents of a file as a java.util.Properties. This is an adapater to the Properties.load( InputStream ) method.

If the file does not exist, null is returned.

8.11.206  readPropertiesFile( String fileName )
Signature static Properties readPropertiesFile( String fileName )
DescriptionreadPropertiesFile returns the contents of a file as a java.util.Properties. This is an adapater to the Properties.load( InputStream ) method.

If the file does not exist, null is returned.

8.11.207  removeCSListDuplicates
Signaturestatic void removeCSListDuplicates( List list )
DescriptionRemoves any duplicate or null strings from 'list' - an ArrayList containing strings or CDataAttribute objects

8.11.208  removeChars
Signaturestatic String removeChars( String data, String unwantedChars )
DescriptionRemove unwanted characters from a data string. The result is the data string less the unwanted characters. In other words, the return value is constructed by removing all occurrences (in the data string) of each chracter in the unwantedChars string. If either the data or the unwanted characters are null or empty, then 'data' is returned.

8.11.209  removePunctuationAndCapitalise
Signaturestatic String removePunctuationAndCapitalise( String inputString )
DescriptionremovePunctuationAndCapitalise takes away the punctuation from a string and capitalises the character after one or more separators. For example, foo_-bar&too becomes FooBarToo.

More exactly, any characters that are not letters or digits are removed. Note this means that legal Java characters - '_' and '$' - are also removed. This then yields a conventional Java class name. This method is used to support Jaxb name conversion.

If the input string is null, null is returned.

8.11.210  removeSpaces
Signaturestatic String removeSpaces(String s)
DescriptionConverts a string with spaces to one without. E.g. 'My old String' becomes MyoldString'

8.11.211  removeSpacesCapitalise
Signaturestatic String removeSpacesCapitalise(String s)
DescriptionConverts a string to a string in the Java variable name style, i.e. spaces are removed characters that followed a removed space are upper-cased the first character is upper-cased.

For example, 'My old String' becomes 'MyOldString'.

8.11.212  removeSpacesProperCase
Signaturestatic String removeSpacesProperCase(String s)
DescriptionConverts a string to a string in the Java variable name style, i.e. spaces are removed characters that followed a removed space are upper-cased the first character is lower-cased.

For example, 'My old String' becomes 'myOldString'.

8.11.213  removeString
Signaturestatic String removeString( String inputString, String separators )
DescriptionremoveString takes away the separators from a string and capitalises the character after a separator. For example, removing "_" from foo_bar becomes fooBar.

If the input string is null, null is returned.

8.11.214  removeStringNoCapital
Signaturestatic String removeStringNoCapital( String inputString, String separators )
DescriptionTakes away the separators from a string. This version does *not* capitalise the character after a separator. For example, removing "_" from foo_bar becomes foobar.

8.11.215  renderString
Signature String renderString( String fieldName, String fieldValue )
DescriptionRenders a field (whose name is fieldName and value is fieldValue) in the context of this model object.

'fieldName' is only used for error reporting.

This is used as a subroutine by getRenderedText(), but can also be used to render strings in general directly

This only takes any action if the fieldValue is non-empty and contains a '$'; otherwise fieldValue is returned.

In JeeWiz V4, this method used to throw an exception if the string contained the '#' character. As of JeeWiz V5, this method silently ignores '#' as a special character, which means that

    • you can use the '#' character as a literal
    • calls to macros are ignored during the rendering
    • you cannot define local methods (because the # in '#method()' is taken as a literal), so only methods defined on objects via component.methods or .control files are recognised.
For example:
    $this.renderString( "filter-expression", filterExpressionProperty );


This method uses the Velocity variable $dummy--hash--variable if a '#' character is present in fieldValue.

8.11.216  reportAllPrefixToURIMappings
Signature String reportAllPrefixToURIMappings()
DescriptionGives a line-by-line dump of getAllPrefixToURIMappings(), suitable for error messages.

8.11.217  resetPatternErrorMessages
Signaturestatic void resetPatternErrorMessages()
DescriptionNormally messages discovered in the Java code for the meta-model are logged in the list of pattern error messages. Eventually this turns into a fatal error message.

In some situations, the Java code may report an error message, but the templates can take action to avoid a fatal error. The resetPatternErrorMessages() allows the templates to avoid the consequences of previous pattern error messages, by discarding the current error messages.

8.11.218  rightJustify
Signaturestatic String rightJustify( String s, int n )
DescriptionReturns a string 's' in a field of 'n' characters wide.

If s.length() < n, the returned value is the required number of spaces followed by 's'; otherwise, 's' is returned.

8.11.219  separateByCapitals
Signaturestatic String separateByCapitals( String inputString )
DescriptionThis takes an input string and splits it before a capital, by inserting a space. If there is a sequence of capitals a space is only inserted before the last one. A space is never inserted before the first character or the last. eg. "ZIPCode" becomes "ZIP Code", and "ISBN" stays "ISBN".

8.11.220  setCurrentScript
Signature void setCurrentScript( String s )
Description'setCurrentScript' allows the 'currentScript' Velocity variable to be used as a normal variable (for users who forget about its built-in use) - as compared to its normal use in getCurrentScript.

If a non-null value is set via this method, subsequent calls to 'getCurrentScript()' will the return that value. If a null value is set, subsequent calls to 'getCurrentScript()' will the return the Velocity script name.

8.11.221  setNextPattern
Signature String setNextPattern( String nextPattern )
DescriptionsetNextPattern sets the next pattern in a multi-pattern sequence for a particular metaClass.

This property can be set from Velocity scripts; it is set to null as each pattern starts, so it only affects the very next pattern to be run.

It is permitted to set this property multiple times, presumably from different files in a multi-pattern sequence. However, the value cannot be changed from an existing value. For example, if an includeSpec.vm has set nextPattern to "includeSpec2.vm", by executing $this.setNextPattern( "includeSpec2.vm" ) it is not permitted in the same pattern processing (of the includeSpec or one of its #parse'd files) to changed the value, say to 'includeSpec3.vm'.

To enable patterns to be programmed without knowledge of what related super patterns (i.e. included by #parse) do, it is recommended that the later patterns in a sequence have a sequence number (2, 3...) added. For example, the includeSpec.vm's next pattern (if any) should be includeSpec2.vm, then includeSpec3.vm and so on.

8.11.222  setPatternRootObject
Signature String setPatternRootObject( Object o )
DescriptionSets the location of the root element for a pattern.

For more information, see the section on the The Mechanics Of Patterns

The return value is "", so this method can be used directly in Velocity templates - there is no need for a '#set...' operation surrounding it.

8.11.223  setPatternXmlDeclaration
Signature String setPatternXmlDeclaration( String decl )
DescriptionThis method sets the XML declaration for the current pattern. If this method is called but not within the execution of a pattern, it has no effect. Setting the XML declaration allows patterns to use a different character encoding from the default of UTF-8.

It is permitted to set this property multiple times, from different files in a multi-pattern sequence. However, the value cannot be changed from an existing value. For example, if an includeSpec.vm sets the encoding to ISO-8859-1, by executing $this.setPatternXmlDeclaration( "<?xml version='1.0' encoding='ISO-8859-1'?>" ) then it is an error to attempt to set the encoding any different string value (case-sensitive).

The XML declaration should start with "<?xml version='1.0'" or equivalent.

8.11.224  setSourcePattern
Signature void setSourcePattern( String sourcePattern )
Description'sourcePattern' poses as a standard property of a metaClass, but the setter does two additional things:
  • if the value is set more than once, it concatenates the values set (with a ',' separator). This allows the 'sourcePattern' to be used to hold a list of the patterns that have created or altered an object
  • it adds the property to the list of set attributes so that the property comes out on the xmlDump.
'sourcePattern' is used to debug pattern scripts. By including, in objects being created, the attribute

    sourcePattern="$currentScript"

the current script will be included in the XML dump as an attribute of the object being creating, and identify which file created the object.

For objects being embellished (i.e. they already exist, for example '<this>' in preIncludeSpec's and extraIncludeSpec's), the above technique is not ideal - it is better to set the source pattern directly on the current object.

    $this.setSourcePattern( $currentScript )

This is better because it can capture the action of multiple "super" scripts. This is not possible to do easily or modularly using an attribute, which is restricted (by XML) to only appearing once, so only one pattern can set a 'sourcePattern' attribute.

There is a refinement of the above example: it can be expressed simply as

    $this.addSourcePattern()

See addSourcePattern for details. See also getCurrentScript.

8.11.225  setText
Signature void setText(String text)
DescriptionsetText sets the 'text' attribute. For a model object, this is would normally the nested character data or CDATA from the XML specification. However, this method allows this property to be set from Java or Velocity directly.

8.11.226  setX( String key, String value )
Signature String setX( String key, String value )
DescriptionNormally values put into an object during rendering are not reported in This method allows you to specifically set an attribute value so it will be reported in these cases.

Note that the value is a string not an Object, which is just as well if we want to write it to XML!

This uses the same underlying mechanism as #set from Velocity, which means that a setter method is used if it exists, otherwise the key/value pair is put into the metaClass's extra properties ListMap. The important side-effect of using 'setX' is that the property will appear in the reports listed above.

Use this method anywhere in Velocity code. If the line it appears on is empty or only has whitespace, the line will be removed from the output.

It is possible to set a qualified key, such as "xmi:id".

If 'processPrefixes' is true, this will be set under the 'id' key.

If 'processPrefixes' is false, this will be set under the 'xmiId' key (considering 'xmi:id' as a name, and using ':' as an invalid character).

However, note that the aggregate dump (from the 'dump=' build property) records the original (qualified) key.

8.11.227  setX( String key, boolean value )
Signature String setX( String key, boolean value )
DescriptionThis variant of setX allows the use of '#set( $mo.attr = true )' or '#set( $mo.attr = false )' in Velocity. This is a tricky area ... if someone sets an 'xml'-style (for that is what setX() implies) property to boolean true, should we -- allow it and coerce the value to a string (which means it's no longer a Java Boolean, but does mean if satisfies #if() ) -- disallow it by not having this method.

Disallowing the method is a pig - it is very difficult to diagnose because Velocity quietly ignores the call, so it's as if the value has not been set. So allowing is is the lesser of two evils.

8.11.228  sleep
Signature static void sleep( long nMilliseconds )
DescriptionSleep for a certain number of milliseconds. This ignores InterruptedException's.

8.11.229  spaces( String s )
Signaturestatic String spaces( String s )
DescriptionReturns a string as long as the input string, up to a maximum of 600 characters or so, but filled with spaces.

If 's' is null or 0-length, "" is returned

8.11.230  spaces( int n )
Signaturestatic String spaces( int n )
DescriptionReturns a string 'n' spaces long, up to a maximum of 600 or so. If n is less than or equal to 0, the empty string is returned.

8.11.231  spaces1
Signaturestatic String spaces1( int n )
DescriptionReturns a string 'n' spaces long, up to a maximum of 600 or so. If n is less than or equal to 1, one space is returned.

8.11.232  splitCSString
Signaturestatic ArrayList splitCSString( String csString )
DescriptionSplits up a comma separated string, returning the resulting tokens (substrings) between the comma's in a List.

The substrings are trimmed, i.e. leading and trailing whitespace is removed.

If the input string 'csString' is null or zero-length, a List with no items is returned.

8.11.233  splitCSStringWithoutDuplicates
Signaturestatic ArrayList splitCSStringWithoutDuplicates( String csString )
DescriptionBuilds a comma separated string from a List containing either Strings or CDataAttribute objects (one CDataAttribute object is created by JeeWiz to read each <description> element).

This method ensures uniqueness of items in the list by removing duplicates.

Leading and trailing spaces are removed from items in the list, before checking for duplicates.

If the input string 'csString' is null or zero-length, a List with no items is returned.

8.11.234  splitSeparatorString( String stringToSplit, String delimiters )
Signaturestatic ArrayList splitSeparatorString( String stringToSplit, String delimiters )
DescriptionSplits up the string 'stringToSplit' into tokens based on the provided delimiters, with the resulting tokens trimmed (as in 'String.trim()'). Only non-empty tokens are returned; 0-length strings are discarded. The returned ArrayList contains Strings, one for each token.

For example, splitSeparatorString( "abc.dot=equ", ".=" ) = List{ "abc", "dot", "equ" }

8.11.235  splitSeparatorString( String stringToSplit, String delimiters, boolean returnDelims )
Signaturestatic ArrayList splitSeparatorString( String stringToSplit, String delimiters, boolean returnDelims )
DescriptionSplits up the string 'stringToSplit' into tokens based on the provided delimiters with the resulting tokens trimmed (as in 'String.trim()'). Only non-empty tokens are returned; 0-length strings are discarded.. The returned ArrayList contains one token for each non-empty non-delimiter string and, if returnDelims is true, for every delimiter . If returnDelims is false, this operates in the same way as the two-parameter splitSeparatorString() method.

For example, splitSeparatorString( "abc.dot=equ", ".=", true ) = List{ "abc", ".", "dot", "=", "equ" }

8.11.236  splitStringIntoTwo
Signaturestatic ArrayList splitStringIntoTwo( String stringToSplit, String separatorString )
DescriptionsplitStringIntoTwo() splits a string based on a separator string.

For example, splitStringIntoTwo( "GiveMeCookies", "Me" ) = { "Give", "Cookies" }

The method returns an ArrayList of precisely two Strings. The first item in the returned ArrayList is equal to getFirstPieceOf( stringToSplit, separatorString ). The second item is the remainder after the separatorString if it is present in the stringToSplit, otherwise empty.

If the stringToSplit or the separatorString are null or empty, a list of two empty strings {"", ""} is returned.

8.11.237  stopBuild
Signature void stopBuild()
DescriptionStops the build right now, without error.

8.11.238  stringNumberEqual
Signaturestatic boolean stringNumberEqual( String s1, String s2 )
DescriptionArbitrary precision number comparison. Returns true if s1 is numerically equal to s2

8.11.239  stringNumberGreater
Signaturestatic boolean stringNumberGreater( String s1, String s2 )
DescriptionArbitrary precision number comparison. Returns true if s1 is greater than s2

8.11.240  stringNumberGreaterOrEqual
Signaturestatic boolean stringNumberGreaterOrEqual( String s1, String s2 )
DescriptionArbitrary precision number comparison. Returns true if s1 is >= s2

8.11.241  stringNumberLess
Signaturestatic boolean stringNumberLess( String s1, String s2 )
DescriptionArbitrary precision number comparison. Returns true if s1 is less than s2

8.11.242  stringNumberLessOrEqual
Signaturestatic boolean stringNumberLessOrEqual( String s1, String s2 )
DescriptionArbitrary precision number comparison. Returns true if s1 is <= than s2

8.11.243  stringToCDATAsection
Signature static String stringToCDATAsection( String s )
Descriptiongenerates a CDATA section holding the trimmed input 's', as long as s is not null or empty or whitespace only.

In other words, the return value will be "<![CDATA[" + s.trim() + " ]]>".

If s is null or empty or whitespace only, then the empty string is returned.

8.11.244  stringToXMLAttr
Signature static String stringToXMLAttr( String s )
DescriptionstringToXMLAttr(s) converts the input string 's' from an string value into an XML attribute, including the appropriate quotes ('' or "") and &'s etc converted to '&' etc.

This
  • chooses the correct quote type
  • replaces <& by the correct XML values
For example - the returned value is showed below *not* in Java String format, because it is easier to see without that
  • stringToXMLAttr( null ) = [ empty string ]
  • stringToXMLAttr( "" ) = [ empty string ]
  • stringToXMLAttr( "\"" ) = '"'
  • stringToXMLAttr( "'" ) = "'"
  • stringToXMLAttr( "&<\">" ) = "&amp;&lt;&quot;>"

8.11.245  stringToXMLAttrWithoutQuotes
Signature static String stringToXMLAttrWithoutQuotes( String s )
DescriptionReturned value is same as stringToXMLAttr, but without the enclosing quotes.

8.11.246  stringToXMLCharacterData
Signature static String stringToXMLCharacterData( String s )
Descriptiongenerate XML character data. If there are sensitive characters, then this adds a CDATA and then converts ]]> to a <[CDATA[...]]> sequence. If there are no sensitive characters, the input string is returned as is.

8.11.247  stringWithinCData
Signature static String stringWithinCData( String s )
Descriptiongenerate characters within a CData section.

If there are ]]> sequences, they are converted to a "]]>" + "]]&gt;" + "<
If there are no ]]> sequences, the input string is returned as is.

8.11.248  toHTML
Signaturestatic String toHTML( String inputLine )
Description'toHTML' is used to create HTML documentation from a simple layout. This is used in documenting the standard meta-models.

The conversions that are applied are:

  • adjacent non-empty lines are joined into paragraphs
  • blank lines create paragraph boundaries
  • left-justified '-' followed by whitespace creates an unnumbered list item, the start and end of the list is detected automatically
  • whitespace then '-' then whitespace creates a second-level unnumbered list item.
This is a convenience so that the descriptions can be read in the raw file or in an HTML document. See the JeeWiz metaModel, specifications directory (jeewiz/resources/JeeWiz/specification) and the JeeWiz Meta-MetaModel chapter for examples.

8.11.249  uncapitalise
Signaturestatic String uncapitalise( String inputString )
DescriptionReturns the input string as is, except that if the first letter is upper-case, it is converted to lower case.

8.11.250  uncapitaliseInitialGroup
Signaturestatic String uncapitaliseInitialGroup( String inputString )
DescriptionReturns the input string uncapitalising all but the last of a leading group of capital letters. The first two characters are always decapitalised

8.11.251  uncapitaliseSecond
Signaturestatic String uncapitaliseSecond( String inputString )
DescriptionReturns the input string as is, except that if the *second* letter is upper-case, it is converted to lower case.

8.11.252  uncapitalize
Signaturestatic String uncapitalize( String inputString )
DescriptionSynonym for uncapitalise

8.11.253  writeStringToFile( File file, String stringToWrite )
Signature static void writeStringToFile( File file, String stringToWrite )
DescriptionwriteStringToFile writes the contents of a String to a file using the default character encoding.

If the file is not successfully written, this method issues a BuildException (stopping the build).

If the parent directory for the indicated file does not exist, this method mkdir's it.

8.11.254  writeStringToFile( File file, String stringToWrite, String encoding )
Signature static void writeStringToFile( File file, String stringToWrite, String encoding )
DescriptionwriteStringToFile writes the contents of a String to a file the specified character encoding. 'encoding' must be the name of a valid encoding (e.g. 'windows-1252').

If the file is not successfully written, this method issues a BuildException (stopping the build).

If the parent directory for the indicated file does not exist, this method mkdir's it.

8.11.255  writeStringToFile( String fileName, String stringToWrite )
Signature static void writeStringToFile( String fileName, String stringToWrite )
DescriptionwriteStringToFile writes the contents of the stringToWrite parameter to a file using the default character encoding. 'fileName' is interpreted as a file name.

The output encoding is the JeeWiz output encoding - either the outputEncoding property specified at start of day or the system default if not.

If the file is not successfully written, this method issues a BuildException (stopping the build).

If the parent directory for the indicated file does not exist, this method mkdir's it.

8.11.256  writeStringToFile( String fileName, String stringToWrite, String encoding )
Signature static void writeStringToFile( String fileName, String stringToWrite, String encoding )
DescriptionwriteStringToFile writes the contents of a String to a file using the specified character encoding.

'fileName' is interpreted as a file name, and used to call writeStringToFile(file). 'encoding' must be the name of a valid encoding (e.g. 'windows-1252').

If the file is not successfully written, this method issues a BuildException (stopping the build).

If the parent directory for the indicated file does not exist, this method mkdir's it.
 


Copyright (c) 2001-2008 New Technology/enterprise Ltd.