1 12 package org.openbravo.xmlEngine; 13 14 import org.openbravo.utils.Replace; 15 16 import java.util.Enumeration ; 17 18 class ParameterValue implements XmlComponentValue { 19 String strValue = null; 20 ParameterTemplate parameterTemplate; 21 XmlComponentValue xmlComponentValue = null; 22 23 24 public ParameterValue(ParameterTemplate ParameterTemplate, XmlDocument xmlDocument) { 25 this.parameterTemplate = ParameterTemplate; 26 } 27 28 public void setXmlComponentValue(XmlDocument xmlDocument) { 29 if (parameterTemplate.xmlComponentTemplate != null) { 30 xmlComponentValue = parameterTemplate.xmlComponentTemplate.createXmlComponentValue(xmlDocument.parentXmlDocument); 31 } 32 } 33 34 private String replace(String strIni) { 35 if (parameterTemplate.vecReplace != null) { 36 String strFin = strIni; 37 for (Enumeration <ReplaceElement> e = parameterTemplate.vecReplace.elements() ; e.hasMoreElements();) { 38 ReplaceElement replaceElement = e.nextElement(); 39 strFin = Replace.replace(strFin, replaceElement.replaceWhat, replaceElement.replaceWith); 40 } 41 return strFin; 42 } else { 43 return strIni; 44 } 45 } 46 47 48 public void setValue(String strValue) { 49 this.strValue = replace(strValue); 50 } 51 52 public String print() { 53 if (xmlComponentValue != null) { 54 return xmlComponentValue.print(); 55 } else { 56 return strValue; 57 } 58 } 59 60 public String printPrevious() { 61 if (xmlComponentValue != null) { 62 return xmlComponentValue.printPrevious(); 63 } else { 64 return strValue; 65 } 66 } 67 68 public String printSimple() { 69 if (xmlComponentValue != null) { 70 return xmlComponentValue.printSimple(); 71 } else { 72 return strValue; 73 } 74 } 75 76 public String printPreviousSimple() { 77 if (xmlComponentValue != null) { 78 return xmlComponentValue.printPreviousSimple(); 79 } else { 80 return strValue; 81 } 82 } 83 } 84 | Popular Tags |