Package Torello.Java
Class OSJavaPipe
- java.lang.Object
-
- Torello.Java.OSJavaPipe
-
- All Implemented Interfaces:
java.lang.Cloneable
public class OSJavaPipe extends java.lang.Object implements java.lang.Cloneable
Allows a user to pipe data directly from Java-Memory, and into an instance ofjava.lang.Process
.
Hi-Lited Source-Code:- View Here: Torello/Java/OSJavaPipe.java
- Open New Browser-Tab: Torello/Java/OSJavaPipe.java
File Size: 13,619 Bytes Line Count: 360 '\n' Characters Found
-
-
Field Summary
Fields Modifier and Type Field static byte
BYTE_ARR
static byte
CHAR_ARR
static byte
INPUT_STREAM
static byte
INT_ARR
static byte
STRING
-
Constructor Summary
Constructors Constructor OSJavaPipe(byte[] byteArrData)
OSJavaPipe(char[] charArrData)
OSJavaPipe(int[] intArrData)
OSJavaPipe(InputStream inputStream)
OSJavaPipe(String strData)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Object
clone()
boolean
equals(Object other)
byte
getDataType()
Object
getPipeData()
int
hashCode()
void
setData(byte[] byteArrData)
void
setData(char[] charArrData)
void
setData(int[] intArrData)
void
setData(InputStream inputStream)
void
setData(String strData)
String
toString()
-
-
-
Field Detail
-
INT_ARR
public static final byte INT_ARR
Constant used to indicate that this class data-contents currently contain a non-nullint[]
-Array.- See Also:
- Constant Field Values
- Code:
- Exact Field Declaration Expression:
public static final byte INT_ARR = 1;
-
BYTE_ARR
public static final byte BYTE_ARR
Constant used to indicate that this class data-contents currently contain a non-nullbyte[]
-Array.- See Also:
- Constant Field Values
- Code:
- Exact Field Declaration Expression:
public static final byte BYTE_ARR = 2;
-
CHAR_ARR
public static final byte CHAR_ARR
Constant used to indicate that this class data-contents currently contain a non-nullchar[]
-Array.- See Also:
- Constant Field Values
- Code:
- Exact Field Declaration Expression:
public static final byte CHAR_ARR = 3;
-
STRING
public static final byte STRING
Constant used to indicate that this class data-contents currently contain a non-nullString
.- See Also:
- Constant Field Values
- Code:
- Exact Field Declaration Expression:
public static final byte STRING = 4;
-
INPUT_STREAM
public static final byte INPUT_STREAM
Constant used to indicate that this class data-contents currently contain a non-nullInputStream
.- See Also:
- Constant Field Values
- Code:
- Exact Field Declaration Expression:
public static final byte INPUT_STREAM = 5;
-
-
Constructor Detail
-
OSJavaPipe
public OSJavaPipe(int[] intArrData)
Constructs an instance of this class, assigning the inputint[]
-Array Parameter to the internal Data-Field.- Parameters:
intArrData
- Any Javaint[]
Integer-Array.- Throws:
java.lang.NullPointerException
- if'intArrData'
is null.
-
OSJavaPipe
public OSJavaPipe(byte[] byteArrData)
Constructs an instance of this class, assigning the inputbyte[]
-Array Parameter to the internal Data-Field.- Parameters:
byteArrData
- Any Javabyte[]
Byte-Array.- Throws:
java.lang.NullPointerException
- if'byteArrData'
is null.
-
OSJavaPipe
public OSJavaPipe(char[] charArrData)
Constructs an instance of this class, assigning the inputchar[]
-Array Parameter to the internal Data-Field.- Parameters:
charArrData
- Any Javachar[]
Char-Array.- Throws:
java.lang.NullPointerException
- if'charArrData'
is null.
-
OSJavaPipe
public OSJavaPipe(java.lang.String strData)
Constructs an instance of this class, assigning the inputString
-Parameter to the internal Data-Field.- Parameters:
strData
- Any JavaString
.- Throws:
java.lang.NullPointerException
- if'strData'
is null.
-
OSJavaPipe
public OSJavaPipe(java.io.InputStream inputStream)
Constructs an instance of this class, assigning theInputStream
Parameter to the internal Data-Field.- Parameters:
inputStream
- Any Java Input-Stream.- Throws:
java.lang.NullPointerException
- if'inputStream'
is null.
-
-
Method Detail
-
getDataType
public byte getDataType()
Retrieve the Data-Type that is contained by this instance' internal PIPE-Data contents.- Returns:
- The Static-Flag Constant associated with the Data-Type that has been assigned to this instance.
- Code:
- Exact Method Body:
return this.dataType;
-
getPipeData
public java.lang.Object getPipeData()
Retrieve the actual data, as ajava.lang.Object
contained by this instance.- Returns:
- This class internal Data-Field
- Code:
- Exact Method Body:
return this.textOrDataToPipe;
-
setData
public void setData(int[] intArrData)
Sets the data to be used for piping into an Operating-System Process.- Parameters:
intArrData
- Any Javaint[]
Integer-Array.- Throws:
java.lang.NullPointerException
- if'intArrData'
is null.- Code:
- Exact Method Body:
Objects.requireNonNull(intArrData, "The int[]-Array passed may not be null"); this.textOrDataToPipe = intArrData; this.dataType = INT_ARR;
-
setData
public void setData(byte[] byteArrData)
Sets the data to be used for piping into an Operating-System Process.- Parameters:
byteArrData
- Any Javabyte[]
Byte-Array.- Throws:
java.lang.NullPointerException
- if'byteArrData'
is null.- Code:
- Exact Method Body:
Objects.requireNonNull(byteArrData, "The byte[]-Array passed may not be null"); this.textOrDataToPipe = byteArrData; this.dataType = BYTE_ARR;
-
setData
public void setData(char[] charArrData)
Sets the data to be used for piping into an Operating-System Process.- Parameters:
charArrData
- Any Javachar[]
Char-Array.- Throws:
java.lang.NullPointerException
- if'charArrData'
is null.- Code:
- Exact Method Body:
Objects.requireNonNull(charArrData, "The char[]-Array passed may not be null"); this.textOrDataToPipe = charArrData; this.dataType = CHAR_ARR;
-
setData
public void setData(java.lang.String strData)
Sets the data to be used for piping into an Operating-System Process.- Parameters:
strData
- Any JavaString
.- Throws:
java.lang.NullPointerException
- if'strData'
is null.- Code:
- Exact Method Body:
Objects.requireNonNull(strData, "The String-Data passed may not be null"); this.textOrDataToPipe = strData; this.dataType = STRING;
-
setData
public void setData(java.io.InputStream inputStream)
Sets the data to be used for piping into an Operating-System Process.- Parameters:
inputStream
- Any Java Input-Stream.- Throws:
java.lang.NullPointerException
- if'inputStream'
is null.- Code:
- Exact Method Body:
Objects.requireNonNull(inputStream, "The Input-Stream passed may not be null"); this.textOrDataToPipe = inputStream; this.dataType = INPUT_STREAM;
-
toString
public java.lang.String toString()
Generates aString
this class. The returnedString
merely converts the contained data to aString
, using Standard Java Methods.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A simple representation of this class, as a
java.lang.String
- Code:
- Exact Method Body:
switch (this.dataType) { case INT_ARR : return NAME + "int[]:\n" + StrPrint.abbrev( Arrays.toString((int[]) this.textOrDataToPipe), 60, true, null, 120 ); case BYTE_ARR : return NAME + "byte[]:\n" + StrPrint.abbrev( Arrays.toString((byte[]) this.textOrDataToPipe), 60, true, null, 120 ); case CHAR_ARR : return NAME + "char[]:\n" + StrPrint.abbrev( Arrays.toString((char[]) this.textOrDataToPipe), 60, true, null, 120 ); case STRING : return NAME + "String:\n" + StrPrint.abbrev ((String) this.textOrDataToPipe, 60, true, null, 120); case INPUT_STREAM : return NAME + "InputStream: Non-Null Data-Input\n"; default: throw new UnreachableError(); }
-
equals
public boolean equals(java.lang.Object other)
Checks for equality based on whether two instances have identical references.- Overrides:
equals
in classjava.lang.Object
- Parameters:
other
- Any Java Object. Only a valid sub-class ofOSJavaPipe
could possibly produce aTRUE
return value- Returns:
TRUE
if and only if this class' internal fields are identical references in both'this'
and'other'
.- Code:
- Exact Method Body:
if (other == null) return false; if (! (other instanceof OSJavaPipe)) return false; final OSJavaPipe o = (OSJavaPipe) other; return Objects.equals(this.textOrDataToPipe, o.textOrDataToPipe) && (this.dataType == o.dataType);
-
clone
public java.lang.Object clone()
Makes a copy of'this'
instance and returns it.- Overrides:
clone
in classjava.lang.Object
- Returns:
- a clone of
'this'
instance - Code:
- Exact Method Body:
// Private-Internal Zero-Argument Constructor OSJavaPipe ret = new OSJavaPipe(); ret.dataType = this.dataType; ret.textOrDataToPipe = this.textOrDataToPipe; return ret;
-
hashCode
public int hashCode()
Produces a Hash-Code that may be used to place this instance-reference into a Hash-Table, Set or Map. The code produced is generated using whatever hash-code value is returned by this class' internaltextOrDataToPipe
hash-code method.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- a hashcode
- Code:
- Exact Method Body:
return this.textOrDataToPipe.hashCode();
-
-