Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.eyrie.remctl.core;
  
Represents a remctl status token. This is sent from the server to the client and represents the end of output from a command. It carries the status code of the command, which is zero for success and non-zero for some sort of failure.
  
 public class RemctlStatusToken extends RemctlMessageToken {
    
Status (exit) code of command.
 
     private final int status;

    
Construct a status token with the given status code.

Parameters:
status The exit status code of the command, which must be between 0 and 255, inclusive.
Throws:
RemctlException Thrown if the status parameter is out of range.
 
     public RemctlStatusToken(final int statusthrows RemctlException {
         super(2);
         if (status < 0 || status > 255) {
             throw new RemctlException("status " + status + " out of range");
         }
         this. = status;
     }

    
Create a Status token from command specific bytes.

Parameters:
data command specific bytes
Throws:
RemctlErrorException If bytes make an invalid token
 
     public RemctlStatusToken(final byte[] datathrows RemctlErrorException {
         super(2);
         if (data.length != 1)
             throw new RemctlErrorException(."Expected size 1, byte length "
                     + data.length);
 
         this. = data[0];
 
     }

    
Determine the length of this status message token.

Returns:
The length of the wire representation of the data payload of this status token
 
     @Override
     int length() {
         return 1;
     }

    
Write the wire representation of this status token to the provided output stream.

Parameters:
stream Output stream to which to write the encoded token
Throws:
java.io.IOException On errors writing to the output stream
 
     @Override
     void writeData(final DataOutputStream streamthrows IOException {
         stream.writeByte(this.);
     }

    

Returns:
the status
 
     public int getStatus() {
         return this.;
     }

    
Check if the status was success

Returns:
true if status was 0, or false for non-zero return codes.
 
     boolean isSuccessful() {
         return 0 == this.;
     }
 
     /*
      * (non-Javadoc)
      * 
      * @see java.lang.Object#toString()
      */
     @Override
     public String toString() {
         return "RemctlStatusToken [status=" + this. + "]";
     }
 
     @Override
         return .;
    }
New to GrepCode? Check out our FAQ X