kopia lustrzana https://github.com/bertrik/ttnhabbridge
Fix some PMD warnings.
rodzic
1ce025f9e0
commit
25daf045e3
|
@ -68,13 +68,10 @@ public final class CayenneItem {
|
|||
*/
|
||||
public static CayenneItem parse(ByteBuffer bb) throws CayenneException {
|
||||
try {
|
||||
final int channel = bb.get();
|
||||
final int type = bb.get() & 0xFF;
|
||||
final ECayenneItem ct = ECayenneItem.parse(type);
|
||||
if (ct == null) {
|
||||
throw new CayenneException("Invalid cayenne type " + type);
|
||||
}
|
||||
final Double[] values = ct.parse(bb);
|
||||
int channel = bb.get();
|
||||
int type = bb.get() & 0xFF;
|
||||
ECayenneItem ct = ECayenneItem.parse(type);
|
||||
Double[] values = ct.parse(bb);
|
||||
return new CayenneItem(channel, ct, values);
|
||||
} catch (BufferUnderflowException e) {
|
||||
throw new CayenneException(e);
|
||||
|
|
|
@ -48,9 +48,9 @@ public final class CayenneMessage {
|
|||
* @throws CayenneException in case something went wrong during encoding (e.g. message too big)
|
||||
*/
|
||||
public byte[] encode(int maxSize) throws CayenneException {
|
||||
final ByteBuffer bb = ByteBuffer.allocate(maxSize).order(ByteOrder.LITTLE_ENDIAN);
|
||||
for (CayenneItem i : items) {
|
||||
i.encode(bb);
|
||||
ByteBuffer bb = ByteBuffer.allocate(maxSize).order(ByteOrder.LITTLE_ENDIAN);
|
||||
for (CayenneItem item : items) {
|
||||
item.encode(bb);
|
||||
}
|
||||
return Arrays.copyOfRange(bb.array(), 0, bb.position());
|
||||
}
|
||||
|
|
|
@ -52,9 +52,14 @@ public enum ECayenneItem {
|
|||
*
|
||||
* @param type the type code
|
||||
* @return the enum, or null if not found
|
||||
* @throws CayenneException
|
||||
*/
|
||||
public static ECayenneItem parse(int type) {
|
||||
return LOOKUP.get(type);
|
||||
public static ECayenneItem parse(int type) throws CayenneException {
|
||||
ECayenneItem item = LOOKUP.get(type);
|
||||
if (item == null) {
|
||||
throw new CayenneException("Invalid cayenne type " + type);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
|
|
|
@ -12,7 +12,7 @@ public final class FloatFormatter extends BaseFormatter {
|
|||
private final int size;
|
||||
private final double scale;
|
||||
private final boolean signed;
|
||||
private final String format;
|
||||
private final String formatString;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -27,7 +27,7 @@ public final class FloatFormatter extends BaseFormatter {
|
|||
this.size = size;
|
||||
this.scale = scale;
|
||||
this.signed = signed;
|
||||
this.format = createFormatString(scale);
|
||||
this.formatString = createFormatString(scale);
|
||||
}
|
||||
|
||||
private String createFormatString(double scale) {
|
||||
|
@ -51,7 +51,7 @@ public final class FloatFormatter extends BaseFormatter {
|
|||
public String[] format(Double[] values) {
|
||||
final String[] formatted = new String[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
formatted[i] = String.format(Locale.US, format, values[i]);
|
||||
formatted[i] = String.format(Locale.US, formatString, values[i]);
|
||||
}
|
||||
return formatted;
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue