tracesrv/tracecompiler/src/com.nokia.tracecompiler/src/com/nokia/tracecompiler/decodeplugins/dictionary/encoder/TraceGroup.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 groups objects
       
    17 *
       
    18 */
       
    19 package com.nokia.tracecompiler.decodeplugins.dictionary.encoder;
       
    20 
       
    21 /**
       
    22  * Writes groups objects
       
    23  * 
       
    24  */
       
    25 public class TraceGroup {
       
    26 
       
    27 	/**
       
    28 	 * Writes <options>
       
    29 	 */
       
    30 	public static void startOptions() {
       
    31 		Options.startOptions(TagWriter.INDENT_3);
       
    32 	}
       
    33 
       
    34 	/**
       
    35 	 * Writes user defined tags <mytagXXX>value</mytagXXX>
       
    36 	 * 
       
    37 	 * @param tag
       
    38 	 *            user defined tag
       
    39 	 * @param value
       
    40 	 *            value of the tag
       
    41 	 */
       
    42 	public static void writeOption(String tag, String value) {
       
    43 		Options.writeOptions(tag, value, TagWriter.INDENT_4);
       
    44 	}
       
    45 
       
    46 	/**
       
    47 	 * Writes </options>
       
    48 	 */
       
    49 	public static void endOptions() {
       
    50 		Options.endOptions(TagWriter.INDENT_3);
       
    51 	}
       
    52 
       
    53 	/**
       
    54 	 * Starts <trace data-ref=""> structure
       
    55 	 * 
       
    56 	 * @param dataRef
       
    57 	 *            reference to actual data stored in <data> structure
       
    58 	 * @param name
       
    59 	 *            name of the trace. Can be null if trace doesn't have name            
       
    60 	 */
       
    61 	public static void startTrace(int dataRef, String name) {
       
    62 		Trace.startTrace(dataRef, name);
       
    63 	}
       
    64 
       
    65 	/**
       
    66 	 * Writes </trace>
       
    67 	 */
       
    68 	public static void endTrace() {
       
    69 		Trace.endTrace();
       
    70 	}
       
    71 
       
    72 	/**
       
    73 	 * Starts <group id="", name="" prefix="" suffix=""> structure
       
    74 	 * 
       
    75 	 * @param id
       
    76 	 *            unique group identifier within dictionary
       
    77 	 * @param name
       
    78 	 *            group name
       
    79 	 * @param prefix
       
    80 	 *            optional prefix for the group
       
    81 	 * @param suffix
       
    82 	 *            optional suffix for the group
       
    83 	 */
       
    84 	static void startGroup(int id, String name, String prefix, String suffix) {
       
    85 		StringBuffer sb = new StringBuffer();
       
    86 		sb.append(TagWriter.GROUP_START_OPEN);
       
    87 		TagWriter.appendAttribute(sb, TagWriter.ID_ATTR, String.valueOf(id),
       
    88 				false);
       
    89 		TagWriter.appendAttribute(sb, TagWriter.NAME_ATTR, name, true);
       
    90 		if (prefix != null) {
       
    91 			TagWriter.appendAttribute(sb, TagWriter.PREFIX_ATTR, prefix, true);
       
    92 		}
       
    93 		if (suffix != null) {
       
    94 			TagWriter.appendAttribute(sb, TagWriter.SUFFIX_ATTR, suffix, true);
       
    95 		}
       
    96 		sb.append(TagWriter.TAG_CLOSE);
       
    97 		TagWriter.write(sb.toString(), TagWriter.INDENT_2);
       
    98 
       
    99 	}
       
   100 
       
   101 	/**
       
   102 	 * Writes </group>
       
   103 	 */
       
   104 	static void endGroup() {
       
   105 		TagWriter.write(TagWriter.GROUP_END, TagWriter.INDENT_2);
       
   106 	}
       
   107 }