1 4 package com.tc.config.schema.dynamic; 5 6 import org.apache.xmlbeans.XmlObject; 7 8 import com.tc.config.schema.context.ConfigContext; 9 10 import java.io.File ; 11 12 16 public class FileXPathBasedConfigItem extends XPathBasedConfigItem implements FileConfigItem { 17 18 private final File relativeTo; 19 20 public FileXPathBasedConfigItem(ConfigContext context, String xpath, File relativeTo) { 21 super(context, xpath); 22 this.relativeTo = relativeTo; 23 } 24 25 public FileXPathBasedConfigItem(ConfigContext context, String xpath) { 26 this(context, xpath, null); 27 } 28 29 protected Object fetchDataFromXmlObject(XmlObject xmlObject) { 30 String theString = (String ) super.fetchDataFromXmlObjectByReflection(xmlObject, "getStringValue"); 31 if (theString == null || theString.trim().length() == 0) return null; 32 33 File out = new File (theString); 34 if (this.relativeTo != null && !out.isAbsolute()) out = new File (this.relativeTo, theString); 35 return out; 36 } 37 38 protected final File relativeTo() { 39 return this.relativeTo; 40 } 41 42 public File getFile() { 43 return (File ) getObject(); 44 } 45 46 } 47 | Popular Tags |