Java Doc for CmsMacroResolver.java in  » Content-Management-System » opencms » org » opencms » util » 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 » Content Management System » opencms » org.opencms.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.opencms.util.CmsMacroResolver

CmsMacroResolver
public class CmsMacroResolver implements I_CmsMacroResolver(Code)
Resolves macros in the form of %(key) or ${key} in an input String.

Starting with OpenCms 7.0, the preferred form of a macro is %(key). This is to avoid conflicts / confusion with the JSP EL, which also uses the ${key} syntax.

The macro names that can be resolved depend of the context objects provided to the resolver using the set... methods.


author:
   Alexander Kandzior
author:
   Thomas Weckert
version:
   $Revision: 1.26 $
since:
   6.0.0



Field Summary
final public static  StringKEY_ATTRIBUTE
     The prefix indicating that the key represents an OpenCms runtime attribute.
final public static  StringKEY_CURRENT_ORGUNIT_DESCRIPTION
     Key used to specify the description of the current organizational unit as macro value.
final public static  StringKEY_CURRENT_ORGUNIT_FQN
     Key used to specify the full qualified name of the current organizational unit as macro value.
final public static  StringKEY_CURRENT_TIME
     Key used to specify the current time as macro value.
final public static  StringKEY_CURRENT_USER_CITY
     Key used to specify the city of the current user as macro value.
final public static  StringKEY_CURRENT_USER_COUNTRY
     Key used to specify the country of the current user as macro value.
final public static  StringKEY_CURRENT_USER_DISPLAYNAME
     Key used to specify the display name of the current user as macro value.
final public static  StringKEY_CURRENT_USER_EMAIL
     Key used to specify the email address of the current user as macro value.
final public static  StringKEY_CURRENT_USER_FIRSTNAME
     Key used to specify the first name of the current user as macro value.
final public static  StringKEY_CURRENT_USER_FULLNAME
     Key used to specify the full name of the current user as macro value.
final public static  StringKEY_CURRENT_USER_LASTLOGIN
     Key used to specify the last login date of the current user as macro value.
final public static  StringKEY_CURRENT_USER_LASTNAME
     Key used to specify the last name of the current user as macro value.
final public static  StringKEY_CURRENT_USER_NAME
     Key used to specify the user name of the current user as macro value.
final public static  StringKEY_CURRENT_USER_STREET
     Key used to specify the street of the current user as macro value.
final public static  StringKEY_CURRENT_USER_ZIP
     Key used to specify the zip code of the current user as macro value.
final public static  StringKEY_LOCALIZED_PREFIX
     Key prefix used to specify the value of a localized key as macro value.
final public static  StringKEY_OPENCMS
     Identifier for "magic" parameter names.
final public static  StringKEY_PAGE_CONTEXT
     The prefix indicating that the key represents a page context object.
final public static  StringKEY_PROJECT_ID
     Key used to specify the project id as macro value.
final public static  StringKEY_PROPERTY
     The prefix indicating that the key represents a property to be read on the current request URI.
final public static  StringKEY_PROPERTY_ELEMENT
     The prefix indicating that the key represents a property to be read on the current element.
final public static  StringKEY_REQUEST_ENCODING
     Key used to specify the request encoding as macro value.
final public static  StringKEY_REQUEST_FOLDER
     Key used to specify the folder of the request URI as macro value.
final public static  StringKEY_REQUEST_LOCALE
     Key user to specify the request locale as macro value.
final public static  StringKEY_REQUEST_PARAM
     The prefix indicating that the key represents a HTTP request parameter.
final public static  StringKEY_REQUEST_URI
     Key used to specify the request uri as macro value.
final public static  StringKEY_VALIDATION_PATH
     Key used to specify the validation path as macro value.
final public static  StringKEY_VALIDATION_REGEX
     Key used to specify the validation regex as macro value.
final public static  StringKEY_VALIDATION_VALUE
     Key used to specify the validation value as macro value.
final public static  ListVALUE_NAMES
     The "magic" commands wrapped in a List.
final static  String[]VALUE_NAMES_ARRAY
     Identified for "magic" parameter commands.
protected  Mapm_additionalMacros
     A map of additional values provided by the calling class.
