|
1 /* |
|
2 * Copyright (c) 2010 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 */package com.nokia.s60tools.crashanalyser.containers; |
|
17 |
|
18 import org.w3c.dom.NamedNodeMap; |
|
19 import org.w3c.dom.Node; |
|
20 |
|
21 public final class OstTraceLine { |
|
22 // XML tags |
|
23 public static final String TAG_LINE = "line"; |
|
24 public static final String ATTRIBUTE_TYPE = "type"; |
|
25 public static final String ATTRIBUTE_TIMESTAMP = "timestamp"; |
|
26 public static final String ATTRIBUTE_PREFIX = "prefix"; |
|
27 public static final String ATTRIBUTE_COMPONENT = "component"; |
|
28 public static final String ATTRIBUTE_GROUP = "group"; |
|
29 public static final String ATTRIBUTE_ID = "id"; |
|
30 public static final String ATTRIBUTE_FILE = "file"; |
|
31 public static final String ATTRIBUTE_LINE_NUMBER = "line_number"; |
|
32 public static final String ATTRIBUTE_CONTEXT_ID = "context_id"; |
|
33 |
|
34 |
|
35 private final String type; |
|
36 private final String timestamp; |
|
37 private final String prefix; |
|
38 private final String component; |
|
39 private final String group; |
|
40 private final String id; |
|
41 private final String file; |
|
42 private final String lineNumber; |
|
43 private final String contextId; |
|
44 private final String traceText; |
|
45 |
|
46 |
|
47 /** |
|
48 * Constructor |
|
49 * @param aType type |
|
50 * @param aTimestamp timestamp |
|
51 * @param aPrefix prefix |
|
52 * @param aComponent component |
|
53 * @param aGroup group |
|
54 * @param aId id |
|
55 * @param aFile file |
|
56 * @param aLineNumber line number |
|
57 * @param aContextId context id |
|
58 * |
|
59 */ |
|
60 private OstTraceLine(String aType, String aTimestamp, String aPrefix, |
|
61 String aComponent, String aGroup, String aId, String aFile, |
|
62 String aLineNumber, String aContextId, String aTraceText) { |
|
63 type = aType; |
|
64 timestamp = aTimestamp; |
|
65 prefix = aPrefix; |
|
66 component = aComponent; |
|
67 group = aGroup; |
|
68 id = aId; |
|
69 file = aFile; |
|
70 lineNumber = aLineNumber; |
|
71 contextId = aContextId; |
|
72 traceText = aTraceText; |
|
73 } |
|
74 |
|
75 |
|
76 /** |
|
77 * Reads trace from an XML element |
|
78 * @param elementTraceLine One line element |
|
79 * @return a created OstTrace class or null |
|
80 */ |
|
81 public static OstTraceLine read(Node elementTraceLine) { |
|
82 |
|
83 if (elementTraceLine.getNodeName().equals(TAG_LINE)) { |
|
84 String traceTextStr = elementTraceLine.getFirstChild().getNodeValue(); |
|
85 NamedNodeMap attributes = elementTraceLine.getAttributes(); |
|
86 if(attributes != null) { |
|
87 String typeStr = getAttributeStr(attributes, ATTRIBUTE_TYPE); |
|
88 String timestampStr = getAttributeStr(attributes, ATTRIBUTE_TIMESTAMP); |
|
89 String prefixStr = getAttributeStr(attributes, ATTRIBUTE_PREFIX); |
|
90 String componentStr = getAttributeStr(attributes, ATTRIBUTE_COMPONENT); |
|
91 String groupStr = getAttributeStr(attributes, ATTRIBUTE_GROUP); |
|
92 String idStr = getAttributeStr(attributes, ATTRIBUTE_ID); |
|
93 String fileStr = getAttributeStr(attributes, ATTRIBUTE_FILE); |
|
94 String lineNumberStr = getAttributeStr(attributes, ATTRIBUTE_LINE_NUMBER); |
|
95 String contextIdStr = getAttributeStr(attributes, ATTRIBUTE_CONTEXT_ID); |
|
96 |
|
97 return new OstTraceLine(typeStr, timestampStr, prefixStr, componentStr, groupStr, idStr, |
|
98 fileStr, lineNumberStr, contextIdStr, traceTextStr); |
|
99 } |
|
100 } |
|
101 return null; |
|
102 } |
|
103 |
|
104 public String getType() { |
|
105 return type; |
|
106 } |
|
107 |
|
108 public String getTimestamp() { |
|
109 return timestamp; |
|
110 } |
|
111 |
|
112 public String getPrefix() { |
|
113 return prefix; |
|
114 } |
|
115 |
|
116 public String getComponent() { |
|
117 return component; |
|
118 } |
|
119 |
|
120 public String getGroup() { |
|
121 return group; |
|
122 } |
|
123 |
|
124 public String getId() { |
|
125 return id; |
|
126 } |
|
127 |
|
128 public String getFile() { |
|
129 return file; |
|
130 } |
|
131 |
|
132 public String getLineNumber() { |
|
133 return lineNumber; |
|
134 } |
|
135 |
|
136 public String getContextId() { |
|
137 return contextId; |
|
138 } |
|
139 |
|
140 public String getTraceText() { |
|
141 return traceText; |
|
142 } |
|
143 |
|
144 private static String getAttributeStr(NamedNodeMap attributes, String tag) { |
|
145 Node node = attributes.getNamedItem(tag); |
|
146 if (node != null) { |
|
147 return node.getNodeValue(); |
|
148 } |
|
149 return ""; |
|
150 } |
|
151 } |