KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jibx > binding > def > IMapping


1 /*
2 Copyright (c) 2003-2005, Dennis M. Sosnoski
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without modification,
6 are permitted provided that the following conditions are met:
7
8  * Redistributions of source code must retain the above copyright notice, this
9    list of conditions and the following disclaimer.
10  * Redistributions in binary form must reproduce the above copyright notice,
11    this list of conditions and the following disclaimer in the documentation
12    and/or other materials provided with the distribution.
13  * Neither the name of JiBX nor the names of its contributors may be used
14    to endorse or promote products derived from this software without specific
15    prior written permission.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */

28
29 package org.jibx.binding.def;
30
31 import org.jibx.binding.classes.*;
32 import org.jibx.runtime.JiBXException;
33
34 /**
35  * Interface for mapping definitions. This defines the additional access methods
36  * used with mappings (beyond those used with ordinary components).
37  *
38  * @author Dennis M. Sosnoski
39  * @version 1.0
40  */

41
42 public interface IMapping extends IComponent
43 {
44     /**
45      * Get class name handled by mapping.
46      *
47      * @return name of class bound by mapping
48      */

49     public String JavaDoc getBoundType();
50     
51     /**
52      * Get binding component implementing mapping. This call is only valid for
53      * mappings with child components, not for mappings defined using
54      * marshallers or unmarshallers.
55      *
56      * @return binding component implementing this mapping
57      */

58     public IComponent getImplComponent();
59
60     /**
61      * Get marshaller class used for mapping.
62      *
63      * @return marshaller class information
64      * @throws JiBXException if error in configuration
65      */

66     public ClassFile getMarshaller() throws JiBXException;
67
68     /**
69      * Get unmarshaller class used for mapping.
70      *
71      * @return unmarshaller class information
72      * @throws JiBXException if error in configuration
73      */

74     public ClassFile getUnmarshaller() throws JiBXException;
75
76     /**
77      * Get mapped element name.
78      *
79      * @return mapped element name information (may be <code>null</code> if no
80      * element name defined for mapping)
81      */

82     public NameDefinition getName();
83
84     /**
85      * Get mapped class index number.
86      *
87      * @return mapped class index number in context
88      */

89     public int getIndex();
90
91     /**
92      * Add namespace. This adds a namespace definition to those active for the
93      * mapping.
94      *
95      * @param ns namespace definition to be added
96      * @throws JiBXException if error in defining namespace
97      */

98     public void addNamespace(NamespaceDefinition ns) throws JiBXException;
99
100     /**
101      * Check if mapping is abstract.
102      *
103      * @return <code>true</code> if an abstract mapping, <code>false</code> if
104      * not
105      */

106     public boolean isAbstract();
107
108     /**
109      * Add extension to abstract mapping. This call is only valid for abstract
110      * mappings.
111      *
112      * @param mdef extension mapping definition
113      */

114     public void addExtension(MappingDefinition mdef);
115
116     /**
117      * Build reference to mapping. Constructs and returns the component for
118      * handling the mapping.
119      *
120      * @param parent containing binding definition structure
121      * @param objc current object context
122      * @param type mapped value type
123      * @param prop property definition (may be <code>null</code>)
124      * @return constructed mapping reference component
125      * @throws JiBXException if configuration error
126      */

127     public IComponent buildRef(IContainer parent, IContextObj objc, String JavaDoc type,
128         PropertyDefinition prop) throws JiBXException;
129     
130     /**
131      * Generate required code for mapping.
132      *
133      * @throws JiBXException if error in transformation
134      */

135     public void generateCode() throws JiBXException;
136 }
Popular Tags