protected  CmsObjectm_cms
     The OpenCms user context to use for resolving macros.
protected  PageContextm_jspPageContext
     The JSP's page context to use for resolving macros.
protected  booleanm_keepEmptyMacros
     Indicates if unresolved macros should be kept "as is" or replaced by an empty String.
protected  CmsMessagesm_messages
     The messages resource bundle to resolve localized keys with.
protected  Stringm_resourceName
     The resource name to use for resolving macros.


Method Summary
public  voidaddMacro(String key, String value)
    
public static  StringformatMacro(String input)
    
public  StringgetMacroValue(String macro)
    
public  booleanisKeepEmptyMacros()
    
public static  booleanisMacro(String input)
    
public static  booleanisMacro(String input, String macroName)
    
public static  StringlocalizedKeyMacro(String keyName, Object[] params)
    
public static  CmsMacroResolvernewInstance()
    
public static  StringresolveMacros(String input, CmsObject cms, CmsMessages messages)
    
public static  StringresolveMacros(String input, I_CmsMacroResolver resolver)
    
public  StringresolveMacros(String input)
     Resolves the macros in the given input.

Calls CmsMacroResolver.resolveMacros(String) until no more macros can be resolved in the input.

public  CmsMacroResolversetAdditionalMacros(Map additionalMacros)
    
public  CmsMacroResolversetCmsObject(CmsObject cms)
    
public  CmsMacroResolversetJspPageContext(PageContext jspPageContext)
    
public  CmsMacroResolversetKeepEmptyMacros(boolean keepEmptyMacros)
    
public  CmsMacroResolversetMessages(CmsMessages messages)
    
public  CmsMacroResolversetResourceName(String resourceName)
    
public static  StringstripMacro(String input)
    

Field Detail
KEY_ATTRIBUTE
final public static String KEY_ATTRIBUTE(Code)
The prefix indicating that the key represents an OpenCms runtime attribute.



KEY_CURRENT_ORGUNIT_DESCRIPTION
final public static String KEY_CURRENT_ORGUNIT_DESCRIPTION(Code)
Key used to specify the description of the current organizational unit as macro value.



KEY_CURRENT_ORGUNIT_FQN
final public static String KEY_CURRENT_ORGUNIT_FQN(Code)
Key used to specify the full qualified name of the current organizational unit as macro value.



KEY_CURRENT_TIME
final public static String KEY_CURRENT_TIME(Code)
Key used to specify the current time as macro value.



KEY_CURRENT_USER_CITY
final public static String KEY_CURRENT_USER_CITY(Code)
Key used to specify the city of the current user as macro value.



KEY_CURRENT_USER_COUNTRY
final public static String KEY_CURRENT_USER_COUNTRY(Code)
Key used to specify the country of the current user as macro value.



KEY_CURRENT_USER_DISPLAYNAME
final public static String KEY_CURRENT_USER_DISPLAYNAME(Code)
Key used to specify the display name of the current user as macro value.



KEY_CURRENT_USER_EMAIL
final public static String KEY_CURRENT_USER_EMAIL(Code)
Key used to specify the email address of the current user as macro value.



KEY_CURRENT_USER_FIRSTNAME
final public static String KEY_CURRENT_USER_FIRSTNAME(Code)
Key used to specify the first name of the current user as macro value.



KEY_CURRENT_USER_FULLNAME
final public static String KEY_CURRENT_USER_FULLNAME(Code)
Key used to specify the full name of the current user as macro value.



KEY_CURRENT_USER_LASTLOGIN
final public static String KEY_CURRENT_USER_LASTLOGIN(Code)
Key used to specify the last login date of the current user as macro value.



KEY_CURRENT_USER_LASTNAME
final public static String KEY_CURRENT_USER_LASTNAME(Code)
Key used to specify the last name of the current user as macro value.



KEY_CURRENT_USER_NAME
final public static String KEY_CURRENT_USER_NAME(Code)
Key used to specify the user name of the current user as macro value.



KEY_CURRENT_USER_STREET
final public static String KEY_CURRENT_USER_STREET(Code)
Key used to specify the street of the current user as macro value.



