Package org.jastacry.layer
Class AbstractBasicLayer
- java.lang.Object
-
- org.jastacry.layer.AbstractBasicLayer
-
- Direct Known Subclasses:
AesCbcLayer
,AesCtrLayer
,AesEcbLayer
,AppendLayer
,AsciiTransportLayer
,FilemergeLayer
,Md5DesLayer
,RandomLayer
,ReadWriteLayer
,ReverseLayer
,RotateLayer
,TransparentLayer
,XorLayer
public abstract class AbstractBasicLayer extends Object implements Runnable, Layer
Abstract base class for the actual worker layers.SPDX-License-Identifier: MIT
- Author:
- Kai Kretschmann
-
-
Field Summary
Fields Modifier and Type Field Description protected CountDownLatch
endController
Countdown for managing threads running.protected InputStream
inputStream
Input stream.protected org.apache.logging.log4j.Logger
logger
Logger object.protected OutputStream
outputStream
Output stream.
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractBasicLayer(Class<?> caller, String layerName)
Constructor of Layer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
progress(long stepsize)
Call this function for every step forward in encoding or decoding.protected int
rangeCheck(int iInput)
Private range check function for byte values.protected int
readAllBytes(InputStream is, byte[] aTarget, int len)
Read all wanted bytes from inputStream.void
run()
Thread entry function for layer work.void
setAction(GlobalData.Action newAction)
Property setter for action.void
setEndController(CountDownLatch newEndController)
Property setter for endcontroller.void
setInputStream(InputStream newInputStream)
Property setter for input stream.void
setOutputStream(OutputStream newOutputStream)
property setter for output stream.void
setRealLayerName(String newRealLayerName)
Property setter for realLayerName.String
toString()
Show a human readable name of the layer.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.jastacry.layer.Layer
decStream, encodeAndDecode, encStream, init
-
-
-
-
Field Detail
-
inputStream
protected InputStream inputStream
Input stream.
-
outputStream
protected OutputStream outputStream
Output stream.
-
logger
protected final org.apache.logging.log4j.Logger logger
Logger object.
-
endController
protected CountDownLatch endController
Countdown for managing threads running.
-
-
Method Detail
-
toString
public final String toString()
Show a human readable name of the layer.- Overrides:
toString
in classObject
- Returns:
- a human readable name of the layer
- See Also:
Object.toString()
-
rangeCheck
protected final int rangeCheck(int iInput)
Private range check function for byte values.- Parameters:
iInput
- as input value- Returns:
- range checked byte value
-
setInputStream
public final void setInputStream(InputStream newInputStream)
Description copied from interface:Layer
Property setter for input stream.- Specified by:
setInputStream
in interfaceLayer
- Parameters:
newInputStream
- the new stream
-
setOutputStream
public final void setOutputStream(OutputStream newOutputStream)
Description copied from interface:Layer
property setter for output stream.- Specified by:
setOutputStream
in interfaceLayer
- Parameters:
newOutputStream
- the new output stream
-
setAction
public final void setAction(GlobalData.Action newAction)
Description copied from interface:Layer
Property setter for action.
-
setEndController
public final void setEndController(CountDownLatch newEndController)
Property setter for endcontroller.- Parameters:
newEndController
- the new endcontroller
-
progress
protected final void progress(long stepsize)
Call this function for every step forward in encoding or decoding.- Parameters:
stepsize
- number of bytes we processed in this step
-
setRealLayerName
public final void setRealLayerName(String newRealLayerName)
Description copied from interface:Layer
Property setter for realLayerName.- Specified by:
setRealLayerName
in interfaceLayer
- Parameters:
newRealLayerName
- the new layer name
-
readAllBytes
protected final int readAllBytes(InputStream is, byte[] aTarget, int len) throws IOException
Read all wanted bytes from inputStream.- Parameters:
is
- the stream to read fromaTarget
- target byte arraylen
- complete wanted length- Returns:
- number of bytes read
- Throws:
IOException
- in case of error
-
-