Java Doc for PreferenceManager.java in  » Graphic-Library » batik » org » apache » batik » 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 » Graphic Library » batik » org.apache.batik.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.batik.util.PreferenceManager

All known Subclasses:   org.apache.batik.apps.svgbrowser.XMLPreferenceManager,
PreferenceManager
public class PreferenceManager (Code)
This class allows to manage users preferences.

Here is a short usage example:

 // at application intialization
 HashMap defaults = new HashMap();
 defaults.put("windowSize", new Dimension(640, 480));
 defaults.put("antialias", Boolean.TRUE);
 PreferenceManager prefs = new PreferenceManager("application.ini", defaults);
 try {
 prefs.load();
 } catch (IOException e) {
 //
 }
 myApplication.setSize(prefs.getDimension("windowSize"));
 myApplication.setAntialiasingOn(prefs.getBoolean("antialias"));
 // later a dialog box may customize preferences
 myApplication.setAntialiasingOn(antialiasCheckBox.getState());
 prefs.setBoolean("antialias", antialiasCheckBox.getState());
 // when leaving the application we need to save the preferences
 prefs.setDimension("windowSize", myApplication.getSize());
 prefs.setFiles("history", lastVisitedFileArray);
 try {
 prefs.save()
 } catch (IOException e) {
 //
 }
 


author:
   Christophe Jolif
version:
   $Id: PreferenceManager.java 478169 2006-11-22 14:23:24Z dvholten $



Field Summary
final protected static  StringFILE_SEP
    
final protected static  StringUSER_DIR
    
final protected static  StringUSER_HOME
    
protected  Mapdefaults
    
protected  StringfullName
    
protected  Propertiesinternal
    
protected  StringprefFileName
    

Constructor Summary
public  PreferenceManager(String prefFileName)
     Creates a preference manager.
public  PreferenceManager(String prefFileName, Map defaults)
     Creates a preference manager with a default values initialization map.

Method Summary
public  booleangetBoolean(String key)
     Gets a boolean preference.
public  ColorgetColor(String key)
     Retruns a Color preference.
public  DimensiongetDimension(String key)
     Returns a Dimension preference.
public  FilegetFile(String key)
     Returns a File preference.
public  File[]getFiles(String mkey)
     Returns an array of Files preference.
public  floatgetFloat(String key)
     Gets a float preference.
public  FontgetFont(String key)
     Returns a font preference.
public  intgetInteger(String key)
     Gets an int preference.
public  PointgetPoint(String key)
     Returns a point preference.
public static  StringgetPreferenceDirectory()
     Returns a String representing the directory where PreferenceManager instances should look for preferences.
public  RectanglegetRectangle(String key)
     Returns a Rectangle preference.
public  StringgetString(String key)
     Returns a String preference.
public  String[]getStrings(String mkey)
     Returns an array of String preference.
protected static  StringgetSystemProperty(String prop)
     Gets a System property if accessible.
public  URLgetURL(String key)
     Returns an URL preference.
public  URL[]getURLs(String mkey)
     Returns an array of URLs preference.
public  voidload()
     Loads the preference file.
public  voidsave()
     Saves the preference file.
public  voidsetBoolean(String key, boolean value)
     Sets a boolean property.
public  voidsetColor(String key, Color value)
     Sets a Color preference.
public  voidsetDimension(String key, Dimension value)
     Sets a Dimension preference.
public  voidsetFile(String key, File value)
     Sets a File property.
public  voidsetFiles(String mkey, File[] values)
     Sets an array of Files property.
public  voidsetFloat(String key, float value)
     Sets a float property.
public  voidsetFont(String key, Font value)
     Sets a Font preference.
public  voidsetInteger(String key, int value)
     Sets an int property.
public  voidsetPoint(String key, Point value)
     Sets a Point preference.
public static  voidsetPreferenceDirectory(String dir)
     Sets a String representing the directory where PreferenceManager instances should look for preferences files.
public  voidsetRectangle(String key, Rectangle value)
     Sets a Rectangle preference.
public  voidsetString(String key, String value)
     Sets a String preference.
public  voidsetStrings(String mkey, String[] values)
     Sets a String array preference.
public  voidsetURL(String key, URL value)
     Sets an URL property.
public  voidsetURLs(String mkey, URL[] values)
     Sets an array of URLs property.

Field Detail
FILE_SEP
final protected static String FILE_SEP(Code)



USER_DIR
final protected static String USER_DIR(Code)



USER_HOME
final protected static String USER_HOME(Code)



defaults
protected Map defaults(Code)



