628
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
package com.nokia.helium.environment;
|
|
19 |
|
|
20 |
import java.io.File;
|
|
21 |
|
|
22 |
/**
|
|
23 |
* An executable on the file system.
|
|
24 |
*/
|
|
25 |
public class Executable {
|
|
26 |
|
|
27 |
private String name;
|
|
28 |
private String version = "unknown";
|
|
29 |
private String path;
|
|
30 |
private String hash;
|
|
31 |
private long lastModified;
|
|
32 |
private long length;
|
|
33 |
private boolean executed;
|
|
34 |
|
|
35 |
public Executable(String name) {
|
|
36 |
this.name = name;
|
|
37 |
}
|
|
38 |
|
|
39 |
public String getName() {
|
|
40 |
return name;
|
|
41 |
}
|
|
42 |
|
|
43 |
public void setName(String name) {
|
|
44 |
this.name = name;
|
|
45 |
}
|
|
46 |
|
|
47 |
public String getNameNoExt() {
|
|
48 |
String nameNoExt = name;
|
|
49 |
if (nameNoExt.contains(".")) {
|
|
50 |
nameNoExt = nameNoExt.substring(0, nameNoExt.indexOf("."));
|
|
51 |
}
|
|
52 |
return nameNoExt;
|
|
53 |
}
|
|
54 |
|
|
55 |
public String getVersion() {
|
|
56 |
return version;
|
|
57 |
}
|
|
58 |
|
|
59 |
public void setVersion(String version) {
|
|
60 |
this.version = version;
|
|
61 |
}
|
|
62 |
|
|
63 |
public String getPath() {
|
|
64 |
return path;
|
|
65 |
}
|
|
66 |
|
|
67 |
public void setPath(String path) {
|
|
68 |
this.path = path;
|
|
69 |
}
|
|
70 |
|
|
71 |
public String getHash() {
|
|
72 |
return hash;
|
|
73 |
}
|
|
74 |
|
|
75 |
public void setHash(String hash) {
|
|
76 |
this.hash = hash;
|
|
77 |
}
|
|
78 |
|
|
79 |
public long getLastModified() {
|
|
80 |
return lastModified;
|
|
81 |
}
|
|
82 |
|
|
83 |
public void setLastModified(long lastModified) {
|
|
84 |
this.lastModified = lastModified;
|
|
85 |
}
|
|
86 |
|
|
87 |
public long getLength() {
|
|
88 |
return length;
|
|
89 |
}
|
|
90 |
|
|
91 |
public void setLength(long length) {
|
|
92 |
this.length = length;
|
|
93 |
}
|
|
94 |
|
|
95 |
public boolean isExecuted() {
|
|
96 |
return executed;
|
|
97 |
}
|
|
98 |
|
|
99 |
public void setExecuted(boolean executed) {
|
|
100 |
this.executed = executed;
|
|
101 |
}
|
|
102 |
|
|
103 |
public boolean equals(Object object) {
|
|
104 |
if (object != null && object instanceof Executable) {
|
|
105 |
Executable executable = (Executable) object;
|
|
106 |
if (executable.getPath() != null && path != null) {
|
|
107 |
return executable.getPath().toLowerCase().equals(path.toLowerCase());
|
|
108 |
}
|
|
109 |
return executable.getName().equals(name);
|
|
110 |
}
|
|
111 |
return false;
|
|
112 |
}
|
|
113 |
|
|
114 |
public int hashCode() {
|
|
115 |
return name.hashCode();
|
|
116 |
}
|
|
117 |
|
|
118 |
public String toString() {
|
|
119 |
if (path != null) {
|
|
120 |
return path + File.separator + name;
|
|
121 |
}
|
|
122 |
return name;
|
|
123 |
}
|
|
124 |
}
|