41
|
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 |
* Dictionary tag
|
|
17 |
*
|
|
18 |
*/
|
|
19 |
package com.nokia.tracecompiler.decodeplugins.dictionary.encoder;
|
|
20 |
|
|
21 |
/**
|
|
22 |
* Dictionary tag
|
|
23 |
*
|
|
24 |
*/
|
|
25 |
public class Dictionary {
|
|
26 |
|
|
27 |
/**
|
|
28 |
* Writes start of the XML file and starts <tracedictionary> structure
|
|
29 |
*/
|
|
30 |
public static void startDictionary() {
|
|
31 |
TagWriter.write(TagWriter.XML_START, TagWriter.INDENT_0);
|
|
32 |
TagWriter.write(TagWriter.DICTIONARY_START, TagWriter.INDENT_0);
|
|
33 |
}
|
|
34 |
|
|
35 |
/**
|
|
36 |
* Writes </tracedictionary>
|
|
37 |
*/
|
|
38 |
public static void endDictionary() {
|
|
39 |
TagWriter.write(TagWriter.DICTIONARY_END, TagWriter.INDENT_0);
|
|
40 |
TagWriter.close();
|
|
41 |
}
|
|
42 |
|
|
43 |
/**
|
|
44 |
* Starts <component id="", name="" prefix="" suffix=""> structure
|
|
45 |
*
|
|
46 |
* @param id
|
|
47 |
* unique component id within dictionary
|
|
48 |
* @param name
|
|
49 |
* name of the component
|
|
50 |
* @param prefix
|
|
51 |
* optional prefix for the component
|
|
52 |
* @param suffix
|
|
53 |
* optional suffix for the component
|
|
54 |
*/
|
|
55 |
public static void startComponent(int id, String name, String prefix,
|
|
56 |
String suffix) {
|
|
57 |
TraceComponent.startComponent(id, name, prefix, suffix);
|
|
58 |
|
|
59 |
}
|
|
60 |
|
|
61 |
/**
|
|
62 |
* Writes </component>
|
|
63 |
*/
|
|
64 |
public static void endComponent() {
|
|
65 |
TraceComponent.endComponent();
|
|
66 |
}
|
|
67 |
|
|
68 |
/**
|
|
69 |
* Starts <metadata> structure
|
|
70 |
*/
|
|
71 |
public static void startMetaData() {
|
|
72 |
TagWriter.write(TagWriter.METADATA_START, TagWriter.INDENT_1);
|
|
73 |
}
|
|
74 |
|
|
75 |
/**
|
|
76 |
* Writes user defined tags <mytagXXX>value</mytagXXX>
|
|
77 |
*
|
|
78 |
* @param name
|
|
79 |
* tag
|
|
80 |
* @param value
|
|
81 |
* value of the tag
|
|
82 |
*/
|
|
83 |
public static void writeMetaData(String name, String value) {
|
|
84 |
StringBuffer sb = new StringBuffer();
|
|
85 |
sb.append(TagWriter.START_TAG_OPEN);
|
|
86 |
sb.append(name);
|
|
87 |
sb.append(TagWriter.TAG_CLOSE);
|
|
88 |
sb.append(XMLDataFilter.changeData(value));
|
|
89 |
sb.append(TagWriter.END_TAG_OPEN);
|
|
90 |
sb.append(name);
|
|
91 |
sb.append(TagWriter.TAG_CLOSE);
|
|
92 |
TagWriter.write(sb.toString(), TagWriter.INDENT_2);
|
|
93 |
}
|
|
94 |
|
|
95 |
/**
|
|
96 |
* Writes </metadata>
|
|
97 |
*/
|
|
98 |
public static void endMetaData() {
|
|
99 |
TagWriter.write(TagWriter.METADATA_END, TagWriter.INDENT_1);
|
|
100 |
}
|
|
101 |
} |