Skip to content

Commit 7b3a4ca

Browse files
authored
0.50.0
JSON API refactor. Event model refactor. Misc fixes. DSISetAction. DSTimezone. Fix action parameter metadata bug. Move DSISetAction to action package. Fixes and changes for broker implementation. Log names correspond to paths.
2 parents 03e9795 + 6840fce commit 7b3a4ca

File tree

150 files changed

+3364
-3017
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+3364
-3017
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
* [Documentation](https://github.com/iot-dsa-v2/sdk-dslink-java-v2/wiki)
55
* [Javadoc](https://jitpack.io/com/github/iot-dsa-v2/sdk-dslink-java-v2/dslink-v2/master-SNAPSHOT/javadoc/)
6-
* JDK 1.6+
6+
* JDK 1.8+
77

88

99
## Overview
@@ -23,6 +23,14 @@ the DSA architecture, please visit
2323

2424
Please read the [developer guide](https://github.com/iot-dsa-v2/sdk-dslink-java-v2/wiki/DSLink-Development-Guide).
2525

26+
## Version Control
27+
28+
TODO
29+
30+
## Dependency Management
31+
32+
TODO
33+
2634
## Acknowledgements
2735

2836
_Project Tyrus_

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ subprojects {
55
apply plugin: 'maven'
66

77
group 'org.iot-dsa'
8-
version '0.49.0'
8+
version '0.50.0'
99

1010
sourceCompatibility = 1.8
1111
targetCompatibility = 1.8

dslink-v2/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ artifacts {
44
}
55

66
dependencies {
7+
compileOnly 'javax.websocket:javax.websocket-api:1.1'
78
testImplementation 'org.testng:testng:6.14.3'
89
}
910

dslink-v2/src/main/java/com/acuity/iot/dsa/dslink/io/DSBase64.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,14 @@ public static String encode(byte[] buf, int linelen) {
110110
return encode(buf, 0, buf.length, linelen, true);
111111
}
112112

113+
/**
114+
* Encodes to a URL safe base64 string. Replaces / with _ and + with -.
115+
*/
116+
public static String encodeUrl(byte[] bytes) {
117+
String enc = encode(bytes);
118+
return enc.replace('+', '-').replace('/', '_');
119+
}
120+
113121
/**
114122
* Encodes a buffer into a base 64 string.
115123
*
@@ -172,14 +180,6 @@ private static String encode(byte[] bytes,
172180
return buf.toString();
173181
}
174182

175-
/**
176-
* Encodes to a URL safe base64 string. Replaces / with _ and + with -.
177-
*/
178-
public static String encodeUrl(byte[] bytes) {
179-
String enc = encode(bytes);
180-
return enc.replace('+', '-').replace('/', '_');
181-
}
182-
183183
///////////////////////////////////////////////////////////////////////////
184184
// Initialization
185185
///////////////////////////////////////////////////////////////////////////

dslink-v2/src/main/java/com/acuity/iot/dsa/dslink/io/DSByteBuffer.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,6 @@ public DSByteBuffer clear() {
5353
return this;
5454
}
5555

56-
/**
57-
* Increases the childCount of the buffer to at least the given.
58-
*/
59-
private void growBuffer(int minSize) {
60-
int size = buffer.length;
61-
while (size < minSize) {
62-
size *= 2;
63-
}
64-
byte[] tmp = new byte[size];
65-
System.arraycopy(buffer, offset, tmp, 0, length);
66-
buffer = tmp;
67-
offset = 0;
68-
}
69-
7056
/**
7157
* Number of bytes available for reading.
7258
*/
@@ -634,4 +620,18 @@ public byte[] toByteArray() {
634620
return ret;
635621
}
636622

623+
/**
624+
* Increases the childCount of the buffer to at least the given.
625+
*/
626+
private void growBuffer(int minSize) {
627+
int size = buffer.length;
628+
while (size < minSize) {
629+
size *= 2;
630+
}
631+
byte[] tmp = new byte[size];
632+
System.arraycopy(buffer, offset, tmp, 0, length);
633+
buffer = tmp;
634+
offset = 0;
635+
}
636+
637637
}

dslink-v2/src/main/java/com/acuity/iot/dsa/dslink/io/DSCharBuffer.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,6 @@ public long getTimeout() {
8080
return timeout;
8181
}
8282

83-
/**
84-
* Increases the childCount of the buffer to at least the given.
85-
*/
86-
private void growBuffer(int minSize) {
87-
int size = buffer.length;
88-
while (size < minSize) {
89-
size *= 2;
90-
}
91-
char[] tmp = new char[size];
92-
System.arraycopy(buffer, offset, tmp, 0, length);
93-
buffer = tmp;
94-
offset = 0;
95-
}
96-
9783
public boolean isOpen() {
9884
return open;
9985
}
@@ -273,4 +259,18 @@ public DSCharBuffer setTimeout(long timeout) {
273259
return this;
274260
}
275261

262+
/**
263+
* Increases the childCount of the buffer to at least the given.
264+
*/
265+
private void growBuffer(int minSize) {
266+
int size = buffer.length;
267+
while (size < minSize) {
268+
size *= 2;
269+
}
270+
char[] tmp = new char[size];
271+
System.arraycopy(buffer, offset, tmp, 0, length);
272+
buffer = tmp;
273+
offset = 0;
274+
}
275+
276276
}

dslink-v2/src/main/java/com/acuity/iot/dsa/dslink/io/msgpack/MsgpackReader.java

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ public class MsgpackReader extends AbstractReader implements DSIReader, MsgpackC
2323
// Fields
2424
// ---------
2525

26-
private byte[] bytes;
2726
private ByteBuffer byteBuffer;
27+
private byte[] bytes;
2828
private CharBuffer charBuffer;
2929
private CharsetDecoder decoder = DSString.UTF8.newDecoder();
30-
private InputStream in;
3130
private Frame frame;
31+
private InputStream in;
3232
private boolean wasValue = true;
3333

3434
// Constructors
@@ -53,42 +53,6 @@ public void close() {
5353
}
5454
}
5555

56-
/**
57-
* Returns a byte buffer wrapping the given bytes and ready for reading (getting). Attempts to
58-
* reuse the same buffer.
59-
*/
60-
private ByteBuffer getByteBuffer(byte[] bytes, int off, int len) {
61-
if ((byteBuffer == null) || (byteBuffer.capacity() < len)) {
62-
int tmp = 1024;
63-
while (tmp < len) {
64-
tmp += 1024;
65-
}
66-
byteBuffer = ByteBuffer.allocate(tmp);
67-
} else {
68-
byteBuffer.clear();
69-
}
70-
byteBuffer.put(bytes, 0, len);
71-
byteBuffer.flip();
72-
return byteBuffer;
73-
}
74-
75-
/**
76-
* Returns a char buffer with the given capacity, ready for writing (putting). Attempts to
77-
* reuse the same char buffer.
78-
*/
79-
private CharBuffer getCharBuffer(int size) {
80-
if ((charBuffer == null) || (charBuffer.length() < size)) {
81-
int tmp = 1024;
82-
while (tmp < size) {
83-
tmp += 1024;
84-
}
85-
charBuffer = CharBuffer.allocate(tmp);
86-
} else {
87-
charBuffer.clear();
88-
}
89-
return charBuffer;
90-
}
91-
9256
public static final boolean isFixInt(byte b) {
9357
int v = b & 0xff;
9458
return v <= 0x7f || v >= 0xe0;
@@ -184,6 +148,65 @@ public Token next() {
184148
throw new IllegalStateException("Unknown type: " + b);
185149
}
186150

151+
public String readUTF(int len) throws IOException {
152+
byte[] bytes = readBytes(len);
153+
ByteBuffer byteBuf = getByteBuffer(bytes, 0, len);
154+
CharBuffer charBuf = getCharBuffer(len);
155+
decoder.decode(byteBuf, charBuf, false);
156+
charBuf.flip();
157+
return charBuf.toString();
158+
}
159+
160+
@Override
161+
public MsgpackReader reset() {
162+
super.reset();
163+
return this;
164+
}
165+
166+
/**
167+
* Sets the input source, resets to ROOT, and returns this.
168+
*/
169+
public MsgpackReader setInput(InputStream inputStream) {
170+
this.in = inputStream;
171+
return reset();
172+
}
173+
174+
/**
175+
* Returns a byte buffer wrapping the given bytes and ready for reading (getting). Attempts to
176+
* reuse the same buffer.
177+
*/
178+
private ByteBuffer getByteBuffer(byte[] bytes, int off, int len) {
179+
if ((byteBuffer == null) || (byteBuffer.capacity() < len)) {
180+
int tmp = 1024;
181+
while (tmp < len) {
182+
tmp += 1024;
183+
}
184+
byteBuffer = ByteBuffer.allocate(tmp);
185+
} else {
186+
byteBuffer.clear();
187+
}
188+
byteBuffer.put(bytes, 0, len);
189+
byteBuffer.flip();
190+
return byteBuffer;
191+
}
192+
193+
/**
194+
* Returns a char buffer with the given capacity, ready for writing (putting). Attempts to
195+
* reuse the same char buffer.
196+
*/
197+
private CharBuffer getCharBuffer(int size) {
198+
if ((charBuffer == null) || (charBuffer.length() < size)) {
199+
int tmp = 1024;
200+
while (tmp < size) {
201+
tmp += 1024;
202+
}
203+
charBuffer = CharBuffer.allocate(tmp);
204+
} else {
205+
charBuffer.clear();
206+
}
207+
return charBuffer;
208+
}
209+
187210
/**
188211
* Reads bytes into an array that is guaranteed to be at least the given size but will probably
189212
* be longer.
@@ -202,20 +225,6 @@ private byte[] readBytes(int size) throws IOException {
202225
return bytes;
203226
}
204227

205-
@Override
206-
public MsgpackReader reset() {
207-
super.reset();
208-
return this;
209-
}
210-
211-
/**
212-
* Sets the input source, resets to ROOT, and returns this.
213-
*/
214-
public MsgpackReader setInput(InputStream inputStream) {
215-
this.in = inputStream;
216-
return reset();
217-
}
218-
219228
private Token readBytes(byte b) throws IOException {
220229
int size = 0;
221230
switch (b) {
@@ -321,23 +330,14 @@ private Token readString(byte b) throws IOException {
321330
return last();
322331
}
323332

324-
public String readUTF(int len) throws IOException {
325-
byte[] bytes = readBytes(len);
326-
ByteBuffer byteBuf = getByteBuffer(bytes, 0, len);
327-
CharBuffer charBuf = getCharBuffer(len);
328-
decoder.decode(byteBuf, charBuf, false);
329-
charBuf.flip();
330-
return charBuf.toString();
331-
}
332-
333333
// Inner Classes
334334
// -------------
335335

336336
private class Frame {
337337

338338
boolean map = true;
339-
int size;
340339
Frame parent;
340+
int size;
341341

342342
Frame(int size, boolean map) {
343343
this.map = map;

0 commit comments

Comments
 (0)