Revision 6 trunk/libraries/libCq CMS for java.old/src/org/cresques/io/DataSource.java

View differences:

DataSource.java
4 4

  
5 5
package org.cresques.io;
6 6

  
7
import java.util.Hashtable;
8

  
7 9
/**
8 10
 * Origen de datos. Unidad, volumen de red, etc.
9 11
 * 
......
12 14

  
13 15
public class DataSource {
14 16
	private static int counter = 0;
17
	private static Hashtable units = new Hashtable();
15 18
	String path = null;
16 19
	String name = null;
17 20

  
18 21
	public DataSource(String path, String name) {
19 22
		this.path = path;
20 23
		this.name = name;
24
		units.put(name, this);
21 25
	}
22 26
	
27
	public String getName() { return name; }
28
	public String getPath() { return path; }
29
	
30
	public static DataSource getDSFromName(String name) {
31
		if (name.startsWith("[")) name = name.substring(1);
32
		if (name.indexOf("]") >= 0) name = name.substring(name.indexOf("]"));
33
		DataSource ds = (DataSource) units.get(name);
34
		return ds;
35
	}
36
	
23 37
	public String toString() {
24
		return "[DS"+counter+"]";
38
		return "["+counter+"]";
25 39
	}
26 40
}

Also available in: Unified diff