tracesrv/tracecompiler/src/com.nokia.tracecompiler/src/com/nokia/tracecompiler/decodeplugins/dictionary/encoder/TraceComponent.java
author hgs
Fri, 08 Oct 2010 14:56:39 +0300
changeset 56 aa2539c91954
parent 41 tracefw/tracecompiler/src/com.nokia.tracecompiler/src/com/nokia/tracecompiler/decodeplugins/dictionary/encoder/TraceComponent.java@838cdffd57ce
permissions -rw-r--r--
201041

/*
* 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 component objects
*
*/
package com.nokia.tracecompiler.decodeplugins.dictionary.encoder;

/**
 * Writes component objects
 * 
 */
public class TraceComponent {

	/**
	 * Starts <component id="", name="" prefix="" suffix=""> structure
	 * 
	 * @param id
	 *            unique component id within dictionary
	 * @param name
	 *            name of the component
	 * @param prefix
	 *            optional prefix for the component
	 * @param suffix
	 *            optional suffix for the component
	 */
	static void startComponent(int id, String name, String prefix, String suffix) {
		StringBuffer sb = new StringBuffer();
		sb.append(TagWriter.COMPONENT_START_OPEN);
		TagWriter.appendAttribute(sb, TagWriter.ID_ATTR, String.valueOf(id),
				false);
		TagWriter.appendAttribute(sb, TagWriter.NAME_ATTR, name, true);
		if (prefix != null) {
			TagWriter.appendAttribute(sb, TagWriter.PREFIX_ATTR, prefix, true);
		}
		if (suffix != null) {
			TagWriter.appendAttribute(sb, TagWriter.SUFFIX_ATTR, suffix, true);
		}
		sb.append(TagWriter.TAG_CLOSE);
		TagWriter.write(sb.toString(), TagWriter.INDENT_1);
	}

	/**
	 * Writes </component>
	 */
	static void endComponent() {
		TagWriter.write(TagWriter.COMPONENT_END, TagWriter.INDENT_1);
	}

	/**
	 * Writes <options>
	 */
	public static void startOptions() {
		Options.startOptions(TagWriter.INDENT_2);
	}

	/**
	 * Writes user defined tags <mytagXXX>value</mytagXXX>
	 * 
	 * @param tag
	 *            user defined tag
	 * @param value
	 *            value of the tag
	 */
	public static void writeOption(String tag, String value) {
		Options.writeOptions(tag, value, TagWriter.INDENT_3);
	}

	/**
	 * Writes </options>
	 */
	public static void endOptions() {
		Options.endOptions(TagWriter.INDENT_2);
	}

	/**
	 * Starts <group id="", name="" prefix="" suffix=""> structure
	 * 
	 * @param id
	 *            unique group identifier within dictionary
	 * @param name
	 *            group name
	 * @param prefix
	 *            optional prefix for the group
	 * @param suffix
	 *            optional suffix for the group
	 */
	public static void startGroup(int id, String name, String prefix,
			String suffix) {
		TraceGroup.startGroup(id, name, prefix, suffix);
	}

	/**
	 * Writes </group>
	 */
	public static void endGroup() {
		TraceGroup.endGroup();
	}
}