1 /*******************************************************************************
2 * Copyright (c) 2013 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
.linuxtools
.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() {
121 // ------------------------------------------------------------------------
122 // Comparator & Equals
123 // ------------------------------------------------------------------------
126 public int compareTo(FileAndName o
) {
127 int retVal
= getFile().compareTo(o
.getFile());
129 if (getTraceTypeId() != null) {
130 if (getTraceTypeId() != null) {
131 if (o
.getTraceTypeId() != null) {
132 retVal
= getTraceTypeId().compareTo(o
.getTraceTypeId());
141 public int hashCode() {
142 // do not take "name" into account since it can change on the fly.
143 final int prime
= 31;
145 result
= prime
* result
+ ((fTraceTypeId
== null) ?
0 : fTraceTypeId
.hashCode());
146 result
= prime
* result
+ ((fFile
== null) ?
0 : fFile
.hashCode());
151 public boolean equals(Object obj
) {
152 // do not take "name" into account since it can change on the fly.
159 if (!(obj
instanceof FileAndName
)) {
162 FileAndName other
= (FileAndName
) obj
;
163 if (fTraceTypeId
== null) {
164 if (other
.fTraceTypeId
!= null) {
167 } else if (!fTraceTypeId
.equals(other
.fTraceTypeId
)) {
171 if (other
.fFile
!= null) {
174 } else if (!fFile
.equals(other
.fFile
)) {
This page took 0.034751 seconds and 6 git commands to generate.