KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mondrian > olap > OlapElementBase


1 /*
2 // $Id: //open/mondrian/src/main/mondrian/olap/OlapElementBase.java#17 $
3 // This software is subject to the terms of the Common Public License
4 // Agreement, available at the following URL:
5 // http://www.opensource.org/licenses/cpl.html.
6 // Copyright (C) 2001-2002 Kana Software, Inc.
7 // Copyright (C) 2001-2006 Julian Hyde and others
8 // All Rights Reserved.
9 // You must accept the terms of that agreement to use this software.
10 //
11 // jhyde, 6 August, 2001
12 */

13
14 package mondrian.olap;
15
16 import org.apache.log4j.Logger;
17
18 /**
19  * <code>OlapElementBase</code> is an abstract base class for implementations of
20  * {@link OlapElement}.
21  *
22  * @author jhyde
23  * @version $Id: //open/mondrian/src/main/mondrian/olap/OlapElementBase.java#17 $
24  * @since 6 August, 2001
25  */

26 public abstract class OlapElementBase
27         implements OlapElement {
28
29     private String JavaDoc caption = null;
30
31     protected OlapElementBase() {
32     }
33
34     protected abstract Logger getLogger();
35
36     public boolean equals(Object JavaDoc o) {
37         return (o == this) ||
38             ((o instanceof OlapElement) && equals((OlapElement) o));
39     }
40
41     public boolean equals(OlapElement mdxElement) {
42         return mdxElement != null &&
43                 getClass() == mdxElement.getClass() &&
44                 getUniqueName().equalsIgnoreCase(mdxElement.getUniqueName());
45     }
46
47     public int hashCode() {
48         int i = (getClass().hashCode() << 8),
49                 j = getUniqueName().hashCode(),
50                 k = i ^ j;
51         return k;
52     }
53
54     public String JavaDoc toString() {
55         return getUniqueName();
56     }
57
58     public Object JavaDoc clone() {
59         return this;
60     }
61
62     /**
63      * Returns the display name of this catalog element.
64      * If no caption is defined, the name is returned.
65      */

66     public String JavaDoc getCaption() {
67         if (caption != null) {
68             return caption;
69         } else {
70             return getName();
71         }
72     }
73
74     /**
75      * Sets the display name of this catalog element.
76      */

77     public void setCaption(String JavaDoc caption) {
78         this.caption = caption;
79     }
80 }
81
82 // End OlapElementBase.java
83
Popular Tags