Java Doc for Constants.java in  » J2EE » spring-framework-2.0.6 » org » springframework » core » 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 » J2EE » spring framework 2.0.6 » org.springframework.core 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.springframework.core.Constants

Constants
public class Constants (Code)
This class can be used to parse other classes containing constant definitions in public static final members. The asXXXX methods of this class allow these constant values to be accessed via their string names.

Consider class Foo containing public final static int CONSTANT1 = 66; An instance of this class wrapping Foo.class will return the constant value of 66 from its asNumber method given the argument "CONSTANT1".

This class is ideal for use in PropertyEditors, enabling them to recognize the same names as the constants themselves, and freeing them from maintaining their own mapping.
author:
   Rod Johnson
author:
   Juergen Hoeller
since:
   16.03.2003




Constructor Summary
public  Constants(Class clazz)
     Create a new Constants converter class wrapping the given class.

Method Summary
public  NumberasNumber(String code)
     Return a constant value cast to a Number.
public  ObjectasObject(String code)
     Parse the given String (upper or lower case accepted) and return the appropriate value if it's the name of a constant field in the class that we're analysing.
public  StringasString(String code)
     Return a constant value as a String.
final public  StringgetClassName()
     Return the name of the analyzed class.
final protected  MapgetFieldCache()
     Exposes the field cache to subclasses: a Map from String field name to object value.
public  SetgetNames(String namePrefix)
     Return all names of the given group of constants.

