Java Doc for ConfigurationInterpolator.java in  » Library » Apache-commons-configuration-1.4-src » org » apache » commons » configuration » interpol » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Library » Apache commons configuration 1.4 src » org.apache.commons.configuration.interpol 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.apache.commons.configuration.interpol.ConfigurationInterpolator

ConfigurationInterpolator
public class ConfigurationInterpolator extends StrLookup (Code)

A class that handles interpolation (variable substitution) for configuration objects.

Each instance of AbstractConfiguration is associated with an object of this class. Each interpolation tasks are delegated to this object.

ConfigurationInterpolator works together with the StrSubstitutor class from Commons Lang. By extending StrLookup it is able to provide values for variables that appear in expressions.

The basic idea of this class is that it can maintain a set of primitive StrLookup objects, each of which are identified by a special prefix. The variables to be processed have the form ${prefix:name}. ConfigurationInterpolator will extract the prefix and determine, which primitive lookup object is registered for it. Then the name of the variable is passed to this object to obtain the actual value. It is also possible to define a default lookup object, which will be used for variables that do not have a prefix.

When a new instance of this class is created it is initialized with a default set of primitive lookup objects. This set can be customized using the static methods registerGlobalLookup() and deregisterGlobalLookup(). Per default it contains the following standard lookup objects:

Prefix Lookup object
sys With this prefix a lookup object is associated that is able to resolve system properties.
const The const prefix indicates that a variable is to be interpreted as a constant member field of a class (i.e. a field with the static final modifiers). The name of the variable must be of the form <full qualified class name>.<field name>, e.g. org.apache.commons.configuration.interpol.ConfigurationInterpolator.PREFIX_CONSTANTS .

After an instance has been created the current set of lookup objects can be modified using the registerLookup() and deregisterLookup() methods. The default lookup object (that is invoked for variables without a prefix) can be set with the setDefaultLookup() method. (If a ConfigurationInterpolator instance is created by a configuration object, this lookup points to the configuration itself, so that variables are resolved using the configuration's properties. This ensures backward compatibility to earlier version of Commons Configuration.)

Implementation node: Instances of this class are not thread-safe related to modifications of their current set of registered lookup objects. It is intended that each instance is associated with a single Configuration object and used for its interpolation tasks.


version:
   $Id: ConfigurationInterpolator.java 491243 2006-12-30 16:04:03Z oheger $
since:
   1.4
author:
   author:
   href="http://jakarta.apache.org/commons/configuration/team-list.html">Commons
author:
   Configuration team


Field Summary
final public static  StringPREFIX_CONSTANTS
     Constant for the prefix of the standard lookup object for resolving constant values.
final public static  StringPREFIX_SYSPROPERTIES
     Constant for the prefix of the standard lookup object for resolving system properties.

Constructor Summary
public  ConfigurationInterpolator()
     Creates a new instance of ConfigurationInterpolator.

Method Summary
public static  booleanderegisterGlobalLookup(String prefix)
     Deregisters the global lookup object for the specified prefix.
public  booleanderegisterLookup(String prefix)
     Deregisters the lookup object for the specified prefix at this instance.
protected  StrLookupfetchLookupForPrefix(String prefix)
     Obtains the lookup object for the specified prefix.
protected  StrLookupfetchNoPrefixLookup()
     Returns the lookup object to be used for variables without a prefix.
public  StrLookupgetDefaultLookup()
     Returns the default lookup object.
public  Stringlookup(String var)
     Resolves the specified variable.
public  SetprefixSet()
     Returns a set with the prefixes, for which lookup objects are registered at this instance.
public static  voidregisterGlobalLookup(String prefix, StrLookup lookup)
     Registers the given lookup object for the specified prefix globally.
public  voidregisterLookup(String prefix, StrLookup lookup)
     Registers the given lookup object for the specified prefix at this instance.
public  voidsetDefaultLookup(StrLookup defaultLookup)
     Sets the default lookup object.

Field Detail
PREFIX_CONSTANTS
final public static String PREFIX_CONSTANTS(Code)
Constant for the prefix of the standard lookup object for resolving constant values.



PREFIX_SYSPROPERTIES
final public static String PREFIX_SYSPROPERTIES(Code)
Constant for the prefix of the standard lookup object for resolving system properties.




Constructor Detail
ConfigurationInterpolator
public ConfigurationInterpolator()(Code)
Creates a new instance of ConfigurationInterpolator.




Method Detail
deregisterGlobalLookup
public static boolean deregisterGlobalLookup(String prefix)(Code)
Deregisters the global lookup object for the specified prefix. This means that this lookup object won't be available for later created instances any more. For already existing instances this operation does not have any impact.
Parameters:
  prefix - the variable prefix a flag whether for this prefix a lookup object had beenregistered



deregisterLookup
public boolean deregisterLookup(String prefix)(Code)
Deregisters the lookup object for the specified prefix at this instance. It will be removed from this instance.
Parameters:
  prefix - the variable prefix a flag whether for this prefix a lookup object had beenregistered



fetchLookupForPrefix
protected StrLookup fetchLookupForPrefix(String prefix)(Code)
Obtains the lookup object for the specified prefix. This method is called by the lookup() method. This implementation will check whether a lookup object is registered for the given prefix. If not, a null lookup object will be returned.
Parameters:
  prefix - the prefix the lookup object to be used for this prefix



fetchNoPrefixLookup
protected StrLookup fetchNoPrefixLookup()(Code)
Returns the lookup object to be used for variables without a prefix. This implementation will check whether a default lookup object was set. If this is the case, it will be returned. Otherwise a null lookup object will be returned. the lookup object to be used for variables without a prefix



getDefaultLookup
public StrLookup getDefaultLookup()(Code)
Returns the default lookup object. the default lookup object



lookup
public String lookup(String var)(Code)
Resolves the specified variable. This implementation will try to extract a variable prefix from the given variable name (the first colon (':') is used as prefix separator). It then passes the name of the variable with the prefix stripped to the lookup object registered for this prefix. If no prefix can be found, the default lookup object will be used.
Parameters:
  var - the name of the variable whose value is to be looked up the value of this variable or null if it cannot beresolved



prefixSet
public Set prefixSet()(Code)
Returns a set with the prefixes, for which lookup objects are registered at this instance. This means that variables with these prefixes can be processed. a set with the registered variable prefixes



registerGlobalLookup
public static void registerGlobalLookup(String prefix, StrLookup lookup)(Code)
Registers the given lookup object for the specified prefix globally. This means that all instances that are created later will use this lookup object for this prefix. If for this prefix a lookup object is already registered, the new lookup object will replace the old one. Note that the lookup objects registered here will be shared between multiple clients. So they should be thread-safe.
Parameters:
  prefix - the variable prefix (must not be null)
Parameters:
  lookup - the lookup object to be used for this prefix (must not benull)



registerLookup
public void registerLookup(String prefix, StrLookup lookup)(Code)
Registers the given lookup object for the specified prefix at this instance. From now on this lookup object will be used for variables that have the specified prefix.
Parameters:
  prefix - the variable prefix (must not be null)
Parameters:
  lookup - the lookup object to be used for this prefix (must not benull)



setDefaultLookup
public void setDefaultLookup(StrLookup defaultLookup)(Code)
Sets the default lookup object. This lookup object will be used for all variables without a special prefix. If it is set to null, such variables won't be processed.
Parameters:
  defaultLookup - the new default lookup object



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.