Java Doc for EnumConverter.java in  » Swing-Library » jide-common » com » jidesoft » converter » 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 » Swing Library » jide common » com.jidesoft.converter 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.jidesoft.converter.EnumConverter

EnumConverter
public class EnumConverter implements ObjectConverter(Code)
A typical way to define a constant is to use int as the value type. For example, in SwingConstants, the following values are defined.
 public static final int CENTER  = 0;
 public static final int TOP     = 1;
 public static final int LEFT    = 2;
 public static final int BOTTOM  = 3;
 public static final int RIGHT   = 4;
 
Before JDK1.5, there is no enum type, so this is one way to define enumeration. When you use it, you just need to define a int field say _locaton and the valid value for _location is one of the values above. If you want to display it in UI and allow user to specify the value of _location, problem comes. You don't want to use 0, 1, 2, 3, 4 as the value doesn't mean anything from user point of view. You want user to be able to use meanful names such as "Center", "Top", "Left", "Bottom", "Right". Obviously you need a converter here to convert from integer in an enum to string, such as converting from 0 to "Center" and vice versa. That's what EnumConverter for.

Combining with EnumCellConverter, EnumCellEditor, you can easily use combobox to choose value for _location like the example above using meanful strings.




Constructor Summary
public  EnumConverter(String name, Object[] values, String[] strings)
    
public  EnumConverter(String name, Class type, Object[] values, String[] strings)
    
public  EnumConverter(String name, Class type, Object[] objects, String[] strings, Object defaultValue)
     Creates an EnumConverter.
Parameters:
  name - the name of the converter.

Method Summary
public  ObjectfromString(String string, ConverterContext context)
     Converts the string to the object.
public  ConverterContextgetContext()
     Gets the converter context of this converter.
public  ObjectgetDefault()
     Gets the default value of the converter if it failed to find the matching object for a particular string.
public  StringgetName()
     Gets the name of the converter.
public  Object[]getObjects()
     Gets the objects array.
public  String[]getStrings()
     Gets the strings array.
public  ClassgetType()
     Gets the type of the converter.
public  booleansupportFromString(String string, ConverterContext context)
    
public  booleansupportToString(Object object, ConverterContext context)
    
public  StringtoString(Object object, ConverterContext context)
     Converts the object to string.


Constructor Detail
EnumConverter
public EnumConverter(String name, Object[] values, String[] strings)(Code)



EnumConverter
public EnumConverter(String name, Class type, Object[] values, String[] strings)(Code)



EnumConverter
public EnumConverter(String name, Class type, Object[] objects, String[] strings, Object defaultValue)(Code)
Creates an EnumConverter.
Parameters:
  name - the name of the converter. The name is used to create ConverterContext and later on the EditorContext.
Parameters:
  type - the type of the element in objects array.
Parameters:
  objects - the objects array. All elements in the objects array should have the same type.
Parameters:
  strings - the strings array. It contains the meanful names for the elements in objects array.They should one to one match with each other. The length of stringsarray should be the same as that of objects array. Otherwise IllegalArgumentExceptio will be thrown.
Parameters:
  defaultValue - the default value




Method Detail
fromString
public Object fromString(String string, ConverterContext context)(Code)
Converts the string to the object. It will find the string from the strings array and find the matching object from objects array.
Parameters:
  string - the string to be converted
Parameters:
  context - the converter context. the object of the string.



getContext
public ConverterContext getContext()(Code)
Gets the converter context of this converter. The name of the context is the name of the converter where you pass in to EnumConverter's constructor. the converter context of this converter.



getDefault
public Object getDefault()(Code)
Gets the default value of the converter if it failed to find the matching object for a particular string. the default value.



getName
public String getName()(Code)
Gets the name of the converter. the name of the converter.



getObjects
public Object[] getObjects()(Code)
Gets the objects array. the objects array.



getStrings
public String[] getStrings()(Code)
Gets the strings array. the strings array.



getType
public Class getType()(Code)
Gets the type of the converter. the type of the converter.



supportFromString
public boolean supportFromString(String string, ConverterContext context)(Code)



supportToString
public boolean supportToString(Object object, ConverterContext context)(Code)



toString
public String toString(Object object, ConverterContext context)(Code)
Converts the object to string. It will find the object from the objects array and find the matching string from strings array.
Parameters:
  object - the object to be converted.
Parameters:
  context - the converter context. the string for the object.



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.