Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: edu/ou/kmi/buddyspace/xml/XDataBuilder.java


1   /*
2    *   License
3    *
4    * The contents of this file are subject to the Jabber Open Source License
5    * Version 1.0 (the "License").  You may not copy or use this file, in either
6    * source code or executable form, except in compliance with the License.  You
7    * may obtain a copy of the License at http://www.jabber.com/license/ or at
8    * http://www.opensource.org/.  
9    *
10   * Software distributed under the License is distributed on an "AS IS" basis,
11   * WITHOUT WARRANTY OF ANY KIND, either express or implied.  See the License
12   * for the specific language governing rights and limitations under the
13   * License.
14   *
15   *   Copyrights
16   *
17   * Portions created by or assigned to Jabber.com, Inc. are 
18   * Copyright (c) 2000 Jabber.com, Inc.  All Rights Reserved.  Contact
19   * information for Jabber.com, Inc. is available at http://www.jabber.com/.
20   *
21   * Portions Copyright (c) 1999-2000 David Waite 
22   *
23   *   Acknowledgements
24   * 
25   * Special thanks to the Jabber Open Source Contributors for their
26   * suggestions and support of Jabber.
27   * 
28   *   Changes
29   *
30   * @author  David Waite <a href="mailto:dwaite@jabber.com">
31   *                      <i>&lt;dwaite@jabber.com&gt;</i></a>
32   *
33   * @author  $Author: brouk $
34   * @version $Revision: 1.2 $
35   *
36   * j.komzak
37   * Changed into XDataBuilder
38   */
39  
40  package edu.ou.kmi.buddyspace.xml;
41  
42  /*
43   * XDataBuilder.java
44   *
45   * Project: BuddySpace
46   * (C) Copyright Knowledge Media Institute 2003
47   *
48   *
49   * Created on 4 February 2003, 16:11
50   */
51  
52  import java.util.Vector;
53  import org.jabber.jabberbeans.Extension.*;
54  
55  /**
56   * <code>XDataBuilder</code> is used to construct XData objects
57   *
58   * @author  Jiri Komzak, Knowledge Media Institute, Open University, United Kingdom
59   */
60  public class XDataBuilder
61      implements ExtensionBuilder
62  {
63      /** Vector of field objects contained. */
64      private Vector fields;
65      /** Vector of item and reported objects contained. */
66      private Vector items;
67      
68      private String type = null;
69      private String title = null;
70      private String instructions = null;
71  
72      /** Creates a new <code>XDataBuilder</code> instance. */
73      public XDataBuilder()
74      { reset(); }
75      
76      /**
77       * <code>reset</code> the builder to a default state, so it can be reused.
78       */
79      public void reset() {
80          fields = new Vector();
81          items = new Vector();
82          type = title = instructions = null;
83      }
84      
85      public void setType(String newType) {
86          type = newType;
87      }
88      
89      public String getType() {
90          return type;
91      }
92  
93      public void setTitle(String newTitle) {
94          title = newTitle;
95      }
96      
97      public String getTitle() {
98          return title;
99      }
100 
101     public void setInstructions(String newInstructions) {
102         instructions = newInstructions;
103     }
104     
105     public String getInstructions() {
106         return instructions;
107     }
108 
109     /**
110      * <code>addField</code> adds a new field object to the end of this
111      * list.
112      *
113      * @param field an <code>XDataField</code> value
114      */
115     public void addField(XDataField field)
116     {
117         if (!fields.contains(field))
118             fields.addElement(field);
119     }
120 
121     /**
122      * <code>getFields</code> returns the vector representing the field
123      * objects associated with this object.
124      *
125      * @return a <code>Vector</code> value
126      */
127     public Vector getFields()
128     { return fields; }
129     
130     /**
131      * <code>addItem</code> adds a new item object to the end of this
132      * list.
133      *
134      * @param item an <code>XDataItem</code> value
135      */
136     public void addItem(XDataItem item)
137     {
138         if (!items.contains(item))
139             items.addElement(item);
140     }
141 
142     /**
143      * <code>getItems</code> returns the vector representing the item/reported
144      * objects associated with this object.
145      *
146      * @return a <code>Vector</code> value
147      */
148     public Vector getItems()
149     { return items; }
150 
151     /**
152      * <code>build</code> a new XData object
153      *
154      * @return an <code>Extension</code> value
155      * @exception InstantiationException if insufficient or incorrect data
156      * was proviced.
157      */
158     public Extension build()
159         throws InstantiationException
160     { return new XData(this); }
161 }