1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 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 * Matthew Khouzam - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.internal
.tmf
.ui
.project
.wizards
.importtrace
;
18 * File and name internal helper class <br>
19 * it has the file, a name to display, whether the name is conflicting and a
20 * reference to the configuration element defining its trace type.
22 * @author Matthew Khouzam
25 class FileAndName
implements Comparable
<FileAndName
> {
27 final private File fFile
;
28 private String fTraceTypeId
;
30 private boolean fConflict
;
32 // ------------------------------------------------------------------------
34 // ------------------------------------------------------------------------
40 * the file, can only be set here
42 * the name, can be renamed
45 public FileAndName(File f
, String n
) {
51 // ------------------------------------------------------------------------
53 // ------------------------------------------------------------------------
60 public String
getName() {
70 public void setName(String name
) {
75 * Sets the configuration element of the
80 public void setTraceTypeId(String elem
) {
85 * Gets the configuration element canonical name
87 * @return gets the configuration element canonical name
89 public String
getTraceTypeId() {
98 public File
getFile() {
103 * Set that the name is conflicting or not
106 * if the name is conflicting or not
108 public void setConflictingName(boolean conflict
) {
109 fConflict
= conflict
;
113 * Is the name conflicting?
115 * @return is the name conflicting?
117 public boolean isConflictingName() {
122 * Is the fileAndName renamed
124 * @return true if the name does not match the filename
126 public boolean isRenamed() {
127 return !fName
.equals(fFile
.getName());
130 // ------------------------------------------------------------------------
131 // Comparator & Equals
132 // ------------------------------------------------------------------------
135 public int compareTo(FileAndName o
) {
136 int retVal
= getFile().compareTo(o
.getFile());
138 if (getTraceTypeId() != null) {
139 if (getTraceTypeId() != null) {
140 if (o
.getTraceTypeId() != null) {
141 retVal
= getTraceTypeId().compareTo(o
.getTraceTypeId());
150 public int hashCode() {
151 // do not take "name" into account since it can change on the fly.
152 final int prime
= 31;
154 result
= prime
* result
+ ((fTraceTypeId
== null) ?
0 : fTraceTypeId
.hashCode());
155 result
= prime
* result
+ ((fFile
== null) ?
0 : fFile
.hashCode());
160 public boolean equals(Object obj
) {
161 // do not take "name" into account since it can change on the fly.
168 if (!(obj
instanceof FileAndName
)) {
171 FileAndName other
= (FileAndName
) obj
;
172 if (fTraceTypeId
== null) {
173 if (other
.fTraceTypeId
!= null) {
176 } else if (!fTraceTypeId
.equals(other
.fTraceTypeId
)) {
180 if (other
.fFile
!= null) {
183 } else if (!fFile
.equals(other
.fFile
)) {
This page took 0.037043 seconds and 5 git commands to generate.