1 /*******************************************************************************
2 * Copyright (c) 2010, 2014 Ericsson
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
10 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.core
.parsers
.custom
;
15 import java
.util
.regex
.Matcher
;
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
;
22 * Trace context for custom text traces.
24 * @author Patrick Tassé
27 public class CustomTxtTraceContext
extends TmfContext
{
29 /** Regex matcher for the first line of the trace */
30 public Matcher firstLineMatcher
;
32 /** First line of the text file */
33 public String firstLine
;
35 /** Position in the file where the 'current' next line is */
36 public long nextLineLocation
;
38 /** InputLine object for the currently read line */
39 public InputLine inputLine
;
45 * Location in the trace
47 * Rank of the event at this location
49 public CustomTxtTraceContext(ITmfLocation location
, long rank
) {
50 super(location
, rank
);
54 public int hashCode() {
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));
65 public boolean equals(Object obj
) {
69 if (!super.equals(obj
)) {
72 if (!(obj
instanceof CustomTxtTraceContext
)) {
75 CustomTxtTraceContext other
= (CustomTxtTraceContext
) obj
;
76 if (firstLine
== null) {
77 if (other
.firstLine
!= null) {
80 } else if (!firstLine
.equals(other
.firstLine
)) {
83 if (firstLineMatcher
== null) {
84 if (other
.firstLineMatcher
!= null) {
87 } else if (!firstLineMatcher
.equals(other
.firstLineMatcher
)) {
90 if (inputLine
== null) {
91 if (other
.inputLine
!= null) {
94 } else if (!inputLine
.equals(other
.inputLine
)) {
97 if (nextLineLocation
!= other
.nextLineLocation
) {