Merge branch 'maint/jjg' into maint/lp

This commit is contained in:
Lucas Pleß 2012-03-25 18:17:57 +02:00
commit 1921417667
4 changed files with 14 additions and 9 deletions

View File

@ -28,7 +28,7 @@ public class ByteUtils {
private final byte[] data; private final byte[] data;
public ByteUtils(byte[] data) { public ByteUtils(byte[] data) {
this.data = data; this.data = data.clone();
} }
public static int byteToUint(byte b) { public static int byteToUint(byte b) {
@ -40,7 +40,7 @@ public class ByteUtils {
} }
public final byte[] getBytes() { public final byte[] getBytes() {
return data; return data.clone();
} }
public final int getInt16(int offset) { public final int getInt16(int offset) {

View File

@ -37,7 +37,7 @@ public abstract class ArtNetPacket {
} }
public final void setData(byte[] data) { public final void setData(byte[] data) {
this.data = new ByteUtils(data); this.data = new ByteUtils(data.clone());
} }
public final PacketType getType() { public final PacketType getType() {

View File

@ -19,6 +19,9 @@
package de.ctdo.bunti.artnet.packets; package de.ctdo.bunti.artnet.packets;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public enum PacketType { public enum PacketType {
ART_POLL(0x2000, null), ART_POLL(0x2000, null),
@ -47,6 +50,8 @@ public enum PacketType {
private final int opCode; private final int opCode;
private final Class<? extends ArtNetPacket> packetClass; private final Class<? extends ArtNetPacket> packetClass;
private static final Logger LOGGER = LoggerFactory.getLogger(PacketType.class);
private PacketType(int code, Class<? extends ArtNetPacket> clazz) { private PacketType(int code, Class<? extends ArtNetPacket> clazz) {
opCode = code; opCode = code;
@ -59,9 +64,9 @@ public enum PacketType {
try { try {
p = packetClass.newInstance(); p = packetClass.newInstance();
} catch (InstantiationException e) { } catch (InstantiationException e) {
e.printStackTrace(); LOGGER.error("Could not instanciate ArtNetPacket: ",e);
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
e.printStackTrace(); LOGGER.error("Could not instanciate ArtNetPacket: ",e);
} }
} }
return p; return p;

View File

@ -27,12 +27,12 @@ public abstract class BuntiDevice {
*/ */
@Transient @Transient
public final String getType() { public final String getType() {
String FQClassName = this.getClass().getName(); String fqClassName = this.getClass().getName();
int firstChar = FQClassName.lastIndexOf ('.') + 1; int firstChar = fqClassName.lastIndexOf ('.') + 1;
if ( firstChar > 0 ) { if ( firstChar > 0 ) {
FQClassName = FQClassName.substring ( firstChar ); fqClassName = fqClassName.substring ( firstChar );
} }
return FQClassName; return fqClassName;
} }
/** /**