KEY_CURRENT_USER_ZIP
final public static String KEY_CURRENT_USER_ZIP(Code)
Key used to specify the zip code of the current user as macro value.



KEY_LOCALIZED_PREFIX
final public static String KEY_LOCALIZED_PREFIX(Code)
Key prefix used to specify the value of a localized key as macro value.



KEY_OPENCMS
final public static String KEY_OPENCMS(Code)
Identifier for "magic" parameter names.



KEY_PAGE_CONTEXT
final public static String KEY_PAGE_CONTEXT(Code)
The prefix indicating that the key represents a page context object.



KEY_PROJECT_ID
final public static String KEY_PROJECT_ID(Code)
Key used to specify the project id as macro value.



KEY_PROPERTY
final public static String KEY_PROPERTY(Code)
The prefix indicating that the key represents a property to be read on the current request URI.



KEY_PROPERTY_ELEMENT
final public static String KEY_PROPERTY_ELEMENT(Code)
The prefix indicating that the key represents a property to be read on the current element.



KEY_REQUEST_ENCODING
final public static String KEY_REQUEST_ENCODING(Code)
Key used to specify the request encoding as macro value.



KEY_REQUEST_FOLDER
final public static String KEY_REQUEST_FOLDER(Code)
Key used to specify the folder of the request URI as macro value.



KEY_REQUEST_LOCALE
final public static String KEY_REQUEST_LOCALE(Code)
Key user to specify the request locale as macro value.



KEY_REQUEST_PARAM
final public static String KEY_REQUEST_PARAM(Code)
The prefix indicating that the key represents a HTTP request parameter.



KEY_REQUEST_URI
final public static String KEY_REQUEST_URI(Code)
Key used to specify the request uri as macro value.



KEY_VALIDATION_PATH
final public static String KEY_VALIDATION_PATH(Code)
Key used to specify the validation path as macro value.



KEY_VALIDATION_REGEX
final public static String KEY_VALIDATION_REGEX(Code)
Key used to specify the validation regex as macro value.



KEY_VALIDATION_VALUE
final public static String KEY_VALIDATION_VALUE(Code)
Key used to specify the validation value as macro value.



VALUE_NAMES
final public static List VALUE_NAMES(Code)
The "magic" commands wrapped in a List.



VALUE_NAMES_ARRAY
final static String[] VALUE_NAMES_ARRAY(Code)
Identified for "magic" parameter commands.



m_additionalMacros
protected Map m_additionalMacros(Code)
A map of additional values provided by the calling class.



m_cms
protected CmsObject m_cms(Code)
The OpenCms user context to use for resolving macros.



m_jspPageContext
protected PageContext m_jspPageContext(Code)
The JSP's page context to use for resolving macros.



m_keepEmptyMacros
protected boolean m_keepEmptyMacros(Code)
Indicates if unresolved macros should be kept "as is" or replaced by an empty String.



m_messages
protected CmsMessages m_messages(Code)
The messages resource bundle to resolve localized keys with.



m_resourceName
protected String m_resourceName(Code)
The resource name to use for resolving macros.





Method Detail
addMacro
public void addMacro(String key, String value)(Code)
Adds a customized macro to this macro resolver.


Parameters:
  key - the macro to add
Parameters:
  value - the value to return if the macro is encountered




formatMacro
public static String formatMacro(String input)(Code)
Adds macro delimiters to the given input, for example key becomes %(key).


Parameters:
  input - the input to format as a macro the input formatted as a macro




getMacroValue
public String getMacroValue(String macro)(Code)

See Also:   org.opencms.util.I_CmsMacroResolver.getMacroValue(java.lang.String)



isKeepEmptyMacros
public boolean isKeepEmptyMacros()(Code)

See Also:   org.opencms.util.I_CmsMacroResolver.isKeepEmptyMacros



isMacro
public static boolean isMacro(String input)(Code)
Returns true if the given input String if formatted like a macro, that is it starts with I_CmsMacroResolver.MACRO_DELIMITER_OLD + I_CmsMacroResolver.MACRO_START_OLD and ends with I_CmsMacroResolver.MACRO_END_OLD .


Parameters:
  input - the input to check for a macro true if the given input String if formatted like a macro




