You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by jf...@apache.org on 2019/03/07 09:20:45 UTC
[incubator-plc4x] branch extend-Field-with-type-information created
(now 19e4265)
This is an automated email from the ASF dual-hosted git repository.
jfeinauer pushed a change to branch extend-Field-with-type-information
in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git.
at 19e4265 Necessary changes to make the (new) plc scraper driver agnostic: * The PlcField interface has a (default) method to return the expected java type (to know this upfront) * The PlcConnection interface has a new "parse()" method which allows to explicitly create a Field instance for a given type.
This branch includes the following new commits:
new 19e4265 Necessary changes to make the (new) plc scraper driver agnostic: * The PlcField interface has a (default) method to return the expected java type (to know this upfront) * The PlcConnection interface has a new "parse()" method which allows to explicitly create a Field instance for a given type.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[incubator-plc4x] 01/01: Necessary changes to make the (new) plc
scraper driver agnostic: * The PlcField interface has a (default) method to
return the expected java type (to know this upfront) * The PlcConnection
interface has a new "parse()" method which allows to explicitly create a
Field instance for a given type.
Posted by jf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jfeinauer pushed a commit to branch extend-Field-with-type-information
in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git
commit 19e4265444c0c5266715fc7740b6b279dbf10e39
Author: Julian Feinauer <j....@pragmaticminds.de>
AuthorDate: Thu Mar 7 10:20:12 2019 +0100
Necessary changes to make the (new) plc scraper driver agnostic:
* The PlcField interface has a (default) method to return the expected java type (to know this upfront)
* The PlcConnection interface has a new "parse()" method which allows to explicitly create a Field instance for a given type.
---
.../src/main/java/org/apache/plc4x/java/api/PlcConnection.java | 10 ++++++++++
.../main/java/org/apache/plc4x/java/api/model/PlcField.java | 9 +++++++++
2 files changed, 19 insertions(+)
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/PlcConnection.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/PlcConnection.java
index a4732e1..ea8525c 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/PlcConnection.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/PlcConnection.java
@@ -19,12 +19,14 @@ under the License.
package org.apache.plc4x.java.api;
import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
+import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
import org.apache.plc4x.java.api.exceptions.PlcUnsupportedOperationException;
import org.apache.plc4x.java.api.messages.PlcReadRequest;
import org.apache.plc4x.java.api.messages.PlcSubscriptionRequest;
import org.apache.plc4x.java.api.messages.PlcUnsubscriptionRequest;
import org.apache.plc4x.java.api.messages.PlcWriteRequest;
import org.apache.plc4x.java.api.metadata.PlcConnectionMetadata;
+import org.apache.plc4x.java.api.model.PlcField;
/**
* Interface defining the most basic methods a PLC4X connection should support.
@@ -53,6 +55,14 @@ public interface PlcConnection extends AutoCloseable {
void close() throws Exception;
/**
+ * Parse a fieldQuery for the given connection type
+ * @throws PlcRuntimeException If the string cannot be parsed
+ */
+ default PlcField parse(String fieldQuery) throws PlcRuntimeException {
+ throw new PlcRuntimeException("Parse method is not implemented for this connection / driver");
+ }
+
+ /**
* Provides connection metadata.
*/
PlcConnectionMetadata getMetadata();
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/model/PlcField.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/model/PlcField.java
index 280e244..48216e8 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/model/PlcField.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/model/PlcField.java
@@ -32,4 +32,13 @@ package org.apache.plc4x.java.api.model;
*/
public interface PlcField {
+ /**
+ * Returns the "default" type of the response one can expect from this field as java type.
+ * I.e., a call to getXXX for the ResponseItem should succeed.
+ * @return Either specific type or Object.class if no specific type is known.
+ */
+ default Class<?> getDefaultJavaType() {
+ return Object.class;
+ }
+
}