1 /*******************************************************************************
2 * Copyright (c) 2010 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
.ITmfLocation
;
19 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfContext
;
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 * @see java.lang.Object#hashCode()
56 public int hashCode() {
58 int result
= super.hashCode();
59 result
= prime
* result
+ ((firstLine
== null) ?
0 : firstLine
.hashCode());
60 result
= prime
* result
+ ((firstLineMatcher
== null) ?
0 : firstLineMatcher
.hashCode());
61 result
= prime
* result
+ ((inputLine
== null) ?
0 : inputLine
.hashCode());
62 result
= prime
* result
+ (int) (nextLineLocation ^
(nextLineLocation
>>> 32));
67 * @see java.lang.Object#equals(java.lang.Object)
70 public boolean equals(Object obj
) {
74 if (!super.equals(obj
)) {
77 if (!(obj
instanceof CustomTxtTraceContext
)) {
80 CustomTxtTraceContext other
= (CustomTxtTraceContext
) obj
;
81 if (firstLine
== null) {
82 if (other
.firstLine
!= null) {
85 } else if (!firstLine
.equals(other
.firstLine
)) {
88 if (firstLineMatcher
== null) {
89 if (other
.firstLineMatcher
!= null) {
92 } else if (!firstLineMatcher
.equals(other
.firstLineMatcher
)) {
95 if (inputLine
== null) {
96 if (other
.inputLine
!= null) {
99 } else if (!inputLine
.equals(other
.inputLine
)) {
102 if (nextLineLocation
!= other
.nextLineLocation
) {