1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License").  You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22/*
23 * ident	"%Z%%M%	%I%	%E% SMI"
24 *
25 * Copyright (c) 2000 by Sun Microsystems, Inc.
26 * All rights reserved.
27 */
28
29/*
30 *        Copyright (C) 1996  Active Software, Inc.
31 *                  All rights reserved.
32 *
33 * @(#) @(#) CharacterConverter.java 1.10 - last change made 07/25/97
34 */
35
36package sunsoft.jws.visual.rt.type;
37
38/**
39 * Converts Character objects to strings and back again.
40 *
41 * @see Character
42 * @version 	1.10, 07/25/97
43 */
44public class CharacterConverter extends Converter {
45    /**
46     * Converts a Character to a string.
47     *
48     * @param obj a instance of Character
49     */
50    public String convertToString(Object obj) {
51        Character c = (Character)obj;
52        if (c.charValue() == (char)0)
53            return /* NOI18N */"";
54        else
55            return (c.toString());
56    }
57
58    /**
59     * Converts a string into a Character.  Uses only the
60     * first letter in the
61     * string.
62     */
63    public Object convertFromString(String s) {
64        if (s == null || s.equals(/* NOI18N */"")) {
65            return new Character((char)0);
66        } else {
67            return new Character(s.charAt(0));
68        }
69    }
70
71    /**
72     * Returns a block of code that will create a
73     * Character liek the one given.
74     *
75     * @param obj a instance of Character
76     */
77    public String convertToCode(Object obj) {
78        return (/* NOI18N */"new Character('" +
79		((Character) obj).toString() + /* NOI18N */"')");
80    }
81}
82