KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > config > schema > dynamic > SubstitutedFileXPathBasedConfigItem


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

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 JavaDoc;
11
12 /**
13  * A {@link com.tc.config.schema.dynamic.FileXPathBasedConfigItem} that uses the
14  * {@link com.tc.config.schema.dynamic.ParameterSubstituter} to substitute values before processing.
15  */

16 public class SubstitutedFileXPathBasedConfigItem extends FileXPathBasedConfigItem {
17
18   public SubstitutedFileXPathBasedConfigItem(ConfigContext context, String JavaDoc xpath, File JavaDoc relativeTo) {
19     super(context, xpath, relativeTo);
20   }
21
22   public SubstitutedFileXPathBasedConfigItem(ConfigContext context, String JavaDoc xpath) {
23     super(context, xpath);
24   }
25
26   protected Object JavaDoc fetchDataFromXmlObject(XmlObject xmlObject) {
27     String JavaDoc theString = (String JavaDoc) super.fetchDataFromXmlObjectByReflection(xmlObject, "getStringValue");
28     if (theString == null || theString.trim().length() == 0) return null;
29     String JavaDoc substituted = ParameterSubstituter.substitute(theString);
30
31     File JavaDoc out = new File JavaDoc(substituted);
32     if (relativeTo() != null && !out.isAbsolute()) out = new File JavaDoc(relativeTo(), substituted);
33     return out;
34   }
35
36 }
37
Popular Tags