Coverage Report - org.simpleframework.xml.Serializer
 
Classes in this File Line Coverage Branch Coverage Complexity
Serializer
N/A
N/A
1
 
 1  
 /*
 2  
  * Serializer.java July 2006
 3  
  *
 4  
  * Copyright (C) 2006, Niall Gallagher <niallg@users.sf.net>
 5  
  *
 6  
  * Licensed under the Apache License, Version 2.0 (the "License");
 7  
  * you may not use this file except in compliance with the License.
 8  
  * You may obtain a copy of the License at
 9  
  *
 10  
  *     http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
 15  
  * implied. See the License for the specific language governing 
 16  
  * permissions and limitations under the License.
 17  
  */
 18  
 
 19  
 package org.simpleframework.xml;
 20  
 
 21  
 import java.io.InputStream;
 22  
 import java.io.OutputStream;
 23  
 import java.io.Reader;
 24  
 import java.io.Writer;
 25  
 import java.io.File;
 26  
 
 27  
 import org.simpleframework.xml.stream.InputNode;
 28  
 import org.simpleframework.xml.stream.OutputNode;
 29  
 
 30  
 /**
 31  
  * The <code>Serializer</code> interface is used to represent objects
 32  
  * that can serialize and deserialize objects to an from XML. This 
 33  
  * exposes several <code>read</code> and <code>write</code> methods
 34  
  * that can read from and write to various sources. Typically an
 35  
  * object will be read from an XML file and written to some other 
 36  
  * file or stream. 
 37  
  * <p>
 38  
  * An implementation of the <code>Serializer</code> interface is free
 39  
  * to use any desired XML parsing framework. If a framework other 
 40  
  * than the Java streaming API for XML is required then it should be
 41  
  * wrapped within the <code>org.simpleframework.xml.stream</code> API,
 42  
  * which offers a framework neutral facade.
 43  
  * 
 44  
  * @author Niall Gallagher
 45  
  */
 46  
 public interface Serializer {
 47  
    
 48  
    /**
 49  
     * This <code>read</code> method will read the contents of the XML
 50  
     * document from the provided source and convert it into an object
 51  
     * of the specified type. If the XML source cannot be deserialized
 52  
     * or there is a problem building the object graph an exception
 53  
     * is thrown. The instance deserialized is returned.
 54  
     * 
 55  
     * @param type this is the class type to be deserialized from XML
 56  
     * @param source this provides the source of the XML document
 57  
     * 
 58  
     * @return the object deserialized from the XML document 
 59  
     * 
 60  
     * @throws Exception if the object cannot be fully deserialized
 61  
     */
 62  
    <T> T read(Class<? extends T> type, String source) throws Exception;
 63  
         
 64  
    /**
 65  
     * This <code>read</code> method will read the contents of the XML
 66  
     * document from the provided source and convert it into an object
 67  
     * of the specified type. If the XML source cannot be deserialized
 68  
     * or there is a problem building the object graph an exception
 69  
     * is thrown. The instance deserialized is returned.
 70  
     * 
 71  
     * @param type this is the class type to be deserialized from XML
 72  
     * @param source this provides the source of the XML document
 73  
     * 
 74  
     * @return the object deserialized from the XML document 
 75  
     * 
 76  
     * @throws Exception if the object cannot be fully deserialized
 77  
     */
 78  
    <T> T read(Class<? extends T> type, File source) throws Exception;
 79  
 
 80  
    /**
 81  
     * This <code>read</code> method will read the contents of the XML
 82  
     * document from the provided source and convert it into an object
 83  
     * of the specified type. If the XML source cannot be deserialized
 84  
     * or there is a problem building the object graph an exception
 85  
     * is thrown. The instance deserialized is returned.
 86  
     * 
 87  
     * @param type this is the class type to be deserialized from XML
 88  
     * @param source this provides the source of the XML document
 89  
     * 
 90  
     * @return the object deserialized from the XML document 
 91  
     * 
 92  
     * @throws Exception if the object cannot be fully deserialized
 93  
     */
 94  
    <T> T read(Class<? extends T> type, InputStream source) throws Exception;
 95  
 
 96  
    /**
 97  
     * This <code>read</code> method will read the contents of the XML
 98  
     * document from the provided source and convert it into an object
 99  
     * of the specified type. If the XML source cannot be deserialized
 100  
     * or there is a problem building the object graph an exception
 101  
     * is thrown. The instance deserialized is returned.
 102  
     * 
 103  
     * @param type this is the class type to be deserialized from XML
 104  
     * @param source this provides the source of the XML document
 105  
     * 
 106  
     * @return the object deserialized from the XML document 
 107  
     * 
 108  
     * @throws Exception if the object cannot be fully deserialized
 109  
     */   
 110  
    <T> T read(Class<? extends T> type, Reader source) throws Exception;
 111  
    
 112  
    /**
 113  
     * This <code>read</code> method will read the contents of the XML
 114  
     * document from the provided source and convert it into an object
 115  
     * of the specified type. If the XML source cannot be deserialized
 116  
     * or there is a problem building the object graph an exception
 117  
     * is thrown. The instance deserialized is returned.
 118  
     * 
 119  
     * @param type this is the class type to be deserialized from XML
 120  
     * @param source this provides the source of the XML document
 121  
     * 
 122  
     * @return the object deserialized from the XML document 
 123  
     * 
 124  
     * @throws Exception if the object cannot be fully deserialized
 125  
     */   
 126  
    <T> T read(Class<? extends T> type, InputNode source) throws Exception;
 127  
    
 128  
    /**
 129  
     * This <code>read</code> method will read the contents of the XML
 130  
     * document from the provided source and convert it into an object
 131  
     * of the specified type. If the XML source cannot be deserialized
 132  
     * or there is a problem building the object graph an exception
 133  
     * is thrown. The instance deserialized is returned.
 134  
     * 
 135  
     * @param type this is the class type to be deserialized from XML
 136  
     * @param source this provides the source of the XML document
 137  
     * @param strict this determines whether to read in strict mode
 138  
     * 
 139  
     * @return the object deserialized from the XML document 
 140  
     * 
 141  
     * @throws Exception if the object cannot be fully deserialized
 142  
     */
 143  
    <T> T read(Class<? extends T> type, String source, boolean strict) throws Exception;
 144  
         
 145  
    /**
 146  
     * This <code>read</code> method will read the contents of the XML
 147  
     * document from the provided source and convert it into an object
 148  
     * of the specified type. If the XML source cannot be deserialized
 149  
     * or there is a problem building the object graph an exception
 150  
     * is thrown. The instance deserialized is returned.
 151  
     * 
 152  
     * @param type this is the class type to be deserialized from XML
 153  
     * @param source this provides the source of the XML document
 154  
     * @param strict this determines whether to read in strict mode 
 155  
     * 
 156  
     * @return the object deserialized from the XML document 
 157  
     * 
 158  
     * @throws Exception if the object cannot be fully deserialized
 159  
     */
 160  
    <T> T read(Class<? extends T> type, File source, boolean strict) throws Exception;
 161  
 
 162  
    /**
 163  
     * This <code>read</code> method will read the contents of the XML
 164  
     * document from the provided source and convert it into an object
 165  
     * of the specified type. If the XML source cannot be deserialized
 166  
     * or there is a problem building the object graph an exception
 167  
     * is thrown. The instance deserialized is returned.
 168  
     * 
 169  
     * @param type this is the class type to be deserialized from XML
 170  
     * @param source this provides the source of the XML document
 171  
     * @param strict this determines whether to read in strict mode
 172  
     * 
 173  
     * @return the object deserialized from the XML document 
 174  
     * 
 175  
     * @throws Exception if the object cannot be fully deserialized
 176  
     */
 177  
    <T> T read(Class<? extends T> type, InputStream source, boolean strict) throws Exception;
 178  
 
 179  
    /**
 180  
     * This <code>read</code> method will read the contents of the XML
 181  
     * document from the provided source and convert it into an object
 182  
     * of the specified type. If the XML source cannot be deserialized
 183  
     * or there is a problem building the object graph an exception
 184  
     * is thrown. The instance deserialized is returned.
 185  
     * 
 186  
     * @param type this is the class type to be deserialized from XML
 187  
     * @param source this provides the source of the XML document
 188  
     * @param strict this determines whether to read in strict mode
 189  
     * 
 190  
     * @return the object deserialized from the XML document 
 191  
     * 
 192  
     * @throws Exception if the object cannot be fully deserialized
 193  
     */   
 194  
    <T> T read(Class<? extends T> type, Reader source, boolean strict) throws Exception;
 195  
    
 196  
    /**
 197  
     * This <code>read</code> method will read the contents of the XML
 198  
     * document from the provided source and convert it into an object
 199  
     * of the specified type. If the XML source cannot be deserialized
 200  
     * or there is a problem building the object graph an exception
 201  
     * is thrown. The instance deserialized is returned.
 202  
     * 
 203  
     * @param type this is the class type to be deserialized from XML
 204  
     * @param source this provides the source of the XML document
 205  
     * @param strict this determines whether to read in strict mode
 206  
     * 
 207  
     * @return the object deserialized from the XML document 
 208  
     * 
 209  
     * @throws Exception if the object cannot be fully deserialized
 210  
     */   
 211  
    <T> T read(Class<? extends T> type, InputNode source, boolean strict) throws Exception;
 212  
    
 213  
    /**
 214  
     * This <code>read</code> method will read the contents of the XML
 215  
     * document from the provided source and populate the object with
 216  
     * the values deserialized. This is used as a means of injecting an
 217  
     * object with values deserialized from an XML document. If the
 218  
     * XML source cannot be deserialized or there is a problem building
 219  
     * the object graph an exception is thrown.
 220  
     * 
 221  
     * @param value this is the object to deserialize the XML in to
 222  
     * @param source this provides the source of the XML document
 223  
     * 
 224  
     * @return the same instance provided is returned when finished  
 225  
     * 
 226  
     * @throws Exception if the object cannot be fully deserialized
 227  
     */
 228  
    <T> T read(T value, String source) throws Exception;
 229  
         
 230  
    /**
 231  
     * This <code>read</code> method will read the contents of the XML
 232  
     * document from the provided source and populate the object with
 233  
     * the values deserialized. This is used as a means of injecting an
 234  
     * object with values deserialized from an XML document. If the
 235  
     * XML source cannot be deserialized or there is a problem building
 236  
     * the object graph an exception is thrown.
 237  
     * 
 238  
     * @param value this is the object to deserialize the XML in to
 239  
     * @param source this provides the source of the XML document
 240  
     * 
 241  
     * @return the same instance provided is returned when finished 
 242  
     * 
 243  
     * @throws Exception if the object cannot be fully deserialized
 244  
     */
 245  
    <T> T read(T value, File source) throws Exception;
 246  
 
 247  
    /**
 248  
     * This <code>read</code> method will read the contents of the XML
 249  
     * document from the provided source and populate the object with
 250  
     * the values deserialized. This is used as a means of injecting an
 251  
     * object with values deserialized from an XML document. If the
 252  
     * XML source cannot be deserialized or there is a problem building
 253  
     * the object graph an exception is thrown.
 254  
     * 
 255  
     * @param value this is the object to deserialize the XML in to
 256  
     * @param source this provides the source of the XML document
 257  
     * 
 258  
     * @return the same instance provided is returned when finished 
 259  
     * 
 260  
     * @throws Exception if the object cannot be fully deserialized
 261  
     */
 262  
    <T> T read(T value, InputStream source) throws Exception;
 263  
 
 264  
    /**
 265  
     * This <code>read</code> method will read the contents of the XML
 266  
     * document from the provided source and populate the object with
 267  
     * the values deserialized. This is used as a means of injecting an
 268  
     * object with values deserialized from an XML document. If the
 269  
     * XML source cannot be deserialized or there is a problem building
 270  
     * the object graph an exception is thrown.
 271  
     * 
 272  
     * @param value this is the object to deserialize the XML in to
 273  
     * @param source this provides the source of the XML document
 274  
     * 
 275  
     * @return the same instance provided is returned when finished 
 276  
     * 
 277  
     * @throws Exception if the object cannot be fully deserialized
 278  
     */   
 279  
    <T> T read(T value, Reader source) throws Exception;
 280  
    
 281  
    /**
 282  
     * This <code>read</code> method will read the contents of the XML
 283  
     * document from the provided source and populate the object with
 284  
     * the values deserialized. This is used as a means of injecting an
 285  
     * object with values deserialized from an XML document. If the
 286  
     * XML source cannot be deserialized or there is a problem building
 287  
     * the object graph an exception is thrown.
 288  
     * 
 289  
     * @param value this is the object to deserialize the XML in to
 290  
     * @param source this provides the source of the XML document
 291  
     * 
 292  
     * @return the same instance provided is returned when finished 
 293  
     * 
 294  
     * @throws Exception if the object cannot be fully deserialized
 295  
     */ 
 296  
    <T> T read(T value, InputNode source) throws Exception;
 297  
    
 298  
    /**
 299  
     * This <code>read</code> method will read the contents of the XML
 300  
     * document from the provided source and populate the object with
 301  
     * the values deserialized. This is used as a means of injecting an
 302  
     * object with values deserialized from an XML document. If the
 303  
     * XML source cannot be deserialized or there is a problem building
 304  
     * the object graph an exception is thrown.
 305  
     * 
 306  
     * @param value this is the object to deserialize the XML in to
 307  
     * @param source this provides the source of the XML document
 308  
     * @param strict this determines whether to read in strict mode
 309  
     * 
 310  
     * @return the same instance provided is returned when finished  
 311  
     * 
 312  
     * @throws Exception if the object cannot be fully deserialized
 313  
     */
 314  
    <T> T read(T value, String source, boolean strict) throws Exception;
 315  
         
 316  
    /**
 317  
     * This <code>read</code> method will read the contents of the XML
 318  
     * document from the provided source and populate the object with
 319  
     * the values deserialized. This is used as a means of injecting an
 320  
     * object with values deserialized from an XML document. If the
 321  
     * XML source cannot be deserialized or there is a problem building
 322  
     * the object graph an exception is thrown.
 323  
     * 
 324  
     * @param value this is the object to deserialize the XML in to
 325  
     * @param source this provides the source of the XML document
 326  
     * @param strict this determines whether to read in strict mode
 327  
     * 
 328  
     * @return the same instance provided is returned when finished 
 329  
     * 
 330  
     * @throws Exception if the object cannot be fully deserialized
 331  
     */
 332  
    <T> T read(T value, File source, boolean strict) throws Exception;
 333  
 
 334  
    /**
 335  
     * This <code>read</code> method will read the contents of the XML
 336  
     * document from the provided source and populate the object with
 337  
     * the values deserialized. This is used as a means of injecting an
 338  
     * object with values deserialized from an XML document. If the
 339  
     * XML source cannot be deserialized or there is a problem building
 340  
     * the object graph an exception is thrown.
 341  
     * 
 342  
     * @param value this is the object to deserialize the XML in to
 343  
     * @param source this provides the source of the XML document
 344  
     * @param strict this determines whether to read in strict mode
 345  
     * 
 346  
     * @return the same instance provided is returned when finished 
 347  
     * 
 348  
     * @throws Exception if the object cannot be fully deserialized
 349  
     */
 350  
    <T> T read(T value, InputStream source, boolean strict) throws Exception;
 351  
 
 352  
    /**
 353  
     * This <code>read</code> method will read the contents of the XML
 354  
     * document from the provided source and populate the object with
 355  
     * the values deserialized. This is used as a means of injecting an
 356  
     * object with values deserialized from an XML document. If the
 357  
     * XML source cannot be deserialized or there is a problem building
 358  
     * the object graph an exception is thrown.
 359  
     * 
 360  
     * @param value this is the object to deserialize the XML in to
 361  
     * @param source this provides the source of the XML document
 362  
     * @param strict this determines whether to read in strict mode
 363  
     * 
 364  
     * @return the same instance provided is returned when finished 
 365  
     * 
 366  
     * @throws Exception if the object cannot be fully deserialized
 367  
     */   
 368  
    <T> T read(T value, Reader source, boolean strict) throws Exception;
 369  
    
 370  
    /**
 371  
     * This <code>read</code> method will read the contents of the XML
 372  
     * document from the provided source and populate the object with
 373  
     * the values deserialized. This is used as a means of injecting an
 374  
     * object with values deserialized from an XML document. If the
 375  
     * XML source cannot be deserialized or there is a problem building
 376  
     * the object graph an exception is thrown.
 377  
     * 
 378  
     * @param value this is the object to deserialize the XML in to
 379  
     * @param source this provides the source of the XML document
 380  
     * @param strict this determines whether to read in strict mode
 381  
     * 
 382  
     * @return the same instance provided is returned when finished 
 383  
     * 
 384  
     * @throws Exception if the object cannot be fully deserialized
 385  
     */ 
 386  
    <T> T read(T value, InputNode source, boolean strict) throws Exception;
 387  
    
 388  
    /**
 389  
     * This <code>validate</code> method will validate the contents of
 390  
     * the XML document against the specified XML class schema. This is
 391  
     * used to perform a read traversal of the class schema such that 
 392  
     * the document can be tested against it. This is preferred to
 393  
     * reading the document as it does not instantiate the objects or
 394  
     * invoke any callback methods, thus making it a safe validation.
 395  
     * 
 396  
     * @param type this is the class type to be validated against XML
 397  
     * @param source this provides the source of the XML document
 398  
     * 
 399  
     * @return true if the document matches the class XML schema 
 400  
     * 
 401  
     * @throws Exception if the class XML schema does not fully match
 402  
     */
 403  
    boolean validate(Class type, String source) throws Exception;
 404  
         
 405  
    /**
 406  
     * This <code>validate</code> method will validate the contents of
 407  
     * the XML document against the specified XML class schema. This is
 408  
     * used to perform a read traversal of the class schema such that 
 409  
     * the document can be tested against it. This is preferred to
 410  
     * reading the document as it does not instantiate the objects or
 411  
     * invoke any callback methods, thus making it a safe validation.
 412  
     * 
 413  
     * @param type this is the class type to be validated against XML
 414  
     * @param source this provides the source of the XML document
 415  
     * 
 416  
     * @return true if the document matches the class XML schema 
 417  
     * 
 418  
     * @throws Exception if the class XML schema does not fully match
 419  
     */
 420  
    boolean validate(Class type, File source) throws Exception;
 421  
 
 422  
    /**
 423  
     * This <code>validate</code> method will validate the contents of
 424  
     * the XML document against the specified XML class schema. This is
 425  
     * used to perform a read traversal of the class schema such that 
 426  
     * the document can be tested against it. This is preferred to
 427  
     * reading the document as it does not instantiate the objects or
 428  
     * invoke any callback methods, thus making it a safe validation.
 429  
     * 
 430  
     * @param type this is the class type to be validated against XML
 431  
     * @param source this provides the source of the XML document
 432  
     * 
 433  
     * @return true if the document matches the class XML schema 
 434  
     * 
 435  
     * @throws Exception if the class XML schema does not fully match
 436  
     */
 437  
    boolean validate(Class type, InputStream source) throws Exception;
 438  
 
 439  
    /**
 440  
     * This <code>validate</code> method will validate the contents of
 441  
     * the XML document against the specified XML class schema. This is
 442  
     * used to perform a read traversal of the class schema such that 
 443  
     * the document can be tested against it. This is preferred to
 444  
     * reading the document as it does not instantiate the objects or
 445  
     * invoke any callback methods, thus making it a safe validation.
 446  
     * 
 447  
     * @param type this is the class type to be validated against XML
 448  
     * @param source this provides the source of the XML document
 449  
     * 
 450  
     * @return true if the document matches the class XML schema 
 451  
     * 
 452  
     * @throws Exception if the class XML schema does not fully match
 453  
     */  
 454  
    boolean validate(Class type, Reader source) throws Exception;
 455  
    
 456  
    /**
 457  
     * This <code>validate</code> method will validate the contents of
 458  
     * the XML document against the specified XML class schema. This is
 459  
     * used to perform a read traversal of the class schema such that 
 460  
     * the document can be tested against it. This is preferred to
 461  
     * reading the document as it does not instantiate the objects or
 462  
     * invoke any callback methods, thus making it a safe validation.
 463  
     * 
 464  
     * @param type this is the class type to be validated against XML
 465  
     * @param source this provides the source of the XML document
 466  
     * 
 467  
     * @return true if the document matches the class XML schema 
 468  
     * 
 469  
     * @throws Exception if the class XML schema does not fully match
 470  
     */
 471  
    boolean validate(Class type, InputNode source) throws Exception;
 472  
    
 473  
    /**
 474  
     * This <code>validate</code> method will validate the contents of
 475  
     * the XML document against the specified XML class schema. This is
 476  
     * used to perform a read traversal of the class schema such that 
 477  
     * the document can be tested against it. This is preferred to
 478  
     * reading the document as it does not instantiate the objects or
 479  
     * invoke any callback methods, thus making it a safe validation.
 480  
     * 
 481  
     * @param type this is the class type to be validated against XML
 482  
     * @param source this provides the source of the XML document
 483  
     * @param strict this determines whether to read in strict mode
 484  
     * 
 485  
     * @return true if the document matches the class XML schema 
 486  
     * 
 487  
     * @throws Exception if the class XML schema does not fully match
 488  
     */
 489  
    boolean validate(Class type, String source, boolean strict) throws Exception;
 490  
         
 491  
    /**
 492  
     * This <code>validate</code> method will validate the contents of
 493  
     * the XML document against the specified XML class schema. This is
 494  
     * used to perform a read traversal of the class schema such that 
 495  
     * the document can be tested against it. This is preferred to
 496  
     * reading the document as it does not instantiate the objects or
 497  
     * invoke any callback methods, thus making it a safe validation.
 498  
     * 
 499  
     * @param type this is the class type to be validated against XML
 500  
     * @param source this provides the source of the XML document
 501  
     * @param strict this determines whether to read in strict mode
 502  
     * 
 503  
     * @return true if the document matches the class XML schema 
 504  
     * 
 505  
     * @throws Exception if the class XML schema does not fully match
 506  
     */
 507  
    boolean validate(Class type, File source, boolean strict) throws Exception;
 508  
 
 509  
    /**
 510  
     * This <code>validate</code> method will validate the contents of
 511  
     * the XML document against the specified XML class schema. This is
 512  
     * used to perform a read traversal of the class schema such that 
 513  
     * the document can be tested against it. This is preferred to
 514  
     * reading the document as it does not instantiate the objects or
 515  
     * invoke any callback methods, thus making it a safe validation.
 516  
     * 
 517  
     * @param type this is the class type to be validated against XML
 518  
     * @param source this provides the source of the XML document
 519  
     * @param strict this determines whether to read in strict mode
 520  
     * 
 521  
     * @return true if the document matches the class XML schema 
 522  
     * 
 523  
     * @throws Exception if the class XML schema does not fully match
 524  
     */
 525  
    boolean validate(Class type, InputStream source, boolean strict) throws Exception;
 526  
 
 527  
    /**
 528  
     * This <code>validate</code> method will validate the contents of
 529  
     * the XML document against the specified XML class schema. This is
 530  
     * used to perform a read traversal of the class schema such that 
 531  
     * the document can be tested against it. This is preferred to
 532  
     * reading the document as it does not instantiate the objects or
 533  
     * invoke any callback methods, thus making it a safe validation.
 534  
     * 
 535  
     * @param type this is the class type to be validated against XML
 536  
     * @param source this provides the source of the XML document
 537  
     * @param strict this determines whether to read in strict mode
 538  
     * 
 539  
     * @return true if the document matches the class XML schema 
 540  
     * 
 541  
     * @throws Exception if the class XML schema does not fully match
 542  
     */  
 543  
    boolean validate(Class type, Reader source, boolean strict) throws Exception;
 544  
    
 545  
    /**
 546  
     * This <code>validate</code> method will validate the contents of
 547  
     * the XML document against the specified XML class schema. This is
 548  
     * used to perform a read traversal of the class schema such that 
 549  
     * the document can be tested against it. This is preferred to
 550  
     * reading the document as it does not instantiate the objects or
 551  
     * invoke any callback methods, thus making it a safe validation.
 552  
     * 
 553  
     * @param type this is the class type to be validated against XML
 554  
     * @param source this provides the source of the XML document
 555  
     * @param strict this determines whether to read in strict mode
 556  
     * 
 557  
     * @return true if the document matches the class XML schema 
 558  
     * 
 559  
     * @throws Exception if the class XML schema does not fully match
 560  
     */
 561  
    boolean validate(Class type, InputNode source, boolean strict) throws Exception;
 562  
      
 563  
    /**
 564  
     * This <code>write</code> method will traverse the provided object
 565  
     * checking for field annotations in order to compose the XML data.
 566  
     * This uses the <code>getClass</code> method on the object to
 567  
     * determine the class file that will be used to compose the schema.
 568  
     * If there is no <code>Root</code> annotation for the class then
 569  
     * this will throw an exception. The root annotation is the only
 570  
     * annotation required for an object to be serialized.  
 571  
     * 
 572  
     * @param source this is the object that is to be serialized
 573  
     * @param out this is where the serialized XML is written to
 574  
     * 
 575  
     * @throws Exception if the schema for the object is not valid
 576  
     */
 577  
    void write(Object source, File out) throws Exception;
 578  
 
 579  
    /**
 580  
     * This <code>write</code> method will traverse the provided object
 581  
     * checking for field annotations in order to compose the XML data.
 582  
     * This uses the <code>getClass</code> method on the object to
 583  
     * determine the class file that will be used to compose the schema.
 584  
     * If there is no <code>Root</code> annotation for the class then
 585  
     * this will throw an exception. The root annotation is the only
 586  
     * annotation required for an object to be serialized.  
 587  
     * 
 588  
     * @param source this is the object that is to be serialized
 589  
     * @param out this is where the serialized XML is written to
 590  
     * 
 591  
     * @throws Exception if the schema for the object is not valid
 592  
     */   
 593  
    void write(Object source, OutputStream out) throws Exception;
 594  
    
 595  
    /**
 596  
     * This <code>write</code> method will traverse the provided object
 597  
     * checking for field annotations in order to compose the XML data.
 598  
     * This uses the <code>getClass</code> method on the object to
 599  
     * determine the class file that will be used to compose the schema.
 600  
     * If there is no <code>Root</code> annotation for the class then
 601  
     * this will throw an exception. The root annotation is the only
 602  
     * annotation required for an object to be serialized.  
 603  
     * 
 604  
     * @param source this is the object that is to be serialized
 605  
     * @param out this is where the serialized XML is written to
 606  
     * 
 607  
     * @throws Exception if the schema for the object is not valid
 608  
     */   
 609  
    void write(Object source, Writer out) throws Exception;
 610  
    
 611  
    /**
 612  
     * This <code>write</code> method will traverse the provided object
 613  
     * checking for field annotations in order to compose the XML data.
 614  
     * This uses the <code>getClass</code> method on the object to
 615  
     * determine the class file that will be used to compose the schema.
 616  
     * If there is no <code>Root</code> annotation for the class then
 617  
     * this will throw an exception. The root annotation is the only
 618  
     * annotation required for an object to be serialized.  
 619  
     * 
 620  
     * @param source this is the object that is to be serialized
 621  
     * @param root this is where the serialized XML is written to
 622  
     * 
 623  
     * @throws Exception if the schema for the object is not valid
 624  
     */
 625  
    void write(Object source, OutputNode root) throws Exception;
 626  
 }