001: /*
002: * %W% %E%
003: *
004: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: */
026:
027: package com.sun.jump.command;
028:
029: import com.sun.jump.message.JUMPMessage;
030: import com.sun.jump.message.JUMPMessageReader;
031: import com.sun.jump.message.JUMPOutgoingMessage;
032: import com.sun.jump.command.JUMPResponse;
033:
034: /**
035: * <code>JUMPResponse</code> encapsulates the response command
036: */
037: public class JUMPResponseInteger extends JUMPResponse {
038: private int theInt = 0;
039:
040: public int getInt() {
041: return theInt;
042: }
043:
044: public static final String ID_SUCCESS = JUMPResponse.ID_SUCCESS;
045: public static final String ID_FAILURE = JUMPResponse.ID_FAILURE;
046:
047: /**
048: * Creates a new instance of <code>JUMPResponseInteger</code> by
049: * deserializing the data from the <code>JUMPMessage</code>
050: */
051: public static JUMPResponse fromMessage(JUMPMessage message) {
052: return (JUMPResponse) JUMPCommand.fromMessage(message,
053: JUMPResponseInteger.class);
054: }
055:
056: //
057: // To be filled in when de-serializing
058: //
059: protected JUMPResponseInteger() {
060: super ();
061: }
062:
063: //
064: // A private constructor when the request is to be filled in
065: // by deserialization from a message
066: //
067: private JUMPResponseInteger(String messageType) {
068: super (messageType, "", null);
069: }
070:
071: public JUMPResponseInteger(String messageType, String id) {
072: super (messageType, id, null);
073: }
074:
075: public JUMPResponseInteger(String messageType, String id, int theInt) {
076: super (messageType, id, null);
077: this .theInt = theInt;
078: }
079:
080: /**
081: * For subclasses to use to initialize any fields
082: * using <code>JUMPMessage.get*</code> methods.
083: */
084: protected void deserializeFrom(JUMPMessageReader message) {
085: // First deserialize any shared fields
086: super .deserializeFrom(message);
087: // And now lifecycle request specific fields
088: this .theInt = message.getInt();
089: }
090:
091: /**
092: * For subclasses to use to put data in a message
093: * using <code>JUMPOutgoingMessage.add*</code> methods.
094: */
095: protected void serializeInto(JUMPOutgoingMessage message) {
096: // First deserialize any shared fields
097: super .serializeInto(message);
098: // And now lifecycle request specific fields
099: message.addInt(this.theInt);
100: }
101:
102: }
|