View Javadoc

1   //
2   // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v@@BUILD_VERSION@@ 
3   // 	See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
4   // 	Any modifications to this file will be lost upon recompilation of the source schema. 
5   // 	Generated on: 2005.06.30 um 05:21:08 CEST 
6   //
7   
8   package de.nierbeck.timeTrack.model.impl.runtime;
9   
10  import javax.xml.bind.ValidationEvent;
11  
12  import org.xml.sax.SAXException;
13  
14  import com.sun.xml.bind.JAXBObject;
15  import com.sun.xml.bind.marshaller.IdentifiableObject;
16  import com.sun.xml.bind.serializer.AbortSerializationException;
17  
18  /***
19   * Receives XML serialization event
20   * 
21   * <p>
22   * This object coordinates the overall marshalling efforts across different
23   * content-tree objects and different target formats.
24   * 
25   * <p>
26   * The following CFG gives the proper sequence of method invocation.
27   * 
28   * <pre>
29   *     MARSHALLING  :=  ELEMENT
30   *     ELEMENT      :=  &quot;startElement&quot; NSDECL* &quot;endNamespaceDecls&quot;
31   *                            ATTRIBUTE* &quot;endAttributes&quot; BODY &quot;endElement&quot;
32   *     
33   *     NSDECL       :=  &quot;declareNamespace&quot;
34   *     
35   *     ATTRIBUTE    :=  &quot;startAttribute&quot; ATTVALUES &quot;endAttribute&quot;
36   *     ATTVALUES    :=  &quot;text&quot;*
37   *     
38   *     
39   *     BODY         :=  ( &quot;text&quot; | ELEMENT )*
40   * </pre>
41   * 
42   * <p>
43   * A marshalling of one element consists of two stages. The first stage is for
44   * marshalling attributes and collecting namespace declarations. The second
45   * stage is for marshalling characters/child elements of that element.
46   * 
47   * <p>
48   * Observe that multiple invocation of "text" is allowed.
49   * 
50   * <p>
51   * Also observe that the namespace declarations are allowed only between
52   * "startElement" and "endAttributes".
53   * 
54   * 
55   * @author Kohsuke Kawaguchi
56   */
57  public interface XMLSerializer {
58  	/***
59  	 * Errors detected by the XMLSerializable should be either thrown as
60  	 * {@link SAXException} or reported through this method.
61  	 * 
62  	 * The callee should report an error to the client application and
63  	 */
64  	void reportError(ValidationEvent e) throws AbortSerializationException;
65  
66  	/***
67  	 * Starts marshalling of an element. Calling this method will push the
68  	 * internal state into the internal stack.
69  	 */
70  	void startElement(String uri, String local) throws SAXException;
71  
72  	/***
73  	 * Switches to the mode to marshal attribute values. This method has to be
74  	 * called after the 1st pass is completed.
75  	 */
76  	void endNamespaceDecls() throws SAXException;
77  
78  	/***
79  	 * Switches to the mode to marshal child texts/elements. This method has to
80  	 * be called after the 2nd pass is completed.
81  	 */
82  	void endAttributes() throws SAXException;
83  
84  	/***
85  	 * Ends marshalling of an element. Pops the internal stack.
86  	 */
87  	void endElement() throws SAXException;
88  
89  	/***
90  	 * Marshalls text.
91  	 * 
92  	 * <p>
93  	 * This method can be called (i) after the startAttribute method and (ii)
94  	 * before the endAttribute method, to marshal attribute values. If the
95  	 * method is called more than once, those texts are considered as separated
96  	 * by whitespaces. For example,
97  	 * 
98  	 * <pre>
99  	 * c.startAttribute();
100 	 * c.text(&quot;abc&quot;);
101 	 * c.text(&quot;def&quot;);
102 	 * c.endAttribute(&quot;&quot;, &quot;foo&quot;);
103 	 * </pre>
104 	 * 
105 	 * will generate foo="abc def".
106 	 * 
107 	 * <p>
108 	 * Similarly, this method can be called after the endAttributes method to
109 	 * marshal texts inside elements. The same rule about multiple invokations
110 	 * apply to this case, too. For example,
111 	 * 
112 	 * <pre>
113 	 * c.startElement(&quot;&quot;, &quot;foo&quot;);
114 	 * c.endNamespaceDecls();
115 	 * c.endAttributes();
116 	 * c.text(&quot;abc&quot;);
117 	 * c.text(&quot;def&quot;);
118 	 * c.startElement(&quot;&quot;, &quot;bar&quot;);
119 	 * c.endAttributes();
120 	 * c.endElement();
121 	 * c.text(&quot;ghi&quot;);
122 	 * c.endElement();
123 	 * </pre>
124 	 * 
125 	 * will generate <code>&lt;foo>abc def&lt;bar/>ghi&lt;/foo></code>.
126 	 */
127 	void text(String text, String fieldName) throws SAXException;
128 
129 	/***
130 	 * Starts marshalling of an attribute.
131 	 * 
132 	 * The marshalling of an attribute will be done by
133 	 * <ol>
134 	 * <li>call the startAttribute method
135 	 * <li>call the text method (several times if necessary)
136 	 * <li>call the endAttribute method
137 	 * </ol>
138 	 * 
139 	 * No two attributes can be marshalled at the same time. Note that the whole
140 	 * attribute marshalling must be happened after the startElement method and
141 	 * before the endAttributes method.
142 	 */
143 	void startAttribute(String uri, String local) throws SAXException;
144 
145 	void endAttribute() throws SAXException;
146 
147 	/***
148 	 * Obtains a namespace context object, which is used to declare/obtain
149 	 * namespace bindings.
150 	 */
151 	NamespaceContext2 getNamespaceContext();
152 
153 	/***
154 	 * Notifies the serializer that an ID value has just marshalled.
155 	 * 
156 	 * The serializer may or may not check the consistency of ID/IDREFs and may
157 	 * throw a SAXException.
158 	 * 
159 	 * @param owner
160 	 *            JAXB content object that posesses the ID.
161 	 * @param value
162 	 *            The value of the ID.
163 	 * 
164 	 * @return Return the value parameter without any modification, so that the
165 	 *         invocation of this method can be done transparently by a
166 	 *         transducer.
167 	 */
168 	String onID(IdentifiableObject owner, String value) throws SAXException;
169 
170 	/***
171 	 * Notifies the serializer that an IDREF value has just marshalled.
172 	 * 
173 	 * The serializer may or may not check the consistency of ID/IDREFs and may
174 	 * throw a SAXException.
175 	 * 
176 	 * @return Return the value parameter without any modification. so that the
177 	 *         invocation of this method can be done transparently by a
178 	 *         transducer.
179 	 */
180 	String onIDREF(IdentifiableObject obj) throws SAXException;
181 
182 	// I suppose we don't want to use SAXException. -kk
183 
184 	// those method signatures are purposely made to JAXBContext, not
185 	// XMLSerializable, to avoid N^2 proxy overhead.
186 
187 	/***
188 	 * This method is called when an JAXBObject object is found while the
189 	 * marshaller is in the "element" mode (i.e. marshalling a content model of
190 	 * an element)
191 	 * 
192 	 * @param fieldName
193 	 *            property name of the parent objeect from which 'o' comes. Used
194 	 *            as a part of the error message in case anything goes wrong
195 	 *            with 'o'.
196 	 */
197 	void childAsBody(JAXBObject o, String fieldName) throws SAXException;
198 
199 	/***
200 	 * This method is called when an JAXBObject object is found while the
201 	 * marshaller is in the "attribute" mode (i.e. marshalling attributes of an
202 	 * element)
203 	 * 
204 	 * @param fieldName
205 	 *            property name of the parent objeect from which 'o' comes. Used
206 	 *            as a part of the error message in case anything goes wrong
207 	 *            with 'o'.
208 	 */
209 	void childAsAttributes(JAXBObject o, String fieldName) throws SAXException;
210 
211 	/***
212 	 * This method is called when an JAXBObject object is found while the
213 	 * marshaller is in the "URI" mode.
214 	 * 
215 	 * @param fieldName
216 	 *            property name of the parent objeect from which 'o' comes. Used
217 	 *            as a part of the error message in case anything goes wrong
218 	 *            with 'o'.
219 	 */
220 	void childAsURIs(JAXBObject o, String fieldName) throws SAXException;
221 }