ss: Move plugins to Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / parsers / custom / CustomTxtTraceContext.java
1 /*******************************************************************************
2 * Copyright (c) 2010, 2014 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.tmf.core.parsers.custom;
14
15 import java.util.regex.Matcher;
16
17 import org.eclipse.linuxtools.tmf.core.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 * @since 3.0
26 */
27 public class CustomTxtTraceContext extends TmfContext {
28
29 /** Regex matcher for the first line of the trace */
30 public Matcher firstLineMatcher;
31
32 /** First line of the text file */
33 public String firstLine;
34
35 /** Position in the file where the 'current' next line is */
36 public long nextLineLocation;
37
38 /** InputLine object for the currently read line */
39 public InputLine inputLine;
40
41 /**
42 * Constructor.
43 *
44 * @param location
45 * Location in the trace
46 * @param rank
47 * Rank of the event at this location
48 */
49 public CustomTxtTraceContext(ITmfLocation location, long rank) {
50 super(location, rank);
51 }
52
53 @Override
54 public int hashCode() {
55 final int prime = 31;
56 int result = super.hashCode();
57 result = prime * result + ((firstLine == null) ? 0 : firstLine.hashCode());
58 result = prime * result + ((firstLineMatcher == null) ? 0 : firstLineMatcher.hashCode());
59 result = prime * result + ((inputLine == null) ? 0 : inputLine.hashCode());
60 result = prime * result + (int) (nextLineLocation ^ (nextLineLocation >>> 32));
61 return result;
62 }
63
64 @Override
65 public boolean equals(Object obj) {
66 if (this == obj) {
67 return true;
68 }
69 if (!super.equals(obj)) {
70 return false;
71 }
72 if (!(obj instanceof CustomTxtTraceContext)) {
73 return false;
74 }
75 CustomTxtTraceContext other = (CustomTxtTraceContext) obj;
76 if (firstLine == null) {
77 if (other.firstLine != null) {
78 return false;
79 }
80 } else if (!firstLine.equals(other.firstLine)) {
81 return false;
82 }
83 if (firstLineMatcher == null) {
84 if (other.firstLineMatcher != null) {
85 return false;
86 }
87 } else if (!firstLineMatcher.equals(other.firstLineMatcher)) {
88 return false;
89 }
90 if (inputLine == null) {
91 if (other.inputLine != null) {
92 return false;
93 }
94 } else if (!inputLine.equals(other.inputLine)) {
95 return false;
96 }
97 if (nextLineLocation != other.nextLineLocation) {
98 return false;
99 }
100 return true;
101 }
102
103 }
This page took 0.033304 seconds and 5 git commands to generate.