KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > schema2beans > Wrapper


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.schema2beans;
21
22 /**
23  * The Wrapper interface is one of the two ways a user can initialize a
24  * Wrapper object.
25  *
26  * By default, when schema2beans generates the java classes, a #PCDATA DTD type
27  * is mapped to a java String. Sometime, the user might want to map an
28  * element to either a scalar or a specialized type (user defined class).
29  *
30  * For example, a price DTD element specified as #PCDATA could be mapped
31  * to a float or integer data type. Or a date DTD element also specified
32  * as #PCDATA could be mapped to a specialized Date object, that the user might
33  * provide. schema2beans calls these specialized object 'wrappers'.
34  *
35  * If the user specifies a wrapper object in the mdd file (see user
36  * documentation for mdd explanations), schema2beans uses the wrapper class
37  * instead of the String type. In this case, schema2beans needs to initialize
38  * the wrapper object using the String value from the XML document, and
39  * also needs to be able to get the String value from the wrapper
40  * object (in order to write back the XML document).
41  *
42  * This what this Wrapper interface provides. A wrapper class has
43  * has either to have a String constructor and toString() method,
44  * or implements the Wrapper interface. This is how schema2beans can set/get
45  * the String values of user wrapper/customized object.
46  *
47  */

48 public interface Wrapper {
49     /**
50      * Method called by the schema2beans runtime to get the String value of the
51      * wrapper object. This String value is the value that has to appear
52      * in the XML document.
53      */

54     public String JavaDoc getWrapperValue();
55     
56     /**
57      * Method called by the schema2beans runtime to set the value of the
58      * wrapper object. The String value is the value read in the XML document.
59      */

60     public void setWrapperValue(String JavaDoc value);
61 }
62
Popular Tags