com.ebasetech.ufs.utility
Class FieldSubstituter

java.lang.Object
  extended bycom.ebasetech.ufs.utility.FieldSubstituter

public class FieldSubstituter
extends java.lang.Object


Field Summary
private  FieldNameResolver source
           
private  java.lang.String substitutionString
           
 
Constructor Summary
FieldSubstituter(FieldNameResolver source, java.lang.String substitutionString)
           
 
Method Summary
static boolean checkSubstitutions(java.util.Hashtable fields, java.lang.String inString, java.lang.String screenField, FieldNameResolver source, DesignerApplet applet)
          Check that resource fields exist for variables within the passed string.
static java.util.List getFieldNamesFromString(java.lang.String inString, FieldNameResolver source)
           
 boolean hasFields(java.lang.String inString)
           
 java.lang.String substitute(java.lang.String inString)
          Method : substitute Description : replaces references to fields with the field values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

source

private FieldNameResolver source

substitutionString

private java.lang.String substitutionString
Constructor Detail

FieldSubstituter

public FieldSubstituter(FieldNameResolver source,
                        java.lang.String substitutionString)
Method Detail

hasFields

public boolean hasFields(java.lang.String inString)

substitute

public java.lang.String substitute(java.lang.String inString)
                            throws com.ebasetech.ufs.kernel.InvalidSubstitutionException
Method : substitute Description : replaces references to fields with the field values. A field to be replaced is enclosed within control character sequences identified by the constants replacementStartString and replacementEndString. Any number of replacements can be made in a single pass. e.g. &&field1 will be replaced with the value of field1 enclosed within single quotes if so requested WHERE GROUP_ID = &&field1 becomes.... WHERE GROUP_ID = 'abcde' (where abcde is the value of field1) This is the mail text for customer ID &&custid becomes This is the mail text for customer ID 444-5678 (where 444-5678 is the value of custid) A variable can also be enclosed in curly brackets e.g. &&{MYVAR}. In this case, the value substituted from MYVAR is never enclosed in quotes (this applies only to database resources and lists). e.g. where CUSTOMER_NAME = &&CUSTOMER_NAME will normally be quoted if CUSTOMER_NAME is a character type... where CUSTOMER_NAME = 'VODAFONE' however, where CUSTOMER_NAME like '%&&{CUSTOMER_NAME}%' will become .... where CUSTOMER_NAME like '%VODAFONE%' Parameters : text to be replaced Returns : replaced text - strings substituted without problem null - strings could not be substituted. Reasons could be : normal - dependent field has a null value and is optional abnormal - dependent field referenced does not exist in source_fields/mappings - syntax error in replacement string FormException:dependent field has a null value and is mandatory Change log ********************************************************************************** 28/07/2001 * Jon * Initial setup 09/11/2001 * Hovik * Added encloseInQuotes parameter Introduced Mandatory source_fields. 21/11/2001 * Hovik * All the following situations are handled - Error to the user Referenced field is not a Source Field Referenced field does not have a corresponding Field Mapping Referenced field is mandatory, but has no value 18/12/2001 * Hovik * boolean encloseInQuotes is redundant. Field substitution now performed by convertInternalToSource(). 07/01/2002 * Hovik * parameters are now denoted by leading && (ParameterSubstitutionString) 18/03/2003 * Jon * resource field names no longer converted to upper case 20/03/2003 * Jon * search first for a resource field with the specified name. If * * not found, then try the name in upper case 16/05/2006 * Jon * Refactored from Source/DBSource/DynamicList.substituteFieldValues() * * Allow curly brackets i.e. &&{MYVAR} **********************************************************************************

Throws:
com.ebasetech.ufs.kernel.InvalidSubstitutionException

checkSubstitutions

public static boolean checkSubstitutions(java.util.Hashtable fields,
                                         java.lang.String inString,
                                         java.lang.String screenField,
                                         FieldNameResolver source,
                                         DesignerApplet applet)
Check that resource fields exist for variables within the passed string. If not, issue an error message and return false. Change log ************************************************************************************ 18/03/2003 * Jon * Field names no longer converted to upper case 20/03/2003 * Jon * If name not found as specified, try in upper case 12/08/2003 * Jon * Support field names containing spaces within [] 16/05/2005 * Jon * Moved from DesignerHelper and added support for curly brackets ************************************************************************************


getFieldNamesFromString

public static java.util.List getFieldNamesFromString(java.lang.String inString,
                                                     FieldNameResolver source)
                                              throws com.ebasetech.ufs.kernel.InvalidSubstitutionException
Throws:
com.ebasetech.ufs.kernel.InvalidSubstitutionException