KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > serializers > encoding > AbstractCharset


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 package org.apache.cocoon.components.serializers.encoding;
17
18 /**
19  *
20  *
21  * @author <a HREF="mailto:pier@apache.org">Pier Fumagalli</a>, February 2003
22  * @version CVS $Id: AbstractCharset.java 30932 2004-07-29 17:35:38Z vgritsenko $
23  */

24 public abstract class AbstractCharset implements Charset {
25
26     /** The name of this <code>Charset</code>. */
27     private String JavaDoc name;
28     /** All alias names for this <code>Charset</code>. */
29     private String JavaDoc aliases[];
30
31     /**
32      * Create a new instance of this <code>AbstractCharset</code>.
33      *
34      * @param name This <code>Charset</code> name.
35      * @param aliases This <code>Charset</code> alias names.
36      * @throws NullPointerException If one of the arguments is <b>null</b>.
37      */

38     public AbstractCharset(String JavaDoc name, String JavaDoc aliases[]) {
39         super();
40         if (name == null) throw new NullPointerException JavaDoc("Invalid name");
41         if (aliases == null) throw new NullPointerException JavaDoc("Invalid aliases");
42         this.name = name;
43         this.aliases = aliases;
44     }
45
46     /**
47      * Return the primary name of this <code>Charset</code>
48      */

49     public String JavaDoc getName() {
50         return(this.name);
51     }
52
53     /**
54      * Return all alias names for this <code>Charset</code>
55      */

56     public String JavaDoc[] getAliases() {
57         String JavaDoc array[] = new String JavaDoc[this.aliases.length];
58         System.arraycopy(this.aliases, 0, array, 0, array.length);
59         return(array);
60     }
61
62     /**
63      * Compare an object to this <code>Charset</code> instances for equality.
64      */

65     public boolean equals(Object JavaDoc object) {
66         if (object instanceof Charset) return(equals((Charset)object));
67         return(false);
68     }
69
70     /**
71      * Compare two <code>Charset</code> instances for equality.
72      */

73     public boolean equals(Charset charset) {
74         if (charset == null) return(false);
75         if ((charset.getClass().getName().equals(this.getClass().getName()))
76             && (charset.getName().equals(this.getName()))) return(true);
77         return(false);
78     }
79
80     /**
81      * Return a <code>String</code> representation of this
82      * <code>Charset</code>.
83      */

84     public String JavaDoc toString() {
85         return(super.toString() + "[" + this.getName() + "]");
86     }
87 }
88
Popular Tags