1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Property value list for style property values. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 package com.nokia.tools.themeinstaller.odtconverter; |
|
20 |
|
21 import java.io.IOException; |
|
22 import java.util.Enumeration; |
|
23 import java.util.Vector; |
|
24 |
|
25 public class PropertyValueList |
|
26 { |
|
27 |
|
28 // CONSTANTS |
|
29 private static int PROPERTY_VALUE_LIST_TYPE = 3; |
|
30 |
|
31 // Property item list |
|
32 private Vector iList; |
|
33 |
|
34 // Reference to the String Pool |
|
35 private StringPool iStringPool; |
|
36 |
|
37 /** |
|
38 * Constructor. |
|
39 */ |
|
40 public PropertyValueList( StringPool aStringPool ) |
|
41 { |
|
42 iStringPool = aStringPool; |
|
43 iList = new Vector(); |
|
44 } |
|
45 |
|
46 /** |
|
47 * Create a new item and add it to the list. |
|
48 * @param aItem The new item |
|
49 */ |
|
50 public PropertyValue newItem() |
|
51 { |
|
52 PropertyValue propVal = new PropertyValue( iStringPool ); |
|
53 iList.add( propVal ); |
|
54 return propVal; |
|
55 } |
|
56 |
|
57 /** |
|
58 * Remove an item from the list. |
|
59 * @param aItem Item to remove |
|
60 * @return true if the item was removed, otherwise false is returned |
|
61 */ |
|
62 public boolean removeItem( PropertyValue aItem ) |
|
63 { |
|
64 return iList.remove( aItem ); |
|
65 } |
|
66 |
|
67 /** |
|
68 * Externalize the list to the stream. |
|
69 * @param aStream Target stream |
|
70 * @throws IOException if writing to a stream fails |
|
71 * @throws ODTException if writing to a stream fails |
|
72 */ |
|
73 public void externalize( ODTDataOutputStream aStream ) |
|
74 throws ODTException, IOException |
|
75 { |
|
76 // Write list type - int8 |
|
77 aStream.writeByte( PROPERTY_VALUE_LIST_TYPE ); |
|
78 |
|
79 // Write item count - int32 |
|
80 aStream.writeInt32( iList.size() ); |
|
81 |
|
82 Enumeration elements = iList.elements(); |
|
83 |
|
84 // Write all property values |
|
85 while( elements.hasMoreElements() ) |
|
86 { |
|
87 PropertyValue propVal = ( PropertyValue ) elements.nextElement(); |
|
88 propVal.externalize( aStream ); |
|
89 } |
|
90 } |
|
91 |
|
92 |
|
93 } |
|