KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openbravo > erpCommon > utility > QueryFieldStructure


1 /*
2  *************************************************************************
3  * The contents of this file are subject to the Openbravo Public License
4  * Version 1.0 (the "License"), being the Mozilla Public License
5  * Version 1.1 with a permitted attribution clause; you may not use this
6  * file except in compliance with the License. You may obtain a copy of
7  * the License at http://www.openbravo.com/legal/license.html
8  * Software distributed under the License is distributed on an "AS IS"
9  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
10  * License for the specific language governing rights and limitations
11  * under the License.
12  * The Original Code is Openbravo ERP.
13  * The Initial Developer of the Original Code is Openbravo SL
14  * All portions are Copyright (C) 2001-2006 Openbravo SL
15  * All Rights Reserved.
16  * Contributor(s): ______________________________________.
17  ************************************************************************
18 */

19 package org.openbravo.erpCommon.utility;
20
21 import java.util.Hashtable JavaDoc;
22
23 public class QueryFieldStructure {
24   private Hashtable JavaDoc<String JavaDoc, String JavaDoc> data = new Hashtable JavaDoc<String JavaDoc, String JavaDoc>();
25
26   public QueryFieldStructure() {
27   }
28
29   public QueryFieldStructure(String JavaDoc _field, String JavaDoc _aliasJoin, String JavaDoc _alias, String JavaDoc _type) {
30     setData("field", _field);
31     setData("aliasJoin", _aliasJoin);
32     setData("alias", _alias);
33     setData("type", _type);
34   }
35
36   public void setData(String JavaDoc name, String JavaDoc value) {
37     if (name==null) return;
38     if (this.data==null) this.data = new Hashtable JavaDoc<String JavaDoc, String JavaDoc>();
39     if (value==null || value.equals("")) this.data.remove(name);
40     else this.data.put(name, value);
41   }
42
43   public String JavaDoc getData(String JavaDoc name) {
44     return data.get(name);
45   }
46   
47   public void setField(String JavaDoc _data) {
48     setData("field", _data);
49   }
50
51   public String JavaDoc getField() {
52     return getData("field");
53   }
54
55   public String JavaDoc getAlias() {
56     return getData("alias");
57   }
58
59   public String JavaDoc getType() {
60     return getData("type");
61   }
62
63   public String JavaDoc toString() {
64     return toString(false);
65   }
66   
67   public String JavaDoc toString(boolean printAlias) {
68     StringBuffer JavaDoc text = new StringBuffer JavaDoc();
69     text.append(getData("field"));
70     if (printAlias) text.append(getData("aliasJoin")).append(getData("alias"));
71     return text.toString();
72   }
73 }
74
Popular Tags