KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openbravo > xmlEngine > FieldTemplate


1 /*
2  ************************************************************************************
3  * Copyright (C) 2001-2006 Openbravo S.L.
4  * Licensed under the Apache Software License version 2.0
5  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6  * Unless required by applicable law or agreed to in writing, software distributed
7  * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
8  * CONDITIONS OF ANY KIND, either express or implied. See the License for the
9  * specific language governing permissions and limitations under the License.
10  ************************************************************************************
11 */

12 package org.openbravo.xmlEngine;
13
14 import java.util.Vector JavaDoc;
15 import java.text.DecimalFormat JavaDoc;
16
17 import org.apache.log4j.Logger ;
18
19 class FieldTemplate implements XmlComponentTemplate, IDComponent {
20   private String JavaDoc fieldName;
21   int type = FIELD;
22   DecimalFormat JavaDoc formatOutput;
23   DecimalFormat JavaDoc formatSimple;
24   Vector JavaDoc vecReplace;
25
26   static Logger log4jFieldTemplate = Logger.getLogger(FieldTemplate.class);
27
28   public FieldTemplate(String JavaDoc fieldName, DecimalFormat JavaDoc formatOutput, DecimalFormat JavaDoc formatSimple,
29       Vector JavaDoc vecReplace) { //, StructureSQL structureSQL) {
30
this.fieldName = fieldName;
31     this.formatOutput = formatOutput;
32     this.formatSimple = formatSimple;
33     this.vecReplace = vecReplace;
34   }
35
36   public int type() {
37     return type;
38   }
39
40   public String JavaDoc name() {
41     return fieldName;
42   }
43
44   /* CHX
45      public FieldValue createFieldValue(XmlDocument xmlDocument) {
46      for (Enumeration e1 = xmlDocument.hasDataValue.elements() ; e1.hasMoreElements();) {
47      DataValue dataValue = (DataValue)e1.nextElement();
48      for (Enumeration e2 = dataValue.vecFieldValue.elements() ; e2.hasMoreElements();) {
49      FieldValue fieldValue = (FieldValue)e2.nextElement();
50      log4jFieldTemplate.debug("Comparing: " + fieldName + " & " + fieldValue.fieldTemplate.name());
51      if (fieldValue.fieldTemplate.name().equals(fieldName)) {
52      return fieldValue;
53      }
54      }
55      }
56      log4jFieldTemplate.info("New FieldValue: " + fieldName);
57      FieldValue fieldValue = new FieldValue(this, xmlDocument);
58      return fieldValue;
59      }
60      */

61   //CHX
62
public FieldValue createFieldValue(XmlDocument xmlDocument) {
63     FieldValue fieldValue = (FieldValue)xmlDocument.hasXmlComponentValue.get(this);
64     if (fieldValue == null) {
65       fieldValue = new FieldValue(this, xmlDocument);
66       xmlDocument.hasXmlComponentValue.put(this, fieldValue);
67     }
68     return fieldValue;
69   }
70
71   public XmlComponentValue createXmlComponentValue(XmlDocument xmlDocument) {
72     return createFieldValue(xmlDocument);
73   }
74   }
75
Popular Tags