comparison src/de/mpg/mpiwg/itgroup/indexMeta/Utils/ParseIndexMeta.java @ 9:e63a64652f4d

added comments
author dwinter
date Mon, 03 Jan 2011 16:53:48 +0100
parents 83c58ea33792
children
comparison
equal deleted inserted replaced
8:52023cf79d86 9:e63a64652f4d
1 package de.mpg.mpiwg.itgroup.indexMeta.Utils; 1 package de.mpg.mpiwg.itgroup.indexMeta.Utils;
2 2
3 import java.io.File;
4 import java.io.IOException; 3 import java.io.IOException;
5 import java.io.InputStream; 4 import java.io.InputStream;
6
7 5
8 import org.eclipse.core.resources.IFile; 6 import org.eclipse.core.resources.IFile;
9 import org.eclipse.core.runtime.CoreException; 7 import org.eclipse.core.runtime.CoreException;
10 import org.jdom.Document; 8 import org.jdom.Document;
11 import org.jdom.Element; 9 import org.jdom.Element;
12 import org.jdom.JDOMException; 10 import org.jdom.JDOMException;
13 import org.jdom.input.SAXBuilder; 11 import org.jdom.input.SAXBuilder;
14 import org.jdom.xpath.XPath; 12 import org.jdom.xpath.XPath;
15 13
14 /**
15 *
16 * Utilities to parse index.meta files following the standards of the MPIWG
17 * @author dwinter
18 *
19 */
16 public class ParseIndexMeta { 20 public class ParseIndexMeta {
17 21
18 private Document dom; 22 private Document dom;
19 23
20 public ParseIndexMeta(IFile indexMetaFile) throws JDOMException, IOException, CoreException { 24 public ParseIndexMeta(IFile indexMetaFile) throws JDOMException, IOException, CoreException {
21 SAXBuilder builder = new SAXBuilder(); 25 SAXBuilder builder = new SAXBuilder();
22 InputStream is = indexMetaFile.getContents(); 26 InputStream is = indexMetaFile.getContents();
23 dom = builder.build(is); 27 dom = builder.build(is);
24 } 28 }
25 29
30 /**
31 * @return the content of the archive-path tag.
32 * @throws JDOMException
33 */
26 public String getPath() throws JDOMException { 34 public String getPath() throws JDOMException {
27 // TODO Auto-generated method stub 35
28 XPath xpath = XPath.newInstance("//archive-path"); 36 XPath xpath = XPath.newInstance("//archive-path");
29 Element el = (Element)xpath.selectSingleNode(dom); 37 Element el = (Element)xpath.selectSingleNode(dom);
30 if (el==null) 38 if (el==null)
31 return null; 39 return null;
32 return el.getTextTrim(); 40 return el.getTextTrim();
33 } 41 }
34 42
43 /**
44 * @return the content of //texttool/image
45 * @throws JDOMException
46 */
35 public String getImagePath() throws JDOMException{ 47 public String getImagePath() throws JDOMException{
36 String path = getPath(); 48 String path = getPath();
37 49
38 XPath xpath = XPath.newInstance("//texttool/image"); 50 XPath xpath = XPath.newInstance("//texttool/image");
39 Element el = (Element)xpath.selectSingleNode(dom); 51 Element el = (Element)xpath.selectSingleNode(dom);