01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.components.serializers.encoding;
18:
19: /**
20: *
21: *
22: * @author <a href="mailto:pier@apache.org">Pier Fumagalli</a>, February 2003
23: * @version CVS $Id: AbstractCharset.java 433543 2006-08-22 06:22:54Z crossley $
24: */
25: public abstract class AbstractCharset implements Charset {
26:
27: /** The name of this <code>Charset</code>. */
28: private String name;
29: /** All alias names for this <code>Charset</code>. */
30: private String aliases[];
31:
32: /**
33: * Create a new instance of this <code>AbstractCharset</code>.
34: *
35: * @param name This <code>Charset</code> name.
36: * @param aliases This <code>Charset</code> alias names.
37: * @throws NullPointerException If one of the arguments is <b>null</b>.
38: */
39: public AbstractCharset(String name, String aliases[]) {
40: super ();
41: if (name == null)
42: throw new NullPointerException("Invalid name");
43: if (aliases == null)
44: throw new NullPointerException("Invalid aliases");
45: this .name = name;
46: this .aliases = aliases;
47: }
48:
49: /**
50: * Return the primary name of this <code>Charset</code>
51: */
52: public String getName() {
53: return (this .name);
54: }
55:
56: /**
57: * Return all alias names for this <code>Charset</code>
58: */
59: public String[] getAliases() {
60: String array[] = new String[this .aliases.length];
61: System.arraycopy(this .aliases, 0, array, 0, array.length);
62: return (array);
63: }
64:
65: /**
66: * Compare an object to this <code>Charset</code> instances for equality.
67: */
68: public boolean equals(Object object) {
69: if (object instanceof Charset)
70: return (equals((Charset) object));
71: return (false);
72: }
73:
74: /**
75: * Compare two <code>Charset</code> instances for equality.
76: */
77: public boolean equals(Charset charset) {
78: if (charset == null)
79: return (false);
80: if ((charset.getClass().getName().equals(this .getClass()
81: .getName()))
82: && (charset.getName().equals(this .getName())))
83: return (true);
84: return (false);
85: }
86:
87: /**
88: * Return a <code>String</code> representation of this
89: * <code>Charset</code>.
90: */
91: public String toString() {
92: return (super .toString() + "[" + this .getName() + "]");
93: }
94: }
|