1 16 17 package org.apache.cocoon.components.modules.input; 18 19 import org.apache.avalon.framework.configuration.Configuration; 20 import org.apache.avalon.framework.configuration.ConfigurationException; 21 import org.apache.avalon.framework.thread.ThreadSafe; 22 23 import org.apache.cocoon.environment.ObjectModelHelper; 24 25 import java.util.Iterator ; 26 import java.util.Map ; 27 import java.util.Vector ; 28 29 37 38 59 public class RealPathModule extends AbstractInputModule implements ThreadSafe { 60 61 private final static Vector returnNames; 62 static { 63 Vector tmp = new Vector (); 64 tmp.add("realPath"); 65 returnNames = tmp; 66 } 67 68 public Object getAttribute(String name, Configuration modeConf, Map objectModel) 69 throws ConfigurationException { 70 String uri = ObjectModelHelper.getContext(objectModel).getRealPath(name); 71 if (uri == null) { 72 return null; 73 } 74 75 int lastCharPos = uri.length() - 1; 76 if (uri.charAt(lastCharPos) == '\\') { 77 uri = uri.substring(0, lastCharPos); 78 } 79 return uri; 80 } 81 82 public Iterator getAttributeNames(Configuration modeConf, Map objectModel) 83 throws ConfigurationException { 84 return RealPathModule.returnNames.iterator(); 85 } 86 87 public Object [] getAttributeValues( String name, Configuration modeConf, Map objectModel ) 88 throws ConfigurationException { 89 return new Object [] { getAttribute(name, modeConf, objectModel) }; 90 } 91 } 92 | Popular Tags |