isMacro
public static boolean isMacro(String input, String macroName)(Code)
Returns true if the given input String is a macro equal to the given macro name.


Parameters:
  input - the input to check for a macro
Parameters:
  macroName - the macro name to check for true if the given input String is a macro equal to the given macro name




localizedKeyMacro
public static String localizedKeyMacro(String keyName, Object[] params)(Code)
Returns a macro for the given localization key with the given parameters.


Parameters:
  keyName - the name of the localized key
Parameters:
  params - the optional parameter array a macro for the given localization key with the given parameters




newInstance
public static CmsMacroResolver newInstance()(Code)
Factory method to create a new CmsMacroResolver instance.

a new instance of a CmsMacroResolver




resolveMacros
public static String resolveMacros(String input, CmsObject cms, CmsMessages messages)(Code)
Resolves the macros in the given input using the provided parameters.

A macro in the form %(key) or ${key} in the content is replaced with it's assigned value returned by the I_CmsMacroResolver.getMacroValue(String) method of the given I_CmsMacroResolver instance.

If a macro is found that can not be mapped to a value by the given macro resolver, it is left untouched in the input.


Parameters:
  input - the input in which to resolve the macros
Parameters:
  cms - the OpenCms user context to use when resolving macros
Parameters:
  messages - the message resource bundle to use when resolving macros the input with the macros resolved




resolveMacros
public static String resolveMacros(String input, I_CmsMacroResolver resolver)(Code)
Resolves macros in the provided input String using the given macro resolver.

A macro in the form %(key) or ${key} in the content is replaced with it's assigned value returned by the I_CmsMacroResolver.getMacroValue(String) method of the given I_CmsMacroResolver instance.

If a macro is found that can not be mapped to a value by the given macro resolver, I_CmsMacroResolver.isKeepEmptyMacros controls if the macro is replaced by an empty String, or is left untouched in the input.


Parameters:
  input - the input in which to resolve the macros
Parameters:
  resolver - the macro resolver to use the input with all macros resolved




resolveMacros
public String resolveMacros(String input)(Code)
Resolves the macros in the given input.

Calls CmsMacroResolver.resolveMacros(String) until no more macros can be resolved in the input. This way "nested" macros in the input are resolved as well.


See Also:   org.opencms.util.I_CmsMacroResolver.resolveMacros(java.lang.String)




setAdditionalMacros
public CmsMacroResolver setAdditionalMacros(Map additionalMacros)(Code)
Provides a set of additional macros to this macro resolver.

Macros added with CmsMacroResolver.addMacro(String,String) are added to the same set
Parameters:
  additionalMacros - the additional macros to add this instance of the macro resolver




setCmsObject
public CmsMacroResolver setCmsObject(CmsObject cms)(Code)
Provides an OpenCms user context to this macro resolver, required to resolve certain macros.


Parameters:
  cms - the OpenCms user context this instance of the macro resolver




setJspPageContext
public CmsMacroResolver setJspPageContext(PageContext jspPageContext)(Code)
Provides a JSP page context to this macro resolver, required to resolve certain macros.


Parameters:
  jspPageContext - the JSP page context to use this instance of the macro resolver




setKeepEmptyMacros
public CmsMacroResolver setKeepEmptyMacros(boolean keepEmptyMacros)(Code)
Controls of macros that can't be resolved are left unchanged in the input, or are replaced with an empty String.


Parameters:
  keepEmptyMacros - the replacement flag to use this instance of the macro resolver
See Also:   CmsMacroResolver.isKeepEmptyMacros()




setMessages
public CmsMacroResolver setMessages(CmsMessages messages)(Code)
Provides a set of CmsMessages to this macro resolver, required to resolve localized macros.


Parameters:
  messages - the message resource bundle to use this instance of the macro resolver




setResourceName
public CmsMacroResolver setResourceName(String resourceName)(Code)
Provides a resource name to this macro resolver, required to resolve certain macros.


Parameters:
  resourceName - the resource name to use this instance of the macro resolver




stripMacro
public static String stripMacro(String input)(Code)
Strips the macro delimiters from the given input, for example %(key) or ${key} becomes key.

In case the input is not a macro, null is returned.


Parameters:
  input - the input to strip the macro stripped from the input, or null




Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

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