1 12 package org.openbravo.xmlEngine; 13 14 import java.text.DecimalFormat ; 15 16 import org.apache.log4j.Logger ; 17 18 class FunctionTemplate implements XmlComponentTemplate, IDComponent { 19 protected String fieldName; 20 protected FieldTemplate fieldTemplate; 21 DecimalFormat formatOutput; 22 DecimalFormat formatSimple; 23 public DataTemplate dataTemplate; 24 protected XmlComponentTemplate arg1Template; 25 protected XmlComponentTemplate arg2Template; 26 27 static Logger log4jFunctionTemplate = Logger.getLogger(FunctionTemplate.class); 28 29 public FunctionTemplate() {} 30 31 public FunctionTemplate(String fieldName, FieldTemplate field, 32 DecimalFormat formatOutput, DecimalFormat formatSimple, DataTemplate dataTemplate) { 33 this.fieldName = fieldName; 34 this.fieldTemplate = field; 35 this.formatOutput = formatOutput; 36 this.formatSimple = formatSimple; 37 this.dataTemplate = dataTemplate; 38 } 39 40 public FunctionTemplate(String fieldName, DecimalFormat formatOutput, DecimalFormat formatSimple, 41 DataTemplate dataTemplate, XmlComponentTemplate arg1, XmlComponentTemplate arg2) { 42 this.fieldName = fieldName; this.formatOutput = formatOutput; 44 this.formatSimple = formatSimple; 45 this.dataTemplate = dataTemplate; 46 this.arg1Template = arg1; 47 this.arg2Template = arg2; 48 } 49 50 public int type() { 51 return FUNCTION; 52 } 53 54 public String printFormatOutput(double value) { 55 if (formatOutput != null) { 56 return formatOutput.format(value); 57 } else { 58 return Double.toString(value); 59 } 60 } 61 62 public String printFormatSimple(double value) { 63 if (formatSimple != null) { 64 return formatSimple.format(value); 65 } else { 66 return Double.toString(value); 67 } 68 } 69 70 public FunctionValue createFunctionValue(XmlDocument xmlDocument) {return null;} 71 72 98 public FunctionValue searchFunction(XmlDocument xmlDocument) { 100 FunctionValue functionValue = (FunctionValue)xmlDocument.hasXmlComponentValue.get(this); 101 return functionValue; 102 } 103 104 public XmlComponentValue createXmlComponentValue(XmlDocument xmlDocument) { 105 return createFunctionValue(xmlDocument); 106 } 107 108 } 109
| Popular Tags
|