View Javadoc

1   /*
2    * $HeadURL: $
3    * $Date: $
4    * $Revision: $
5    * $Author: $
6    * 
7    * Copyright (c) 2005 MindTree Consulting Ltd. 
8    * 
9    * This file is part of Insight.
10   * 
11   * Insight is free software: you can redistribute it and/or modify it under the 
12   * terms of the GNU General Public License as published by the Free Software 
13   * Foundation, either version 3 of the License, or (at your option) any later 
14   * version.
15   * 
16   * Insight is distributed in the hope that it will be useful, but 
17   * WITHOUT ANY WARRANTY; without even the implied warranty of 
18   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General 
19   * Public License for more details.
20   * 
21   * You should have received a copy of the GNU General Public License along with 
22   * Insight.  If not, see <http://www.gnu.org/licenses/>.
23   */
24  
25  package com.mindtree.techworks.insight.preferences.xmlpersistence;
26  
27  import java.util.ArrayList;
28  import java.util.Stack;
29  
30  import org.xml.sax.Attributes;
31  import org.xml.sax.SAXException;
32  import org.xml.sax.helpers.DefaultHandler;
33  
34  import com.mindtree.techworks.insight.preferences.model.ListPreferenceAttribute;
35  import com.mindtree.techworks.insight.preferences.model.Preference;
36  import com.mindtree.techworks.insight.preferences.model.PreferenceAttribute;
37  import com.mindtree.techworks.insight.preferences.model.PreferenceAttributeType;
38  import com.mindtree.techworks.insight.preferences.util.Crypt;
39  
40  
41  /**
42   * Reads data from the XML Preference store and populates the preference objects
43   * into the {@link XMLPreferenceDataCache Data Cache}.
44   * 
45   * This class is a specialization of {@link org.xml.sax.helpers.DefaultHandler 
46   * Default Handler}.
47   * 
48   * This class reads XML data for the following Schema 
49   * 
50   * <pre>
51   * &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
52   *    &lt;!-- edited with XMLSPY v5 rel. 4 U (http://www.xmlspy.com) by Bindul Bhowmik (GALILEO INTERNATIONAL) --&gt;
53   *    &lt;xs:schema targetNamespace=&quot;http://mindtree.com/logging/insight/Preferences&quot; xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:preferences=&quot;http://mindtree.com/logging/insight/Preferences&quot; elementFormDefault=&quot;qualified&quot; attributeFormDefault=&quot;unqualified&quot; version=&quot;1.0&quot;&gt;
54   *    	&lt;!-- Root element --&gt;
55   *    	&lt;xs:element name=&quot;InsightPreferences&quot;&gt;
56   *    		 &lt;xs:annotation&gt;
57   *    			&lt;xs:documentation&gt;Stores all the preferences for Insight. All preferences are to be configured in an XML file conforming to this XSD, this Schema will also define the storage of the preference values in a user's system.&lt;/xs:documentation&gt;
58   *    		&lt;/xs:annotation&gt;
59   *    		&lt;xs:complexType&gt;
60   *    			&lt;xs:sequence&gt;
61   *    				&lt;xs:element name=&quot;preference&quot; type=&quot;preferences:Preference&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;unbounded&quot;&gt;
62   *    					&lt;xs:annotation&gt;
63   *    						&lt;xs:documentation&gt;See documentation with Preference&lt;/xs:documentation&gt;
64   *    					&lt;/xs:annotation&gt;
65   *    				&lt;/xs:element&gt;
66   *    			&lt;/xs:sequence&gt;
67   *    		&lt;/xs:complexType&gt;
68   *    	&lt;/xs:element&gt;
69   *    	&lt;!-- ComplexType representing a particular Preference --&gt;
70   *    	&lt;xs:complexType name=&quot;Preference&quot;&gt;
71   *    		&lt;xs:annotation&gt;
72   *    			&lt;xs:documentation&gt;Correspons to a particular Preference, which in turn will have a list of preference attributes&lt;/xs:documentation&gt;
73   *    		&lt;/xs:annotation&gt;
74   *    		&lt;xs:sequence&gt;
75   *    			&lt;xs:element name=&quot;preferenceAttribute&quot; type=&quot;preferences:PreferenceAttribute&quot; maxOccurs=&quot;unbounded&quot;&gt;
76   *    				&lt;xs:annotation&gt;
77   *    					&lt;xs:documentation&gt;See documentation with PreferenceAttribute&lt;/xs:documentation&gt;
78   *    				&lt;/xs:annotation&gt;
79   *    			&lt;/xs:element&gt;
80   *    		&lt;/xs:sequence&gt;
81   *    		&lt;xs:attribute name=&quot;id&quot; use=&quot;required&quot;&gt;
82   *    			&lt;xs:annotation&gt;
83   *    				&lt;xs:documentation&gt;The ID of the Preference Attribute. Each attribute will be uniquely identified by a combination of the Preference ID and the Preference Attribute ID&lt;/xs:documentation&gt;
84   *    			&lt;/xs:annotation&gt;
85   *    			&lt;xs:simpleType&gt;
86   *    				&lt;xs:restriction base=&quot;xs:string&quot;&gt;
87   *    					&lt;xs:whiteSpace value=&quot;collapse&quot;/&gt;
88   *    					&lt;xs:minLength value=&quot;3&quot;/&gt;
89   *    				&lt;/xs:restriction&gt;
90   *    			&lt;/xs:simpleType&gt;
91   *    		&lt;/xs:attribute&gt;
92   *    		&lt;xs:attribute name=&quot;name&quot; use=&quot;required&quot;&gt;
93   *    			&lt;xs:annotation&gt;
94   *    				&lt;xs:documentation&gt;The Display name of the Preference Attribute&lt;/xs:documentation&gt;
95   *    			&lt;/xs:annotation&gt;
96   *    			&lt;xs:simpleType&gt;
97   *    				&lt;xs:restriction base=&quot;xs:string&quot;&gt;
98   *    					&lt;xs:minLength value=&quot;5&quot;/&gt;
99   *    					&lt;xs:whiteSpace value=&quot;collapse&quot;/&gt;
100  *    				&lt;/xs:restriction&gt;
101  *    			&lt;/xs:simpleType&gt;
102  *    		&lt;/xs:attribute&gt;
103  *    	&lt;/xs:complexType&gt;
104  *    	&lt;!-- Complex type representing a PreferenceAttribute --&gt;
105  *    	&lt;xs:complexType name=&quot;PreferenceAttribute&quot;&gt;
106  *    		&lt;xs:annotation&gt;
107  *    			&lt;xs:documentation&gt;A Preference Attribute is a particular value within a Preference. It is uniquely identified by the id of this element.&lt;/xs:documentation&gt;
108  *    		&lt;/xs:annotation&gt;
109  *    		&lt;xs:sequence&gt;
110  *    			&lt;xs:element name=&quot;defaultValue&quot; type=&quot;xs:string&quot; minOccurs=&quot;0&quot;&gt;
111  *    				&lt;xs:annotation&gt;
112  *    					&lt;xs:documentation&gt;The value to be supplied when no value is set.&lt;/xs:documentation&gt;
113  *    				&lt;/xs:annotation&gt;
114  *    			&lt;/xs:element&gt;
115  *    			&lt;xs:element name=&quot;value&quot; type=&quot;xs:string&quot; minOccurs=&quot;0&quot;&gt;
116  *    				&lt;xs:annotation&gt;
117  *    					&lt;xs:documentation&gt;The value of the attribute. The value if set for transient attributes will be ignored, and will not be stored back.&lt;/xs:documentation&gt;
118  *    				&lt;/xs:annotation&gt;
119  *    			&lt;/xs:element&gt;
120  *    			&lt;xs:element name=&quot;type&quot; default=&quot;TEXT&quot;&gt;
121  *    				&lt;xs:annotation&gt;
122  *    					&lt;xs:documentation&gt;The type of the attribute, as of version 1.0 only two types are supported, TEXT and LIST&lt;/xs:documentation&gt;
123  *    				&lt;/xs:annotation&gt;
124  *    				&lt;xs:simpleType&gt;
125  *    					&lt;xs:restriction base=&quot;xs:string&quot;&gt;
126  *    						&lt;xs:enumeration value=&quot;TEXT&quot;/&gt;
127  *    						&lt;xs:enumeration value=&quot;LIST&quot;/&gt;
128  *    					&lt;/xs:restriction&gt;
129  *    				&lt;/xs:simpleType&gt;
130  *    			&lt;/xs:element&gt;
131  *    			&lt;xs:element name=&quot;persistant&quot; type=&quot;xs:boolean&quot; default=&quot;true&quot;&gt;
132  *    				&lt;xs:annotation&gt;
133  *    					&lt;xs:documentation&gt;Indicates whether a particular preference attribute value will persist across instances of the application&lt;/xs:documentation&gt;
134  *    				&lt;/xs:annotation&gt;
135  *    			&lt;/xs:element&gt;
136  *    			&lt;xs:element name=&quot;userModifiable&quot; type=&quot;xs:string&quot; default=&quot;true&quot;&gt;
137  *    				&lt;xs:annotation&gt;
138  *    					&lt;xs:documentation&gt;Identifies whether the user can modify this attribute using the GUI.&lt;/xs:documentation&gt;
139  *    				&lt;/xs:annotation&gt;
140  *    			&lt;/xs:element&gt;
141  *    		&lt;/xs:sequence&gt;
142  *    		&lt;xs:attribute name=&quot;id&quot; use=&quot;required&quot;&gt;
143  *    			&lt;xs:annotation&gt;
144  *    				&lt;xs:documentation&gt;The ID of the Preference Attribute. Each attribute will be uniquely identified by a combination of the Preference ID and the Preference Attribute ID&lt;/xs:documentation&gt;
145  *    			&lt;/xs:annotation&gt;
146  *    			&lt;xs:simpleType&gt;
147  *    				&lt;xs:restriction base=&quot;xs:string&quot;&gt;
148  *    					&lt;xs:whiteSpace value=&quot;collapse&quot;/&gt;
149  *    					&lt;xs:minLength value=&quot;3&quot;/&gt;
150  *    				&lt;/xs:restriction&gt;
151  *    			&lt;/xs:simpleType&gt;
152  *    		&lt;/xs:attribute&gt;
153  *    		&lt;xs:attribute name=&quot;name&quot; use=&quot;required&quot;&gt;
154  *    			&lt;xs:annotation&gt;
155  *    				&lt;xs:documentation&gt;The Display name of the Preference Attribute&lt;/xs:documentation&gt;
156  *    			&lt;/xs:annotation&gt;
157  *    			&lt;xs:simpleType&gt;
158  *    				&lt;xs:restriction base=&quot;xs:string&quot;&gt;
159  *    					&lt;xs:minLength value=&quot;5&quot;/&gt;
160  *    					&lt;xs:whiteSpace value=&quot;collapse&quot;/&gt;
161  *    				&lt;/xs:restriction&gt;
162  *    			&lt;/xs:simpleType&gt;
163  *    		&lt;/xs:attribute&gt;
164  *    	&lt;/xs:complexType&gt;
165  *    	&lt;!-- A specialization of the Preference Attribute to have a list of values --&gt;
166  *    	&lt;xs:complexType name=&quot;ListPreferenceAttribute&quot;&gt;
167  *    		&lt;xs:annotation&gt;
168  *    			&lt;xs:documentation&gt;A specialized form of attribute where a list of possible values or options are provided.&lt;/xs:documentation&gt;
169  *    		&lt;/xs:annotation&gt;
170  *    		&lt;xs:complexContent&gt;
171  *    			&lt;xs:extension base=&quot;preferences:PreferenceAttribute&quot;&gt;
172  *    				&lt;xs:sequence&gt;
173  *    					&lt;xs:element name=&quot;options&quot;&gt;
174  *    						&lt;xs:annotation&gt;
175  *    							&lt;xs:documentation&gt;The various optoins from which the value of the preference attribute this list is part of can be derived&lt;/xs:documentation&gt;
176  *    						&lt;/xs:annotation&gt;
177  *    						&lt;xs:complexType&gt;
178  *    							&lt;xs:sequence&gt;
179  *    								&lt;xs:element name=&quot;option&quot; type=&quot;xs:string&quot; maxOccurs=&quot;unbounded&quot;&gt;
180  *    									&lt;xs:annotation&gt;
181  *    										&lt;xs:documentation&gt;A particular option. See documentation for options.&lt;/xs:documentation&gt;
182  *    									&lt;/xs:annotation&gt;
183  *    								&lt;/xs:element&gt;
184  *    							&lt;/xs:sequence&gt;
185  *    						&lt;/xs:complexType&gt;
186  *    					&lt;/xs:element&gt;
187  *    				&lt;/xs:sequence&gt;
188  *    			&lt;/xs:extension&gt;
189  *    		&lt;/xs:complexContent&gt;
190  *    	&lt;/xs:complexType&gt;
191  *    &lt;/xs:schema&gt;
192  *    
193  *   
194  *  
195  * </pre>
196  * @author Bindul Bhowmik
197  * @version $Revision: 161 $ $Date: 2008-04-04 22:48:39 -0600 (Fri, 04 Apr 2008) $
198  */
199 public class XMLPreferenceDataReader extends DefaultHandler implements PreferenceXMLNameConstants {
200 
201 	/**
202 	 * The current Preference being read
203 	 */
204 	private Preference currentPreference;
205 	
206 	/**
207 	 * Stack for nested Preferences.
208 	 */
209 	private Stack preferenceStack;
210 
211 	/**
212 	 * The id of the current PreferenceAttribute being read
213 	 */
214 	private String currentPreferenceAttributeId;
215 
216 	/**
217 	 * The name of the current PreferenceAttribute being read
218 	 */
219 	private String currentPreferenceAttributeName;
220 
221 	/**
222 	 * The xsi:type of the current PreferenceAttribute being read
223 	 */
224 	private String currentPreferenceAttributeXSIType;
225 
226 	/**
227 	 * The defaultValue of the current PreferenceAttribute being read
228 	 */
229 	private String currentPreferenceAttributeDefaultValue = "";
230 
231 	/**
232 	 * The value of the current PreferenceAttribute being read
233 	 */
234 	private String currentPreferenceAttributeValue = "";
235 
236 	/**
237 	 * Tells whether the value of the current PreferenceAttribute is encrypted.
238 	 */
239 	private boolean isPreferenceAttributeValueEncrypted = false;
240 	
241 	/**
242 	 * The isPersistant of the current PreferenceAttribute being read
243 	 */
244 	private boolean isCurrentPreferenceAttributePersistant = true;
245 
246 	/**
247 	 * The isUserModifiable of the current PreferenceAttribute being read
248 	 */
249 	private boolean isCurrentPreferenceAttributeUserModifiable = true;
250 
251 	/**
252 	 * Read CDATA for the which element?
253 	 */
254 	private String currentElementToReadDataFor;
255 
256 	/**
257 	 * The type of the current PreferenceAttribute being read
258 	 */
259 	private PreferenceAttributeType currentPreferenceAttributeType;
260 
261 	/**
262 	 * Instance of the cache to which preferences will be stored.
263 	 */
264 	private XMLPreferenceDataCache cache;
265 
266 	/**
267 	 * The  of the current PreferenceAttribute being read
268 	 */
269 	private ArrayList currentPreferenceAttributeOptionList;
270 	
271 	/**
272 	 * The character buffer is used to hold the character data being parsed.
273 	 */
274 	private StringBuffer characterBuffer;
275 
276 	/**
277 	 * Default constructor
278 	 */
279 	public XMLPreferenceDataReader () {
280 
281 		cache = XMLPreferenceDataCache.getInstance();
282 		preferenceStack = new Stack();
283 		characterBuffer = new StringBuffer();
284 	}
285 
286 	/**
287 	 * @see org.xml.sax.ContentHandler#endElement(java.lang.String,
288 	 *      java.lang.String, java.lang.String)
289 	 */
290 	public void endElement (String uri, String localName, String qName)
291 			throws SAXException {
292 
293 		// Set the value of the element
294 		if (null != currentElementToReadDataFor && characterBuffer.length() > 0) {
295 			if (currentElementToReadDataFor
296 					.equals(XMLNAME_PREF_ATT_DEFAULT_VALUE)) {
297 				currentPreferenceAttributeDefaultValue = currentPreferenceAttributeDefaultValue + characterBuffer.toString();
298 			} else if (currentElementToReadDataFor
299 					.equals(XMLNAME_PREF_ATT_VALUE)) {
300 				currentPreferenceAttributeValue = currentPreferenceAttributeValue + characterBuffer.toString();
301 			} else if (currentElementToReadDataFor
302 					.equals(XMLNAME_PREF_ATT_TYPE)) {
303 				currentPreferenceAttributeType = PreferenceAttributeType
304 						.getPreferenceAttributeByName(characterBuffer.toString());
305 			} else if (currentElementToReadDataFor
306 					.equals(XMLNAME_PREF_ATT_ENCRYPTED)) {
307 				isPreferenceAttributeValueEncrypted = TRUE.equals(characterBuffer.toString());
308 				if(isPreferenceAttributeValueEncrypted)
309 					currentPreferenceAttributeValue = 
310 						Crypt.decryptHexString(currentPreferenceAttributeValue);
311 			} else if (currentElementToReadDataFor
312 					.equals(XMLNAME_PREF_ATT_PERSISTANT)) {
313 				isCurrentPreferenceAttributePersistant = TRUE.equals(characterBuffer.toString());
314 			} else if (currentElementToReadDataFor
315 					.equals(XMLNAME_PREF_ATT_USER_MOD)) {
316 				isCurrentPreferenceAttributeUserModifiable = TRUE.equals(characterBuffer.toString());
317 			} else if (currentElementToReadDataFor
318 					.equals(XMLNAME_PREF_ATT_OPTION_VAL)
319 					&& null != currentPreferenceAttributeOptionList) {
320 				currentPreferenceAttributeOptionList.add(characterBuffer.toString());
321 			}
322 			
323 			characterBuffer.setLength(0);
324 		}
325 		
326 		if (XMLNAME_PREFERENCE.equals(localName)) {
327 			endPreference();
328 		} else if (XMLNAME_INSIGHT_PREFERENCE.equals(localName)) {
329 			//System.out.println("End insight preferences");
330 		} else if (XMLNAME_PREFERENCE_ATTRIBUTE.equals(localName)) {
331 			endPreferenceAttribute();
332 		} else if (XMLNAME_PREF_ATT_DEFAULT_VALUE.equals(localName)
333 				|| XMLNAME_PREF_ATT_VALUE.equals(localName)
334 				|| XMLNAME_PREF_ATT_TYPE.equals(localName)
335 				|| XMLNAME_PREF_ATT_ENCRYPTED.equals(localName)
336 				|| XMLNAME_PREF_ATT_PERSISTANT.equals(localName)
337 				|| XMLNAME_PREF_ATT_USER_MOD.equals(localName)
338 				|| XMLNAME_PREF_ATT_OPTION_VAL.equals(localName)) {
339 			currentElementToReadDataFor = null;
340 		} else if (XMLNAME_PREF_ATT_OPTIONS.equals(localName)) {
341 			//do nothing
342 		} else {
343 			System.out.println("END-" + uri + "_" + localName + "_" + qName);
344 		}
345 	}
346 
347 	/**
348 	 * @see org.xml.sax.ContentHandler#startElement(java.lang.String,
349 	 *      java.lang.String, java.lang.String, org.xml.sax.Attributes)
350 	 */
351 	public void startElement (String uri, String localName, String qName,
352 			Attributes attributes) throws SAXException {
353 
354 		if (XMLNAME_PREFERENCE.equals(localName)) {
355 			startPreference(attributes);
356 		} else if (XMLNAME_INSIGHT_PREFERENCE.equals(localName)) {
357 			//System.out.println("Started insight preferences");
358 		} else if (XMLNAME_PREFERENCE_ATTRIBUTE.equals(localName)) {
359 			startPreferenceAttribute(attributes);
360 		} else if (XMLNAME_PREF_ATT_DEFAULT_VALUE.equals(localName)
361 				|| XMLNAME_PREF_ATT_VALUE.equals(localName)
362 				|| XMLNAME_PREF_ATT_TYPE.equals(localName)
363 				|| XMLNAME_PREF_ATT_ENCRYPTED.equals(localName)
364 				|| XMLNAME_PREF_ATT_PERSISTANT.equals(localName)
365 				|| XMLNAME_PREF_ATT_USER_MOD.equals(localName)
366 				|| XMLNAME_PREF_ATT_OPTION_VAL.equals(localName)) {
367 			currentElementToReadDataFor = localName;
368 		} else if (XMLNAME_PREF_ATT_OPTIONS.equals(localName)) {
369 			startOptions();
370 		} else {
371 			System.out.println("START-" + uri + "_" + localName + "_" + qName);
372 		}
373 		
374 		// Clear the character buffer
375 		characterBuffer.setLength(0);
376 	}
377 
378 	/**
379 	 * @see org.xml.sax.ContentHandler#characters(char[], int, int)
380 	 */
381 	public void characters (char [] ch, int start, int length)
382 			throws SAXException {
383 
384 		if (null != currentElementToReadDataFor) {
385 			characterBuffer.append(ch, start, length);
386 		}
387 
388 	}	
389 
390 	/**
391 	 * Creates a Preference Object
392 	 * 
393 	 * @param attributes attributes of the preference
394 	 */
395 	private void startPreference (Attributes attributes) {
396 
397 		String id = attributes.getValue(XMLNAME_PREFERENCE_ID);
398 		String name = attributes.getValue(XMLNAME_PREFERENCE_NAME);
399 		String isUserModifableValue = attributes.getValue(XMLNAME_PREFERENCE_ISUSERMOD);
400 		boolean isUserModifiable = TRUE.equals(isUserModifableValue);
401 		String isAggregatedValue = attributes.getValue(XMLNAME_PREFERENCE_ISAGGREGATED);
402 		boolean isAggregated = TRUE.equals(isAggregatedValue);
403 		String displayClass = attributes.getValue(XMLNAME_PREFERENCE_DISPLAY_CLASS);
404 
405 		if (null != currentPreference) {
406 			// Nested Preferences
407 			preferenceStack.push(currentPreference);
408 			
409 			currentPreference = new Preference(id, isUserModifiable, isAggregated, name);
410 			currentPreference.setDisplayClass(displayClass);
411 			
412 			Preference parentPreference = (Preference) preferenceStack.peek();
413 			parentPreference.addChildPreference(currentPreference);
414 		} else {
415 			currentPreference = new Preference(id, isUserModifiable, isAggregated, name);
416 			currentPreference.setDisplayClass(displayClass);
417 		}
418 	}
419 
420 	/**
421 	 * Clears the current Preference after saving it to the cache.
422 	 */
423 	private void endPreference () {
424 
425 		if (preferenceStack.empty()) {
426 			cache.addPreference(currentPreference);
427 			currentPreference = null;
428 		} else {
429 			// Nested Preferences
430 			currentPreference = (Preference) preferenceStack.pop();
431 		}
432 		
433 	}
434 
435 	/**
436 	 * Marks the start of an Preference Attribute element.
437 	 * 
438 	 * @param attributes The XML attributes of the Preference Attribute
439 	 */
440 	private void startPreferenceAttribute (Attributes attributes) {
441 
442 		currentPreferenceAttributeId = attributes
443 				.getValue(XMLNAME_PREFERENCE_ATT_ID);
444 		currentPreferenceAttributeName = attributes
445 				.getValue(XMLNAME_PREFERENCE_ATT_NAME);
446 		currentPreferenceAttributeXSIType = attributes.getValue(XSI_NAMESPACE,
447 				XMLNAME_XSI_TYPE);
448 	}
449 
450 	/**
451 	 * Creates the appropriate Preference Attribute object and adds it to the
452 	 * current Preference
453 	 */
454 	private void endPreferenceAttribute () {
455 
456 		if (!currentPreference.isUserModifiable()) {
457 			isCurrentPreferenceAttributeUserModifiable = false;
458 		}
459 		
460 		if (XMLNAME_LIST_PREFERENCE_ATTRIBUTE
461 				.equals(currentPreferenceAttributeXSIType)) {
462 			//List Preference Attribute
463 			ListPreferenceAttribute preferenceAttribute = new ListPreferenceAttribute(
464 					currentPreferenceAttributeId,
465 					currentPreferenceAttributeValue,
466 					isPreferenceAttributeValueEncrypted,
467 					isCurrentPreferenceAttributePersistant,
468 					isCurrentPreferenceAttributeUserModifiable,
469 					currentPreference, currentPreferenceAttributeOptionList);
470 
471 			if (null != currentPreferenceAttributeDefaultValue) {
472 				preferenceAttribute.setDefaultValue(currentPreferenceAttributeDefaultValue);
473 			}
474 			preferenceAttribute.setName(currentPreferenceAttributeName);
475 			currentPreference.addPreferenceAttribute(preferenceAttribute);
476 			
477 		} else {
478 			PreferenceAttribute preferenceAttribute = new PreferenceAttribute(
479 					currentPreferenceAttributeType,
480 					currentPreferenceAttributeId,
481 					currentPreferenceAttributeValue,
482 					isPreferenceAttributeValueEncrypted,
483 					isCurrentPreferenceAttributePersistant,
484 					isCurrentPreferenceAttributeUserModifiable,
485 					currentPreference);
486 
487 			if (null != currentPreferenceAttributeDefaultValue) {
488 				preferenceAttribute.setDefaultValue(currentPreferenceAttributeDefaultValue);
489 			}
490 			preferenceAttribute.setName(currentPreferenceAttributeName);
491 			currentPreference.addPreferenceAttribute(preferenceAttribute);
492 		}
493 
494 		currentPreferenceAttributeId = null;
495 		currentPreferenceAttributeName = null;
496 		currentPreferenceAttributeXSIType = null;
497 		currentPreferenceAttributeDefaultValue = "";
498 		currentPreferenceAttributeValue = "";
499 		currentPreferenceAttributeType = null;
500 		isPreferenceAttributeValueEncrypted = false;
501 		isCurrentPreferenceAttributePersistant = true;
502 		isCurrentPreferenceAttributeUserModifiable = true;
503 		currentPreferenceAttributeOptionList = null;
504 	}
505 
506 	/**
507 	 * Starts an options section of ListPreferenceAttribute.
508 	 * Intializes the arraylist.
509 	 */
510 	private void startOptions () {
511 
512 		currentPreferenceAttributeOptionList = new ArrayList();
513 	}
514 }