KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > appserv > management > util > stringifier > Stringifier


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23  
24 /*
25  * $Header: /cvs/glassfish/admin-core/mbeanapi/src/java/com/sun/appserv/management/util/stringifier/Stringifier.java,v 1.3 2005/12/25 03:52:00 tcfujii Exp $
26  * $Revision: 1.3 $
27  * $Date: 2005/12/25 03:52:00 $
28  */

29  
30  
31 package com.sun.appserv.management.util.stringifier;
32
33 /**
34     Convert an object to a String. The intent of this is to provide a flexible means
35     to control the string representation of an Object. The toString() routine has many
36     issues, including:
37     - appropriateness for end-user viewing (within a CLI for example)
38     - an object may not have implemented a toString() method
39     - the output of toString() may simply be unacceptable (eg class@eebc1933)
40     - it may be desirable to have many variations on the output
41     - modifying toString() requires modifying the orignal class; a Stringifier
42     or many of them can exist independently, making it easy to apply many different
43     types of formatting to the same class.
44     
45     The intended use is generally to have a separate class implement Stringifier, rather
46     than the class to be stringified.
47  */

48 public interface Stringifier
49 {
50     /**
51         Produce a String representation of an object. The actual output has no
52         other semantics; each Stringifier may choose to target a particular type
53         of user.
54         <p>
55         The resulting String should be suitable for display to a user.
56         
57         @param object the Object for which a String should be produced
58      */

59     public String JavaDoc stringify( Object JavaDoc object );
60 }
61
62
Popular Tags