View Javadoc

1   /**********************************************************************
2    * XmlBeansAdapter.java
3    * created on 02.12.2006 by netseeker
4    * $Id: XmlBeansAdapter.java,v 1.2 2007/03/03 00:01:42 netseeker Exp $
5    * $Log: XmlBeansAdapter.java,v $
6    * Revision 1.2  2007/03/03 00:01:42  netseeker
7    * *** empty log message ***
8    *
9    * Revision 1.1  2006/12/02 18:23:20  netseeker
10   * *** empty log message ***
11   *
12   *
13   * ====================================================================
14   *
15   *  Copyright 2005-2006 netseeker aka Michael Manske
16   *
17   *  Licensed under the Apache License, Version 2.0 (the "License");
18   *  you may not use this file except in compliance with the License.
19   *  You may obtain a copy of the License at
20   *
21   *      http://www.apache.org/licenses/LICENSE-2.0
22   *
23   *  Unless required by applicable law or agreed to in writing, software
24   *  distributed under the License is distributed on an "AS IS" BASIS,
25   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26   *  See the License for the specific language governing permissions and
27   *  limitations under the License.
28   * ====================================================================
29   *
30   * This file is part of the EJOE framework.
31   * For more information on the author, please see
32   * <http://www.manskes.de/>.
33   *
34   *********************************************************************/
35  package de.netseeker.ejoe.adapter;
36  
37  import java.io.InputStream;
38  import java.io.OutputStream;
39  
40  import org.apache.xmlbeans.XmlObject;
41  
42  /***
43   * A simple SerializeAdapter for the great XMLBeans framework.
44   * @see <a href="http://xmlbeans.apache.org/index.html">http://xmlbeans.apache.org/index.html</a>
45   * @author netseeker
46   * @since 0.3.9.2
47   */
48  public class XmlBeansAdapter extends BaseAdapter
49  {
50      /***
51       * 
52       */
53      private static final long serialVersionUID = 1L;
54  
55      /***
56       * Creates a new instance of XmlBeansAdapter
57       */
58      public XmlBeansAdapter()
59      {
60      }
61  
62      /*
63       * (non-Javadoc)
64       * 
65       * @see de.netseeker.ejoe.adapter.SerializeAdapter#read(java.io.InputStream)
66       */
67      public Object read( InputStream in ) throws Exception
68      {
69          return XmlObject.Factory.parse( in );
70      }
71  
72      /*
73       * (non-Javadoc)
74       * 
75       * @see de.netseeker.ejoe.adapter.SerializeAdapter#write(java.lang.Object, java.io.OutputStream)
76       */
77      public void write( Object obj, OutputStream out ) throws Exception
78      {
79          XmlObject xmlObj = (XmlObject) obj;
80          xmlObj.save( out );
81      }
82  
83      /*
84       * (non-Javadoc)
85       * 
86       * @see de.netseeker.ejoe.adapter.BaseAdapter#getContentType()
87       */
88      public String getContentType()
89      {
90          return "text/xml";
91      }
92  }