Commit | Line | Data |
---|---|---|
6151d86c PT |
1 | /******************************************************************************* |
2 | * Copyright (c) 2010 Ericsson | |
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 | ||
13 | package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom; | |
14 | ||
15 | import java.util.regex.Matcher; | |
16 | ||
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; | |
20 | ||
a0a88f65 AM |
21 | /** |
22 | * Trace context for custom text traces. | |
23 | * | |
24 | * @author Patrick Tassé | |
25 | */ | |
6151d86c | 26 | public class CustomTxtTraceContext extends TmfContext { |
a0a88f65 AM |
27 | |
28 | /** Regex matcher for the first line of the trace */ | |
6151d86c | 29 | public Matcher firstLineMatcher; |
a0a88f65 AM |
30 | |
31 | /** First line of the text file */ | |
6151d86c | 32 | public String firstLine; |
a0a88f65 AM |
33 | |
34 | /** Position in the file where the 'current' next line is */ | |
6151d86c | 35 | public long nextLineLocation; |
a0a88f65 AM |
36 | |
37 | /** InputLine object for the currently read line */ | |
6151d86c PT |
38 | public InputLine inputLine; |
39 | ||
a0a88f65 AM |
40 | /** |
41 | * Constructor. | |
42 | * | |
43 | * @param location | |
44 | * Location in the trace | |
45 | * @param rank | |
46 | * Rank of the event at this location | |
47 | */ | |
6151d86c PT |
48 | public CustomTxtTraceContext(ITmfLocation location, long rank) { |
49 | super(location, rank); | |
50 | } | |
51 | ||
52 | /* (non-Javadoc) | |
53 | * @see java.lang.Object#hashCode() | |
54 | */ | |
55 | @Override | |
56 | public int hashCode() { | |
57 | final int prime = 31; | |
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)); | |
63 | return result; | |
64 | } | |
65 | ||
66 | /* (non-Javadoc) | |
67 | * @see java.lang.Object#equals(java.lang.Object) | |
68 | */ | |
69 | @Override | |
70 | public boolean equals(Object obj) { | |
71 | if (this == obj) { | |
72 | return true; | |
73 | } | |
74 | if (!super.equals(obj)) { | |
75 | return false; | |
76 | } | |
77 | if (!(obj instanceof CustomTxtTraceContext)) { | |
78 | return false; | |
79 | } | |
80 | CustomTxtTraceContext other = (CustomTxtTraceContext) obj; | |
81 | if (firstLine == null) { | |
82 | if (other.firstLine != null) { | |
83 | return false; | |
84 | } | |
85 | } else if (!firstLine.equals(other.firstLine)) { | |
86 | return false; | |
87 | } | |
88 | if (firstLineMatcher == null) { | |
89 | if (other.firstLineMatcher != null) { | |
90 | return false; | |
91 | } | |
92 | } else if (!firstLineMatcher.equals(other.firstLineMatcher)) { | |
93 | return false; | |
94 | } | |
95 | if (inputLine == null) { | |
96 | if (other.inputLine != null) { | |
97 | return false; | |
98 | } | |
99 | } else if (!inputLine.equals(other.inputLine)) { | |
100 | return false; | |
101 | } | |
102 | if (nextLineLocation != other.nextLineLocation) { | |
103 | return false; | |
104 | } | |
105 | return true; | |
106 | } | |
107 | ||
c3c5c786 | 108 | } |