00001 package org.gridlab.gat.io;
00002
00003 import java.io.IOException;
00004 import java.io.Serializable;
00005 import java.net.URI;
00006
00007 import org.gridlab.gat.GATContext;
00008 import org.gridlab.gat.Preferences;
00009 import org.gridlab.gat.engine.GATEngine;
00010 import org.gridlab.gat.io.cpi.FileCpi;
00011 import org.gridlab.gat.monitoring.Monitorable;
00012 import org.gridlab.gat.net.RemoteException;
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 public abstract class File extends java.io.File implements Monitorable, Serializable {
00039
00040 protected URI location;
00041 protected GATContext gatContext;
00042 protected Preferences preferences;
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 protected File(GATContext gatContext, Preferences preferences,
00062 URI location) {
00063 super(location);
00064 this.location = location;
00065 this.gatContext = gatContext;
00066 this.preferences = preferences;
00067 }
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 public static File create(GATContext gatContext, URI location) {
00084 return create(gatContext, null, location);
00085 }
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104 public static File create(GATContext gatContext, Preferences preferences,
00105 URI location) {
00106
00107
00108
00109
00110 URI tmpLocation = location;
00111 if(tmpLocation.getScheme() == null) {
00112 java.io.File tmp = new java.io.File(tmpLocation.toString());
00113 tmpLocation = tmp.toURI();
00114 }
00115
00116 GATEngine gatEngine = GATEngine.getGATEngine();
00117 Object[] array = new Object[1];
00118 array[0] = tmpLocation;
00119 FileCpi f = (FileCpi) gatEngine.getAdaptor(FileCpi.class,
00120 gatContext, preferences, array);
00121 return f;
00122 }
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139 public boolean equals(Object object) {
00140 if (!(object instanceof org.gridlab.gat.io.File)) return false;
00141
00142 org.gridlab.gat.io.File file = (org.gridlab.gat.io.File) object;
00143 return location.equals(file.getURI());
00144 }
00145
00146
00147
00148
00149
00150
00151 public URI getURI() {
00152 return location;
00153 }
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166 public abstract void copy(URI loc) throws IOException, RemoteException;
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180 public void move(URI location) throws IOException {
00181
00182 copy(location);
00183
00184
00185 delete();
00186
00187
00188 this.location = location;
00189 }
00190 }