Java Doc for EnumSyntax.java in  » 6.0-JDK-Core » print » javax » print » attribute » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
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
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » print » javax.print.attribute 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   javax.print.attribute.EnumSyntax

All known Subclasses:   javax.print.attribute.standard.ColorSupported,  javax.print.attribute.standard.JobState,  javax.print.attribute.standard.SheetCollate,  javax.print.attribute.standard.PrinterStateReason,  javax.print.attribute.standard.PrintQuality,  javax.print.attribute.standard.OrientationRequested,  javax.print.attribute.standard.Chromaticity,  javax.print.attribute.standard.Finishings,  javax.print.attribute.standard.MultipleDocumentHandling,  javax.print.attribute.standard.Compression,  javax.print.attribute.standard.PDLOverrideSupported,  javax.print.attribute.standard.PrinterState,  javax.print.attribute.standard.JobSheets,  javax.print.attribute.standard.ReferenceUriSchemesSupported,  javax.print.attribute.standard.Fidelity,  javax.print.attribute.standard.PresentationDirection,  javax.print.attribute.standard.Sides,  javax.print.attribute.standard.Severity,  javax.print.attribute.standard.PrinterIsAcceptingJobs,  javax.print.attribute.standard.JobStateReason,  javax.print.attribute.standard.Media,
EnumSyntax
abstract public class EnumSyntax implements Serializable,Cloneable(Code)
Class EnumSyntax is an abstract base class providing the common implementation of all "type safe enumeration" objects. An enumeration class (which extends class EnumSyntax) provides a group of enumeration values (objects) that are singleton instances of the enumeration class; for example:
 public class Bach extends EnumSyntax {
 public static final Bach JOHANN_SEBASTIAN     = new Bach(0);
 public static final Bach WILHELM_FRIEDEMANN   = new Bach(1);
 public static final Bach CARL_PHILIP_EMMANUEL = new Bach(2);
 public static final Bach JOHANN_CHRISTIAN     = new Bach(3);
 public static final Bach P_D_Q                = new Bach(4);
 private static final String[] stringTable = {
 "Johann Sebastian Bach",
 "Wilhelm Friedemann Bach",
 "Carl Philip Emmanuel Bach",
 "Johann Christian Bach",
 "P.D.Q. Bach"
 };
 protected String[] getStringTable() {
 return stringTable;
 }
 private static final Bach[] enumValueTable = {
 JOHANN_SEBASTIAN,
 WILHELM_FRIEDEMANN,
 CARL_PHILIP_EMMANUEL,
 JOHANN_CHRISTIAN,
 P_D_Q
 };
 protected EnumSyntax[] getEnumValueTable() {
 return enumValueTable;
 }
 }
 
You can then write code that uses the == and != operators to test enumeration values; for example:
 Bach theComposer;
 . . .
 if (theComposer == Bach.JOHANN_SEBASTIAN) {
 System.out.println ("The greatest composer of all time!");
 }
 
The equals() method for an enumeration class just does a test for identical objects (==).

You can convert an enumeration value to a string by calling EnumSyntax.toString() toString() . The string is obtained from a table supplied by the enumeration class.

Under the hood, an enumeration value is just an integer, a different integer for each enumeration value within an enumeration class. You can get an enumeration value's integer value by calling EnumSyntax.getValue() getValue() . An enumeration value's integer value is established when it is constructed (see EnumSyntax.EnumSyntax(int) EnumSyntax(int) ). Since the constructor is protected, the only possible enumeration values are the singleton objects declared in the enumeration class; additional enumeration values cannot be created at run time.

You can define a subclass of an enumeration class that extends it with additional enumeration values. The subclass's enumeration values' integer values need not be distinct from the superclass's enumeration values' integer values; the ==, !=, equals(), and toString() methods will still work properly even if the subclass uses some of the same integer values as the superclass. However, the application in which the enumeration class and subclass are used may need to have distinct integer values in the superclass and subclass.


author:
   David Mendenhall
author:
   Alan Kaminsky




Constructor Summary
protected  EnumSyntax(int value)
     Construct a new enumeration value with the given integer value.

Method Summary
public  Objectclone()
     Returns a clone of this enumeration value, which to preserve the semantics of enumeration values is the same object as this enumeration value.