Note that this method assumes that constants are named in accordance with the standard Java convention for constant values (i.e.

public  SetgetNamesForProperty(String propertyName)
     Return all names of the group of constants for the given bean property name.
public  SetgetNamesForSuffix(String nameSuffix)
     Return all names of the given group of constants.

Note that this method assumes that constants are named in accordance with the standard Java convention for constant values (i.e.

final public  intgetSize()
     Return the number of constants exposed.
public  SetgetValues(String namePrefix)
     Return all values of the given group of constants.

Note that this method assumes that constants are named in accordance with the standard Java convention for constant values (i.e.

public  SetgetValuesForProperty(String propertyName)
     Return all values of the group of constants for the given bean property name.
public  SetgetValuesForSuffix(String nameSuffix)
     Return all values of the given group of constants.

Note that this method assumes that constants are named in accordance with the standard Java convention for constant values (i.e.

public  StringpropertyToConstantNamePrefix(String propertyName)
     Convert the given bean property name to a constant name prefix.
public  StringtoCode(Object value, String namePrefix)
     Look up the given value within the given group of constants.
public  StringtoCodeForProperty(Object value, String propertyName)
     Look up the given value within the group of constants for the given bean property name.
public  StringtoCodeForSuffix(Object value, String nameSuffix)
     Look up the given value within the given group of constants.


Constructor Detail
Constants
public Constants(Class clazz)(Code)
Create a new Constants converter class wrapping the given class.

All public static final variables will be exposed, whatever their type.
Parameters:
  clazz - the class to analyze
throws:
  IllegalArgumentException - if the supplied clazz is null





Method Detail
asNumber
public Number asNumber(String code) throws ConstantException(Code)
Return a constant value cast to a Number.
Parameters:
  code - the name of the field (never null) the Number value
See Also:   Constants.asObject
throws:
  ConstantException - if the field name wasn't foundor if the type wasn't compatible with Number



asObject
public Object asObject(String code) throws ConstantException(Code)
Parse the given String (upper or lower case accepted) and return the appropriate value if it's the name of a constant field in the class that we're analysing.
Parameters:
  code - the name of the field (never null) the Object value
throws:
  ConstantException - if there's no such field



asString
public String asString(String code) throws ConstantException(Code)
Return a constant value as a String.
Parameters:
  code - the name of the field (never null) the String valueWorks even if it's not a string (invokes toString()).
See Also:   Constants.asObject
throws:
  ConstantException - if the field name wasn't found



getClassName
final public String getClassName()(Code)
Return the name of the analyzed class.



getFieldCache
final protected Map getFieldCache()(Code)
Exposes the field cache to subclasses: a Map from String field name to object value.



getNames
public Set getNames(String namePrefix)(Code)
Return all names of the given group of constants.

Note that this method assumes that constants are named in accordance with the standard Java convention for constant values (i.e. all uppercase). The supplied namePrefix will be uppercased (in a locale-insensitive fashion) prior to the main logic of this method kicking in.
Parameters:
  namePrefix - prefix of the constant names to search (may be null) the set of constant names




getNamesForProperty
public Set getNamesForProperty(String propertyName)(Code)
Return all names of the group of constants for the given bean property name.
Parameters:
  propertyName - the name of the bean property the set of values
See Also:   Constants.propertyToConstantNamePrefix



getNamesForSuffix
public Set getNamesForSuffix(String nameSuffix)(Code)
Return all names of the given group of constants.

Note that this method assumes that constants are named in accordance with the standard Java convention for constant values (i.e. all uppercase). The supplied nameSuffix will be uppercased (in a locale-insensitive fashion) prior to the main logic of this method kicking in.
Parameters:
  nameSuffix - suffix of the constant names to search (may be null) the set of constant names




getSize
final public int getSize()(Code)
Return the number of constants exposed.



getValues
public Set getValues(String namePrefix)(Code)
Return all values of the given group of constants.

Note that this method assumes that constants are named in accordance with the standard Java convention for constant values (i.e. all uppercase). The supplied namePrefix will be uppercased (in a locale-insensitive fashion) prior to the main logic of this method kicking in.
Parameters:
  namePrefix - prefix of the constant names to search (may be null) the set of values




getValuesForProperty
public Set getValuesForProperty(String propertyName)(Code)
Return all values of the group of constants for the given bean property name.
Parameters:
  propertyName - the name of the bean property the set of values
See Also:   Constants.propertyToConstantNamePrefix



getValuesForSuffix
public Set getValuesForSuffix(String nameSuffix)(Code)
Return all values of the given group of constants.

Note that this method assumes that constants are named in accordance with the standard Java convention for constant values (i.e. all uppercase). The supplied nameSuffix will be uppercased (in a locale-insensitive fashion) prior to the main logic of this method kicking in.
Parameters:
  nameSuffix - suffix of the constant names to search (may be null) the set of values




propertyToConstantNamePrefix
public String propertyToConstantNamePrefix(String propertyName)(Code)
Convert the given bean property name to a constant name prefix.

Uses a common naming idiom: turning all lower case characters to upper case, and prepending upper case characters with an underscore.

Example: "imageSize" -> "IMAGE_SIZE"
Example: "imagesize" -> "IMAGESIZE".
Example: "ImageSize" -> "_IMAGE_SIZE".
Example: "IMAGESIZE" -> "_I_M_A_G_E_S_I_Z_E"
Parameters:
  propertyName - the name of the bean property the corresponding constant name prefix
See Also:   Constants.getValuesForProperty
See Also:   Constants.toCodeForProperty




toCode
public String toCode(Object value, String namePrefix) throws ConstantException(Code)
Look up the given value within the given group of constants.

Will return the first match.
Parameters:
  value - constant value to look up
Parameters:
  namePrefix - prefix of the constant names to search (may be null) the name of the constant field
throws:
  ConstantException - if the value wasn't found




toCodeForProperty
public String toCodeForProperty(Object value, String propertyName) throws ConstantException(Code)
Look up the given value within the group of constants for the given bean property name. Will return the first match.
Parameters:
  value - constant value to look up
Parameters:
  propertyName - the name of the bean property the name of the constant field
throws:
  ConstantException - if the value wasn't found
See Also:   Constants.propertyToConstantNamePrefix



toCodeForSuffix
public String toCodeForSuffix(Object value, String nameSuffix) throws ConstantException(Code)
Look up the given value within the given group of constants.

Will return the first match.
Parameters:
  value - constant value to look up
Parameters:
  nameSuffix - suffix of the constant names to search (may be null) the name of the constant field
throws:
  ConstantException - if the value wasn't found




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.