Commit | Line | Data |
---|---|---|
6151d86c | 1 | /******************************************************************************* |
60ae41e1 | 2 | * Copyright (c) 2010, 2014 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 | ||
47aafe74 | 13 | package org.eclipse.linuxtools.tmf.core.parsers.custom; |
6151d86c PT |
14 | |
15 | import java.util.regex.Matcher; | |
16 | ||
47aafe74 | 17 | import org.eclipse.linuxtools.tmf.core.parsers.custom.CustomTxtTraceDefinition.InputLine; |
6151d86c | 18 | import org.eclipse.linuxtools.tmf.core.trace.TmfContext; |
a3db8436 | 19 | import 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é | |
47aafe74 | 25 | * @since 3.0 |
a0a88f65 | 26 | */ |
6151d86c | 27 | public class CustomTxtTraceContext extends TmfContext { |
a0a88f65 AM |
28 | |
29 | /** Regex matcher for the first line of the trace */ | |
6151d86c | 30 | public Matcher firstLineMatcher; |
a0a88f65 AM |
31 | |
32 | /** First line of the text file */ | |
6151d86c | 33 | public String firstLine; |
a0a88f65 AM |
34 | |
35 | /** Position in the file where the 'current' next line is */ | |
6151d86c | 36 | public long nextLineLocation; |
a0a88f65 AM |
37 | |
38 | /** InputLine object for the currently read line */ | |
6151d86c PT |
39 | public InputLine inputLine; |
40 | ||
a0a88f65 AM |
41 | /** |
42 | * Constructor. | |
43 | * | |
44 | * @param location | |
45 | * Location in the trace | |
46 | * @param rank | |
47 | * Rank of the event at this location | |
48 | */ | |
6151d86c PT |
49 | public CustomTxtTraceContext(ITmfLocation location, long rank) { |
50 | super(location, rank); | |
51 | } | |
52 | ||
6151d86c PT |
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 | ||
6151d86c PT |
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 | ||
c3c5c786 | 103 | } |