1 12 package org.openbravo.xmlEngine; 13 14 import org.apache.log4j.Logger ; 15 16 23 class XmlThreeTemplate implements XmlComponentTemplate { 24 protected XmlThreeTemplate xmlBegin = null; 25 protected boolean isBeginXmlThreeTemplate = false; 26 protected String stringBegin; 27 protected XmlComponentTemplate xmlMiddle = null; 28 protected XmlThreeTemplate xmlEnd = null; 29 protected boolean isEndXmlThreeTemplate = false; 30 protected String stringEnd; 31 static Logger log4jXmlThreeTemplate = Logger.getLogger(XmlThreeTemplate.class); 32 33 public XmlThreeTemplate() {} 34 35 public XmlThreeTemplate(String character) { 36 log4jXmlThreeTemplate.debug("constructor with parameter:" + character); 37 stringBegin = character; 38 } 39 40 public XmlThreeTemplate(XmlComponentTemplate xmlComponentTemplate) { 41 xmlMiddle = xmlComponentTemplate; 42 } 43 44 public XmlThreeTemplate(String characterBegin, XmlComponentTemplate xmlComponentTemplate, String characterEnd) { 45 stringBegin = characterBegin; 46 stringEnd = characterEnd; 47 xmlMiddle = xmlComponentTemplate; 48 log4jXmlThreeTemplate.debug("constructor with stringBegin: " + stringBegin + " stringEnd: " + stringEnd); 49 } 50 51 public String printStringBegin () { 52 return stringBegin; 53 } 54 55 public String printStringEnd () { 56 return stringEnd; 57 } 58 59 public void replace(AttributeComponentTemplate attributeComponentTemplate) { 60 if (isBeginXmlThreeTemplate) { 61 xmlBegin.replace(attributeComponentTemplate); 62 } else { 63 if (stringBegin != null) { 64 int index = stringBegin.indexOf(attributeComponentTemplate.replace()); 65 if (index != -1) { 66 xmlBegin = new XmlThreeTemplate(stringBegin.substring(0,index), 67 attributeComponentTemplate.xmlComponentTemplate(), 68 stringBegin.substring(index + attributeComponentTemplate.replace().length())); 69 isBeginXmlThreeTemplate = true; 70 } 71 } 72 } 73 if (isEndXmlThreeTemplate) { 74 xmlEnd.replace(attributeComponentTemplate); 75 } else { 76 if (stringEnd != null) { 77 int index = stringEnd.indexOf(attributeComponentTemplate.replace()); 78 if (index != -1) { 79 xmlEnd = new XmlThreeTemplate(stringEnd.substring(0,index), 80 attributeComponentTemplate.xmlComponentTemplate(), 81 stringEnd.substring(index + attributeComponentTemplate.replace().length())); 82 isEndXmlThreeTemplate = true; 83 } 84 } 85 } 86 } 87 88 public XmlThreeValue createXmlThreeValue(XmlDocument xmlDocument) { 89 return new XmlThreeValue(this, xmlDocument); 90 } 91 public XmlComponentValue createXmlComponentValue(XmlDocument xmlDocument) { 92 return new XmlThreeValue(this, xmlDocument); 93 } 94 95 } 96
| Popular Tags
|