tracefw/tracecompiler/src/com.nokia.tracecompiler/src/com/nokia/tracecompiler/decodeplugins/dictionary/encoder/TraceDataStore.java
branchRCL_3
changeset 20 ca8a1b6995f6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tracefw/tracecompiler/src/com.nokia.tracecompiler/src/com/nokia/tracecompiler/decodeplugins/dictionary/encoder/TraceDataStore.java	Tue Aug 31 16:45:49 2010 +0300
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+* Writes Data objects
+*
+*/
+package com.nokia.tracecompiler.decodeplugins.dictionary.encoder;
+
+/**
+ * Writes Data objects
+ * 
+ */
+public class TraceDataStore {
+
+	/**
+	 * Writes <data>
+	 */
+	public static void startDataStore() {
+		TagWriter.write(TagWriter.TRACE_DATA_START, TagWriter.INDENT_1);
+	}
+
+	/**
+	 * Writes <def id="" dataType="">value</def> structure
+	 * 
+	 * @param id
+	 *            unique number in <data> structure, it is data identifier
+	 * @param dataType
+	 *            data type, defaults to string
+	 * @param value
+	 *            the value
+	 * 
+	 */
+	public static void writeData(int id, DataType dataType, String value) {
+		StringBuffer sb = new StringBuffer();
+		sb.append(TagWriter.DEF_START_OPEN);
+		TagWriter.appendAttribute(sb, TagWriter.ID_ATTR, String.valueOf(id),
+				false);
+		if (dataType != null) {
+			TagWriter.appendAttribute(sb, TagWriter.TYPE_ATTR, dataType
+					.getType(), true);
+		}
+		sb.append(TagWriter.TAG_CLOSE);
+		sb.append(XMLDataFilter.changeData(value));
+		sb.append(TagWriter.DEF_END);
+		TagWriter.write(sb.toString(), TagWriter.INDENT_2);
+	}
+
+	/**
+	 * Writes </data>
+	 */
+	public static void endDataStore() {
+		TagWriter.write(TagWriter.TRACE_DATA_END, TagWriter.INDENT_1);
+	}
+}