tracesrv/tracecompiler/src/com.nokia.tracecompiler/src/com/nokia/tracecompiler/decodeplugins/dictionary/encoder/TraceComponent.java
changeset 56 aa2539c91954
parent 41 838cdffd57ce
equal deleted inserted replaced
54:a151135b0cf9 56:aa2539c91954
       
     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 component objects
       
    17 *
       
    18 */
       
    19 package com.nokia.tracecompiler.decodeplugins.dictionary.encoder;
       
    20 
       
    21 /**
       
    22  * Writes component objects
       
    23  * 
       
    24  */
       
    25 public class TraceComponent {
       
    26 
       
    27 	/**
       
    28 	 * Starts <component id="", name="" prefix="" suffix=""> structure
       
    29 	 * 
       
    30 	 * @param id
       
    31 	 *            unique component id within dictionary
       
    32 	 * @param name
       
    33 	 *            name of the component
       
    34 	 * @param prefix
       
    35 	 *            optional prefix for the component
       
    36 	 * @param suffix
       
    37 	 *            optional suffix for the component
       
    38 	 */
       
    39 	static void startComponent(int id, String name, String prefix, String suffix) {
       
    40 		StringBuffer sb = new StringBuffer();
       
    41 		sb.append(TagWriter.COMPONENT_START_OPEN);
       
    42 		TagWriter.appendAttribute(sb, TagWriter.ID_ATTR, String.valueOf(id),
       
    43 				false);
       
    44 		TagWriter.appendAttribute(sb, TagWriter.NAME_ATTR, name, true);
       
    45 		if (prefix != null) {
       
    46 			TagWriter.appendAttribute(sb, TagWriter.PREFIX_ATTR, prefix, true);
       
    47 		}
       
    48 		if (suffix != null) {
       
    49 			TagWriter.appendAttribute(sb, TagWriter.SUFFIX_ATTR, suffix, true);
       
    50 		}
       
    51 		sb.append(TagWriter.TAG_CLOSE);
       
    52 		TagWriter.write(sb.toString(), TagWriter.INDENT_1);
       
    53 	}
       
    54 
       
    55 	/**
       
    56 	 * Writes </component>
       
    57 	 */
       
    58 	static void endComponent() {
       
    59 		TagWriter.write(TagWriter.COMPONENT_END, TagWriter.INDENT_1);
       
    60 	}
       
    61 
       
    62 	/**
       
    63 	 * Writes <options>
       
    64 	 */
       
    65 	public static void startOptions() {
       
    66 		Options.startOptions(TagWriter.INDENT_2);
       
    67 	}
       
    68 
       
    69 	/**
       
    70 	 * Writes user defined tags <mytagXXX>value</mytagXXX>
       
    71 	 * 
       
    72 	 * @param tag
       
    73 	 *            user defined tag
       
    74 	 * @param value
       
    75 	 *            value of the tag
       
    76 	 */
       
    77 	public static void writeOption(String tag, String value) {
       
    78 		Options.writeOptions(tag, value, TagWriter.INDENT_3);
       
    79 	}
       
    80 
       
    81 	/**
       
    82 	 * Writes </options>
       
    83 	 */
       
    84 	public static void endOptions() {
       
    85 		Options.endOptions(TagWriter.INDENT_2);
       
    86 	}
       
    87 
       
    88 	/**
       
    89 	 * Starts <group id="", name="" prefix="" suffix=""> structure
       
    90 	 * 
       
    91 	 * @param id
       
    92 	 *            unique group identifier within dictionary
       
    93 	 * @param name
       
    94 	 *            group name
       
    95 	 * @param prefix
       
    96 	 *            optional prefix for the group
       
    97 	 * @param suffix
       
    98 	 *            optional suffix for the group
       
    99 	 */
       
   100 	public static void startGroup(int id, String name, String prefix,
       
   101 			String suffix) {
       
   102 		TraceGroup.startGroup(id, name, prefix, suffix);
       
   103 	}
       
   104 
       
   105 	/**
       
   106 	 * Writes </group>
       
   107 	 */
       
   108 	public static void endGroup() {
       
   109 		TraceGroup.endGroup();
       
   110 	}
       
   111 }