svn-gvsig-desktop / trunk / libraries / libCq CMS for java.old / src / org / cresques / io / DataSource.java @ 7
History | View | Annotate | Download (1.25 KB)
1 |
/*
|
---|---|
2 |
* Created on 12-may-2004
|
3 |
*/
|
4 |
|
5 |
package org.cresques.io; |
6 |
|
7 |
import java.util.Hashtable; |
8 |
|
9 |
/**
|
10 |
* Origen de datos. Unidad, volumen de red, etc.
|
11 |
*
|
12 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es>
|
13 |
*/
|
14 |
|
15 |
public class DataSource { |
16 |
private static int counter = 0; |
17 |
private static Hashtable units = new Hashtable(); |
18 |
String path = null; |
19 |
String name = null; |
20 |
|
21 |
public DataSource(String path, String name) { |
22 |
this.path = path;
|
23 |
this.name = name;
|
24 |
units.put(name, this);
|
25 |
} |
26 |
|
27 |
public String getName() { return name; } |
28 |
public String getPath() { return path; } |
29 |
|
30 |
public static DataSource getDSFromName(String name) { |
31 |
if (name.indexOf("[") >= 0) name = name.substring(name.indexOf("[")+1); |
32 |
if (name.indexOf("]") >= 0) name = name.substring(0,name.indexOf("]")); |
33 |
DataSource ds = (DataSource) units.get(name); |
34 |
return ds;
|
35 |
} |
36 |
|
37 |
/**
|
38 |
* Sustituye en el path el nombre de la unidad por su path real.
|
39 |
*
|
40 |
* @param path
|
41 |
* @return
|
42 |
*/
|
43 |
public static String normalize(String path) { |
44 |
if (path.indexOf("[") >= 0) { |
45 |
DataSource ds = DataSource.getDSFromName(path); |
46 |
path = path.substring(0,path.indexOf("[")) + |
47 |
ds.getPath() + path.substring(path.indexOf("]")+1); |
48 |
//System.out.println(path);
|
49 |
} |
50 |
return path;
|
51 |
} |
52 |
|
53 |
public String toString() { |
54 |
return "["+counter+"]"; |
55 |
} |
56 |
} |