View Javadoc

1   /*
2      Copyright 2002-2006 Martin van den Bemt
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  package org.xulux.utils;
17  
18  /**
19   * The translation object is a holder of translation
20   * information (url to get names from)
21   * It defaults to classloader loading.
22   *
23   * @todo Automaticaly figure out what to do!
24   *
25   * @author <a href="mailto:martin@mvdb.net">Martin van den Bemt</a>
26   * @version $Id: Translation.java,v 1.1 2005/12/18 12:58:15 mvdb Exp $
27   */
28  public class Translation {
29  
30      /**
31       * the url
32       */
33      private String url;
34      /**
35       * the type
36       */
37      private String type;
38  
39      /**
40       *
41       */
42      public Translation() {
43          super();
44      }
45  
46      /**
47       * Convenient constructor instead of calling
48       * the setters..
49       *
50       * @param url the url
51       * @param type the type
52       */
53      public Translation(String url, String type) {
54          this();
55          setUrl(url);
56          setType(type);
57      }
58  
59      /**
60       * @return the type
61       */
62      public String getType() {
63          return type;
64      }
65  
66      /**
67       * @return the url
68       */
69      public String getUrl() {
70          return url;
71      }
72  
73      /**
74       * @param string the type
75       */
76      public void setType(String string) {
77          type = string;
78      }
79  
80      /**
81       * @param string the type
82       */
83      public void setUrl(String string) {
84          url = string;
85      }
86  
87      /**
88       *
89       * @see java.lang.Object#toString()
90       */
91      public String toString() {
92          return this.url;
93      }
94  
95      /**
96       * Case sensitive comparison of urls.
97       * @see java.lang.Object#equals(java.lang.Object)
98       */
99      public boolean equals(Object object) {
100         if (object instanceof Translation) {
101             Translation trans = (Translation) object;
102             if (getUrl() != null) {
103                 if (getUrl().equals(trans.getUrl())) {
104                     if (getType() != null) {
105                         return getType().equals(trans.getType());
106                     } else {
107                         return trans.getType() == null;
108                     }
109                 }
110             }
111         }
112         return false;
113     }
114 }