01: package com.xoetrope.carousel.langed;
02:
03: /**
04: * A place holder for the language name and code / id.
05: * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
06: * the GNU Public License (GPL), please see license.txt for more details. If
07: * you make commercial use of this software you must purchase a commercial
08: * license from Xoetrope.</p>
09: * <p> $Revision: 1.4 $</p>
10: */
11: public class LangItem {
12: int id;
13: String langStr;
14: String keyStr;
15: boolean hashByName;
16: int status;
17:
18: public static final int OK = 0;
19: public static final int NEW_ITEM = 1;
20: public static final int MODIFIED = 2;
21:
22: public LangItem() {
23: hashByName = false;
24: status = OK;
25: }
26:
27: public LangItem(int _id) {
28: hashByName = false;
29: id = _id;
30: status = OK;
31: }
32:
33: public LangItem(boolean hashMethod) {
34: hashByName = hashMethod;
35: status = OK;
36: }
37:
38: public LangItem(String str, int _id) {
39: langStr = str;
40: id = _id;
41: status = OK;
42: }
43:
44: public String toString() {
45: return langStr;
46: }
47:
48: public String getKeyString() {
49: return keyStr;
50: }
51:
52: public int hashCode() {
53: if (!hashByName)
54: return id;
55: else
56: return langStr.hashCode();
57: }
58:
59: public boolean equals(Object o) {
60: if (!hashByName)
61: return (((LangItem) o).id == id);
62: else
63: return (((LangItem) o).langStr.compareTo(langStr) == 0);
64: }
65:
66: void setLangStr(String newString) {
67: langStr = newString;
68: if (status != NEW_ITEM)
69: status = MODIFIED;
70: }
71:
72: void setKeyString(String newString) {
73: keyStr = newString;
74: if (status != NEW_ITEM)
75: status = MODIFIED;
76: }
77:
78: int getStatus() {
79: return status;
80: }
81: }
|