protected  EnumSyntax[]getEnumValueTable()
     Returns the enumeration value table for this enumeration value's enumeration class.
protected  intgetOffset()
     Returns the lowest integer value used by this enumeration value's enumeration class.

The default implementation returns 0.

protected  String[]getStringTable()
     Returns the string table for this enumeration value's enumeration class.
public  intgetValue()
     Returns this enumeration value's integer value.
public  inthashCode()
     Returns a hash code value for this enumeration value.
protected  ObjectreadResolve()
     During object input, convert this deserialized enumeration instance to the proper enumeration value defined in the enumeration attribute class. The enumeration singleton value stored at indexi-L in the enumeration value table returned by EnumSyntax.getEnumValueTable() getEnumValueTable(), where i is this enumeration value's integer value and L is the value returned by EnumSyntax.getOffset() getOffset().
public  StringtoString()
     Returns a string value corresponding to this enumeration value.


Constructor Detail
EnumSyntax
protected EnumSyntax(int value)(Code)
Construct a new enumeration value with the given integer value.
Parameters:
  value - Integer value.




Method Detail
clone
public Object clone()(Code)
Returns a clone of this enumeration value, which to preserve the semantics of enumeration values is the same object as this enumeration value.



getEnumValueTable
protected EnumSyntax[] getEnumValueTable()(Code)
Returns the enumeration value table for this enumeration value's enumeration class. The enumeration class's integer values are assumed to lie in the range L..L+N-1, where L is the value returned by EnumSyntax.getOffset() getOffset() and N is the length of the enumeration value table. The element in the enumeration value table at index i-L is the enumeration value object whose integer value is i; the EnumSyntax.readResolve() readResolve() method needs this to preserve singleton semantics during deserialization of an enumeration instance. If an integer within the above range is not used by any enumeration value, leave the corresponding table element null.

The default implementation returns null. If the enumeration class (a subclass of class EnumSyntax) does not override this method to return a non-null enumeration value table, and the subclass does not override the EnumSyntax.readResolve() readResolve() method, the base class EnumSyntax.readResolve() readResolve() method will throw an exception whenever an enumeration instance is deserialized from an object input stream. the value table




getOffset
protected int getOffset()(Code)
Returns the lowest integer value used by this enumeration value's enumeration class.

The default implementation returns 0. If the enumeration class (a subclass of class EnumSyntax) uses integer values starting at other than 0, override this method in the subclass. the offset of the lowest enumeration value.




getStringTable
protected String[] getStringTable()(Code)
Returns the string table for this enumeration value's enumeration class. The enumeration class's integer values are assumed to lie in the range L..L+N-1, where L is the value returned by EnumSyntax.getOffset() getOffset() and N is the length of the string table. The element in the string table at index i-L is the value returned by EnumSyntax.toString() toString() for the enumeration value whose integer value is i. If an integer within the above range is not used by any enumeration value, leave the corresponding table element null.

The default implementation returns null. If the enumeration class (a subclass of class EnumSyntax) does not override this method to return a non-null string table, and the subclass does not override the EnumSyntax.toString() toString() method, the base class EnumSyntax.toString() toString() method will return just a string representation of this enumeration value's integer value. the string table




getValue
public int getValue()(Code)
Returns this enumeration value's integer value. the value



hashCode
public int hashCode()(Code)
Returns a hash code value for this enumeration value. The hash code is just this enumeration value's integer value.



readResolve
protected Object readResolve() throws ObjectStreamException(Code)
During object input, convert this deserialized enumeration instance to the proper enumeration value defined in the enumeration attribute class. The enumeration singleton value stored at indexi-L in the enumeration value table returned by EnumSyntax.getEnumValueTable() getEnumValueTable(), where i is this enumeration value's integer value and L is the value returned by EnumSyntax.getOffset() getOffset().
throws:
  ObjectStreamException - if the stream can't be deserialised
throws:
  InvalidObjectException - Thrown if the enumeration value table is null, this enumeration value's integer value does not correspond to an element in the enumeration value table, or the corresponding element in the enumeration value table is null. (Note: java.io.InvalidObjectException InvalidObjectException is a subclass of java.io.ObjectStreamException ObjectStreamException, which readResolve() is declared to throw.)



toString
public String toString()(Code)
Returns a string value corresponding to this enumeration value.



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.