Java Doc for PropertiesManager.java in  » Portal » uPortal_rel-2-6-1-GA » org » jasig » portal » properties » 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 » Portal » uPortal_rel 2 6 1 GA » org.jasig.portal.properties 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.jasig.portal.properties.PropertiesManager

PropertiesManager
public class PropertiesManager (Code)
Provides access to properties.

It is important to understand that usage of this class is different from what you might be used to in java.util.Properties. Specifically, when you get a Properties property, if that property is not set, the return value is NULL. However, when you call the basic getters here, if the property is not set, a RuntimeException is thrown. These methods will never return null (except if you pass in null as the default return value for the methods that take a default).

There are methods to get properties as various primitive types, int, double, float, etc. When you invoke one of these methods on a property that is found but cannot be parsed as your desired type, a RuntimeException is thrown.

There are corresponding methods which take as a second parameter a default value. These methods, instead of throwing a RuntimeException when the property cannot be found, return the default value. You can use the default value "null" to invoke getProperty() with semantics more like the java.util.Properties object. These augmented accessors which take defaults will be, I hope, especially useful in static initializers. Providing a default in your static initializer will keep your class from blowing up at initialization when your property cannot be found. This seems especially advantageous when there is a plausible default value.

This class has a comprehensive JUnit testcase. Please keep the testcase up to date with any changes you make to this class.


author:
   Ken Weiner, kweiner@unicon.net
author:
   howard.gilbert@yale.edu
author:
   andrew.petro@yale.edu
version:
   $Revision: 35627 $ $Date: 2005-04-18 18:19:28 -0700 (Mon, 18 Apr 2005) $
since:
   uPortal 2.4, this class existed in the main package since uPortal 2.0


Field Summary
final public static  StringPORTAL_PROPERTIES_FILE_SYSTEM_VARIABLE
    
final protected static  Loglog
    


Method Summary
public static  SetgetMissingProperties()
     Get a Set of the names of properties that have been requested but were not set.
public static  StringgetProperty(String name)
     Returns the value of a property for a given name.
public static  StringgetProperty(String name, String defaultValue)
     Get the value of the property with the given name. If the named property is not found, returns the supplied default value. This error handling behavior makes this method attractive for use in static initializers.
Parameters:
  name - - the name of the property to be retrieved.
Parameters:
  defaultValue - - a fallback default value which will be returned if the property cannot be found.
public static  booleangetPropertyAsBoolean(String name)
     Returns the value of a property for a given name.
public static  booleangetPropertyAsBoolean(String name, boolean defaultValue)
     Get a property as a boolean, specifying a default value.
public static  bytegetPropertyAsByte(String name)
    
public static  bytegetPropertyAsByte(String name, byte defaultValue)
     Get the value of the given property as a byte, specifying a fallback default value.
public static  doublegetPropertyAsDouble(String name)
    
public static  doublegetPropertyAsDouble(String name, double defaultValue)
     Get the value of the given property as a double.
public static  floatgetPropertyAsFloat(String name)
    
public static  floatgetPropertyAsFloat(String name, float defaultValue)
     Get the value of the given property as a float.
public static  intgetPropertyAsInt(String name)
    
public static  intgetPropertyAsInt(String name, int defaultValue)
     Get the value of a given property as an int.
public static  longgetPropertyAsLong(String name)
    
public static  longgetPropertyAsLong(String name, long defaultValue)
     Get the value of the given property as a long.
public static  shortgetPropertyAsShort(String name)
    
public static  shortgetPropertyAsShort(String name, short defaultValue)
     Returns the value of a property for a given name as a short.
public static  StringgetPropertyUntrimmed(String name)
     Returns the value of a property for a given name including whitespace trailing the property value, but not including whitespace leading the property value.
public static  StringgetPropertyUntrimmed(String name, String defaultValue)
     Get the value of a property for the given name including any whitespace that may be at the beginning or end of the property value.
protected static  voidloadProps()
     Load up the portal properties.
public static synchronized  voidsetProperties(Properties props)
     Setter method to set the underlying Properties. This is a public method to allow poor-man's static dependency injection of the Properties from wherever you want to get them. If Properties have not been injected before any accessor method is invoked, PropertiesManager will invoke loadProperties() to attempt to load its own properties.

Field Detail
PORTAL_PROPERTIES_FILE_SYSTEM_VARIABLE
final public static String PORTAL_PROPERTIES_FILE_SYSTEM_VARIABLE(Code)



