KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sync4j > framework > core > bootstrap > WapProvisioningDoc


1 /**
2  * Copyright (C) 2003-2005 Funambol
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18
19 package sync4j.framework.core.bootstrap;
20
21 import java.io.ByteArrayOutputStream JavaDoc;
22 import java.util.ArrayList JavaDoc;
23 import java.util.List JavaDoc;
24
25 import org.jibx.runtime.BindingDirectory;
26 import org.jibx.runtime.IBindingFactory;
27 import org.jibx.runtime.IMarshallingContext;
28 import org.jibx.runtime.JiBXException;
29
30
31 /**
32  * Corresponds to the <wap-provisioningdoc> tag in a Wap provisioning doc.
33  *
34  * @author Stefano Nichele
35  *
36  * @version $Id: WapProvisioningDoc.java,v 1.1 2005/05/16 17:32:54 nichele Exp $
37  *
38  */

39 public final class WapProvisioningDoc {
40
41     // -------------------------------------------------------------- Properties
42
private ArrayList JavaDoc characteristics = null;
43
44     private String JavaDoc version = null;
45
46     // ------------------------------------------------------------ Constructors
47

48     /**
49      * Creates a new WapProvisioningDoc
50      */

51     public WapProvisioningDoc() {
52         characteristics = new ArrayList JavaDoc();
53     }
54
55
56     /**
57      * Creates a new WapProvisioningDoc with the given versione
58      * @param version the version of this WapProvisioningDoc
59      */

60     public WapProvisioningDoc(String JavaDoc version) {
61         this.version = version;
62         characteristics = new ArrayList JavaDoc();
63     }
64
65
66     /**
67       * Gets the version of this WapProvisioningDoc
68       * @return the version of this WapProvisioningDoc
69       */

70      public String JavaDoc getVersion() {
71          return version;
72      }
73
74      /**
75       * Sets the version of this WapProvisioningDoc
76       * @param name the version to set
77       */

78      public void setVersion(String JavaDoc version) {
79          this.version = version;
80      }
81
82     /**
83      * Adds new <code>Characteristic</code> to this WapProvisioningDoc
84      *
85      * @param characteristicToAdd the characteristic to add
86      */

87     public void addCharacteristic(Characteristic characteristicToAdd) {
88         characteristics.add(characteristicToAdd);
89     }
90
91     /**
92      * Adds a list of<code>Characteristic</code> to this WapProvisioningDoc
93      *
94      * @param characteristicToAdd the characteristic to add
95      */

96     public void addCharacteristicList(List JavaDoc characteristicsToAdd) {
97             characteristics.addAll(characteristicsToAdd);
98     }
99
100     /**
101      * Returns a xml representation of this WapProvisioningDoc
102      * @return String
103      */

104     public String JavaDoc toXml() throws JiBXException {
105         ByteArrayOutputStream JavaDoc bout = new ByteArrayOutputStream JavaDoc();
106
107         IBindingFactory f = BindingDirectory.getFactory(WapProvisioningDoc.class);
108         IMarshallingContext c = f.createMarshallingContext();
109         c.setIndent(0);
110         c.marshalDocument(this, "UTF-8", null, bout);
111
112         String JavaDoc inputXml = new String JavaDoc(bout.toByteArray());
113
114         return inputXml;
115
116     }
117
118 }
Popular Tags