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 threepublic
andfinal
fields 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 thatProcess
will 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
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 responseObject
would have no effect on thejava.lang.Process
routine, 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,406 Bytes Line Count: 189 '\n' Characters Found
-
-
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()
-
-
-
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 theSerializable
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
Thispublic, 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 ofShell.INTERRUPTED
, it will mean that the process was interrupted.
-
standardOutput
public final java.lang.String standardOutput
Thispublic, final, String
field will contain a transcript of the text-character
data that the Operating-System process sent toStandard-Output
.
-
errorOutput
public final java.lang.String errorOutput
Thispublic, final, String
field will contain a transcript of the text-character
data that the Operating-System process sent toStandard-Error
.
-
commandStr
public final java.lang.String commandStr
Maintains a copy of the command (as aString
) that produced this instance
-
-
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 JavaString
response
- 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:
toString
in classjava.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 ajava.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 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:
hashCode
in 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:
equals
in 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:
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));
-
-