tmf: Clean up tmf.core.trace package
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / internal / tmf / ui / parsers / custom / CustomTxtTraceContext.java
1 /*******************************************************************************
2 * Copyright (c) 2010, 2013 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;
14
15 import java.util.regex.Matcher;
16
17 import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputLine;
18 import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
19 import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
20
21 /**
22 * Trace context for custom text traces.
23 *
24 * @author Patrick Tassé
25 */
26 public class CustomTxtTraceContext extends TmfContext {
27
28 /** Regex matcher for the first line of the trace */
29 public Matcher firstLineMatcher;
30
31 /** First line of the text file */
32 public String firstLine;
33
34 /** Position in the file where the 'current' next line is */
35 public long nextLineLocation;
36
37 /** InputLine object for the currently read line */
38 public InputLine inputLine;
39
40 /**
41 * Constructor.
42 *
43 * @param location
44 * Location in the trace
45 * @param rank
46 * Rank of the event at this location
47 */
48 public CustomTxtTraceContext(ITmfLocation location, long rank) {
49 super(location, rank);
50 }
51
52 @Override
53 public int hashCode() {
54 final int prime = 31;
55 int result = super.hashCode();
56 result = prime * result + ((firstLine == null) ? 0 : firstLine.hashCode());
57 result = prime * result + ((firstLineMatcher == null) ? 0 : firstLineMatcher.hashCode());
58 result = prime * result + ((inputLine == null) ? 0 : inputLine.hashCode());
59 result = prime * result + (int) (nextLineLocation ^ (nextLineLocation >>> 32));
60 return result;
61 }
62
63 @Override
64 public boolean equals(Object obj) {
65 if (this == obj) {
66 return true;
67 }
68 if (!super.equals(obj)) {
69 return false;
70 }
71 if (!(obj instanceof CustomTxtTraceContext)) {
72 return false;
73 }
74 CustomTxtTraceContext other = (CustomTxtTraceContext) obj;
75 if (firstLine == null) {
76 if (other.firstLine != null) {
77 return false;
78 }
79 } else if (!firstLine.equals(other.firstLine)) {
80 return false;
81 }
82 if (firstLineMatcher == null) {
83 if (other.firstLineMatcher != null) {
84 return false;
85 }
86 } else if (!firstLineMatcher.equals(other.firstLineMatcher)) {
87 return false;
88 }
89 if (inputLine == null) {
90 if (other.inputLine != null) {
91 return false;
92 }
93 } else if (!inputLine.equals(other.inputLine)) {
94 return false;
95 }
96 if (nextLineLocation != other.nextLineLocation) {
97 return false;
98 }
99 return true;
100 }
101
102 }
This page took 0.032777 seconds and 5 git commands to generate.