|
|
|
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
|
| Signature | static void addErrorMessage( String errmsg ) |
| Description | Error 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
|
| Signature | static void addPatternErrorMessage( String errmsg ) |
| Description | Extra 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 ) |
| Description | Causes 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
|
| Signature | static void addTemplateErrorMessage( String errmsg ) |
| Description | Error 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) |
| Description | addText 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 ) |
| Description | Puts a prefix->URI entry into this element's mapping (as returned by getLocalPrefixToURIMappings() ).
|
8.11.8 addUniqueCSStrings
|
| Signature | static String addUniqueCSStrings( String string1, String string2 ) |
| Description | Add 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
|
| Signature | static String appendToUniqueCSString( List uniqueList, String extraCSItems ) |
| Description | Append 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
|
| Signature | static String arrayListToCsv( ArrayList alIn, String separator, String delimiter ) |
| Description | arrayListToCsv 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
|
| Signature | static String buildCSString( List stringList ) |
| Description | Builds 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 ) |
| Description | Call 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 ) |
| Description | Call a pattern, using 'this' as the context for evaluation.
| parameters | patternFileName | the name of the file containing the pattern to fire. This is looked up in the usual way.
| | patternRootObject | the 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
|
| Signature | static String capitalise( String inputString ) |
| Description | Returns the input string as is, except that if the first letter is lower-case, it is converted to upper case.
|
8.11.15 capitalize
|
| Signature | static String capitalize( String inputString ) |
| Description | Synonym for capitalise.
|
8.11.16 checkXsdDate
|
| Signature | static String checkXsdDate( String s ) |
| Description | Checks that a string, supposedly a valid XML Date, can be converted into a Calendar object.
| parameters | s | The date string to be validated.
| | returns | The exception's error message on failure, otherwise null
|
|
8.11.17 checkXsdDateTime
|
| Signature | static String checkXsdDateTime( String s ) |
| Description | Checks that a string, supposedly a valid XML DateTime, can be converted into a Calendar object.
| parameters | s | The dateTime string to be validated.
| | returns | The exception's error message on failure, otherwise null
|
|
8.11.18 checkXsdTime
|
| Signature | static String checkXsdTime( String s ) |
| Description | Checks that a string, supposedly a valid XML Time, can be converted into a Calendar object.
| parameters | s | The time string to be validated.
| | returns | The exception's error message on failure, otherwise null
|
|
8.11.19 compareStringNumbers
|
| Signature | static int compareStringNumbers( String s1, String s2 ) |
| Description | Calls BigInteger.compareTo for BigIntegers constructed from s1 and s2
|
8.11.20 containsKey
|
| Signature | boolean containsKey( Object key ) |
| Description | returns true if the local properties contains the key
|
8.11.21 createChild
|
| Signature | BaseBuildComponent createChild( String className, String elementTag ) |
| Description | createChild 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 ) |
| Description | Create 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 ) |
| Description | createRootModelObject 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 )
|
| Signature | static ArrayList csvToArrayList( String csv ) |
| Description | Takes 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 )
|
| Signature | static ArrayList csvToArrayList( String csv, String separator, String delimiter ) |
| Description | This 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
|
| Signature | static String decapitalize( String inputString ) |
| Description | This 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 ) |
| Description | doingLogsForLevel 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 )
|
| Signature | static String dumpObject( Object objectToDump ) |
| Description | This 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 )
|
| Signature | static String dumpObject( Object objectToDump, String initialIndent, String indentIncrement ) |
| Description | This 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 ) |
| Description | Dumps 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 ) |
| Description | Removes 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 )
|
| Signature | static void exit( String errorMessage ) |
| Description | exit( 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 )
|
| Signature | static void exit( int exitStatus ) |
| Description | exit( int ) calls System.exit() with the exitStatus parameter
|
8.11.34 exit( long exitStatus )
|
| Signature | static void exit( long exitStatus ) |
| Description | exit( long ) calls System.exit() with the exitStatus parameter, throwing away any high-order bits
|
8.11.35 exit()
|
| Signature | static void exit() |
| Description | exit() calls System.exit() with a 0 exitStatus parameter - which indicates successful execution.
|
8.11.36 extraInitialiseComponent
|
| Signature | boolean extraInitialiseComponent( ArrayList alErrmsgStrings ) |
| Description | extraInitialiseComponent() 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
|
| Signature | static void fatal( String errmsg ) |
| Description | This method is a synonym for fatalErrorMessage, for the lazy.
|
8.11.38 fatalErrorMessage
|
| Signature | static void fatalErrorMessage( String errmsg ) |
| Description | This method is like addErrorMessage, but it also stops any more Velocity processing immediately.
See also "fatal".
|
8.11.39 fatalPatternErrorMessage
|
| Signature | static void fatalPatternErrorMessage( String errmsg ) |
| Description | This method is like addPatternErrorMessage, but it also stops any more Velocity processing immediately
|
8.11.40 fatalTemplateErrorMessage
|
| Signature | static void fatalTemplateErrorMessage( String errmsg ) |
| Description | This method is like addTemplateErrorMessage, but it also stops any more Velocity processing immediately
|
8.11.41 fileIsAbsolute
|
| Signature | static boolean fileIsAbsolute( String path ) |
| Description | Returns true if the input path represents an absolute.file.
This also
|
8.11.42 firstIndexOf
|
| Signature | static int firstIndexOf( String source, String findChars ) |
| Description | Search 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
|
| Signature | static String firstLetterCaps( String inputString ) |
| Description | Synonym for capitalise.
|
8.11.44 firstValue( String s1, String s2 )
|
| Signature | static String firstValue( String s1, String s2 ) |
| Description | Returns 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 )
|
| Signature | static String firstValue( String s1, String s2, String s3 ) |
| Description | Returns 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 )
|
| Signature | static String formatNumericString( String str ) |
| Description | formatNumericString 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 )
|
| Signature | static String formatNumericString( String str, Locale locale ) |
| Description | formatNumericString 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 ) |
| Description | formatXML 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) |
| Description | This 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 ) |
| Description | Get 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 )
|
| Signature | static String getAbsolutePath( File f ) |
| Description | Returns Java's File.getAbsolutePath() value for the input file.
If the input file is null, this returns null.
|
8.11.52 getAbsolutePath( String s )
|
| Signature | static String getAbsolutePath( String s ) |
| Description | Uses 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() |
| Description | Get 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() |
| Description | getAllPrefixToURIMappings() 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() |
| Description | This 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 ) |
| Description | getAttributeOrProperty 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() |
| Description | Gets 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 ) |
| Description | Gets 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
|
| Signature | static String getBasename( String path ) |
| Description | Get 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
|
| Signature | static Boolean getBooleanFalse() |
| Description | returns 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
|
| Signature | static Boolean getBooleanTrue() |
| Description | returns 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 )
|
| Signature | static String getCanonicalPath( File f ) |
| Description | Returns Java's File.getCanonicalPath.
If the input file is null or getCanonicalPath throws an exception, this returns null.
|
8.11.63 getCanonicalPath( String fileName )
|
| Signature | static String getCanonicalPath( String fileName ) |
| Description | Returns 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 ) |
| Description | getCapsAndSeparatorName 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 ) |
| Description | getCapsAndSpacesName 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 ) |
| Description | getCapsAndUnderscoreName 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
|
| Signature | static int getCharacterCount( String s, String c ) |
| Description | Gets 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() |
| Description | Get 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 ) |
| Description | Construct 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) |
| Description | Construct 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 ) |
| Description | Construct 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 ) |
| Description | Construct 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 ) |
| Description | Construct 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 ) |
| Description | Returns 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 ) |
| Description | getContainingBCByType looks for a containing buildcomponent object that is of the passed-in type, or inherits from it.
| parameters | classToFind | can 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() |
| Description | Get 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() |
| Description | Get 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
|
| Signature | static long getCurrentTimeMillis() |
| Description | getCurrentTimeMillis() 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 ) |
| Description | getDelegatedProperty 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 ) |
| Description | getDelegatedPropertyFromAbove 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
|
| Signature | static String getDirname( String path ) |
| Description | Get 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
|
| Signature | static String getEOLString( String inputString ) |
| Description | getEOLString 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 )
|
| Signature | static File getFile( File dir, String fileName ) |
| Description | Returns a Java File from the fileName, i.e. 'new File( dir, fileName )'.
|
8.11.85 getFile( String path )
|
| Signature | static File getFile( String path ) |
| Description | Returns a Java File from the path, i.e. 'new File( path )'.
|
8.11.86 getFileSeparator
|
| Signature | static String getFileSeparator() |
| Description | Returns the file separator, either '/' for UNIX or '\' for Windows.
|
8.11.87 getFinalElementTag
|
| Signature | String getFinalElementTag() |
| Description | Returns 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
|
| Signature | static String getFirstPieceOf( String inputString, String separator ) |
| Description | getFirstPieceOf gets the first piece of the inputString - this variant takes a string to delimit the pieces rather than a character.
| parameters | inputString | the string to be broken apart
| | separator | the separator that defines the pieces.
The separator can be any non-empty string, although normally it is a single character of punctuation.
| | returns | the 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() |
| Description | Gets 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
|
| Signature | static boolean getIsDOS() |
| Description | Returns true if on DOS (Windows)
|
8.11.91 getIsUNIX
|
| Signature | static boolean getIsUNIX() |
| Description | Returns true if on UNIX or Linux.
|
8.11.92 getIsWindows
|
| Signature | static boolean getIsWindows() |
| Description | Returns true if on Windows
|
8.11.93 getJWControlManager
|
| Signature | JWControlManager getJWControlManager() |
| Description | Returns 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() |
| Description | Returns the metaClass's type as a single name, in Java class format (e.g. 'BusinessObject').
|
8.11.95 getJavaClassName()
|
| Signature | String getJavaClassName() |
| Description | Returns 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 )
|
| Signature | static String getJavaClassName( String inputName ) |
| Description | Converts 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:
- capitalise the first character of the name
- find disallowed characters - XML characters that are not allowed in Java ('.', ':' and '-')
- remove these characters and capitalise the next character, if any
- 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
|
| Signature | static String getJavaName( String inputName, boolean capitaliseFirstCharacter ) |
| Description | Converts 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() |
| Description | Returns the metaClass's type as a single name, in Java variable format (e.g. 'businessObject')
|
8.11.99 getJavaVarName()
|
| Signature | String getJavaVarName() |
| Description | Returns 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 )
|
| Signature | static String getJavaVarName( String inputName ) |
| Description | Converts 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 ) |
| Description | get 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
|
| Signature | static String getLastPieceOf( String inputString, String separator ) |
| Description | getLastPieceOf gets the last piece of the inputString
| parameters | inputString | the string to be broken apart
| | separator | the separator character that defines the pieces.
The separator can be any non-empty string, although normally it is a single character of punctuation.
| | returns | the substring of inputString after the last occurrence of separator, of, if there is none, the input string
|
|
8.11.103 getLineSeparator
|
| Signature | static String getLineSeparator() |
| Description | Returns the appropriate line separator for UNIX (\n) or Windows (\r\n).
|
8.11.104 getLocalName
|
| Signature | static String getLocalName( String qName ) |
| Description | Returns 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() |
| Description | This 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() |
| Description | Gets 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() |
| Description | getName() 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() |
| Description | Returns 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() |
| Description | A synonym for getNameCapitalised().
|
8.11.110 getNewArrayList( Collection c )
|
| Signature | static ArrayList getNewArrayList( Collection c ) |
| Description | Returns 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 )
|
| Signature | static ArrayList getNewArrayList( int n ) |
| Description | Returns 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()
|
| Signature | static ArrayList getNewArrayList() |
| Description | Returns a new ArrayList (i.e. a short-hand for using 'getClassInstance( "java.util.ArrayList" )').
|
8.11.113 getNewControl( String templateName )
|
| Signature | static Jwcontrol getNewControl( String templateName ) |
| Description | Returns a new Jwcontrol, specifically for getting an object that can invoke methods.
| parameters | templateName | the name of the control.
This must exactly match the basename of the .control file which defined the control.
| | throws | RuntimeException | If 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 )
|
| Signature | static Jwcontrol getNewControl( String xmlTemplateName, Map map ) |
| Description | Returns a new Jwcontrol, specifically for getting an object that can invoke methods.
| parameters | templateName | the name of the control.
This must exactly match the basename of the .control file which defined the control.
| | map | The 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.
| | throws | RuntimeException | If 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 )
|
| Signature | static Jwcontrol getNewControl( String xmlTemplateName, String propertiesString ) |
| Description | Returns a new Jwcontrol, specifically for getting an object that can invoke methods.
| parameters | templateName | the name of the control.
This must exactly match the basename of the .control file which defined the control.
| | propertiesString | A 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.
| | throws | RuntimeException | If 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()
|
| Signature | static Jwcontrol getNewControl() |
| Description | This 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 )
|
| Signature | static HashMap getNewHashMap( Map m ) |
| Description | Returns 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()
|
| Signature | static HashMap getNewHashMap() |
| Description | Returns a new HashMap (i.e. a short-hand for using 'getClassInstance( "java.util.HashMap" )').
|
8.11.119 getNewListMap
|
| Signature | static ListMap getNewListMap() |
| Description | Returns 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 )
|
| Signature | static TreeMap getNewTreeMap( Map m ) |
| Description | Returns 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()
|
| Signature | static TreeMap getNewTreeMap() |
| Description | Returns a new TreeMap (i.e. a short-hand for using 'getClassInstance( "java.util.TreeMap" )').
|
8.11.122 getNull
|
| Signature | static String getNull() |
| Description | This returns a null, as an easy way to get a null value in Velocity - use $null.
|
8.11.123 getOriginalElementTag
|
| Signature | String getOriginalElementTag() |
| Description | Returns 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() |
| Description | getParentBC 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
|
| Signature | static String getPathSeparator() |
| Description | Returns the path separator, either ':' for UNIX or ';' for Windows.
|
8.11.126 getPatternXmlDeclaration
|
| Signature | String getPatternXmlDeclaration() |
| Description | This 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 )
|
| Signature | static String getPieceOf( String inputString, String leftSeparator, String rightSeparator ) |
| Description | getPieceOf 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.
| parameters | inputString | the string to be broken apart
| | leftSeparator | the separator character that defines the pieces.
In fact, this can be any non-empty string, although normally it is a single-character punctuation.
| | returns | the 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 )
|
| Signature | static String getPieceOf( String inputString, String separator, int pieceNumber ) |
| Description | getPieceOf in this form gets a numbered piece of a string.
For example getPieceOf( "a,b,c", ",", 2 ) returns "b".
| parameters | inputString | the string to be broken apart
| | separator | the 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.
| | pieceNumber | the 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.
| | returns | the 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 )
|
| Signature | static ArrayList getPieces( String inputString, String separator ) |
| Description | getPieces 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.
| returns | null 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 )
|
| Signature | static ArrayList getPieces( String inputString, String separator, boolean removeEmptyPieces ) |
| Description | getPieces 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.
| returns | null 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 )
|
| Signature | static String getPlatformPath( File f ) |
| Description | Returns 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 )
|
| Signature | static String getPlatformPath( String fileName ) |
| Description | Returns 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
|
| Signature | static String getPreLastPieceOf( String inputString, String separator ) |
| Description | getPreLastPieceOf gets the pieces of the inputString before the last.
| parameters | inputString | the string to be broken apart
| | separator | the separator character that defines the pieces.
The separator can be any non-empty string, although normally it is a single character of punctuation.
| | returns | null 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
|
| Signature | static String getPrefix( String qName ) |
| Description | Return 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() |
| Description | Returns 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 )
|
| Signature | static String getRelativePath( String path, String baseDirectory ) |
| Description | getRelativePath 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 )
|
| Signature | static String getRelativePath( String path, String baseDirectory, int nLevels ) |
| Description | getRelativePath 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 )
|
| Signature | static String getRelativePathBS( String path, String baseDirectory ) |
| Description | Returns 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 )
|
| Signature | static String getRelativePathBS( String path, String baseDirectory, int nLevels ) |
| Description | Returns 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() |
| Description | Takes 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
|
| Signature | static String getResolvedPathFrom( String path, String baseDir ) |
| Description | The 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() |
| Description | This 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() |
| Description | Gets 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( ) |
| Description | Converts 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
|
| Signature | static String getSingleLineText( String description ) |
| Description | This 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() |
| Description | Get 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() |
| Description | returns 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() |
| Description | getTemplate() 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() |
| Description | returns 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() |
| Description | getText 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() |
| Description | Returns 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 ) |
| Description | Looks 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 ) |
| Description | Looks 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 ) |
| Description | This 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() |
| Description | This 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 ) |
| Description | getUniqueKey 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 ) |
| Description | getUniqueKey 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 )
|
| Signature | static String getUnixPath( File f ) |
| Description | Returns 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 )
|
| Signature | static String getUnixPath( String fileName ) |
| Description | Creates 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() |
| Description | This 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 )
|
| Signature | static String getWindowsPath( File f ) |
| Description | Returns 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 )
|
| Signature | static String getWindowsPath( String fileName ) |
| Description | Creates 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() |
| Description | Returns the metaClass's type as a single name, in XML element format (e.g. 'business-object')
|
8.11.164 getXMLName
|
| Signature | static String getXMLName( String inputName ) |
| Description | Synonym for 'getXmlName'
|
8.11.165 getXmlDump( String indent )
|
| Signature | String getXmlDump( String indent ) |
| Description | As per getXmlDump() but indented by the 'indent' string, which should be whitespace
|
8.11.166 getXmlDump()
|
| Signature | String getXmlDump() |
| Description | Returns 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 ) |
| Description | getXmlLocalPart 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() |
| Description | Returns 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 )
|
| Signature | static String getXmlName( String inputName ) |
| Description | Converts 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 ) |
| Description | getXmlPrefix 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() |
| Description | Gets 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() |
| Description | Gets 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 ) |
| Description | Gets an XML Schema date string into a calendar object.
| parameters | s | The date, in YYYY-MM-DD format, optionally followed by a timezone specification.
| | throws | IllegalArgumentException | if the input string is not a timezone format, or empty
| | returns | The 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 ) |
| Description | Gets an XML Schema dateTime string into a calendar object.
| parameters | s | The dateTime, in YYYY-MM-DDTHH:MM:SS[.sss] format, optionally followed by a timezone specification.
| | throws | IllegalArgumentException | if the input string is not a valid dateTime.
| | returns | The Calendar object with all fields set.
|
|
8.11.175 getXsdTimeAsCalendar
|
| Signature | static Calendar getXsdTimeAsCalendar( String sIn ) |
| Description | Gets an XML Schema time string into a calendar object.
| parameters | s | The 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.
| | throws | IllegalArgumentException | if the input string is not a timezone format, or empty
| | returns | The 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 ) |
| Description | initialiseComponent() 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 ) |
| Description | Returns 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 ) |
| Description | Returns 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 ) |
| Description | isInstanceOf 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
|
| Signature | static String leftJustify( String s, int n ) |
| Description | Returns a string 'n' spaces long, up to a maximum of 600 or so.
|
8.11.181 list
|
| Signature | static String list( String input, String separator, String addon ) |
| Description | Returns 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 )
|
| Signature | static String log( String indentation, String stringToLog ) |
| Description | Logs 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 )
|
| Signature | static String log( String indentation, String stringToLog, int logLevel ) |
| Description | Logs a message to the standard logging stream, explicitly specifying the indentation and logging level.
|
8.11.184 log( String s )
|
| Signature | static String log( String s ) |
| Description | Logs 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 )
|
| Signature | static String log( String s, boolean messageOnlyFlag ) |
| Description | Logs 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 )
|
| Signature | static String log( String s, int logLevel ) |
| Description | Logs 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:
- = error
- = warning
- = info
- = verbose
- = debug
These values are also defined in antLogLevel* properties in resources/base/control/system.properties
|
8.11.187 logError( String indentation, String s )
|
| Signature | static String logError( String indentation, String s ) |
| Description | Logs an error message explicitly specifying the left-hand indentation (which defaults to 5 spaces).
|
8.11.188 logError( String s )
|
| Signature | static String logError( String s ) |
| Description | Logs 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 ) |
| Description | This 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 ) |
| Description | This 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 )
|
| Signature | static String logObject( Object objectToDump, String initialIndent, String indentIncrement ) |
| Description | This method dumps the object using 'dumpObject' and then logs it using 'log'.
|
8.11.192 lowerCaseOnSecond
|
| Signature | static String lowerCaseOnSecond( String inputString ) |
| Description | Returns 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 ) |
| Description | returns 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() |
| Description | onInstantiation() 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) |
| Description | parseFormat - Similar to parseFormat in the uiBase jwControl, this is to make the same functionality available for .vms
| parameters | format, | 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
| | returns | String returns the value of the relevant format term.
|
|
8.11.196 preInitialiseComponent
|
| Signature | boolean preInitialiseComponent( ArrayList alErrmsgStrings ) |
| Description | preInitialiseComponent() 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
|
| Signature | static String processSpecialCharacters( String resultString ) |
| Description | Processes 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) |
| Description | Puts 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 ) |
| Description | Reads '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 ) |
| Description | readFileAsLines 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 ) |
| Description | Reads '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 ) |
| Description | readFileAsString 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 ) |
| Description | Reads 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 ) |
| Description | Reads 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 ) |
| Description | readPropertiesFile 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 ) |
| Description | readPropertiesFile 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
|
| Signature | static void removeCSListDuplicates( List list ) |
| Description | Removes any duplicate or null strings from 'list' - an ArrayList containing strings or CDataAttribute objects
|
8.11.208 removeChars
|
| Signature | static String removeChars( String data, String unwantedChars ) |
| Description | Remove 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
|
| Signature | static String removePunctuationAndCapitalise( String inputString ) |
| Description | removePunctuationAndCapitalise 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
|
| Signature | static String removeSpaces(String s) |
| Description | Converts a string with spaces to one without. E.g. 'My old String' becomes MyoldString'
|
8.11.211 removeSpacesCapitalise
|
| Signature | static String removeSpacesCapitalise(String s) |
| Description | Converts 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
|
| Signature | static String removeSpacesProperCase(String s) |
| Description | Converts 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
|
| Signature | static String removeString( String inputString, String separators ) |
| Description | removeString 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
|
| Signature | static String removeStringNoCapital( String inputString, String separators ) |
| Description | Takes 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 ) |
| Description | Renders 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() |
| Description | Gives a line-by-line dump of getAllPrefixToURIMappings(), suitable for error messages.
|
8.11.217 resetPatternErrorMessages
|
| Signature | static void resetPatternErrorMessages() |
| Description | Normally 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
|
| Signature | static String rightJustify( String s, int n ) |
| Description | Returns 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
|
| Signature | static String separateByCapitals( String inputString ) |
| Description | This 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 ) |
| Description | setNextPattern 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 ) |
| Description | Sets 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 ) |
| Description | This 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) |
| Description | setText 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 ) |
| Description | Normally 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 ) |
| Description | This 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 ) |
| Description | Sleep for a certain number of milliseconds.
This ignores InterruptedException's.
|
8.11.229 spaces( String s )
|
| Signature | static String spaces( String s ) |
| Description | Returns 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 )
|
| Signature | static String spaces( int n ) |
| Description | Returns 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
|
| Signature | static String spaces1( int n ) |
| Description | Returns 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
|
| Signature | static ArrayList splitCSString( String csString ) |
| Description | Splits 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
|
| Signature | static ArrayList splitCSStringWithoutDuplicates( String csString ) |
| Description | Builds 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 )
|
| Signature | static ArrayList splitSeparatorString( String stringToSplit, String delimiters ) |
| Description | Splits 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 )
|
| Signature | static ArrayList splitSeparatorString( String stringToSplit, String delimiters, boolean returnDelims ) |
| Description | Splits 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
|
| Signature | static ArrayList splitStringIntoTwo( String stringToSplit, String separatorString ) |
| Description | splitStringIntoTwo() 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() |
| Description | Stops the build right now, without error.
|
8.11.238 stringNumberEqual
|
| Signature | static boolean stringNumberEqual( String s1, String s2 ) |
| Description | Arbitrary precision number comparison. Returns true if s1 is numerically equal to s2
|
8.11.239 stringNumberGreater
|
| Signature | static boolean stringNumberGreater( String s1, String s2 ) |
| Description | Arbitrary precision number comparison. Returns true if s1 is greater than s2
|
8.11.240 stringNumberGreaterOrEqual
|
| Signature | static boolean stringNumberGreaterOrEqual( String s1, String s2 ) |
| Description | Arbitrary precision number comparison. Returns true if s1 is >= s2
|
8.11.241 stringNumberLess
|
| Signature | static boolean stringNumberLess( String s1, String s2 ) |
| Description | Arbitrary precision number comparison. Returns true if s1 is less than s2
|
8.11.242 stringNumberLessOrEqual
|
| Signature | static boolean stringNumberLessOrEqual( String s1, String s2 ) |
| Description | Arbitrary precision number comparison. Returns true if s1 is <= than s2
|
8.11.243 stringToCDATAsection
|
| Signature | static String stringToCDATAsection( String s ) |
| Description | generates 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 ) |
| Description | stringToXMLAttr(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( "&<\">" ) = "&<">"
|
8.11.245 stringToXMLAttrWithoutQuotes
|
| Signature | static String stringToXMLAttrWithoutQuotes( String s ) |
| Description | Returned value is same as stringToXMLAttr, but without the enclosing quotes.
|
8.11.246 stringToXMLCharacterData
|
| Signature | static String stringToXMLCharacterData( String s ) |
| Description | generate 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 ) |
| Description | generate characters within a CData section.
If there are ]]> sequences, they are converted to a "]]>" + "]]>" + "< If there are no ]]> sequences, the input string is returned as is.
|
8.11.248 toHTML
|
| Signature | static 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
|
| Signature | static String uncapitalise( String inputString ) |
| Description | Returns the input string as is, except that if the first letter is upper-case, it is converted to lower case.
|
8.11.250 uncapitaliseInitialGroup
|
| Signature | static String uncapitaliseInitialGroup( String inputString ) |
| Description | Returns 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
|
| Signature | static String uncapitaliseSecond( String inputString ) |
| Description | Returns the input string as is, except that if the *second* letter is upper-case, it is converted to lower case.
|
8.11.252 uncapitalize
|
| Signature | static String uncapitalize( String inputString ) |
| Description | Synonym for uncapitalise
|
8.11.253 writeStringToFile( File file, String stringToWrite )
|
| Signature | static void writeStringToFile( File file, String stringToWrite ) |
| Description | writeStringToFile 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 ) |
| Description | writeStringToFile 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 ) |
| Description | writeStringToFile 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 ) |
| Description | writeStringToFile 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.
| |