1 /*******************************************************************************
2 * Copyright (c) 2010, 2013 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
.internal
.tmf
.ui
.parsers
.custom
;
15 import java
.util
.regex
.Matcher
;
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
;
22 * Trace context for custom text traces.
24 * @author Patrick Tassé
26 public class CustomTxtTraceContext
extends TmfContext
{
28 /** Regex matcher for the first line of the trace */
29 public Matcher firstLineMatcher
;
31 /** First line of the text file */
32 public String firstLine
;
34 /** Position in the file where the 'current' next line is */
35 public long nextLineLocation
;
37 /** InputLine object for the currently read line */
38 public InputLine inputLine
;
44 * Location in the trace
46 * Rank of the event at this location
48 public CustomTxtTraceContext(ITmfLocation location
, long rank
) {
49 super(location
, rank
);
53 public int hashCode() {
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));
64 public boolean equals(Object obj
) {
68 if (!super.equals(obj
)) {
71 if (!(obj
instanceof CustomTxtTraceContext
)) {
74 CustomTxtTraceContext other
= (CustomTxtTraceContext
) obj
;
75 if (firstLine
== null) {
76 if (other
.firstLine
!= null) {
79 } else if (!firstLine
.equals(other
.firstLine
)) {
82 if (firstLineMatcher
== null) {
83 if (other
.firstLineMatcher
!= null) {
86 } else if (!firstLineMatcher
.equals(other
.firstLineMatcher
)) {
89 if (inputLine
== null) {
90 if (other
.inputLine
!= null) {
93 } else if (!inputLine
.equals(other
.inputLine
)) {
96 if (nextLineLocation
!= other
.nextLineLocation
) {