You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2019/12/27 19:16:07 UTC
[plc4x] 02/09: - Extended the PlcValue types and added some missing
ones for temporal types. - Minor cleanups - Added support for reading and
writing string data into the Read and WriteBuffers
This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch next-gen-core
in repository https://gitbox.apache.org/repos/asf/plc4x.git
commit 08f29fb1d71cabe518cc063fe879a16a3e2cfd1c
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Wed Dec 25 20:57:35 2019 +0100
- Extended the PlcValue types and added some missing ones for temporal types.
- Minor cleanups
- Added support for reading and writing string data into the Read and WriteBuffers
---
.../apache/plc4x/java/api/value/PlcBigDecimal.java | 136 ++++++++++++++++++
.../apache/plc4x/java/api/value/PlcBigInteger.java | 136 ++++++++++++++++++
.../apache/plc4x/java/api/value/PlcBoolean.java | 99 ++++++++++---
.../api/value/{PlcInteger.java => PlcDate.java} | 41 ++----
.../value/{PlcInteger.java => PlcDateTime.java} | 51 ++++---
.../org/apache/plc4x/java/api/value/PlcDouble.java | 140 ++++++++++++++++++
.../org/apache/plc4x/java/api/value/PlcFloat.java | 140 ++++++++++++++++++
.../apache/plc4x/java/api/value/PlcInteger.java | 110 +++++++++++---
.../org/apache/plc4x/java/api/value/PlcList.java | 2 +-
.../org/apache/plc4x/java/api/value/PlcLong.java | 140 ++++++++++++++++++
.../org/apache/plc4x/java/api/value/PlcString.java | 27 ++--
.../org/apache/plc4x/java/api/value/PlcStruct.java | 2 +-
.../api/value/{PlcInteger.java => PlcTime.java} | 41 ++----
.../org/apache/plc4x/java/api/value/PlcValue.java | 82 ++++++++++-
.../plc4x/java/api/value/PlcValueAdapter.java | 158 +++++++++++++++++----
.../spi/connection/DefaultNettyPlcConnection.java | 4 +-
.../java/spi/connection/NettyChannelFactory.java | 24 ++--
.../plc4x/java/spi/generation/ReadBuffer.java | 4 +
.../plc4x/java/spi/generation/WriteBuffer.java | 4 +
.../tcp/connection/TcpSocketChannelFactory.java | 12 --
.../base/connection/UdpSocketChannelFactory.java | 4 -
21 files changed, 1174 insertions(+), 183 deletions(-)
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcBigDecimal.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcBigDecimal.java
new file mode 100644
index 0000000..bcc28a0
--- /dev/null
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcBigDecimal.java
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.plc4x.java.api.value;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+public class PlcBigDecimal extends PlcSimpleValue<BigDecimal> {
+
+ public PlcBigDecimal(BigDecimal value) {
+ super(value, true);
+ }
+
+ @Override
+ public boolean isBoolean() {
+ return true;
+ }
+
+ @Override
+ public boolean getBoolean() {
+ return (value != null) && !value.equals(BigDecimal.ZERO);
+ }
+
+ @Override
+ public boolean isByte() {
+ return true;
+ }
+
+ @Override
+ public byte getByte() {
+ return value.byteValue();
+ }
+
+ @Override
+ public boolean isShort() {
+ return true;
+ }
+
+ @Override
+ public short getShort() {
+ return value.shortValue();
+ }
+
+ @Override
+ public boolean isInteger() {
+ return true;
+ }
+
+ @Override
+ public int getInteger() {
+ return value.intValue();
+ }
+
+ @Override
+ public boolean isLong() {
+ return true;
+ }
+
+ @Override
+ public long getLong() {
+ return value.longValue();
+ }
+
+ @Override
+ public boolean isBigInteger() {
+ return true;
+ }
+
+ @Override
+ public BigInteger getBigInteger() {
+ return BigInteger.valueOf(value.longValue());
+ }
+
+ @Override
+ public boolean isFloat() {
+ return true;
+ }
+
+ @Override
+ public float getFloat() {
+ return value.floatValue();
+ }
+
+ @Override
+ public boolean isDouble() {
+ return true;
+ }
+
+ @Override
+ public double getDouble() {
+ return value.doubleValue();
+ }
+
+ @Override
+ public boolean isBigDecimal() {
+ return true;
+ }
+
+ @Override
+ public BigDecimal getBigDecimal() {
+ return value;
+ }
+
+ @Override
+ public boolean isString() {
+ return true;
+ }
+
+ @Override
+ public String getString() {
+ return toString();
+ }
+
+ @Override
+ public String toString() {
+ return value.toString();
+ }
+
+}
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcBigInteger.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcBigInteger.java
new file mode 100644
index 0000000..a323d76
--- /dev/null
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcBigInteger.java
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.plc4x.java.api.value;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+public class PlcBigInteger extends PlcSimpleValue<BigInteger> {
+
+ public PlcBigInteger(BigInteger value) {
+ super(value, true);
+ }
+
+ @Override
+ public boolean isBoolean() {
+ return true;
+ }
+
+ @Override
+ public boolean getBoolean() {
+ return (value != null) && !value.equals(BigInteger.ZERO);
+ }
+
+ @Override
+ public boolean isByte() {
+ return true;
+ }
+
+ @Override
+ public byte getByte() {
+ return value.byteValue();
+ }
+
+ @Override
+ public boolean isShort() {
+ return true;
+ }
+
+ @Override
+ public short getShort() {
+ return value.shortValue();
+ }
+
+ @Override
+ public boolean isInteger() {
+ return true;
+ }
+
+ @Override
+ public int getInteger() {
+ return value.intValue();
+ }
+
+ @Override
+ public boolean isLong() {
+ return true;
+ }
+
+ @Override
+ public long getLong() {
+ return value.longValue();
+ }
+
+ @Override
+ public boolean isBigInteger() {
+ return true;
+ }
+
+ @Override
+ public BigInteger getBigInteger() {
+ return value;
+ }
+
+ @Override
+ public boolean isFloat() {
+ return true;
+ }
+
+ @Override
+ public float getFloat() {
+ return value.floatValue();
+ }
+
+ @Override
+ public boolean isDouble() {
+ return true;
+ }
+
+ @Override
+ public double getDouble() {
+ return value.doubleValue();
+ }
+
+ @Override
+ public boolean isBigDecimal() {
+ return true;
+ }
+
+ @Override
+ public BigDecimal getBigDecimal() {
+ return new BigDecimal(value);
+ }
+
+ @Override
+ public boolean isString() {
+ return true;
+ }
+
+ @Override
+ public String getString() {
+ return toString();
+ }
+
+ @Override
+ public String toString() {
+ return value.toString();
+ }
+
+}
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcBoolean.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcBoolean.java
index a179fd4..eabd18b 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcBoolean.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcBoolean.java
@@ -19,45 +19,112 @@
package org.apache.plc4x.java.api.value;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
public class PlcBoolean extends PlcSimpleValue<Boolean> {
- PlcBoolean(Boolean value) {
+ public PlcBoolean(Boolean value) {
super(value, true);
}
- PlcBoolean(boolean bool) {
+ public PlcBoolean(boolean bool) {
super(bool, false);
}
- @Override public boolean isBoolean() {
+ @Override
+ public boolean isBoolean() {
+ return true;
+ }
+
+ @Override
+ public boolean getBoolean() {
+ return (value != null) && value;
+ }
+
+ @Override
+ public boolean isByte() {
+ return true;
+ }
+
+ @Override
+ public byte getByte() {
+ return (byte) (((value != null) && value) ? 1 : 0);
+ }
+
+ @Override
+ public boolean isShort() {
+ return true;
+ }
+
+ @Override
+ public short getShort() {
+ return (short) (((value != null) && value) ? 1 : 0);
+ }
+
+ @Override
+ public boolean isLong() {
return true;
}
- @Override public boolean getBoolean() {
- return value;
+ @Override
+ public long getLong() {
+ return ((value != null) && value) ? 1 : 0;
}
- @Override public double getDouble() {
- return value ? 1.0 : 0.0;
+ @Override
+ public boolean isBigInteger() {
+ return true;
+ }
+
+ @Override
+ public BigInteger getBigInteger() {
+ return value ? BigInteger.ONE : BigInteger.ZERO;
+ }
+
+ @Override
+ public boolean isFloat() {
+ return true;
+ }
+
+ @Override
+ public float getFloat() {
+ return ((value != null) && value) ? 1.0f : 0.0f;
}
- @Override public float getFloat() {
- return value ? 1.0f : 0.0f;
+ @Override
+ public boolean isDouble() {
+ return true;
+ }
+
+ @Override
+ public double getDouble() {
+ return ((value != null) && value) ? 1.0 : 0.0;
+ }
+
+ @Override
+ public boolean isBigDecimal() {
+ return true;
}
- @Override public long getLong() {
- return value ? 1 : 0;
+ @Override
+ public BigDecimal getBigDecimal() {
+ return value ? BigDecimal.ONE : BigDecimal.ZERO;
}
- @Override public int getInteger() {
- return value ? 1 : 0;
+ @Override
+ public boolean isString() {
+ return true;
}
- @Override public String getString() {
- return value ? "true" : "false";
+ @Override
+ public String getString() {
+ return toString();
}
- @Override public String toString() {
+ @Override
+ public String toString() {
return Boolean.toString(value);
}
+
}
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcInteger.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcDate.java
similarity index 60%
copy from plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcInteger.java
copy to plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcDate.java
index 69fc45a..4ec540d 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcInteger.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcDate.java
@@ -19,48 +19,37 @@
package org.apache.plc4x.java.api.value;
-import org.apache.plc4x.java.api.value.PlcSimpleValue;
+import java.time.LocalDate;
-public class PlcInteger extends PlcSimpleValue<Integer> {
+public class PlcDate extends PlcSimpleValue<LocalDate> {
- PlcInteger(Integer value) {
+ public PlcDate(LocalDate value) {
super(value, true);
}
- PlcInteger(int value) {
- super(value, false);
- }
-
- @Override public boolean isString() {
+ @Override
+ public boolean isString() {
return true;
}
- @Override public String getString() {
+ @Override
+ public String getString() {
return value.toString();
}
- @Override public boolean getBoolean() {
- // We like C
- return !(value == 0);
- }
-
- @Override public double getDouble() {
- return (double)value;
- }
-
- @Override public float getFloat() {
- return (float)value;
- }
-
- @Override public long getLong() {
- return value;
+ @Override
+ public boolean isDate() {
+ return true;
}
- @Override public int getInteger() {
+ @Override
+ public LocalDate getDate() {
return value;
}
- @Override public String toString() {
+ @Override
+ public String toString() {
return String.valueOf(value);
}
+
}
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcInteger.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcDateTime.java
similarity index 58%
copy from plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcInteger.java
copy to plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcDateTime.java
index 69fc45a..7f98dae 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcInteger.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcDateTime.java
@@ -19,48 +19,59 @@
package org.apache.plc4x.java.api.value;
-import org.apache.plc4x.java.api.value.PlcSimpleValue;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
-public class PlcInteger extends PlcSimpleValue<Integer> {
+public class PlcDateTime extends PlcSimpleValue<LocalDateTime> {
- PlcInteger(Integer value) {
+ public PlcDateTime(LocalDateTime value) {
super(value, true);
}
- PlcInteger(int value) {
- super(value, false);
- }
-
- @Override public boolean isString() {
+ @Override
+ public boolean isString() {
return true;
}
- @Override public String getString() {
+ @Override
+ public String getString() {
return value.toString();
}
- @Override public boolean getBoolean() {
- // We like C
- return !(value == 0);
+ @Override
+ public boolean isTime() {
+ return true;
}
- @Override public double getDouble() {
- return (double)value;
+ @Override
+ public LocalTime getTime() {
+ return value.toLocalTime();
}
- @Override public float getFloat() {
- return (float)value;
+ @Override
+ public boolean isDate() {
+ return true;
}
- @Override public long getLong() {
- return value;
+ @Override
+ public LocalDate getDate() {
+ return value.toLocalDate();
}
- @Override public int getInteger() {
+ @Override
+ public boolean isDateTime() {
+ return true;
+ }
+
+ @Override
+ public LocalDateTime getDateTime() {
return value;
}
- @Override public String toString() {
+ @Override
+ public String toString() {
return String.valueOf(value);
}
+
}
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcDouble.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcDouble.java
new file mode 100644
index 0000000..4f4cf64
--- /dev/null
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcDouble.java
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.plc4x.java.api.value;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+public class PlcDouble extends PlcSimpleValue<Double> {
+
+ public PlcDouble(Double value) {
+ super(value, true);
+ }
+
+ public PlcDouble(double value) {
+ super(value, false);
+ }
+
+ @Override
+ public boolean isBoolean() {
+ return true;
+ }
+
+ @Override
+ public boolean getBoolean() {
+ return (value != null) && !value.equals(0.0);
+ }
+
+ @Override
+ public boolean isByte() {
+ return true;
+ }
+
+ @Override
+ public byte getByte() {
+ return value.byteValue();
+ }
+
+ @Override
+ public boolean isShort() {
+ return true;
+ }
+
+ @Override
+ public short getShort() {
+ return value.shortValue();
+ }
+
+ @Override
+ public boolean isInteger() {
+ return true;
+ }
+
+ @Override
+ public int getInteger() {
+ return value.intValue();
+ }
+
+ @Override
+ public boolean isLong() {
+ return true;
+ }
+
+ @Override
+ public long getLong() {
+ return value.longValue();
+ }
+
+ @Override
+ public boolean isBigInteger() {
+ return true;
+ }
+
+ @Override
+ public BigInteger getBigInteger() {
+ return BigInteger.valueOf(value.longValue());
+ }
+
+ @Override
+ public boolean isFloat() {
+ return true;
+ }
+
+ @Override
+ public float getFloat() {
+ return value.floatValue();
+ }
+
+ @Override
+ public boolean isDouble() {
+ return true;
+ }
+
+ @Override
+ public double getDouble() {
+ return value;
+ }
+
+ @Override
+ public boolean isBigDecimal() {
+ return true;
+ }
+
+ @Override
+ public BigDecimal getBigDecimal() {
+ return new BigDecimal(value);
+ }
+
+ @Override
+ public boolean isString() {
+ return true;
+ }
+
+ @Override
+ public String getString() {
+ return toString();
+ }
+
+ @Override
+ public String toString() {
+ return Double.toString(value);
+ }
+
+}
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcFloat.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcFloat.java
new file mode 100644
index 0000000..a9635c3
--- /dev/null
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcFloat.java
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.plc4x.java.api.value;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+public class PlcFloat extends PlcSimpleValue<Float> {
+
+ public PlcFloat(Float value) {
+ super(value, true);
+ }
+
+ public PlcFloat(float value) {
+ super(value, false);
+ }
+
+ @Override
+ public boolean isBoolean() {
+ return true;
+ }
+
+ @Override
+ public boolean getBoolean() {
+ return (value != null) && !value.equals(0.0F);
+ }
+
+ @Override
+ public boolean isByte() {
+ return true;
+ }
+
+ @Override
+ public byte getByte() {
+ return value.byteValue();
+ }
+
+ @Override
+ public boolean isShort() {
+ return true;
+ }
+
+ @Override
+ public short getShort() {
+ return value.shortValue();
+ }
+
+ @Override
+ public boolean isInteger() {
+ return true;
+ }
+
+ @Override
+ public int getInteger() {
+ return value.intValue();
+ }
+
+ @Override
+ public boolean isLong() {
+ return true;
+ }
+
+ @Override
+ public long getLong() {
+ return value.longValue();
+ }
+
+ @Override
+ public boolean isBigInteger() {
+ return true;
+ }
+
+ @Override
+ public BigInteger getBigInteger() {
+ return BigInteger.valueOf(value.longValue());
+ }
+
+ @Override
+ public boolean isFloat() {
+ return true;
+ }
+
+ @Override
+ public float getFloat() {
+ return value;
+ }
+
+ @Override
+ public boolean isDouble() {
+ return true;
+ }
+
+ @Override
+ public double getDouble() {
+ return value.doubleValue();
+ }
+
+ @Override
+ public boolean isBigDecimal() {
+ return true;
+ }
+
+ @Override
+ public BigDecimal getBigDecimal() {
+ return new BigDecimal(value);
+ }
+
+ @Override
+ public boolean isString() {
+ return true;
+ }
+
+ @Override
+ public String getString() {
+ return toString();
+ }
+
+ @Override
+ public String toString() {
+ return Float.toString(value);
+ }
+
+}
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcInteger.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcInteger.java
index 69fc45a..b1cb4d9 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcInteger.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcInteger.java
@@ -19,48 +19,122 @@
package org.apache.plc4x.java.api.value;
-import org.apache.plc4x.java.api.value.PlcSimpleValue;
+import java.math.BigDecimal;
+import java.math.BigInteger;
public class PlcInteger extends PlcSimpleValue<Integer> {
- PlcInteger(Integer value) {
+ public PlcInteger(Integer value) {
super(value, true);
}
- PlcInteger(int value) {
+ public PlcInteger(int value) {
super(value, false);
}
- @Override public boolean isString() {
+ @Override
+ public boolean isBoolean() {
return true;
}
- @Override public String getString() {
- return value.toString();
+ @Override
+ public boolean getBoolean() {
+ return (value != null) && !value.equals(0);
}
- @Override public boolean getBoolean() {
- // We like C
- return !(value == 0);
+ @Override
+ public boolean isByte() {
+ return true;
}
- @Override public double getDouble() {
- return (double)value;
+ @Override
+ public byte getByte() {
+ return value.byteValue();
}
- @Override public float getFloat() {
- return (float)value;
+ @Override
+ public boolean isShort() {
+ return true;
}
- @Override public long getLong() {
- return value;
+ @Override
+ public short getShort() {
+ return value.shortValue();
+ }
+
+ @Override
+ public boolean isInteger() {
+ return true;
}
- @Override public int getInteger() {
+ @Override
+ public int getInteger() {
return value;
}
- @Override public String toString() {
- return String.valueOf(value);
+ @Override
+ public boolean isLong() {
+ return true;
+ }
+
+ @Override
+ public long getLong() {
+ return value.longValue();
+ }
+
+ @Override
+ public boolean isBigInteger() {
+ return true;
+ }
+
+ @Override
+ public BigInteger getBigInteger() {
+ return BigInteger.valueOf((long) value);
+ }
+
+ @Override
+ public boolean isFloat() {
+ return true;
+ }
+
+ @Override
+ public float getFloat() {
+ return value.floatValue();
}
+
+ @Override
+ public boolean isDouble() {
+ return true;
+ }
+
+ @Override
+ public double getDouble() {
+ return value.doubleValue();
+ }
+
+ @Override
+ public boolean isBigDecimal() {
+ return true;
+ }
+
+ @Override
+ public BigDecimal getBigDecimal() {
+ return new BigDecimal(value);
+ }
+
+ @Override
+ public boolean isString() {
+ return true;
+ }
+
+ @Override
+ public String getString() {
+ return toString();
+ }
+
+ @Override
+ public String toString() {
+ return Integer.toString(value);
+ }
+
}
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcList.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcList.java
index 546c443..0bdf25d 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcList.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcList.java
@@ -27,7 +27,7 @@ public class PlcList extends PlcValueAdapter {
private final List<PlcValue> listItems;
- PlcList(List<?> listItems) {
+ public PlcList(List<?> listItems) {
List<PlcValue> safelist = listItems.stream().<PlcValue>map(plcValue -> {
// to avoid unwrapped list cause of type erasure
if (plcValue instanceof PlcValue) {
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcLong.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcLong.java
new file mode 100644
index 0000000..f133891
--- /dev/null
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcLong.java
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.plc4x.java.api.value;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+public class PlcLong extends PlcSimpleValue<Long> {
+
+ public PlcLong(Long value) {
+ super(value, true);
+ }
+
+ public PlcLong(long value) {
+ super(value, false);
+ }
+
+ @Override
+ public boolean isBoolean() {
+ return true;
+ }
+
+ @Override
+ public boolean getBoolean() {
+ return (value != null) && !value.equals(0L);
+ }
+
+ @Override
+ public boolean isByte() {
+ return true;
+ }
+
+ @Override
+ public byte getByte() {
+ return value.byteValue();
+ }
+
+ @Override
+ public boolean isShort() {
+ return true;
+ }
+
+ @Override
+ public short getShort() {
+ return value.shortValue();
+ }
+
+ @Override
+ public boolean isInteger() {
+ return true;
+ }
+
+ @Override
+ public int getInteger() {
+ return value.intValue();
+ }
+
+ @Override
+ public boolean isLong() {
+ return true;
+ }
+
+ @Override
+ public long getLong() {
+ return value;
+ }
+
+ @Override
+ public boolean isBigInteger() {
+ return true;
+ }
+
+ @Override
+ public BigInteger getBigInteger() {
+ return BigInteger.valueOf(value);
+ }
+
+ @Override
+ public boolean isFloat() {
+ return true;
+ }
+
+ @Override
+ public float getFloat() {
+ return value.floatValue();
+ }
+
+ @Override
+ public boolean isDouble() {
+ return true;
+ }
+
+ @Override
+ public double getDouble() {
+ return value.doubleValue();
+ }
+
+ @Override
+ public boolean isBigDecimal() {
+ return true;
+ }
+
+ @Override
+ public BigDecimal getBigDecimal() {
+ return new BigDecimal(value);
+ }
+
+ @Override
+ public boolean isString() {
+ return true;
+ }
+
+ @Override
+ public String getString() {
+ return toString();
+ }
+
+ @Override
+ public String toString() {
+ return Long.toString(value);
+ }
+
+}
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcString.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcString.java
index e3bca4d..6d17296 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcString.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcString.java
@@ -21,39 +21,48 @@ package org.apache.plc4x.java.api.value;
public class PlcString extends PlcSimpleValue<String> {
- PlcString(String value) {
+ public PlcString(String value) {
super(value, true);
}
- @Override public boolean isString() {
+ @Override
+ public boolean isString() {
return true;
}
- @Override public String getString() {
+ @Override
+ public String getString() {
return value;
}
- @Override public boolean getBoolean() {
+ @Override
+ public boolean getBoolean() {
return Boolean.parseBoolean(value);
}
- @Override public double getDouble() {
+ @Override
+ public double getDouble() {
return Double.parseDouble(value);
}
- @Override public float getFloat() {
+ @Override
+ public float getFloat() {
return Float.parseFloat(value);
}
- @Override public long getLong() {
+ @Override
+ public long getLong() {
return Long.parseLong(value);
}
- @Override public int getInteger() {
+ @Override
+ public int getInteger() {
return Integer.parseInt(value);
}
- @Override public String toString() {
+ @Override
+ public String toString() {
return "\"" + value + "\"";
}
+
}
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcStruct.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcStruct.java
index ecdb0ef..d8393fc 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcStruct.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcStruct.java
@@ -28,7 +28,7 @@ public class PlcStruct extends PlcValueAdapter {
private final Map<String, PlcValue> map;
- PlcStruct(Map<String, PlcValue> map) {
+ public PlcStruct(Map<String, PlcValue> map) {
this.map = Collections.unmodifiableMap(map);
}
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcInteger.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcTime.java
similarity index 60%
copy from plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcInteger.java
copy to plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcTime.java
index 69fc45a..c33bd39 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcInteger.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcTime.java
@@ -19,48 +19,37 @@
package org.apache.plc4x.java.api.value;
-import org.apache.plc4x.java.api.value.PlcSimpleValue;
+import java.time.LocalTime;
-public class PlcInteger extends PlcSimpleValue<Integer> {
+public class PlcTime extends PlcSimpleValue<LocalTime> {
- PlcInteger(Integer value) {
+ public PlcTime(LocalTime value) {
super(value, true);
}
- PlcInteger(int value) {
- super(value, false);
- }
-
- @Override public boolean isString() {
+ @Override
+ public boolean isString() {
return true;
}
- @Override public String getString() {
+ @Override
+ public String getString() {
return value.toString();
}
- @Override public boolean getBoolean() {
- // We like C
- return !(value == 0);
- }
-
- @Override public double getDouble() {
- return (double)value;
- }
-
- @Override public float getFloat() {
- return (float)value;
- }
-
- @Override public long getLong() {
- return value;
+ @Override
+ public boolean isTime() {
+ return true;
}
- @Override public int getInteger() {
+ @Override
+ public LocalTime getTime() {
return value;
}
- @Override public String toString() {
+ @Override
+ public String toString() {
return String.valueOf(value);
}
+
}
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcValue.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcValue.java
index 0e3aa18..f6dd472 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcValue.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcValue.java
@@ -19,6 +19,13 @@
package org.apache.plc4x.java.api.value;
+import org.apache.plc4x.java.api.exceptions.PlcIncompatibleDatatypeException;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -28,6 +35,43 @@ import java.util.Set;
*/
public interface PlcValue {
+ static PlcValue of(Object value) {
+ if(value instanceof Boolean) {
+ return new PlcBoolean((Boolean) value);
+ }
+ if(value instanceof Integer) {
+ return new PlcInteger((Integer) value);
+ }
+ if(value instanceof Long) {
+ return new PlcLong((Long) value);
+ }
+ if(value instanceof BigInteger) {
+ return new PlcBigInteger((BigInteger) value);
+ }
+ if(value instanceof Float) {
+ return new PlcFloat((Float) value);
+ }
+ if(value instanceof Double) {
+ return new PlcDouble((Double) value);
+ }
+ if(value instanceof BigDecimal) {
+ return new PlcBigDecimal((BigDecimal) value);
+ }
+ if(value instanceof String) {
+ return new PlcString((String) value);
+ }
+ if(value instanceof LocalTime) {
+ return new PlcTime((LocalTime) value);
+ }
+ if(value instanceof LocalDate) {
+ return new PlcDate((LocalDate) value);
+ }
+ if(value instanceof LocalDateTime) {
+ return new PlcDateTime((LocalDateTime) value);
+ }
+ return null;
+ }
+
// Simple Types
boolean isSimple();
@@ -52,23 +96,39 @@ public interface PlcValue {
// Integer
- boolean isLong();
+ boolean isByte();
- long getLong();
+ byte getByte();
+
+ boolean isShort();
+
+ short getShort();
boolean isInteger();
int getInteger();
+ boolean isLong();
+
+ long getLong();
+
+ boolean isBigInteger();
+
+ BigInteger getBigInteger();
+
// Floating Point
+ boolean isFloat();
+
+ float getFloat();
+
boolean isDouble();
double getDouble();
- boolean isFloat();
+ boolean isBigDecimal();
- float getFloat();
+ BigDecimal getBigDecimal();
// String
@@ -76,6 +136,20 @@ public interface PlcValue {
String getString();
+ // Time
+
+ boolean isTime();
+
+ LocalTime getTime();
+
+ boolean isDate();
+
+ LocalDate getDate();
+
+ boolean isDateTime();
+
+ LocalDateTime getDateTime();
+
// Raw Access
byte[] getRaw();
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcValueAdapter.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcValueAdapter.java
index d52ba10..cdb399b 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcValueAdapter.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcValueAdapter.java
@@ -20,121 +20,223 @@ package org.apache.plc4x.java.api.value;
import org.apache.plc4x.java.api.exceptions.PlcIncompatibleDatatypeException;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class PlcValueAdapter implements PlcValue {
- @Override public boolean isSimple() {
+ @Override
+ public boolean isSimple() {
return false;
}
- @Override public boolean isNullable() {
+ @Override
+ public boolean isNullable() {
return false;
}
- @Override public boolean isNull() {
+ @Override
+ public boolean isNull() {
return false;
}
- @Override public boolean is(Class<?> clazz) {
+ @Override
+ public boolean is(Class<?> clazz) {
return false;
}
- @Override public boolean isConvertibleTo(Class<?> clazz) {
+ @Override
+ public boolean isConvertibleTo(Class<?> clazz) {
return false;
}
- @Override public <T> T get(Class<T> clazz) {
+ @Override
+ public <T> T get(Class<T> clazz) {
throw new PlcIncompatibleDatatypeException("");
}
- @Override public boolean isBoolean() {
+ @Override
+ public boolean isBoolean() {
return false;
}
- @Override public boolean getBoolean() {
+ @Override
+ public boolean getBoolean() {
throw new PlcIncompatibleDatatypeException("");
}
- @Override public boolean isDouble() {
+ public boolean isByte() {
return false;
}
- @Override public double getDouble() {
+ @Override
+ public byte getByte() {
throw new PlcIncompatibleDatatypeException("");
}
- @Override public boolean isFloat() {
+ @Override
+ public boolean isShort() {
return false;
}
- @Override public float getFloat() {
+ @Override
+ public short getShort() {
throw new PlcIncompatibleDatatypeException("");
}
- @Override public boolean isLong() {
+ @Override
+ public boolean isInteger() {
return false;
}
- @Override public long getLong() {
+ @Override
+ public int getInteger() {
throw new PlcIncompatibleDatatypeException("");
}
- @Override public boolean isInteger() {
+ @Override
+ public boolean isLong() {
return false;
}
- @Override public int getInteger() {
+ @Override
+ public long getLong() {
throw new PlcIncompatibleDatatypeException("");
}
- @Override public boolean isString() {
+ @Override
+ public boolean isBigInteger() {
return false;
}
- @Override public String getString() {
+ @Override
+ public BigInteger getBigInteger() {
throw new PlcIncompatibleDatatypeException("");
}
- @Override public byte[] getRaw() {
+ @Override
+ public boolean isFloat() {
+ return false;
+ }
+
+ @Override
+ public float getFloat() {
+ throw new PlcIncompatibleDatatypeException("");
+ }
+
+ @Override
+ public boolean isDouble() {
+ return false;
+ }
+
+ @Override
+ public double getDouble() {
+ throw new PlcIncompatibleDatatypeException("");
+ }
+
+ @Override
+ public boolean isBigDecimal() {
+ return false;
+ }
+
+ @Override
+ public BigDecimal getBigDecimal() {
+ throw new PlcIncompatibleDatatypeException("");
+ }
+
+ @Override
+ public boolean isString() {
+ return false;
+ }
+
+ @Override
+ public String getString() {
+ throw new PlcIncompatibleDatatypeException("");
+ }
+
+ @Override
+ public boolean isTime() {
+ return false;
+ }
+
+ @Override
+ public LocalTime getTime() {
+ throw new PlcIncompatibleDatatypeException("");
+ }
+
+ @Override
+ public boolean isDate() {
+ return false;
+ }
+
+ @Override
+ public LocalDate getDate() {
+ throw new PlcIncompatibleDatatypeException("");
+ }
+
+ @Override
+ public boolean isDateTime() {
+ return false;
+ }
+
+ @Override
+ public LocalDateTime getDateTime() {
+ throw new PlcIncompatibleDatatypeException("");
+ }
+
+ @Override
+ public byte[] getRaw() {
throw new PlcIncompatibleDatatypeException("");
}
- @Override public boolean isList() {
+ @Override
+ public boolean isList() {
return false;
}
- @Override public int length() {
+ @Override
+ public int length() {
throw new PlcIncompatibleDatatypeException("");
}
- @Override public PlcValue getIndex(int i) {
+ @Override
+ public PlcValue getIndex(int i) {
throw new PlcIncompatibleDatatypeException("");
}
- @Override public List<? extends PlcValue> getList() {
+ @Override
+ public List<? extends PlcValue> getList() {
throw new PlcIncompatibleDatatypeException("");
}
- @Override public boolean isStruct() {
+ @Override
+ public boolean isStruct() {
return false;
}
- @Override public Set<String> getKeys() {
+ @Override
+ public Set<String> getKeys() {
throw new PlcIncompatibleDatatypeException("");
}
- @Override public boolean hasKey(String key) {
+ @Override
+ public boolean hasKey(String key) {
return false;
}
- @Override public PlcValue getValue(String key) {
+ @Override
+ public PlcValue getValue(String key) {
throw new PlcIncompatibleDatatypeException("");
}
- @Override public Map<String, ? extends PlcValue> getStruct() {
+ @Override
+ public Map<String, ? extends PlcValue> getStruct() {
throw new PlcIncompatibleDatatypeException("");
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/DefaultNettyPlcConnection.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/DefaultNettyPlcConnection.java
index f3c2b7a..4b10746 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/DefaultNettyPlcConnection.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/DefaultNettyPlcConnection.java
@@ -29,10 +29,7 @@ import io.netty.util.Timer;
import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
import org.apache.plc4x.java.api.exceptions.PlcException;
import org.apache.plc4x.java.api.exceptions.PlcIoException;
-import org.apache.plc4x.java.spi.GeneratedDriverByteToMessageCodec;
import org.apache.plc4x.java.spi.InstanceFactory;
-import org.apache.plc4x.java.spi.Plc4xNettyWrapper;
-import org.apache.plc4x.java.spi.Plc4xProtocolBase;
import org.apache.plc4x.java.spi.events.CloseConnectionEvent;
import org.apache.plc4x.java.spi.events.ConnectEvent;
import org.apache.plc4x.java.spi.events.ConnectedEvent;
@@ -197,4 +194,5 @@ public class DefaultNettyPlcConnection<BASE_PROTOCOL_CLASS extends Message> exte
// Send an event to the pipeline telling the Protocol filters what's going on.
channel.pipeline().fireUserEventTriggered(new ConnectEvent());
}
+
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/NettyChannelFactory.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/NettyChannelFactory.java
index 2897b63..9933035 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/NettyChannelFactory.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/NettyChannelFactory.java
@@ -23,15 +23,8 @@ import io.netty.bootstrap.Bootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandler;
-import io.netty.channel.ChannelOption;
-import io.netty.channel.ChannelPipeline;
-import io.netty.channel.EventLoop;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
-import io.netty.channel.socket.SocketChannel;
-import io.netty.channel.socket.nio.NioSocketChannel;
-import io.netty.util.concurrent.Future;
-import io.netty.util.concurrent.GenericFutureListener;
import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
import org.apache.plc4x.java.api.exceptions.PlcException;
import org.slf4j.Logger;
@@ -104,14 +97,16 @@ public abstract class NettyChannelFactory implements ChannelFactory {
* @Deprecated use {@link #createChannel(SocketAddress, ChannelHandler)} instead.
*/
@Deprecated
- @Override public Channel createChannel(ChannelHandler channelHandler) throws PlcConnectionException {
+ @Override
+ public Channel createChannel(ChannelHandler channelHandler) throws PlcConnectionException {
if (this.address == null) {
throw new IllegalStateException("This Method should only be used with the constructor which takes an Address");
}
return this.createChannel(address, channelHandler);
}
- @Override public Channel createChannel(SocketAddress socketAddress, ChannelHandler channelHandler) throws PlcConnectionException {
+ @Override
+ public Channel createChannel(SocketAddress socketAddress, ChannelHandler channelHandler) throws PlcConnectionException {
if (this.address == null) {
this.address = socketAddress;
}
@@ -126,12 +121,10 @@ public abstract class NettyChannelFactory implements ChannelFactory {
bootstrap.handler(channelHandler);
// Start the client.
final ChannelFuture f = bootstrap.connect(socketAddress);
- f.addListener(new GenericFutureListener<Future<? super Void>>() {
- @Override public void operationComplete(Future<? super Void> future) throws Exception {
- if (!future.isSuccess()) {
- logger.info("Unable to connect, shutting down worker thread.");
- workerGroup.shutdownGracefully();
- }
+ f.addListener(future -> {
+ if (!future.isSuccess()) {
+ logger.info("Unable to connect, shutting down worker thread.");
+ workerGroup.shutdownGracefully();
}
});
// Wait for sync
@@ -194,4 +187,5 @@ public abstract class NettyChannelFactory implements ChannelFactory {
protected String getPropertyOrDefault(String key, String defaultValue) {
return getProperties().getProperty(key, defaultValue);
}
+
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/ReadBuffer.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/ReadBuffer.java
index a61b20b..4391a4f 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/ReadBuffer.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/ReadBuffer.java
@@ -257,4 +257,8 @@ public class ReadBuffer {
throw new UnsupportedOperationException("not implemented yet");
}
+ public String readString(int bitLength, String encoding) {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBuffer.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBuffer.java
index 2c10848..c4ac4df 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBuffer.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBuffer.java
@@ -205,4 +205,8 @@ public class WriteBuffer {
throw new UnsupportedOperationException("not implemented yet");
}
+ public void writeString(int bitLength, String encoding, String value) {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+
}
diff --git a/plc4j/transports/tcp/src/main/java/org/apache/plc4x/java/tcp/connection/TcpSocketChannelFactory.java b/plc4j/transports/tcp/src/main/java/org/apache/plc4x/java/tcp/connection/TcpSocketChannelFactory.java
index b7d1488..097f059 100644
--- a/plc4j/transports/tcp/src/main/java/org/apache/plc4x/java/tcp/connection/TcpSocketChannelFactory.java
+++ b/plc4j/transports/tcp/src/main/java/org/apache/plc4x/java/tcp/connection/TcpSocketChannelFactory.java
@@ -20,27 +20,15 @@ package org.apache.plc4x.java.tcp.connection;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.Channel;
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelOption;
-import io.netty.channel.EventLoopGroup;
-import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel;
-import io.netty.util.concurrent.Future;
-import io.netty.util.concurrent.GenericFutureListener;
-import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
-import org.apache.plc4x.java.api.exceptions.PlcException;
import org.apache.plc4x.java.spi.HasConfiguration;
-import org.apache.plc4x.java.spi.connection.ChannelFactory;
import org.apache.plc4x.java.spi.connection.NettyChannelFactory;
-import org.apache.plc4x.java.spi.connection.NettyPlcConnection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
-import java.net.Socket;
import java.net.SocketAddress;
public class TcpSocketChannelFactory extends NettyChannelFactory implements HasConfiguration<TcpConfiguration> {
diff --git a/plc4j/transports/udp/src/main/java/org/apache/plc4x/java/base/connection/UdpSocketChannelFactory.java b/plc4j/transports/udp/src/main/java/org/apache/plc4x/java/base/connection/UdpSocketChannelFactory.java
index ce5b39e..5ab173f 100644
--- a/plc4j/transports/udp/src/main/java/org/apache/plc4x/java/base/connection/UdpSocketChannelFactory.java
+++ b/plc4j/transports/udp/src/main/java/org/apache/plc4x/java/base/connection/UdpSocketChannelFactory.java
@@ -26,8 +26,6 @@ import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioDatagramChannel;
import org.apache.plc4x.java.base.connection.protocol.DatagramUnpackingHandler;
import org.apache.plc4x.java.spi.connection.NettyChannelFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import java.net.InetAddress;
import java.net.InetSocketAddress;
@@ -35,8 +33,6 @@ import java.net.SocketAddress;
public class UdpSocketChannelFactory extends NettyChannelFactory {
- private static final Logger logger = LoggerFactory.getLogger(UdpSocketChannelFactory.class);
-
/**
* @deprecated the next-gen drivers should use the {@link #UdpSocketChannelFactory(SocketAddress)}
* constructor.