log
final protected static Log log(Code)





Method Detail
getMissingProperties
public static Set getMissingProperties()(Code)
Get a Set of the names of properties that have been requested but were not set. a Set of the String names of missing properties.
since:
   uPortal 2.4



getProperty
public static String getProperty(String name) throws MissingPropertyException(Code)
Returns the value of a property for a given name. Any whitespace is trimmed off the beginning and end of the property value. Note that this method will never return null. If the requested property cannot be found, this method throws an UndeclaredPortalException.
Parameters:
  name - the name of the requested property value the value of the property matching the requested name
throws:
  MissingPropertyException - - if the requested property cannot be found



getProperty
public static String getProperty(String name, String defaultValue)(Code)
Get the value of the property with the given name. If the named property is not found, returns the supplied default value. This error handling behavior makes this method attractive for use in static initializers.
Parameters:
  name - - the name of the property to be retrieved.
Parameters:
  defaultValue - - a fallback default value which will be returned if the property cannot be found. the value of the requested property, or the supplied default value if the named property cannot be found.
since:
   uPortal 2.4



getPropertyAsBoolean
public static boolean getPropertyAsBoolean(String name) throws MissingPropertyException(Code)
Returns the value of a property for a given name. This method can be used if the property is boolean in nature and you want to make sure that true is returned if the property is set to "true", "yes", "y", or "on" (regardless of case), and false is returned in all other cases.
Parameters:
  name - the name of the requested property value true if property is set to "true", "yes", "y", or "on" regardless of case, otherwise false
throws:
  MissingPropertyException - - when no property of the given name is declared.



getPropertyAsBoolean
public static boolean getPropertyAsBoolean(String name, boolean defaultValue)(Code)
Get a property as a boolean, specifying a default value. If for any reason we are unable to lookup the desired property, this method returns the supplied default value. This error handling behavior makes this method suitable for calling from static initializers.
Parameters:
  name - - the name of the property to be accessed
Parameters:
  defaultValue - - default value that will be returned in the event of any error the looked up property value, or the defaultValue if any problem.
since:
   uPortal 2.4



getPropertyAsByte
public static byte getPropertyAsByte(String name) throws MissingPropertyException, BadPropertyException(Code)
Returns the value of a property for a given name as a byte
Parameters:
  name - the name of the requested property value the property's value as a byte
throws:
  MissingPropertyException - - if the property is not set
throws:
  BadPropertyException - - if the property cannot be parsed as a byte



getPropertyAsByte
public static byte getPropertyAsByte(String name, byte defaultValue)(Code)
Get the value of the given property as a byte, specifying a fallback default value. If for any reason we are unable to lookup the desired property, this method returns the supplied default value. This error handling behavior makes this method suitable for calling from static initializers.
Parameters:
  name - - the name of the property to be accessed
Parameters:
  defaultValue - - the default value that will be returned in the event of any error the looked up property value, or the defaultValue if any problem.
since:
   uPortal 2.4



getPropertyAsDouble
public static double getPropertyAsDouble(String name) throws MissingPropertyException, BadPropertyException(Code)
Returns the value of a property for a given name as a long
Parameters:
  name - the name of the requested property value the property's value as a double
throws:
  MissingPropertyException - - if the property has not been set
throws:
  BadPropertyException - - if the property cannot be parsed as a double or is not set.



getPropertyAsDouble
public static double getPropertyAsDouble(String name, double defaultValue)(Code)
Get the value of the given property as a double. If for any reason the property cannot be looked up as a double, returns the specified default value. This error handling makes this method a good choice for static initializer calls.
Parameters:
  name - - the name of the requested property
Parameters:
  defaultValue - - a fallback default value that will be returned if there is any problem the value of the property as a double, or the supplied default value if there is any problem.
since:
   uPortal 2.4



getPropertyAsFloat
public static float getPropertyAsFloat(String name) throws MissingPropertyException, BadPropertyException(Code)
Returns the value of a property for a given name as a float
Parameters:
  name - the name of the requested property value the property's value as a float
throws:
  MissingPropertyException - - if the property is not set
throws:
  BadPropertyException - - if the property cannot be parsed as a float



