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
CommitLineData
6151d86c 1/*******************************************************************************
c8422608 2 * Copyright (c) 2010, 2013 Ericsson
6151d86c
PT
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
13package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;
14
15import java.util.regex.Matcher;
16
17import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputLine;
6151d86c 18import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
a3db8436 19import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
6151d86c 20
a0a88f65
AM
21/**
22 * Trace context for custom text traces.
23 *
24 * @author Patrick Tassé
25 */
6151d86c 26public class CustomTxtTraceContext extends TmfContext {
a0a88f65
AM
27
28 /** Regex matcher for the first line of the trace */
6151d86c 29 public Matcher firstLineMatcher;
a0a88f65
AM
30
31 /** First line of the text file */
6151d86c 32 public String firstLine;
a0a88f65
AM
33
34 /** Position in the file where the 'current' next line is */
6151d86c 35 public long nextLineLocation;
a0a88f65
AM
36
37 /** InputLine object for the currently read line */
6151d86c
PT
38 public InputLine inputLine;
39
a0a88f65
AM
40 /**
41 * Constructor.
42 *
43 * @param location
44 * Location in the trace
45 * @param rank
46 * Rank of the event at this location
47 */
6151d86c
PT
48 public CustomTxtTraceContext(ITmfLocation location, long rank) {
49 super(location, rank);
50 }
51
6151d86c
PT
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
6151d86c
PT
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
c3c5c786 102}
This page took 0.075964 seconds and 5 git commands to generate.