KickJava   Java API By Example, From Geeks To Geeks.

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


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 class AttributeItemValue {
15   protected AttributeItemTemplate attributeItemTemplate;
16   XmlThreeValue value;
17   XmlComponentValue valueToCompare = null;
18
19   public AttributeItemValue(AttributeItemTemplate attributeItemTemplate, XmlDocument xmlDocument) {
20     this.attributeItemTemplate = attributeItemTemplate;
21     value = attributeItemTemplate.valueTemplate.createXmlThreeValue(xmlDocument);
22     if (attributeItemTemplate.valueToCompareTemplate != null) {
23       valueToCompare = attributeItemTemplate.valueToCompareTemplate.createXmlComponentValue(xmlDocument);
24     }
25   }
26
27   String JavaDoc print() {
28     if (attributeItemTemplate.name.equals("id") && value.print().startsWith("field")) {
29       return "";
30     } else {
31       return " " + attributeItemTemplate.name + "=\"" + value.print() +"\"";
32     }
33   }
34   String JavaDoc printPrevious() {
35     if (attributeItemTemplate.name.equals("id") && value.printPrevious().startsWith("field")) {
36       return "";
37     } else {
38       return " " + attributeItemTemplate.name + "=\"" + value.printPrevious() +"\"";
39     }
40   }
41 }
42
Popular Tags