Revision 20940

View differences:

trunk/libraries/libMetadata/src/org/gvsig/metadata/IMetadata.java
1
package org.gvsig.metadata;
2

  
3
public interface IMetadata {
4

  
5
	public Object get(String name);
6
	public void set(String name, Object value);
7
	
8
	public int getInt(String name);
9
	public double getDouble(String name);
10
	public boolean getBoolean(String name);
11

  
12
	public void setInt(String name, int value);
13
	public void setDouble(String name, double value);
14
	public void setBoolean(String name, boolean value);
15
	
16
	public boolean hasValue(String name);
17
	
18
}
trunk/libraries/libMetadata/src/org/gvsig/metadata/MetadataManager.java
1
package org.gvsig.metadata;
2

  
3
import java.lang.reflect.Constructor;
4

  
5
public class MetadataManager implements IMetadataManager {
6
	
7
	private static IMetadataManager manager = null;
8
	
9
	public static IMetadataManager getManager() {
10
		if ( manager == null ) {
11
			manager = new MetadataManager();			
12
		}
13
		return manager;
14
	}
15

  
16
	
17
	
18
	private Constructor constructor = null;
19
	
20
	public MetadataManager() {
21
		install(Metadata.class);
22
	}
23
	
24
	public void install(Class metadata) {
25
		// constructor = metadata.getDeclaredConstructor( new { String.class } );
26
	}
27
	
28
	public IMetadata create(String definitionName) {
29
		// return constructor.newInstance(new Object[] { definitionName });
30
		return null;
31
	}
32
	
33
}
trunk/libraries/libMetadata/src/org/gvsig/metadata/IMetadatable.java
1
package org.gvsig.metadata;
2

  
3
import org.gvsig.exceptions.BaseException;
4

  
5
public interface IMetadatable {
6
	public IMetadata getMetadata() throws BaseException;
7
}
trunk/libraries/libMetadata/src/org/gvsig/metadata/IMetadataManager.java
1
package org.gvsig.metadata;
2

  
3
public interface IMetadataManager {
4

  
5
	public void install(Class metadata);
6
	
7
	public IMetadata create(String definitionName);
8
	
9
}
trunk/libraries/libMetadata/src/org/gvsig/metadata/Metadata.java
1
package org.gvsig.metadata;
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
2 22

  
3
import java.util.HashMap;
4
import java.util.Map;
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 Geographic Information research group: http://www.geoinfo.uji.es
26
* Departamento de Lenguajes y Sistemas Inform?ticos (LSI)
27
* Universitat Jaume I   
28
* {{Task}}
29
*/
5 30

  
6
public class Metadata implements IMetadata {
31
package org.gvsig.metadata;
7 32

  
8
	private Map values = new HashMap();
9
	@SuppressWarnings("unused") private String definitionName ;
10
	
11
	Metadata(String definitionName) {
12
		this.definitionName = definitionName;
13
	}
14
	
15
	public Object get(String name) {
16
		return values.get(name);
17
	}
33
import java.util.Date;
18 34

  
19
	public boolean getBoolean(String name) {
20
		return ((Boolean)values.get(name)).booleanValue();
21
	}
35
public interface Metadata {
22 36

  
23
	public double getDouble(String name) {
24
		return ((Double)values.get(name)).doubleValue();
25
	}
26

  
27
	public int getInt(String name) {
28
		return ((Integer)values.get(name)).intValue();
29
	}
30

  
31
	public boolean hasValue(String name) {
32
		return values.containsKey(name);
33
	}
34

  
35
	public void set(String name, Object value) {
36
		values.put(name, value);
37
	}
38

  
39
	public void setBoolean(String name, boolean value) {
40
		values.put(name, Boolean.valueOf(value));		
41
	}
42

  
43
	public void setDouble(String name, double value) {
44
		values.put(name, Double.valueOf(value));		
45
	}
46

  
47
	public void setInt(String name, int value) {
48
		values.put(name, Integer.valueOf(value));		
49
	}
50

  
37
	//public Metadata();
38
	public Object get(String name);
39
	public boolean getBoolean(String name) throws ClassCastException;
40
	public double getDouble(String name) throws ClassCastException;
41
	public int getInt(String name) throws ClassCastException;
42
	public String getString(String name) throws ClassCastException;
43
	public Date getDate(String name) throws ClassCastException;
44
	public void set(String name, Object value);
45
	public void setBoolean(String name, boolean value);
46
	public void setDouble(String name, double value);
47
	public void setInt(String name, int value);
48
	public void setString(String name, String value);
49
	public void setDate(String name, Date value);
50
	public boolean hasValue(String name);
51
	public boolean isEmpty();
51 52
}
trunk/libraries/libMetadata/src/org/gvsig/metadata/extended/ExtendedMetadata.java
1
package org.gvsig.metadata.extended;
2

  
3
import java.util.Date;
4

  
5
import org.gvsig.metadata.extended.manager.MDElement;
6
import org.gvsig.metadata.extended.registry.objects.MDElementDefinition;
7

  
8

  
9
public interface ExtendedMetadata {
10
	
11
	//public Metadata();
12
	//public Metadata(MDDefinition type);
13
	public MDElement getElement(String name);
14
	public void setElement(MDElement elem);
15
	public String getId();
16
	public String getName();
17
	public String getDescription();
18
	public Date getCreateDate();
19
	public Date getChangeDate();
20
	public MDElementDefinition getType();
21
	public String getAuthor();
22
	public Boolean hasElement(String name);
23
	
24
}
trunk/libraries/libMetadata/src/org/gvsig/metadata/extended/persistence/MDPersistence.java
1
package org.gvsig.metadata.extended.persistence;
2

  
3
import org.gvsig.metadata.extended.manager.ExtendedMetadataImpl;
4

  
5

  
6
public interface MDPersistence {
7
	
8
	public Boolean storeMD(ExtendedMetadataImpl md);
9
	public Boolean recoverMD(ExtendedMetadataImpl md);
10
}
trunk/libraries/libMetadata/src/org/gvsig/metadata/extended/registry/MDRegistry.java
1
package org.gvsig.metadata.extended.registry;
2

  
3
import org.gvsig.metadata.extended.registry.objects.MDElementDefinition;
4
import org.gvsig.metadata.extended.registry.objects.MDType;
5

  
6

  
7

  
8
public interface MDRegistry {
9
	
10
	public MDElementDefinition getMDDefinition(String name);
11
	public MDElementDefinition getMDElementDefinition(String name);
12
	public MDType getMDType(String name);
13
	public Boolean setMDDefinition(MDElementDefinition padre, String name, String description);
14
	public Boolean setMDElementDefinition(MDElementDefinition padre, String description, MDType type /* ...*/);
15
	public Boolean setMDType(/* ...*/);
16
	
17
}
trunk/libraries/libMetadata/src/org/gvsig/metadata/extended/registry/objects/MDDefinition.java
1
package org.gvsig.metadata.extended.registry.objects;
2

  
3

  
4
public class MDDefinition {
5
	
6
}
trunk/libraries/libMetadata/src/org/gvsig/metadata/extended/registry/objects/MDType.java
1
package org.gvsig.metadata.extended.registry.objects;
2

  
3
public class MDType {
4
	
5
}
trunk/libraries/libMetadata/src/org/gvsig/metadata/extended/registry/objects/MDElementDefinition.java
1
package org.gvsig.metadata.extended.registry.objects;
2

  
3
import java.util.HashMap;
4
import java.util.Map;
5

  
6

  
7
public class MDElementDefinition {
8
	
9
	private String name;
10
	private Enum type;
11
	private Boolean required;
12
	private Object defaultValue;
13
	private String description;
14
	private Map synonyms = new HashMap();
15
	
16
	public MDElementDefinition() {}
17
	
18
	public MDElementDefinition(String name, Enum type, Boolean required, Object defaultValue, String description) {
19
		this.name = name;
20
		this.type = type;
21
		this.required = required;
22
		this.defaultValue = defaultValue;
23
		this.description = description;
24
	}
25
	
26
	public String getName() {
27
		return this.name;
28
	}
29
	
30
	public Enum getType() {
31
		return this.type;
32
	}
33
	
34
	public Boolean isRequired() {
35
		return this.required;
36
	}
37
	
38
	public Object getDefaultValue() {
39
		return this.defaultValue;
40
	}
41
	
42
	public String getDescription() {
43
		return this.description;
44
	}
45
	
46
	public Object getSynonym(String name) {
47
		return synonyms.get(name);
48
	}
49
	
50
	public void setName(String name) {
51
		this.name = name;
52
	}
53
	
54
	public void setType(Enum type) {
55
		this.type = type;
56
	}
57
	
58
	public void setRequired(Boolean required) {
59
		this.required = required;
60
	}
61
	
62
	public void setDefaultValue(Object defaultValue) {
63
		this.defaultValue = defaultValue;
64
	}
65
	
66
	public void setDescription(String description) {
67
		this.description = description;
68
	}
69
	
70
	public void setSynonym(String name, Object synonym) {
71
		synonyms.put(name, synonym);
72
	}
73
}
trunk/libraries/libMetadata/src/org/gvsig/metadata/extended/manager/ExtendedMDManagerImpl.java
1
package org.gvsig.metadata.extended.manager;
2

  
3
import java.lang.reflect.Constructor;
4

  
5
import org.gvsig.metadata.MDManager;
6
import org.gvsig.metadata.Metadata;
7
import org.gvsig.metadata.extended.registry.objects.MDDefinition;
8
import org.gvsig.metadata.extended.registry.objects.MDElementDefinition;
9

  
10

  
11
public class ExtendedMDManagerImpl {
12

  
13
	
14

  
15
	public String md2xml(ExtendedMetadataImpl md) {
16
		// TODO Auto-generated method stub
17
		return null;
18
	}
19

  
20
	public ExtendedMetadataImpl createMD(String mdd) {
21
		// TODO Auto-generated method stub
22
		return null;
23
	}
24

  
25
	public MDElement createMDElement(String mded) {
26
		// TODO Auto-generated method stub
27
		return null;
28
	}
29

  
30
	
31

  
32
}
33
	
34
	/*
35
	private static IMDManager manager = null;
36
	
37
	public static IMDManager getManager() {
38
		if ( manager == null ) {
39
			manager = new MDManager();			
40
		}
41
		return manager;
42
	}
43

  
44
	
45
	
46
	private Constructor constructor = null;
47
	
48
	public MDManager() {
49
		install(Metadata.class);
50
	}
51
	
52
	public void install(Class metadata) {
53
		// constructor = metadata.getDeclaredConstructor( new { String.class } );
54
	}
55
	
56
	public IMetadata create(String definitionName) {
57
		// return constructor.newInstance(new Object[] { definitionName });
58
		return null;
59
	}
60
	
61
	
62
}
63

  
64
*/
65
	
trunk/libraries/libMetadata/src/org/gvsig/metadata/extended/manager/ExtendedMetadataImpl.java
1
package org.gvsig.metadata.extended.manager;
2

  
3
import java.util.Date;
4
import java.util.HashMap;
5
import java.util.Map;
6

  
7
import org.gvsig.metadata.Metadata;
8
import org.gvsig.metadata.extended.registry.objects.MDDefinition;
9

  
10
public class ExtendedMetadataImpl{
11
	
12
	private String id;
13
	private Date createDate;
14
	private Date changeDate;
15
	private MDDefinition type;
16
	private Map elements = new HashMap();
17
	//private Map metadata = new HashMap();
18
	
19
	
20
	public ExtendedMetadataImpl() {
21
		this.createDate = new Date();
22
		this.changeDate = null;
23
	}
24
	
25
	public ExtendedMetadataImpl(MDDefinition type) {
26
		this.createDate = new Date();
27
		this.changeDate = null;
28
		this.type = type;
29
	}
30
	
31
	public MDElement getElement(String idElem) {
32
		return (MDElement) elements.get(idElem);
33
	}
34

  
35
	public void setElement(MDElement elem) {
36
		String idElem = elem.getId();
37
		elements.put(idElem, elem);
38
	}
39
	
40
	
41
	public boolean hasElement(String id) {
42
		return elements.containsKey(id);
43
	}
44

  
45
	public String getId() {
46
		return this.id;
47
	}
48
	
49
	public Date getCreateDate() {
50
		return this.createDate;
51
	}
52
	
53
	public Date getChangeDate() {
54
		return this.changeDate;
55
	}
56
	
57
	public MDDefinition getType() {
58
		return this.type;
59
	}
60
	
61
	
62
	public void setId(String id) {
63
		this.id = id;
64
		setChangeDate();
65
	}
66
	
67
	private void setChangeDate() {
68
		this.changeDate = new Date();
69
	}
70
	
71
	public void setType(MDDefinition type) {
72
		this.type = type;
73
		setChangeDate();
74
	}
75

  
76
	
77
	
78

  
79
	
80
}
trunk/libraries/libMetadata/src/org/gvsig/metadata/extended/manager/MDElement.java
1
package org.gvsig.metadata.extended.manager;
2

  
3
import java.util.Locale;
4

  
5
import org.gvsig.metadata.extended.registry.objects.MDElementDefinition;
6

  
7

  
8
public class MDElement {
9
	
10
	private String id;
11
	private Object value;
12
	private MDElementDefinition type;
13
	private Locale locale;
14
	
15
	public MDElement() {}
16
	
17
	public MDElement(String id, Object value, MDElementDefinition type, Locale locale) {
18
		this.id = id;
19
		this.value = value;
20
		this.type = type;
21
		this.locale = locale;
22
	}
23
	
24
	public String getId() {
25
		return this.id;
26
	}
27
	
28
	public Object getValue() {
29
		return this.value;
30
	}
31
	
32
	public MDElementDefinition getType() {
33
		return this.type;
34
	}
35
	
36
	public Locale getLocale() {
37
		return this.locale;
38
	}
39
	
40
	public void setId(String id) {
41
		this.id = id;
42
	}
43
	
44
	public void setValue(Object value) {
45
		this.value = value;
46
	}
47
	
48
	public void setType(MDElementDefinition type) {
49
		this.type = type;
50
	}
51
	
52
	public void setLocale(Locale locale) {
53
		this.locale = locale;
54
	}
55
}
trunk/libraries/libMetadata/src/org/gvsig/metadata/extended/ExtendedMDManager.java
1
package org.gvsig.metadata.extended;
2

  
3
import org.gvsig.metadata.Metadata;
4
import org.gvsig.metadata.extended.manager.MDElement;
5
import org.gvsig.metadata.simple.SimpleMetadata;
6

  
7
public interface ExtendedMDManager {
8
	public Metadata createMD(String md);
9
	public MDElement createMDElement(String mded);
10
	public String md2xml(SimpleMetadata md);
11
	public SimpleMetadata importMD(String filePath);
12
	public String exportMD(SimpleMetadata md, String format);
13
}
trunk/libraries/libMetadata/src/org/gvsig/metadata/Metadatable.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 Geographic Information research group: http://www.geoinfo.uji.es
26
* Departamento de Lenguajes y Sistemas Inform?ticos (LSI)
27
* Universitat Jaume I   
28
* {{Task}}
29
*/
30

  
31
package org.gvsig.metadata;
32

  
33
import org.gvsig.metadata.extended.manager.ExtendedMetadataImpl;
34

  
35
public interface Metadatable {
36
	public ExtendedMetadataImpl getMD();
37
}
0 38

  
trunk/libraries/libMetadata/src/org/gvsig/metadata/MDLocator.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 Geographic Information research group: http://www.geoinfo.uji.es
26
* Departamento de Lenguajes y Sistemas Inform?ticos (LSI)
27
* Universitat Jaume I   
28
* {{Task}}
29
*/
30

  
31
package org.gvsig.metadata;
32

  
33
import java.lang.reflect.Constructor;
34
import java.lang.reflect.InvocationTargetException;
35

  
36
import org.gvsig.metadata.simple.SimpleMDManager;
37

  
38

  
39
public class MDLocator {
40
	
41
	private static MDManager manager = null;
42
	private static Constructor constructor = null;
43
	
44
	public MDLocator() {
45
		install(SimpleMDManager.class);
46
	}
47
	
48
	public void install(Class mdManager) {
49
		try {
50
			constructor = mdManager.getDeclaredConstructor(null);
51
		} catch (SecurityException e) {
52
			// TODO Auto-generated catch block
53
			e.printStackTrace();
54
		} catch (NoSuchMethodException e) {
55
			// TODO Auto-generated catch block
56
			e.printStackTrace();
57
		}
58
	}
59
	
60
	private static MDManager create() {
61
		MDManager imdm = null;
62
		try {
63
			imdm = (MDManager) constructor.newInstance(new Object[] {});
64
		} catch (IllegalArgumentException e) {
65
			// TODO Auto-generated catch block
66
			e.printStackTrace();
67
		} catch (InstantiationException e) {
68
			// TODO Auto-generated catch block
69
			e.printStackTrace();
70
		} catch (IllegalAccessException e) {
71
			// TODO Auto-generated catch block
72
			e.printStackTrace();
73
		} catch (InvocationTargetException e) {
74
			// TODO Auto-generated catch block
75
			e.printStackTrace();
76
		}
77
		return imdm;
78
	}
79
	
80
	public static MDManager getManager() {
81
		if ( manager == null ) {
82
			//manager = new org.gvsig.metadata.simple.MDManager();
83
			manager = create();
84
		}
85
		return manager;
86
	}
87
	
88
}
trunk/libraries/libMetadata/src/org/gvsig/metadata/simple/SimpleMetadata.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 Geographic Information research group: http://www.geoinfo.uji.es
26
* Departamento de Lenguajes y Sistemas Inform?ticos (LSI)
27
* Universitat Jaume I   
28
* {{Task}}
29
*/
30

  
31
package org.gvsig.metadata.simple;
32

  
33
import java.util.Date;
34
import java.util.HashMap;
35
import java.util.Map;
36

  
37
import org.gvsig.metadata.Metadata;
38

  
39
public class SimpleMetadata implements Metadata {
40

  
41
	private Map elements = new HashMap();
42
	private String definitionName;
43
	
44
	public SimpleMetadata(String definitionName) {
45
		this.definitionName = definitionName;
46
	}
47

  
48
	public Object get(String name) {
49
		return elements.get(name);
50
	}
51
	
52
	public boolean getBoolean(String name) throws ClassCastException {
53
		return ((Boolean)elements.get(name)).booleanValue();
54
	}
55

  
56
	public double getDouble(String name) throws ClassCastException {
57
		return ((Double)elements.get(name)).doubleValue();
58
	}
59

  
60
	public int getInt(String name) throws ClassCastException {
61
		return ((Integer)elements.get(name)).intValue();
62
	}
63
	
64
	public String getString(String name) throws ClassCastException {
65
		return (String)elements.get(name).toString();
66
	}
67

  
68
	public Date getDate(String name) throws ClassCastException {
69
		return (Date)elements.get(name);
70
	}
71

  
72
	public void set(String name, Object value) {
73
		elements.put(name, value);
74
	}
75
	
76
	public void setBoolean(String name, boolean value) {
77
		elements.put(name, Boolean.valueOf(value));		
78
	}
79

  
80
	public void setDouble(String name, double value) {
81
		elements.put(name, Double.valueOf(value));		
82
	}
83

  
84
	public void setInt(String name, int value) {
85
		elements.put(name, Integer.valueOf(value));		
86
	}
87
	
88
	public void setString(String name, String value) {
89
		elements.put(name, String.valueOf(value));		
90
	}
91

  
92
	public void setDate(String name, Date value) {
93
		elements.put(name, value);		
94
	}
95
	
96
	public boolean hasValue(String name) {
97
		return elements.containsKey(name);
98
	}
99

  
100
	public boolean isEmpty() {
101
		return elements.isEmpty();
102
	}
103
	
104
}
trunk/libraries/libMetadata/src/org/gvsig/metadata/simple/SimpleMDManager.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 Geographic Information research group: http://www.geoinfo.uji.es
26
* Departamento de Lenguajes y Sistemas Inform?ticos (LSI)
27
* Universitat Jaume I   
28
* {{Task}}
29
*/
30

  
31
package org.gvsig.metadata.simple;
32

  
33
import org.gvsig.metadata.MDManager;
34
import org.gvsig.metadata.Metadata;
35
import org.gvsig.metadata.simple.SimpleMetadata;
36

  
37
public class SimpleMDManager implements MDManager {
38
	
39
	public SimpleMDManager() {}
40
	
41
	public Metadata createMD(String mdd) {
42
		return new SimpleMetadata(mdd);
43
	}
44
	
45
}
trunk/libraries/libMetadata/src/org/gvsig/metadata/MDManager.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 Geographic Information research group: http://www.geoinfo.uji.es
26
* Departamento de Lenguajes y Sistemas Inform?ticos (LSI)
27
* Universitat Jaume I   
28
* {{Task}}
29
*/
30

  
31
package org.gvsig.metadata;
32

  
33
public interface MDManager {
34

  
35
	public Metadata createMD(String mdd);
36
	
37
}
trunk/libraries/libMetadata/.settings/org.eclipse.jdt.ui.prefs
1
#Wed Apr 16 11:26:02 CEST 2008
2
eclipse.preferences.version=1
3
internal.default.compliance=user
trunk/libraries/libMetadata/.settings/org.eclipse.jdt.core.prefs
1
#Thu May 22 13:08:04 CEST 2008
2
eclipse.preferences.version=1
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
6
org.eclipse.jdt.core.compiler.compliance=1.5
7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
8
org.eclipse.jdt.core.compiler.debug.localVariable=generate
9
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
10
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
11
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
12
org.eclipse.jdt.core.compiler.source=1.4
trunk/libraries/libMetadata/.classpath
1 1
<?xml version="1.0" encoding="UTF-8"?>
2 2
<classpath>
3 3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="src" path="unittests"/>
4 5
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5 6
	<classpathentry kind="lib" path="lib/org.gvsig.exceptions.jar"/>
7
	<classpathentry kind="lib" path="C:/Program Files/H2/bin/h2.jar"/>
8
	<classpathentry kind="lib" path="lib/antlr-2.7.6.jar"/>
9
	<classpathentry kind="lib" path="lib/asm.jar"/>
10
	<classpathentry kind="lib" path="lib/asm-attrs.jar"/>
11
	<classpathentry kind="lib" path="lib/cglib-2.1.3.jar"/>
12
	<classpathentry kind="lib" path="lib/commons-collections-2.1.1.jar"/>
13
	<classpathentry kind="lib" path="lib/commons-logging-1.0.4.jar"/>
14
	<classpathentry kind="lib" path="lib/dom4j-1.6.1.jar"/>
15
	<classpathentry kind="lib" path="lib/hibernate3.jar"/>
16
	<classpathentry kind="lib" path="lib/jta.jar"/>
17
	<classpathentry kind="lib" path="lib/log4j-1.2.11.jar"/>
18
	<classpathentry kind="lib" path="C:/Documents and Settings/Alejandro/Desktop/software/junit4.4/junit4.4/junit-4.4.jar"/>
6 19
	<classpathentry kind="output" path="bin"/>
7 20
</classpath>
trunk/libraries/libMetadata/unittests/simple/MetadataTest.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 Geographic Information research group: http://www.geoinfo.uji.es
26
* Departamento de Lenguajes y Sistemas Inform?ticos (LSI)
27
* Universitat Jaume I   
28
* {{Task}}
29
*/
30
 
31
package simple;
32

  
33
import java.util.Date;
34

  
35
import junit.framework.TestCase;
36

  
37
import org.gvsig.metadata.Metadata;
38
import org.gvsig.metadata.simple.SimpleMetadata;
39
import org.junit.Assert.*;
40

  
41
import org.junit.After;
42
import org.junit.AfterClass;
43
import org.junit.Before;
44
import org.junit.BeforeClass;
45
import org.junit.Test;
46

  
47
public class MetadataTest extends TestCase{
48

  
49
	//@BeforeClass
50
	public static void setUpBeforeClass() throws Exception {
51
	}
52

  
53
	//@AfterClass
54
	public static void tearDownAfterClass() throws Exception {
55
	}
56

  
57
	//@Before
58
	public void setUp() throws Exception {
59
	}
60

  
61
	//@After
62
	public void tearDown() throws Exception {
63
	}
64

  
65

  
66
	//@Test
67
	public void testSetGetElement() {
68
		Metadata md = new SimpleMetadata("prueba");
69
		md.setString("Author", "Alejandro Llaves");
70
		String ob = md.getString("Author");
71
		String res = "Alejandro Llaves";
72
		assertEquals(res, ob);
73
		md.setInt("Num", 5);
74
		assertEquals(md.getInt("Num"), 5);
75
		
76
	}
77

  
78

  
79
	//@Test
80
	public void testHasValue() {
81
		SimpleMetadata md = new SimpleMetadata("prueba");
82
		assertEquals(md.hasValue("Author"), false);
83
		md.set("Author", "Alejandro Llaves");
84
		assertEquals(md.hasValue("Author"), true);
85
	}
86

  
87
	//@Test
88
	public void testIsEmpty() {
89
		SimpleMetadata md = new SimpleMetadata("prueba");
90
		assertEquals(md.isEmpty(), true);
91
		md.set("Author", "Alejandro Llaves");
92
		assertEquals(md.isEmpty(), false);
93
	}
94

  
95
}
trunk/libraries/libMetadata/unittests/simple/MDLocatorTest.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 Geographic Information research group: http://www.geoinfo.uji.es
26
* Departamento de Lenguajes y Sistemas Inform?ticos (LSI)
27
* Universitat Jaume I   
28
* {{Task}}
29
*/
30
 
31
package simple;
32

  
33
import java.lang.reflect.Constructor;
34
import java.lang.reflect.InvocationTargetException;
35

  
36
import junit.framework.TestCase;
37

  
38
import org.gvsig.metadata.MDManager;
39
import org.gvsig.metadata.MDLocator;
40
import org.gvsig.metadata.simple.SimpleMDManager;
41
import org.junit.Assert.*;
42

  
43
import org.junit.After;
44
import org.junit.AfterClass;
45
import org.junit.Before;
46
import org.junit.BeforeClass;
47
import org.junit.Test;
48

  
49
public class MDLocatorTest extends TestCase{
50

  
51
	//@BeforeClass
52
	public static void setUpBeforeClass() throws Exception {
53
	}
54

  
55
	//@AfterClass
56
	public static void tearDownAfterClass() throws Exception {
57
	}
58

  
59
	//@Before
60
	public void setUp() throws Exception {
61
	}
62

  
63
	//@After
64
	public void tearDown() throws Exception {
65
	}
66

  
67
	//@Test
68
	public void testInstall() {
69
		Class mdm = SimpleMDManager.class;
70
		Constructor cons = null;
71
		MDManager imdm = null;
72
		try {
73
			cons = mdm.getDeclaredConstructor(null);
74
			imdm = (MDManager) cons.newInstance(new Object[] {});
75
		} catch (SecurityException e) {
76
			// TODO Auto-generated catch block
77
			e.printStackTrace();
78
		} catch (NoSuchMethodException e) {
79
			// TODO Auto-generated catch block
80
			e.printStackTrace();
81
		} catch (IllegalArgumentException e) {
82
			// TODO Auto-generated catch block
83
			e.printStackTrace();
84
		} catch (InstantiationException e) {
85
			// TODO Auto-generated catch block
86
			e.printStackTrace();
87
		} catch (IllegalAccessException e) {
88
			// TODO Auto-generated catch block
89
			e.printStackTrace();
90
		} catch (InvocationTargetException e) {
91
			// TODO Auto-generated catch block
92
			e.printStackTrace();
93
		}
94
		MDLocator mdl = new MDLocator();
95
		
96
	}
97

  
98
	//@Test
99
	public void testGetManager() {
100
	}
101

  
102
}

Also available in: Unified diff