getPropertyAsFloat
public static float getPropertyAsFloat(String name, float defaultValue)(Code)
Get the value of the given property as a float. If for any reason the property cannot be looked up as a float, returns the supplied default value. This error handling makes this method a good choice for static initializer calls.
Parameters:
  name - - the name of the requested property
Parameters:
  defaultValue - - a fallback default value that will be returned if there is any problem the value of the property as a float, or the supplied default value if there is any problem.
since:
   uPortal 2.4



getPropertyAsInt
public static int getPropertyAsInt(String name) throws MissingPropertyException, BadPropertyException(Code)
Returns the value of a property for a given name as an int
Parameters:
  name - the name of the requested property value the property's value as an int
throws:
  MissingPropertyException - - if the property is not set
throws:
  BadPropertyException - - if the property cannot be parsed as an int



getPropertyAsInt
public static int getPropertyAsInt(String name, int defaultValue)(Code)
Get the value of a given property as an int. If for any reason the property cannot be looked up as an int, returns the supplied default value. This error handling makes this method a good choice for static initializer calls.
Parameters:
  name - - the name of the requested property
Parameters:
  defaultValue - - a fallback default value for the property the value of the property as an int, or the supplied default value in the event of any problem.
since:
   uPortal 2.4



getPropertyAsLong
public static long getPropertyAsLong(String name) throws MissingPropertyException, BadPropertyException(Code)
Returns the value of a property for a given name as a long
Parameters:
  name - the name of the requested property value the property's value as a long
throws:
  MissingPropertyException - - if the property is not set
throws:
  BadPropertyException - - if the property cannot be parsed as a long



getPropertyAsLong
public static long getPropertyAsLong(String name, long defaultValue)(Code)
Get the value of the given property as a long. If for any reason the property cannot be looked up as a long, returns the supplied default value. This error handling makes this method a good choice for static initializer calls.
Parameters:
  name - - the name of the requested property
Parameters:
  defaultValue - - a fallback default value that will be returned if there is any problem the value of the property as a long, or the supplied default value if there is any problem.
since:
   uPortal 2.4



getPropertyAsShort
public static short getPropertyAsShort(String name) throws MissingPropertyException, BadPropertyException(Code)
Returns the value of a property for a given name as a short
Parameters:
  name - the name of the requested property value the property's value as a short
throws:
  MissingPropertyException - - if the property is not set
throws:
  BadPropertyException - - if the property cannot be parsed as a short or is not set.



getPropertyAsShort
public static short getPropertyAsShort(String name, short defaultValue)(Code)
Returns the value of a property for a given name as a short. If for any reason the property cannot be looked up as a short, returns the supplied default value. This error handling makes this method a good choice for static initializer calls.
Parameters:
  name - - the name of the requested property
Parameters:
  defaultValue - - a default value that will be returned in the event of any error the property value as a short or the default value in the event of any error
since:
   uPortal 2.4



getPropertyUntrimmed
public static String getPropertyUntrimmed(String name) throws MissingPropertyException(Code)
Returns the value of a property for a given name including whitespace trailing the property value, but not including whitespace leading the property value. An UndeclaredPortalException is thrown if the property cannot be found. This method will never return null.
Parameters:
  name - the name of the requested property value the value of the property matching the requested name
throws:
  MissingPropertyException - - (undeclared) if the requested property is not found



getPropertyUntrimmed
public static String getPropertyUntrimmed(String name, String defaultValue)(Code)
Get the value of a property for the given name including any whitespace that may be at the beginning or end of the property value. This method returns the supplied default value if the requested property cannot be found. This error handling behavior makes this method attractive for use in static initializers.
Parameters:
  name - - the name of the requested property
Parameters:
  defaultValue - - a default value to fall back on if the property cannot be found the value of the property with the given name, or the supplied default value if the property could not be found.
since:
   uPortal 2.4



loadProps
protected static void loadProps()(Code)
Load up the portal properties. Right now the portal properties is a simple .properties file with name value pairs. It may evolve to become an XML file later on.



setProperties
public static synchronized void setProperties(Properties props)(Code)
Setter method to set the underlying Properties. This is a public method to allow poor-man's static dependency injection of the Properties from wherever you want to get them. If Properties have not been injected before any accessor method is invoked, PropertiesManager will invoke loadProperties() to attempt to load its own properties. You might call this from a context listener, say. If Properties have already been loaded or injected, this method will overwrite them.
Parameters:
  props - - Properties to be injected.



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.