package org.jvirtanen.nassau.soupbintcp;

import static org.jvirtanen.nassau.soupbintcp.DataTypes.*;

import java.io.IOException;
import java.nio.ByteBuffer;

/**
 * Common definitions.
 */
public class SoupBinTCP {

    public static final byte LOGIN_REJECT_CODE_NOT_AUTHORIZED        = 'A';
    public static final byte LOGIN_REJECT_CODE_SESSION_NOT_AVAILABLE = 'S';

    private SoupBinTCP() {
    }

    /**
     * Payload for the Login Accepted packet.
     */
    public static class LoginAccepted {
        public String session;
        public long   sequenceNumber;

        public void get(ByteBuffer buffer) throws IOException {
            session        = getAlphanumeric(buffer, 10);
            sequenceNumber = getNumeric(buffer, 20);
        }

        public void put(ByteBuffer buffer) {
            putAlphanumericPadLeft(buffer, session, 10);
            putNumeric(buffer, sequenceNumber, 20);
        }
    }

    /**
     * Payload for the Login Rejected packet.
     */
    public static class LoginRejected {
        public byte rejectReasonCode;

        public void get(ByteBuffer buffer) {
            rejectReasonCode = buffer.get();
        }

        public void put(ByteBuffer buffer) {
            buffer.put(rejectReasonCode);
        }
    }

    /**
     * Payload for the Login Request packet.
     */
    public static class LoginRequest {
        public String username;
        public String password;
        public String requestedSession;
        public long   requestedSequenceNumber;

        public void get(ByteBuffer buffer) throws IOException {
            username                = getAlphanumeric(buffer,  6);
            password                = getAlphanumeric(buffer, 10);
            requestedSession        = getAlphanumeric(buffer, 10);
            requestedSequenceNumber = getNumeric(buffer, 20);
        }

        public void put(ByteBuffer buffer) {
            putAlphanumericPadRight(buffer, username, 6);
            putAlphanumericPadRight(buffer, password, 10);
            putAlphanumericPadLeft(buffer, requestedSession, 10);
            putNumeric(buffer, requestedSequenceNumber, 20);
        }
    }

}

@@ -569,39 +569,32 @@
 umber;%0A%0A        
-public 
 void get(ByteBuf
@@ -618,32 +618,32 @@
 s IOException %7B%0A
+
             sess
@@ -748,39 +748,32 @@
      %7D%0A%0A        
-public 
 void put(ByteBuf
@@ -1053,39 +1053,32 @@
 nCode;%0A%0A        
-public 
 void get(ByteBuf
@@ -1147,39 +1147,32 @@
      %7D%0A%0A        
-public 
 void put(ByteBuf
@@ -1500,31 +1500,24 @@
 r;%0A%0A        
-public 
 void get(Byt
@@ -1827,24 +1827,24 @@
      %7D%0A%0A
+
         
 public v
@@ -1835,23 +1835,16 @@
         
-public 
 void put

Make methods private