001: /*
002: * JFolder, Copyright 2001-2006 Gary Steinmetz
003: *
004: * Distributable under LGPL license.
005: * See terms of license at gnu.org.
006: */
007:
008: package org.jfolder.console.web.dictionary;
009:
010: //base classes
011:
012: //project specific classes
013:
014: //other classes
015:
016: public class ConceptTagDictionaryIndexItem implements Comparable {
017:
018: //
019: private String title = null;
020: private String handle = null;
021: private String namespace = null;
022: private String name = null;
023:
024: protected ConceptTagDictionaryIndexItem(String inTitle,
025: String inHandle, String inNamespace, String inName) {
026: //
027: if (inTitle != null) {
028: this .title = inTitle;
029: } else {
030: this .title = "(No Name)";
031: }
032: this .handle = inHandle;
033: this .namespace = inNamespace;
034: this .name = inName;
035: }
036:
037: //
038: public String getTitle() {
039: return this .title;
040: }
041:
042: public String getPreferencesHandle() {
043: return this .handle;
044: }
045:
046: public String getNamespace() {
047: return this .namespace;
048: }
049:
050: public String getName() {
051: return this .name;
052: }
053:
054: public int hashCode() {
055:
056: int outValue = 0;
057:
058: //
059: if (this .title != null) {
060: outValue = outValue + this .title.hashCode();
061: }
062: //
063: if (this .handle != null) {
064: outValue = outValue + this .handle.hashCode();
065: }
066: //
067: if (this .namespace != null) {
068: outValue = outValue + this .namespace.hashCode();
069: }
070: //
071: if (this .name != null) {
072: outValue = outValue + this .name.hashCode();
073: }
074:
075: return outValue;
076: }
077:
078: public boolean equals(Object inValue) {
079:
080: boolean outValue = true;
081:
082: //
083: if (inValue instanceof ConceptTagDictionaryIndexItem) {
084: ConceptTagDictionaryIndexItem value = (ConceptTagDictionaryIndexItem) inValue;
085:
086: //
087: outValue &= equals(this .title, value.title);
088: outValue &= equals(this .handle, value.handle);
089: outValue &= equals(this .namespace, value.namespace);
090: outValue &= equals(this .name, value.name);
091: } else {
092: outValue = false;
093: }
094:
095: return outValue;
096: }
097:
098: public int compareTo(Object inValue) {
099:
100: int outValue = 0;
101:
102: //
103: if (inValue instanceof ConceptTagDictionaryIndexItem) {
104: ConceptTagDictionaryIndexItem value = (ConceptTagDictionaryIndexItem) inValue;
105: //
106: outValue = this .title.toUpperCase().compareTo(
107: value.title.toUpperCase());
108: }
109:
110: return outValue;
111: }
112:
113: private final static boolean equals(String inValue1, String inValue2) {
114: //
115: boolean outValue = false;
116:
117: if (inValue1 != null && inValue2 != null) {
118: outValue = inValue1.equals(inValue2);
119: } else if (inValue1 == null && inValue2 == null) {
120: outValue = true;
121: } else {
122: outValue = false;
123: }
124:
125: return outValue;
126: }
127: }
|