Project

General

Profile

« Previous | Next » 

Revision f0bec55b

Added by Andreas Müller over 15 years ago

View differences:

cdmlib-commons/src/main/java/eu/etaxonomy/cdm/common/XmlHelp.java
158 158
		return  bean;
159 159
	}
160 160
	
161
	
161

  
162 162
	//returns the root Element in the File xmlFile
163 163
	static public  Element getRoot(InputStream xmlInput){
164
		try {
165
			SAXBuilder builder = new SAXBuilder();
166
			Document doc = builder.build(xmlInput);
167
			Element root = doc.getRootElement();
168
			return root;
169
		} catch (JDOMException e) {
170
			e.printStackTrace();
171
			return null;
172
		} catch (IOException e) {
173
			e.printStackTrace();
174
			return null;
175
		} 
176
	}
177
	
178
	//returns the root Element in the File xmlFile
179
	static public  Element getRoot(InputStream xmlInput, String elementName){
180
		try {
181
			SAXBuilder builder = new SAXBuilder();
182
			Document doc = builder.build(xmlInput);
183
			Element root = doc.getRootElement();
184
			if (root.getName() != elementName){
185
				return null;
186
			}else{
187
				return root;
188
			}
189
		} catch (JDOMException e) {
190
			e.printStackTrace();
191
			return null;
192
		} catch (IOException e) {
193
			e.printStackTrace();
194
			return null;
195
		} 
196
	}
197
	
198
	//returns the root Element in the File xmlFile
199
	static public  Element getBeansRoot(InputStream xmlInput){
164 200
		try {
165 201
			SAXBuilder builder = new SAXBuilder();
166 202
			Document doc = builder.build(xmlInput);
cdmlib-commons/src/test/java/eu/etaxonomy/cdm/common/UuidGenerator.java
9 9
package eu.etaxonomy.cdm.common;
10 10

  
11 11
import java.io.File;
12
import java.net.MalformedURLException;
13
import java.net.URL;
14 12
import java.util.UUID;
15 13

  
16 14
import org.apache.log4j.Logger;
......
25 23
	 * @param args
26 24
	 */
27 25
	public static void main(String[] args) {
28
		for (int i = 0; i < 0; i++){
26
		for (int i = 0; i < 10; i++){
29 27
			System.out.println(UUID.randomUUID());
30 28
		}
31 29
		boolean result;
32
		String str =  "file://C:/tmp";
33
		try {
34
			str =  "\\\\Bgbm11\\Edit-WP6";
35
			File file = null;
36
			file = new File(str);
37
			if (file.exists()){
38
				result = true;
39
			}else{
40
				result = false;
41
			}
42
			logger.warn(result);
43
		} catch (Exception e) {
44
			// TODO Auto-generated catch block
45
			e.printStackTrace();
46
		}
30
//		String str =  "file://C:/tmp";
31
//		try {
32
//			str =  "\\\\Bgbm11\\Edit-WP6";
33
//			File file = null;
34
//			file = new File(str);
35
//			if (file.exists()){
36
//				result = true;
37
//			}else{
38
//				result = false;
39
//			}
40
//			logger.warn(result);
41
//		} catch (Exception e) {
42
//			// TODO Auto-generated catch block
43
//			e.printStackTrace();
44
//		}
47 45

  
48 46
	}
49 47

  

Also available in: Unified diff