Package Torello.Java

Class OSResponse

  • All Implemented Interfaces:
    java.io.Serializable

    public class OSResponse
    extends java.lang.Object
    implements java.io.Serializable
    Class Operating-System Response does is used as a return record class for the Java HTML classes Shell, GSUTIL & MSDOS.

    This class contains three public and final fields with all of the available information about the results of the Operating-System invocation. Whenever an Operating-System Process is invoked using Java's class java.lang.Process, the invocation of that Process will yield these data results:

    1. A response-code, which is just an integer. This is an old protocol that writers of operating-system commands used where an integer is returned to the invoking caller after an an O/S Command.
    2. A transcript of the text/character data that has been sent to Standard-Output. The complete text is available in the field standardOutput.
    3. A transcript of the text/character data that has been sent to Error-Output. The complete text is available in the field errorOutput.
    4. The original Command that was invoked, as a java.lang.String


    NOTE:
    The information returned by this class may be immediately discarded, and is solely provided for convenience. If the invocation of the command (not its results) were the only reason for calling an O/S Process, simply ignoring and discarding this response Object would have no effect on the java.lang.Process routine, itself.
    See Also:
    Serialized Form


    • Field Summary

       
      Serializable ID
      Modifier and Type Field
      protected static long serialVersionUID
       
      Original Command
      Modifier and Type Field
      String commandStr
       
      Operating-System Response Code
      Modifier and Type Field
      int response
       
      Standard-Out & Error-Out, as a java.lang.String
      Modifier and Type Field
      String errorOutput
      String standardOutput
       
      Interrupted Flag
      Modifier and Type Field
      static int INTERRUPTED
    • Constructor Summary

      Constructors 
      Modifier Constructor
      protected OSResponse​(String commandStr, int response, String standardOutput, String errorOutput)
    • Method Summary

       
      Methods: interface java.lang.Cloneable
      Modifier and Type Method
      OSResponse clone()
       
      Methods: class java.lang.Object
      Modifier and Type Method
      boolean equals​(Object other)
      int hashCode()
      String toString()
      String toStringComplete()
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • serialVersionUID

        🡇     🗕  🗗  🗖
        protected static final long serialVersionUID
        This fulfils the SerialVersion UID requirement for all classes that implement Java's interface java.io.Serializable. Using the Serializable Implementation offered by java is very easy, and can make saving program state when debugging a lot easier. It can also be used in place of more complicated systems like "hibernate" to store data as well.
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
         protected static final long serialVersionUID = 1;
        
      • INTERRUPTED

        🡅  🡇     🗕  🗗  🗖
        public static final int INTERRUPTED
        This integer-value is used as a response code indicating that the process that was called was interrupted, not completed. This should not be a common occurrence.
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
         public static final int INTERRUPTED = Integer.MIN_VALUE;
        
      • response

        🡅  🡇     🗕  🗗  🗖
        public final int response
        This public, final, int field will hold the "response code" reported by the operating-system. The response-code is a number returned by the invocation of the command to the OS. A value of -1 usually signifies that the process terminated with errors. If this field contains a value of Shell.INTERRUPTED, it will mean that the process was interrupted.
      • standardOutput

        🡅  🡇     🗕  🗗  🗖
        public final java.lang.String standardOutput
        This public, final, String field will contain a transcript of the text-character data that the Operating-System process sent to Standard-Output.
      • errorOutput

        🡅  🡇     🗕  🗗  🗖
        public final java.lang.String errorOutput
        This public, final, String field will contain a transcript of the text-character data that the Operating-System process sent to Standard-Error.
    • Constructor Detail

      • OSResponse

        🡅  🡇     🗕  🗗  🗖
        protected OSResponse​(java.lang.String commandStr,
                             int response,
                             java.lang.String standardOutput,
                             java.lang.String errorOutput)
        Builds an instance of this short return class
        Parameters:
        commandStr - The command which was issued that has produced this response, as a Java String
        response - The integer returned by the O/S command invocation.
        standardOutput - The text/character data (as a String) sent to Standard-Output.
        errorOutput - The text/character data (as a String) sent to Standard-Error.
        Code:
        Exact Constructor Body:
         this.commandStr     = commandStr;
         this.response       = response;
         this.standardOutput = standardOutput;
         this.errorOutput    = errorOutput;
        
    • Method Detail

      • toString

        🡅  🡇     🗕  🗗  🗖
        public java.lang.String toString()
        Convert the information in this class into a java.lang.String
        Overrides:
        toString in class java.lang.Object
        Returns:
        A Java String representation of this class, containing abbreviated output-data
        Code:
        Exact Method Body:
         String s1 = (this.standardOutput == null)
             ? "null"
             : ((this.standardOutput.length() == 0)
                 ? "[Zero-Length-String]"
                 : StrPrint.abbrevEndRDSF(this.standardOutput, 80, true));
        
         String s2 = (this.errorOutput == null)
             ? "null"
             : ((this.errorOutput.length() == 0)
                 ? "[Zero-Length-String]"
                 : StrPrint.abbrevEndRDSF(this.errorOutput, 80, true));
        
         return
             "Command:         " + StrPrint.abbrevEndRDSF(commandStr, 80, true) + '\n' +
             "Response:        " + response + '\n' +
             "Standart-Output: " + s1 + '\n' +
             "Error-Output:    " + s2;
        
      • toStringComplete

        🡅  🡇     🗕  🗗  🗖
        public java.lang.String toStringComplete()
        Convert the information in this class into a java.lang.String
        Returns:
        A Java String representation of this class, containing complete output-data
        Code:
        Exact Method Body:
         String s1 = (this.standardOutput == null)
             ? "null"
             : ((this.standardOutput.length() == 0)
                 ? "[Zero-Length-String]"
                 : StrIndent.indentAfter2ndLine(this.standardOutput, 4, true, true));
        
         String s2 = (this.errorOutput == null)
             ? "null"
             : ((this.errorOutput.length() == 0)
                 ? "[Zero-Length-String]"
                 : StrIndent.indentAfter2ndLine(this.errorOutput, 4, true, true));
        
         return
             "Command:         " + commandStr + '\n' +
             "Response:        " + response + '\n' +
             "Standart-Output: " + s1 + '\n' +
             "Error-Output:    " + s2;
        
      • clone

        🡅  🡇     🗕  🗗  🗖
        public OSResponse clone()
        Creates and returns a copy of this object.
        Overrides:
        clone in class java.lang.Object
        Returns:
        a clone of this instance.
        Code:
        Exact Method Body:
         return new OSResponse
             (this.commandStr, this.response, this.standardOutput, this.errorOutput);
        
      • hashCode

        🡅  🡇     🗕  🗗  🗖
        public int hashCode()
        Returns a hash code for this instance. The hashcode produced simply invokes the hashCode() method on the command (as a String) that was issued to produce this instance
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        a hash code value for this object.
        Code:
        Exact Method Body:
         return commandStr.hashCode();
        
      • equals

        🡅     🗕  🗗  🗖
        public boolean equals​(java.lang.Object other)
        Checks whether 'this' is equal to another possible instance of OSResponse, or a subclass of it.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        other - This may be any Java Object, but only an instance or subclass of this class could possibly have fields that would make an identical match to 'this' instance.
        Returns:
        TRUE if and only if the contents of the fields inside 'this' instance are identical to the fields in 'other'
        Code:
        Exact Method Body:
         if (other == null) return false;
        
         if (! OSResponse.class.isAssignableFrom(other.getClass())) return false;
        
         OSResponse o = (OSResponse) other;
        
         return
                 (this.response == o.response)
             &&  (this.commandStr.equals(o.commandStr))
             &&  (this.standardOutput.equals(o.standardOutput))
             &&  (this.errorOutput.equals(o.errorOutput));