Package Torello.Java
Class OSResponse
- java.lang.Object
-
- Torello.Java.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 classesShell,GSUTIL&MSDOS.
This class contains threepublicandfinalfields with all of the available information about the results of the Operating-System invocation. Whenever an Operating-System Process is invoked using Java'sclass java.lang.Process, the invocation of thatProcesswill yield these data results:
- 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. - A transcript of the text/character data that has been sent to
Standard-Output. The complete text is available in the fieldstandardOutput. - A transcript of the text/character data that has been sent to
Error-Output. The complete text is available in the fielderrorOutput. - The original Command that was invoked, as a
java.lang.String
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 responseObjectwould have no effect on thejava.lang.Processroutine, itself.- See Also:
- Serialized Form
Hi-Lited Source-Code:- View Here: Torello/Java/OSResponse.java
- Open New Browser-Tab: Torello/Java/OSResponse.java
File Size: 7,436 Bytes Line Count: 189 '\n' Characters Found
-
-
Field Summary
Serializable ID Modifier and Type Field protected static longserialVersionUIDOriginal Command Modifier and Type Field StringcommandStrOperating-System Response Code Modifier and Type Field intresponseStandard-Out & Error-Out, as a java.lang.String Modifier and Type Field StringerrorOutputStringstandardOutputInterrupted Flag Modifier and Type Field static intINTERRUPTED
-
Constructor Summary
Constructors Modifier Constructor protectedOSResponse(String commandStr, int response, String standardOutput, String errorOutput)
-
Method Summary
Methods: interface java.lang.Cloneable Modifier and Type Method OSResponseclone()Methods: class java.lang.Object Modifier and Type Method booleanequals(Object other)inthashCode()StringtoString()StringtoStringComplete()
-
-
-
Field Detail
-
serialVersionUID
protected static final long serialVersionUID
This fulfils the SerialVersion UID requirement for all classes that implement Java'sinterface java.io.Serializable. Using theSerializableImplementation 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
Thispublic, final, intfield 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-1usually signifies that the process terminated with errors. If this field contains a value ofShell.INTERRUPTED, it will mean that the process was interrupted.- Code:
- Exact Field Declaration Expression:
public final int response;
-
standardOutput
public final java.lang.String standardOutput
Thispublic, final, Stringfield will contain a transcript of the text-characterdata that the Operating-System process sent toStandard-Output.- Code:
- Exact Field Declaration Expression:
public final String standardOutput;
-
errorOutput
public final java.lang.String errorOutput
Thispublic, final, Stringfield will contain a transcript of the text-characterdata that the Operating-System process sent toStandard-Error.- Code:
- Exact Field Declaration Expression:
public final String errorOutput;
-
commandStr
public final java.lang.String commandStr
Maintains a copy of the command (as aString) that produced this instance- Code:
- Exact Field Declaration Expression:
public final String commandStr;
-
-
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 JavaStringresponse- The integer returned by the O/S command invocation.standardOutput- The text/character data (as aString) sent toStandard-Output.errorOutput- The text/character data (as aString) sent toStandard-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 ajava.lang.String- Overrides:
toStringin classjava.lang.Object- Returns:
- A Java
Stringrepresentation of this class, containing abbreviated output-data - Code:
- Exact Method Body:
final String s1 = (this.standardOutput == null) ? "null" : ((this.standardOutput.length() == 0) ? "[Zero-Length-String]" : StrPrint.abbrevEndRDSF(this.standardOutput, 80, true)); final 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 ajava.lang.String- Returns:
- A Java
Stringrepresentation of this class, containing complete output-data - Code:
- Exact Method Body:
final String s1 = (this.standardOutput == null) ? "null" : ((this.standardOutput.length() == 0) ? "[Zero-Length-String]" : StrIndent.indentAfter2ndLine(this.standardOutput, 4, true, true)); final 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:
clonein classjava.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 thehashCode()method on the command (as aString) that was issued to produce this instance- Overrides:
hashCodein classjava.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 ofOSResponse, or a subclass of it.- Overrides:
equalsin classjava.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:
TRUEif 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; final OSResponse o = (OSResponse) other; return (this.response == o.response) && (this.commandStr.equals(o.commandStr)) && (this.standardOutput.equals(o.standardOutput)) && (this.errorOutput.equals(o.errorOutput));
-
-