Source Code Cross Referenced for EnumeratedParameter.java in  » 6.0-JDK-Modules » Java-Advanced-Imaging » javax » media » jai » 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 » 6.0 JDK Modules » Java Advanced Imaging » javax.media.jai 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $RCSfile: EnumeratedParameter.java,v $
003:         *
004:         * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * Use is subject to license terms.
007:         *
008:         * $Revision: 1.1 $
009:         * $Date: 2005/02/11 04:57:08 $
010:         * $State: Exp $
011:         */
012:        package javax.media.jai;
013:
014:        import java.io.Serializable;
015:
016:        /**
017:         * This class provides a mechanism by which enumerated parameters may be
018:         * added to subclasses of <code>OperationDescriptorImpl</code> while
019:         * retaining the ability to perform introspection on the allowable range of
020:         * values of the enumeration.  An example of an enumerated parameter is the
021:         * <i>type</i> parameter of the "Transpose" operation which is defined in
022:         * <code>TransposeDescriptor</code> to accept only the values defined by the
023:         * <code>FLIP_*</code> and <code>ROTATE_*</code> fields of the descriptor.
024:         *
025:         * <p> This class may be used to create enumerated parameters in an
026:         * <code>OperationDescriptor</code> as follows:
027:         *
028:         * <ul>
029:         *
030:         * <li> For each constrained-value parameter create a final class extending
031:         * <code>EnumeratedParameter</code>.  This class should consist of only a
032:         * package private constructor with a single <code>String</code> parameter
033:         * called <i>name</i> and a single statement invoking the superclass
034:         * constructor with <i>name</i> as the parameter.</li>
035:         *
036:         * <li> Define the class of the parameter in question to be the
037:         * subclass of <code>EnumeratedParameter</code> which was created for it in
038:         * in the previous step.</li>
039:         *
040:         * <li> For each possible value of the parameter, define in the
041:         * <code>OperationDescriptor</code> of the operator a public static final
042:         * field of type equal to the class defined in the first step.  Each field
043:         * should be assigned an instance of the subclass defined in the first step.
044:         * The <i>name</i> and <code>value</code> used for each of these
045:         * <code>EnumeratedParameter</code> subclass instances should be distinct
046:         * for each distinct field or an error will occur.</li>
047:         *
048:         * </ul>
049:         *
050:         * With respect to <code>TransposeDescriptor</code>, the three steps above
051:         * would be to 1) create a final class <code>TransposeType</code> in the
052:         * <code>javax.media.jai.operator</code> package; 2) define the
053:         * type of the "type" parameter as <code>TransposeType.class</code>; and
054:         * 3) define a static final field of class <code>TransposeType</code> for
055:         * each of the enumerated values with each field being initialized to an
056:         * instance of <code>TransposeType</code> with <i>name</i> equal to the name
057:         * of the field and <i>value</i> to its integral (enumerated) value.
058:         *
059:         * @see OperationDescriptorImpl
060:         * @see javax.media.jai.operator.TransposeDescriptor
061:         *
062:         * @since JAI 1.1
063:         */
064:        public class EnumeratedParameter implements  Serializable {
065:            private String name;
066:            private int value;
067:
068:            /**
069:             * Constructs an <code>EnumeratedParameter</code> with the indicated name
070:             * and value.
071:             */
072:            public EnumeratedParameter(String name, int value) {
073:                this .name = name;
074:                this .value = value;
075:            }
076:
077:            /**
078:             * Returns the name assigned to this <code>EnumeratedParameter</code>
079:             * when it was constructed.
080:             */
081:            public String getName() {
082:                return name;
083:            }
084:
085:            /**
086:             * Returns the value assigned to this <code>EnumeratedParameter</code>
087:             * when it was constructed.
088:             */
089:            public int getValue() {
090:                return value;
091:            }
092:
093:            /**
094:             * Returns a hash code value for the object.
095:             */
096:            public int hashCode() {
097:                return (getClass().getName() + (new Integer(value))).hashCode();
098:            }
099:
100:            /**
101:             * Returns <code>true</code> if and only if the parameter is an instance
102:             * of the class on which this method is invoked and has either the same
103:             * name or the same value.
104:             */
105:            public boolean equals(Object o) {
106:                return o != null
107:                        && this .getClass().equals(o.getClass())
108:                        && (name.equals(((EnumeratedParameter) o).getName()) || value == ((EnumeratedParameter) o)
109:                                .getValue());
110:            }
111:
112:            /**
113:             * Returns a <code>String</code> representation of this
114:             * <code>EnumeratedParameter</code> as a concatentation of the form
115:             * <pre>
116:             * [class name]:[parameter name]=[parameter value]
117:             * </pre>
118:             * For example, for an instance of a subclass
119:             * <code>org.foobar.jai.EnumParam</code> with name "SomeValue" and
120:             * value "2" the returned <code>String</code> would be
121:             * <pre>
122:             * org.foobar.jai.EnumParam:SomeValue=2
123:             * </pre>
124:             */
125:            public String toString() {
126:                return getClass().getName() + ":" + name + "="
127:                        + String.valueOf(value);
128:            }
129:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.