|
1 /* |
|
2 * Copyright (c) 2008 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: |
|
15 * |
|
16 * Writes Data objects |
|
17 * |
|
18 */ |
|
19 package com.nokia.tracecompiler.decodeplugins.dictionary.encoder; |
|
20 |
|
21 /** |
|
22 * Writes Data objects |
|
23 * |
|
24 */ |
|
25 public class TraceDataStore { |
|
26 |
|
27 /** |
|
28 * Writes <data> |
|
29 */ |
|
30 public static void startDataStore() { |
|
31 TagWriter.write(TagWriter.TRACE_DATA_START, TagWriter.INDENT_1); |
|
32 } |
|
33 |
|
34 /** |
|
35 * Writes <def id="" dataType="">value</def> structure |
|
36 * |
|
37 * @param id |
|
38 * unique number in <data> structure, it is data identifier |
|
39 * @param dataType |
|
40 * data type, defaults to string |
|
41 * @param value |
|
42 * the value |
|
43 * |
|
44 */ |
|
45 public static void writeData(int id, DataType dataType, String value) { |
|
46 StringBuffer sb = new StringBuffer(); |
|
47 sb.append(TagWriter.DEF_START_OPEN); |
|
48 TagWriter.appendAttribute(sb, TagWriter.ID_ATTR, String.valueOf(id), |
|
49 false); |
|
50 if (dataType != null) { |
|
51 TagWriter.appendAttribute(sb, TagWriter.TYPE_ATTR, dataType |
|
52 .getType(), true); |
|
53 } |
|
54 sb.append(TagWriter.TAG_CLOSE); |
|
55 sb.append(XMLDataFilter.changeData(value)); |
|
56 sb.append(TagWriter.DEF_END); |
|
57 TagWriter.write(sb.toString(), TagWriter.INDENT_2); |
|
58 } |
|
59 |
|
60 /** |
|
61 * Writes </data> |
|
62 */ |
|
63 public static void endDataStore() { |
|
64 TagWriter.write(TagWriter.TRACE_DATA_END, TagWriter.INDENT_1); |
|
65 } |
|
66 } |