blob: 7f3dd15de859941b15d67714ed25358b53a24f4e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
/* Copyright (c) 2016, Isode Limited, London, England.
* All rights reserved.
*
* Acquisition and use of this software and related materials for any
* purpose requires a written license agreement from Isode Limited,
* or a written license from an organisation licensed by Isode Limited
* to grant such a license.
*
*/
package com.isode.stroke.streamstack;
import com.isode.stroke.base.SafeByteArray;
/**
* The {@link DummyStreamLayer} can be used to use a {@link LowLayer} on its own,
* without a functioning parent layer. The {@link DummyStreamLayer} will serve as the
* parent layer to the {@link LowLayer} and is called when the {@link LowLayer} wants
* to write data to its parent layer.
*/
public class DummyStreamLayer implements HighLayer {
private LowLayer childLayer;
public DummyStreamLayer(LowLayer lowLayer) {
childLayer = lowLayer;
childLayer.setParentLayer(this);
}
@Override
public void handleDataRead(SafeByteArray data) {
// Empty Method
}
@Override
public LowLayer getChildLayer() {
return childLayer;
}
@Override
public void setChildLayer(LowLayer childLayer) {
this.childLayer = childLayer;
}
@Override
public void writeDataToChildLayer(SafeByteArray data) {
if (childLayer != null) {
childLayer.writeData(data);
}
}
}
|