1
|
1 package de.mpg.mpiwg.itgroup.indexMeta.Utils;
|
|
2
|
|
3 import java.io.File;
|
|
4 import java.io.IOException;
|
|
5 import java.io.InputStream;
|
|
6
|
|
7
|
|
8 import org.eclipse.core.resources.IFile;
|
|
9 import org.eclipse.core.runtime.CoreException;
|
|
10 import org.jdom.Document;
|
|
11 import org.jdom.Element;
|
|
12 import org.jdom.JDOMException;
|
|
13 import org.jdom.input.SAXBuilder;
|
|
14 import org.jdom.xpath.XPath;
|
|
15
|
|
16 public class ParseIndexMeta {
|
|
17
|
|
18 private Document dom;
|
|
19
|
|
20 public ParseIndexMeta(IFile indexMetaFile) throws JDOMException, IOException, CoreException {
|
|
21 SAXBuilder builder = new SAXBuilder();
|
|
22 InputStream is = indexMetaFile.getContents();
|
|
23 dom = builder.build(is);
|
|
24 }
|
|
25
|
|
26 public String getPath() throws JDOMException {
|
|
27 // TODO Auto-generated method stub
|
|
28 XPath xpath = XPath.newInstance("//archive-path");
|
|
29 Element el = (Element)xpath.selectSingleNode(dom);
|
|
30 if (el==null)
|
|
31 return null;
|
|
32 return el.getTextTrim();
|
|
33 }
|
|
34
|
|
35 public String getImagePath() throws JDOMException{
|
|
36 String path = getPath();
|
|
37
|
|
38 XPath xpath = XPath.newInstance("//texttool/image");
|
|
39 Element el = (Element)xpath.selectSingleNode(dom);
|
|
40 if (el==null)
|
|
41 return null;
|
|
42 String imagePath =el.getTextTrim();
|
|
43
|
|
44 return(path+"/"+imagePath);
|
|
45
|
|
46 }
|
|
47
|
|
48 }
|