Package org.apache.commons.vfs2.util
Class DelegatingFileSystemOptionsBuilder
java.lang.Object
org.apache.commons.vfs2.util.DelegatingFileSystemOptionsBuilder
This class use reflection to set a configuration value using the fileSystemConfigBuilder associated the a scheme.
Example:
FileSystemOptions fso = new FileSystemOptions(); DelegatingFileSystemOptionsBuilder delegate = new DelegatingFileSystemOptionsBuilder(VFS.getManager()); delegate.setConfigString(fso, "sftp", "identities", "c:/tmp/test.ident"); delegate.setConfigString(fso, "http", "proxyPort", "8080"); delegate.setConfigClass(fso, "sftp", "userinfo", TrustEveryoneUserInfo.class);
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
Context. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.apache.commons.logging.Log
private final FileSystemManager
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
convertValuesAndInvoke
(Method configSetter, DelegatingFileSystemOptionsBuilder.Context ctx) Tries to convert the value and pass it to the given methodcreateSchemeMethods
(String scheme) Creates the list of all set*() methods for the given schemeprivate boolean
Fills all available set*() methods for the context-scheme into the context.protected FileSystemManager
getSchemeMethods
(String scheme) Gets (cached) list of set*() methods for the given schemeprivate void
invokeSetter
(Class<?> valueParameter, DelegatingFileSystemOptionsBuilder.Context ctx, Method configSetter, Object values) Invokes the method with the converted valuesvoid
setConfigClass
(FileSystemOptions fso, String scheme, String name, Class<?> className) Sets a single class value.void
setConfigClasses
(FileSystemOptions fso, String scheme, String name, Class<?>[] classNames) Sets an array of class values.void
setConfigString
(FileSystemOptions fso, String scheme, String name, String value) Sets a single string value.void
setConfigStrings
(FileSystemOptions fso, String scheme, String name, String[] values) Sets an array of string value.private void
Sets the values using the informations of the given context.
-
Field Details
-
STRING_PARAM
-
PRIMATIVE_TO_OBJECT
-
log
private static final org.apache.commons.logging.Log log -
manager
-
beanMethods
-
-
Constructor Details
-
DelegatingFileSystemOptionsBuilder
Constructor.Pass in your fileSystemManager instance.
- Parameters:
manager
- the manager to use to get the fileSystemConfigBuilder assocated to a scheme
-
-
Method Details
-
getManager
-
setConfigString
public void setConfigString(FileSystemOptions fso, String scheme, String name, String value) throws FileSystemException Sets a single string value.- Parameters:
fso
- FileSystemOptionsscheme
- schemename
- namevalue
- value- Throws:
FileSystemException
- if an error occurs.
-
setConfigStrings
public void setConfigStrings(FileSystemOptions fso, String scheme, String name, String[] values) throws FileSystemException Sets an array of string value.- Parameters:
fso
- FileSystemOptionsscheme
- schemename
- namevalues
- values- Throws:
FileSystemException
- if an error occurs.
-
setConfigClass
public void setConfigClass(FileSystemOptions fso, String scheme, String name, Class<?> className) throws FileSystemException, IllegalAccessException, InstantiationException Sets a single class value.The class has to implement a no-args constructor, else the instantiation might fail.
- Parameters:
fso
- FileSystemOptionsscheme
- schemename
- nameclassName
- className- Throws:
FileSystemException
- if an error occurs.IllegalAccessException
- if a class canoot be accessed.InstantiationException
- if a class cannot be instantiated.
-
setConfigClasses
public void setConfigClasses(FileSystemOptions fso, String scheme, String name, Class<?>[] classNames) throws FileSystemException, IllegalAccessException, InstantiationException Sets an array of class values.The class has to implement a no-args constructor, else the instantiation might fail.
- Parameters:
fso
- FileSystemOptionsscheme
- schemename
- nameclassNames
- classNames- Throws:
FileSystemException
- if an error occurs.IllegalAccessException
- if a class canoot be accessed.InstantiationException
- if a class cannot be instantiated.
-
setValues
Sets the values using the informations of the given context.- Throws:
FileSystemException
-
convertValuesAndInvoke
private boolean convertValuesAndInvoke(Method configSetter, DelegatingFileSystemOptionsBuilder.Context ctx) throws FileSystemException Tries to convert the value and pass it to the given method- Throws:
FileSystemException
-
invokeSetter
private void invokeSetter(Class<?> valueParameter, DelegatingFileSystemOptionsBuilder.Context ctx, Method configSetter, Object values) throws FileSystemException Invokes the method with the converted values- Throws:
FileSystemException
-
fillConfigSetters
private boolean fillConfigSetters(DelegatingFileSystemOptionsBuilder.Context ctx) throws FileSystemException Fills all available set*() methods for the context-scheme into the context.- Throws:
FileSystemException
-
getSchemeMethods
Gets (cached) list of set*() methods for the given scheme- Throws:
FileSystemException
-
createSchemeMethods
Creates the list of all set*() methods for the given scheme- Throws:
FileSystemException
-