1 12 package org.openbravo.xmlEngine; 13 14 import java.util.Vector ; 15 import java.util.Enumeration ; 16 17 import org.apache.log4j.Logger ; 18 19 class TagValue implements XmlComponentValue { 20 protected TagTemplate tagTemplate; 21 protected Vector <AttributeItemValue> attributeVectorValue; 23 static Logger log4jTagValue = Logger.getLogger(TagValue.class); 24 25 public TagValue(TagTemplate tagTemplate, XmlDocument xmlDocument) { 26 this.tagTemplate = tagTemplate; 27 attributeVectorValue = new Vector <AttributeItemValue>(); 28 for (Enumeration <AttributeItemTemplate> e1 = tagTemplate.attributeVectorTemplate.elements() ; e1.hasMoreElements();) { 29 AttributeItemTemplate attributeItemTemplate = e1.nextElement(); 30 AttributeItemValue attributeItemValue = attributeItemTemplate.createAttributeItemValue(xmlDocument); 31 attributeVectorValue.addElement(attributeItemValue); 32 log4jTagValue.debug("TagValue: " + attributeItemValue.attributeItemTemplate.name); 33 } 34 35 } 36 37 public String print() { 38 String character = ""; 39 if (tagTemplate.tag().equals("DIVFO") || tagTemplate.tag().endsWith("_TMP")) return ""; 40 character = "<" + tagTemplate.tag(); 41 for (Enumeration <AttributeItemValue> e = attributeVectorValue.elements() ; e.hasMoreElements() ;) { 42 AttributeItemValue attribute = e.nextElement(); 43 if (attribute.attributeItemTemplate.attributeBoolean) { 44 String myValue = ""; 45 try { 46 myValue = attribute.valueToCompare.print(); 47 } catch (Exception ex) { 48 myValue = ""; 49 } 50 if (attribute.value.print().equals(myValue)) { 51 character += " " + attribute.attributeItemTemplate.name; 52 } 53 } else { 54 character += attribute.print(); 55 } 56 } 57 character += ">"; 58 return character; 59 } 60 61 public String printPrevious() { 62 if (tagTemplate.tag().equals("DIVFO")) return ""; 63 String character = "<" + tagTemplate.tag(); 64 for (Enumeration <AttributeItemValue> e = attributeVectorValue.elements() ; e.hasMoreElements() ;) { 65 AttributeItemValue attribute = e.nextElement(); 66 character = character + attribute.printPrevious(); 67 } 68 character = character + ">"; 69 return character; 70 } 71 72 public String printSimple() { 74 return print(); 75 } 76 77 public String printPreviousSimple() { 78 return printPrevious(); 79 }} 80 | Popular Tags |