KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > invocation > PayloadKey


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.invocation;
23
24 import java.io.Serializable JavaDoc;
25 import java.io.ObjectStreamException JavaDoc;
26
27 /** Type safe enumeration used for to identify the payloads.
28  *
29  * @author Scott.Stark@jboss.org
30  * @version $Revision: 37459 $
31  */

32 public final class PayloadKey implements Serializable JavaDoc
33 {
34    /** Serial Version Identifier. @since 1.1.4.1 */
35    private static final long serialVersionUID = 5436722659170811314L;
36
37    /** The max ordinal value in use for the PayloadKey enums. When you add a
38     * new key enum value you must assign it an ordinal value of the current
39     * MAX_KEY_ID+1 and update the MAX_KEY_ID value.
40     */

41    private static final int MAX_KEY_ID = 3;
42
43    /** The array of InvocationKey indexed by ordinal value of the key */
44    private static final PayloadKey[] values = new PayloadKey[MAX_KEY_ID+1];
45
46    /** Put me in the transient map, not part of payload. */
47    public final static PayloadKey TRANSIENT = new PayloadKey("TRANSIENT", 0);
48    
49    /** Do not serialize me, part of payload as is. */
50    public final static PayloadKey AS_IS = new PayloadKey("AS_IS", 1);
51
52    /** Put me in the payload map. */
53    public final static PayloadKey PAYLOAD = new PayloadKey("PAYLOAD", 2);
54
55    private final transient String JavaDoc name;
56
57    // this is the only value serialized
58
private final int ordinal;
59  
60    private PayloadKey(String JavaDoc name, int ordinal)
61    {
62       this.name = name;
63       this.ordinal = ordinal;
64       values[ordinal] = this;
65    }
66
67    public String JavaDoc toString()
68    {
69       return name;
70    }
71
72    Object JavaDoc readResolve() throws ObjectStreamException JavaDoc
73    {
74       return values[ordinal];
75    }
76 }
77
Popular Tags