1 /*******************************************************************************
2 * Copyright (c) 2009, 2010, 2012 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 * Francois Chouinard - Initial API and implementation
11 * Francois Chouinard - Updated as per TMF Trace Model 1.0
12 *******************************************************************************/
14 package org
.eclipse
.linuxtools
.tmf
.core
.trace
;
18 * A abstract implementation of ITmfLocation. The concrete classes must provide
19 * comparable location information.
22 * @author Francois Chouinard
24 public abstract class TmfLocation
implements ITmfLocation
, Cloneable
{
26 // ------------------------------------------------------------------------
28 // ------------------------------------------------------------------------
30 private Comparable
<?
> fLocationInfo
;
32 // ------------------------------------------------------------------------
34 // ------------------------------------------------------------------------
37 * Default constructor (for the 'null' location)
39 @SuppressWarnings("unused")
40 private TmfLocation() {
45 * Standard constructor.
47 * @param locationInfo the concrete trace location
49 public TmfLocation(final Comparable
<?
> locationInfo
) {
50 fLocationInfo
= locationInfo
;
56 * @param location the original trace location
58 public TmfLocation(final TmfLocation location
) {
59 fLocationInfo
= location
.fLocationInfo
;
62 // ------------------------------------------------------------------------
64 // ------------------------------------------------------------------------
67 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfLocation#getLocationInfo()
73 public Comparable
<?
> getLocationInfo() {
77 // ------------------------------------------------------------------------
79 // ------------------------------------------------------------------------
82 * @see java.lang.Object#clone()
85 public TmfLocation
clone() {
86 TmfLocation clone
= null;
88 clone
= (TmfLocation
) super.clone();
89 clone
.fLocationInfo
= cloneLocationInfo();
90 } catch (CloneNotSupportedException e
) {
96 * Delegate to the locationInfo cloning to the subclasses
98 * @return the locationInfo clone
101 protected abstract Comparable
<?
> cloneLocationInfo();
103 // ------------------------------------------------------------------------
105 // ------------------------------------------------------------------------
108 * @see java.lang.Object#hashCode()
111 public int hashCode() {
112 final int prime
= 31;
114 result
= prime
* result
+ ((fLocationInfo
!= null) ? fLocationInfo
.hashCode() : 0);
119 * @see java.lang.Object#equals(java.lang.Object)
122 public boolean equals(final Object obj
) {
129 if (getClass() != obj
.getClass()) {
132 final TmfLocation other
= (TmfLocation
) obj
;
133 if (fLocationInfo
== null) {
134 if (other
.fLocationInfo
!= null) {
137 } else if (!fLocationInfo
.equals(other
.fLocationInfo
)) {
144 @SuppressWarnings("nls")
145 public String
toString() {
146 return "TmfLocation [fLocation=" + fLocationInfo
+ "]";