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 | ||
2bdf0193 | 13 | package org.eclipse.tracecompass.tmf.core.parsers.custom; |
6151d86c | 14 | |
7a0ebe01 | 15 | import java.util.Objects; |
6151d86c PT |
16 | import java.util.regex.Matcher; |
17 | ||
2bdf0193 AM |
18 | import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTxtTraceDefinition.InputLine; |
19 | import org.eclipse.tracecompass.tmf.core.trace.TmfContext; | |
20 | import org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation; | |
6151d86c | 21 | |
a0a88f65 AM |
22 | /** |
23 | * Trace context for custom text traces. | |
24 | * | |
25 | * @author Patrick Tassé | |
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; | |
7a0ebe01 | 76 | if (!Objects.equals(firstLine, other.firstLine)) { |
6151d86c PT |
77 | return false; |
78 | } | |
7a0ebe01 | 79 | if (!Objects.equals(firstLineMatcher, other.firstLineMatcher)) { |
6151d86c PT |
80 | return false; |
81 | } | |
7a0ebe01 | 82 | if (!Objects.equals(inputLine, other.inputLine)) { |
6151d86c PT |
83 | return false; |
84 | } | |
85 | if (nextLineLocation != other.nextLineLocation) { | |
86 | return false; | |
87 | } | |
88 | return true; | |
89 | } | |
90 | ||
c3c5c786 | 91 | } |