fullName
protected String fullName(Code)



internal
protected Properties internal(Code)



prefFileName
protected String prefFileName(Code)




Constructor Detail
PreferenceManager
public PreferenceManager(String prefFileName)(Code)
Creates a preference manager.
Parameters:
  prefFileName - the name of the preference file.



PreferenceManager
public PreferenceManager(String prefFileName, Map defaults)(Code)
Creates a preference manager with a default values initialization map.
Parameters:
  prefFileName - the name of the preference file.
Parameters:
  defaults - where to get defaults value if the value isnot specified in the file.




Method Detail
getBoolean
public boolean getBoolean(String key)(Code)
Gets a boolean preference. If not found and no default returns false.



getColor
public Color getColor(String key)(Code)
Retruns a Color preference.



getDimension
public Dimension getDimension(String key)(Code)
Returns a Dimension preference.



getFile
public File getFile(String key)(Code)
Returns a File preference.



getFiles
public File[] getFiles(String mkey)(Code)
Returns an array of Files preference.



getFloat
public float getFloat(String key)(Code)
Gets a float preference.



getFont
public Font getFont(String key)(Code)
Returns a font preference.



getInteger
public int getInteger(String key)(Code)
Gets an int preference.



getPoint
public Point getPoint(String key)(Code)
Returns a point preference.



getPreferenceDirectory
public static String getPreferenceDirectory()(Code)
Returns a String representing the directory where PreferenceManager instances should look for preferences.
See Also:   PreferenceManager.load
See Also:   PreferenceManager.setPreferenceDirectory



getRectangle
public Rectangle getRectangle(String key)(Code)
Returns a Rectangle preference.



getString
public String getString(String key)(Code)
Returns a String preference.



getStrings
public String[] getStrings(String mkey)(Code)
Returns an array of String preference.



getSystemProperty
protected static String getSystemProperty(String prop)(Code)
Gets a System property if accessible. Returns an empty string otherwise



getURL
public URL getURL(String key)(Code)
Returns an URL preference.



getURLs
public URL[] getURLs(String mkey)(Code)
Returns an array of URLs preference.



load
public void load() throws IOException(Code)
Loads the preference file. If the file has already been previously sucessfuly loaded or saved, it will first try to reaload it from this location. Otherwise, it will try to find the file in the following order: in the directory set by PreferenceManager.setPreferenceDirectory if it exists, in the user home directory and then in the current user directory.
exception:
  IOException - if an error occured when reading the file.
See Also:   PreferenceManager.save



save
public void save() throws IOException(Code)
Saves the preference file. If it has previously sucessfuly been loaded or save it will save it at the same location. In other cases it will save it in the directory set by PreferenceManager.setPreferenceDirectory if has been set and exists, otherwise in the user home directory.
exception:
  IOException - if an error occured when writing the file orif is impossible to write the file at all available locations.
See Also:   PreferenceManager.load



setBoolean
public void setBoolean(String key, boolean value)(Code)
Sets a boolean property.



setColor
public void setColor(String key, Color value)(Code)
Sets a Color preference. If null removes it.



setDimension
public void setDimension(String key, Dimension value)(Code)
Sets a Dimension preference. If null removes it.



setFile
public void setFile(String key, File value)(Code)
Sets a File property. If null removes it.



setFiles
public void setFiles(String mkey, File[] values)(Code)
Sets an array of Files property. If null or size null removes previous preference.



setFloat
public void setFloat(String key, float value)(Code)
Sets a float property.



setFont
public void setFont(String key, Font value)(Code)
Sets a Font preference. If null removes it.



setInteger
public void setInteger(String key, int value)(Code)
Sets an int property.



setPoint
public void setPoint(String key, Point value)(Code)
Sets a Point preference. If null removes it.



setPreferenceDirectory
public static void setPreferenceDirectory(String dir)(Code)
Sets a String representing the directory where PreferenceManager instances should look for preferences files. The default value is null which means the automatic mechanism for looking for preferences is used.
See Also:   PreferenceManager.load



setRectangle
public void setRectangle(String key, Rectangle value)(Code)
Sets a Rectangle preference. If null removes it.



setString
public void setString(String key, String value)(Code)
Sets a String preference. If null removes it.



setStrings
public void setStrings(String mkey, String[] values)(Code)
Sets a String array preference. If null or size null removes previous preference.



setURL
public void setURL(String key, URL value)(Code)
Sets an URL property. If null removes it.



setURLs
public void setURLs(String mkey, URL[] values)(Code)
Sets an array of URLs property. If null or size null removes previous preference.



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.