diff options
Diffstat (limited to 'src/main/java/com/iciql/adapter')
7 files changed, 57 insertions, 2 deletions
diff --git a/src/main/java/com/iciql/adapter/GsonTypeAdapter.java b/src/main/java/com/iciql/adapter/GsonTypeAdapter.java index b07b7b5..8d23cfd 100644 --- a/src/main/java/com/iciql/adapter/GsonTypeAdapter.java +++ b/src/main/java/com/iciql/adapter/GsonTypeAdapter.java @@ -18,6 +18,7 @@ package com.iciql.adapter; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.iciql.Iciql.DataTypeAdapter; +import com.iciql.Iciql.Mode; /** * Base class for inserting/retrieving a Java Object (de)serialized as JSON @@ -39,11 +40,18 @@ import com.iciql.Iciql.DataTypeAdapter; */ public abstract class GsonTypeAdapter<T> implements DataTypeAdapter<T> { + protected Mode mode; + protected Gson gson() { return new GsonBuilder().create(); } @Override + public void setMode(Mode mode) { + this.mode = mode; + } + + @Override public String getDataType() { return "TEXT"; } diff --git a/src/main/java/com/iciql/adapter/JavaSerializationTypeAdapter.java b/src/main/java/com/iciql/adapter/JavaSerializationTypeAdapter.java index c475817..df24495 100644 --- a/src/main/java/com/iciql/adapter/JavaSerializationTypeAdapter.java +++ b/src/main/java/com/iciql/adapter/JavaSerializationTypeAdapter.java @@ -25,9 +25,9 @@ import java.io.ObjectOutputStream; import java.sql.Blob; import java.sql.SQLException; -import com.iciql.Iciql; -import com.iciql.IciqlException; import com.iciql.Iciql.DataTypeAdapter; +import com.iciql.Iciql.Mode; +import com.iciql.IciqlException; /** * Base class for inserting/retrieving a Java Object as a BLOB field using Java Serialization. @@ -44,6 +44,13 @@ import com.iciql.Iciql.DataTypeAdapter; */ public abstract class JavaSerializationTypeAdapter<T> implements DataTypeAdapter<T> { + protected Mode mode; + + @Override + public void setMode(Mode mode) { + this.mode = mode; + } + @Override public final String getDataType() { return "BLOB"; diff --git a/src/main/java/com/iciql/adapter/SnakeYamlTypeAdapter.java b/src/main/java/com/iciql/adapter/SnakeYamlTypeAdapter.java index fe4541c..da3b20b 100644 --- a/src/main/java/com/iciql/adapter/SnakeYamlTypeAdapter.java +++ b/src/main/java/com/iciql/adapter/SnakeYamlTypeAdapter.java @@ -21,17 +21,25 @@ import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.nodes.Tag; import com.iciql.Iciql.DataTypeAdapter; +import com.iciql.Iciql.Mode; /** * Base class for inserting/retrieving a Java Object (de)serialized as YAML using SnakeYaml. */ public abstract class SnakeYamlTypeAdapter<T> implements DataTypeAdapter<T> { + protected Mode mode; + protected Yaml yaml() { return new Yaml(); } @Override + public void setMode(Mode mode) { + this.mode = mode; + } + + @Override public String getDataType() { return "TEXT"; } diff --git a/src/main/java/com/iciql/adapter/XStreamTypeAdapter.java b/src/main/java/com/iciql/adapter/XStreamTypeAdapter.java index 5e152df..a554724 100644 --- a/src/main/java/com/iciql/adapter/XStreamTypeAdapter.java +++ b/src/main/java/com/iciql/adapter/XStreamTypeAdapter.java @@ -17,6 +17,7 @@ package com.iciql.adapter; import com.iciql.Iciql.DataTypeAdapter; +import com.iciql.Iciql.Mode; import com.thoughtworks.xstream.XStream; /** @@ -24,11 +25,18 @@ import com.thoughtworks.xstream.XStream; */ public class XStreamTypeAdapter implements DataTypeAdapter<Object> { + protected Mode mode; + protected XStream xstream() { return new XStream(); } @Override + public void setMode(Mode mode) { + this.mode = mode; + } + + @Override public String getDataType() { return "TEXT"; } diff --git a/src/main/java/com/iciql/adapter/postgresql/JsonStringAdapter.java b/src/main/java/com/iciql/adapter/postgresql/JsonStringAdapter.java index c4fbd6a..01d2834 100644 --- a/src/main/java/com/iciql/adapter/postgresql/JsonStringAdapter.java +++ b/src/main/java/com/iciql/adapter/postgresql/JsonStringAdapter.java @@ -20,12 +20,20 @@ import java.sql.SQLException; import org.postgresql.util.PGobject; import com.iciql.Iciql.DataTypeAdapter; +import com.iciql.Iciql.Mode; /** * Handles transforming raw strings to/from the Postgres JSON data type. */ public class JsonStringAdapter implements DataTypeAdapter<String> { + protected Mode mode; + + @Override + public void setMode(Mode mode) { + this.mode = mode; + } + @Override public String getDataType() { return "json"; diff --git a/src/main/java/com/iciql/adapter/postgresql/JsonbStringAdapter.java b/src/main/java/com/iciql/adapter/postgresql/JsonbStringAdapter.java index cc2d9c4..9d7388b 100644 --- a/src/main/java/com/iciql/adapter/postgresql/JsonbStringAdapter.java +++ b/src/main/java/com/iciql/adapter/postgresql/JsonbStringAdapter.java @@ -20,12 +20,20 @@ import java.sql.SQLException; import org.postgresql.util.PGobject; import com.iciql.Iciql.DataTypeAdapter; +import com.iciql.Iciql.Mode; /** * Handles transforming raw strings to/from the Postgres JSONB data type. */ public class JsonbStringAdapter implements DataTypeAdapter<String> { + protected Mode mode; + + @Override + public void setMode(Mode mode) { + this.mode = mode; + } + @Override public String getDataType() { return "jsonb"; diff --git a/src/main/java/com/iciql/adapter/postgresql/XmlStringAdapter.java b/src/main/java/com/iciql/adapter/postgresql/XmlStringAdapter.java index defe9f9..0aea77e 100644 --- a/src/main/java/com/iciql/adapter/postgresql/XmlStringAdapter.java +++ b/src/main/java/com/iciql/adapter/postgresql/XmlStringAdapter.java @@ -20,12 +20,20 @@ import java.sql.SQLException; import org.postgresql.util.PGobject; import com.iciql.Iciql.DataTypeAdapter; +import com.iciql.Iciql.Mode; /** * Handles transforming raw strings to/from the Postgres XML data type. */ public class XmlStringAdapter implements DataTypeAdapter<String> { + protected Mode mode; + + @Override + public void setMode(Mode mode) { + this.mode = mode; + } + @Override public String getDataType() { return "xml"; |