KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > lenya > cms > publication > Label


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17
18 /* @version $Id: Label.java 47098 2004-09-23 11:56:53Z antonio $ */
19
20 package org.apache.lenya.cms.publication;
21
22 /**
23  * The Label class encapsulates a string label of an associated language.
24  */

25 public class Label {
26     private String JavaDoc label = null;
27     private String JavaDoc language = null;
28
29     /**
30      * Creates a new Label object without language.
31      *
32      * @param label the actual label
33      */

34     public Label(String JavaDoc label) {
35         this(label, null);
36     }
37
38     /**
39      * Creates a new Label object.
40      *
41      * @param label the actual label
42      * @param language the label language
43      */

44     public Label(String JavaDoc label, String JavaDoc language) {
45         this.label = label;
46         this.language = language;
47     }
48
49     /**
50      * Get the label.
51      *
52      * @return the actual label as a String
53      */

54     public String JavaDoc getLabel() {
55         return label;
56     }
57
58     /**
59      * Set the label.
60      *
61      * @param label The label.
62      */

63     public void setLabel(String JavaDoc label) {
64         this.label = label;
65     }
66
67     /**
68      * Get the label language
69      *
70      * @return the language
71      */

72
73     public String JavaDoc getLanguage() {
74         return language;
75     }
76     
77     /** (non-Javadoc)
78      * @see java.lang.Object#toString()
79      */

80     public String JavaDoc toString() {
81         return getLabel() + " " + getLanguage();
82     }
83
84     /** (non-Javadoc)
85      * @see java.lang.Object#equals(java.lang.Object)
86      */

87     public boolean equals(Object JavaDoc obj) {
88         boolean equals = false;
89
90         if (getClass().isInstance(obj)) {
91             Label otherLabel = (Label)obj;
92             equals =
93                 getLabel().equals(otherLabel.getLabel())
94                     && getLanguage().equals(otherLabel.getLanguage());
95         }
96
97         return equals;
98     }
99
100     /** (non-Javadoc)
101      * @see java.lang.Object#hashCode()
102      */

103     public int hashCode() {
104         return getLabel().hashCode() + getLanguage().hashCode();
105     }
106 }
107
Popular Tags