-{
- public ZonedDateTimeSerializer()
- {
- }
-
- @Override
- public void serialize(LocalDateTime value, JsonGenerator generator, SerializerProvider provider) throws IOException
- {
- generator.writeString(value.format(DateTimeFormatter.ISO_ZONED_DATE_TIME));
- }
-}
diff --git a/src/main/java/com/guicedee/guicedinjection/json/mapkeys/LocalDateDeserializerKey.java b/src/main/java/com/guicedee/guicedinjection/json/mapkeys/LocalDateDeserializerKey.java
deleted file mode 100644
index fdcea3e..0000000
--- a/src/main/java/com/guicedee/guicedinjection/json/mapkeys/LocalDateDeserializerKey.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.guicedee.guicedinjection.json.mapkeys;
-
-import com.fasterxml.jackson.databind.*;
-import com.guicedee.guicedinjection.json.*;
-
-import java.io.*;
-
-public class LocalDateDeserializerKey
- extends KeyDeserializer
-{
- @Override
- public Object deserializeKey(String key, DeserializationContext ctxt) throws IOException
- {
- return new LocalDateDeserializer().convert(key);
- }
-}
diff --git a/src/main/java/com/guicedee/guicedinjection/json/mapkeys/LocalDateTimeDeserializerKey.java b/src/main/java/com/guicedee/guicedinjection/json/mapkeys/LocalDateTimeDeserializerKey.java
deleted file mode 100644
index 0b2b484..0000000
--- a/src/main/java/com/guicedee/guicedinjection/json/mapkeys/LocalDateTimeDeserializerKey.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.guicedee.guicedinjection.json.mapkeys;
-
-import com.fasterxml.jackson.databind.*;
-import com.guicedee.guicedinjection.json.*;
-
-import java.io.*;
-
-public class LocalDateTimeDeserializerKey
- extends KeyDeserializer
-{
- @Override
- public Object deserializeKey(String key, DeserializationContext ctxt) throws IOException
- {
- return new LocalDateTimeDeserializer().convert(key);
- }
-}
diff --git a/src/main/java/com/guicedee/guicedinjection/json/mapkeys/OffsetDateTimeDeserializerKey.java b/src/main/java/com/guicedee/guicedinjection/json/mapkeys/OffsetDateTimeDeserializerKey.java
deleted file mode 100644
index 16f9fa8..0000000
--- a/src/main/java/com/guicedee/guicedinjection/json/mapkeys/OffsetDateTimeDeserializerKey.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.guicedee.guicedinjection.json.mapkeys;
-
-import com.fasterxml.jackson.databind.*;
-import com.guicedee.guicedinjection.json.*;
-
-import java.io.*;
-
-public class OffsetDateTimeDeserializerKey
- extends KeyDeserializer
-{
- @Override
- public Object deserializeKey(String key, DeserializationContext ctxt) throws IOException
- {
- return new OffsetDateTimeDeserializer().convert(key);
- }
-}
diff --git a/src/main/java/com/guicedee/guicedinjection/representations/IExcelRepresentation.java b/src/main/java/com/guicedee/guicedinjection/representations/IExcelRepresentation.java
deleted file mode 100644
index 5ad7d20..0000000
--- a/src/main/java/com/guicedee/guicedinjection/representations/IExcelRepresentation.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.guicedee.guicedinjection.representations;
-
-import com.guicedee.guicedinjection.representations.excel.ExcelReader;
-import com.guicedee.guicedinjection.exceptions.ExcelRenderingException;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-
-public interface IExcelRepresentation
-{
-
- /**
- * Reads an excel file into it's objects representation
- *
- *
- * @param stream
- * @param objectType
- * @param sheetName
- * @param
- * @return
- * @throws ExcelRenderingException
- */
- default List fromExcel(InputStream stream, Class objectType, String sheetName) throws ExcelRenderingException
- {
- try (ExcelReader excelReader = new ExcelReader(stream, "xlsx"))
- {
- return excelReader.getRecords(sheetName, objectType);
- }
- catch (IOException e)
- {
- throw new ExcelRenderingException("Cannot read the excel file");
- }
- catch (Exception e)
- {
- throw new ExcelRenderingException("General error with the excel file", e);
- }
- }
-
- default String toExcel()
- {
- return null;
- }
-
-
-}
diff --git a/src/main/java/com/guicedee/guicedinjection/representations/IJsonRepresentation.java b/src/main/java/com/guicedee/guicedinjection/representations/IJsonRepresentation.java
deleted file mode 100644
index 946eb6a..0000000
--- a/src/main/java/com/guicedee/guicedinjection/representations/IJsonRepresentation.java
+++ /dev/null
@@ -1,309 +0,0 @@
-package com.guicedee.guicedinjection.representations;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.*;
-import com.guicedee.guicedinjection.GuiceContext;
-import com.guicedee.guicedinjection.exceptions.JsonRenderException;
-import com.guicedee.guicedinjection.interfaces.ObjectBinderKeys;
-
-import java.io.*;
-import java.net.URL;
-import java.util.*;
-
-import static com.guicedee.guicedinjection.interfaces.ObjectBinderKeys.*;
-
-@SuppressWarnings("unused")
-public interface IJsonRepresentation extends ICopyable
-{
- /**
- * Serializes this object as JSON
- *
- * @return The rendered JSON or an empty string
- */
- default String toJson()
- {
- return toJson(false);
- }
-
- /**
- * Serializes this object as JSON
- *
- * @return The rendered JSON or an empty string
- */
- default String toJson(boolean tiny)
- {
- ObjectMapper objectMapper = GuiceContext.get(DefaultObjectMapper);
- try
- {
- if (tiny)
- {
- return objectMapper.disable(SerializationFeature.INDENT_OUTPUT)
- .writeValueAsString(this);
- }
- else
- {
- return objectMapper.writerWithDefaultPrettyPrinter()
- .writeValueAsString(this);
- }
- }
- catch (JsonProcessingException e)
- {
- throw new JsonRenderException("Unable to serialize as JSON", e);
- }
- }
-
- /**
- * Deserializes this object from a JSON String (updates the current object)
- *
- * @param json The JSON String
- * @return This object updated
- */
- default J fromJson(String json)
- {
- ObjectMapper objectMapper = GuiceContext.get(DefaultObjectMapper);
- try
- {
- return objectMapper.readerForUpdating(this)
- .readValue(json);
- }
- catch (IOException e)
- {
- throw new JsonRenderException("Unable to serialize as JSON", e);
- }
- }
-
- /**
- * Deserializes this object from a JSON String (updates the current object)
- *
- * @param json The JSON String
- * @return This object updated
- */
- @SuppressWarnings({"UnusedReturnValue"})
- default List fromJsonArray(String json)
- {
- ObjectMapper objectMapper = GuiceContext.get(DefaultObjectMapper);
- try
- {
- return objectMapper.readerFor(new TypeReference>() {})
- .readValue(json);
- }
- catch (IOException e)
- {
- throw new JsonRenderException("Unable to serialize as JSON", e);
- }
- }
-
- /**
- * Deserializes this object from a JSON String (updates the current object)
- *
- * @param json The JSON String
- * @return This object updated
- */
- @SuppressWarnings({"UnusedReturnValue"})
- default Set fromJsonArrayUnique(String json, @SuppressWarnings("unused")
- Class type)
- {
- ObjectMapper objectMapper = GuiceContext.get(DefaultObjectMapper);
- try
- {
- return objectMapper.readerFor(new TypeReference>() {})
- .readValue(json);
- }
- catch (IOException e)
- {
- throw new JsonRenderException("Unable to serialize as JSON", e);
- }
- }
-
- /**
- * Read direct from the stream
- *
- * @param
- * @param file the stream
- * @param clazz
- * @return
- * @throws IOException
- */
- static T From(InputStream file, Class clazz) throws IOException
- {
- return getJsonObjectReader().forType(clazz)
- .readValue(file);
- }
-
-
- /**
- * Read from a file
- *
- * @param
- * @param file
- * @param clazz
- * @return
- * @throws IOException
- */
- static T From(File file, Class clazz) throws IOException
- {
- return getJsonObjectReader().forType(clazz)
- .readValue(file);
- }
-
- /**
- * Read from a reader
- *
- * @param
- * @param file
- * @param clazz
- * @return
- * @throws IOException
- */
- static T From(Reader file, Class clazz) throws IOException
- {
- return getJsonObjectReader().forType(clazz)
- .readValue(file);
- }
-
- static ObjectReader getJsonObjectReader()
- {
- return GuiceContext.get(ObjectBinderKeys.JSONObjectReader);
- }
-
- /**
- * Read from a content string
- *
- * @param
- * @param content
- * @param clazz
- * @return
- * @throws IOException
- */
- static T From(String content, Class clazz) throws IOException
- {
- return getJsonObjectReader().forType(clazz)
- .readValue(content);
- }
-
- /**
- * Read from a URL
- *
- * @param
- * @param content
- * @param clazz
- * @return
- * @throws IOException
- */
- static T From(URL content, Class clazz) throws IOException
- {
- return getJsonObjectReader().forType(clazz)
- .readValue(content);
- }
-
-
- /**
- * Read direct from the stream
- *
- * @param
- * @param file the stream
- * @param clazz
- * @return
- * @throws IOException
- */
- static List fromToList(InputStream file, Class clazz)
- {
- T list = null;
- try
- {
- list = GuiceContext.get(DefaultObjectMapper)
- .reader()
- .forType(clazz)
- .readValue(file);
- }
- catch (IOException e)
- {
- throw new JsonRenderException("Unable to read the input stream ", e);
- }
- ArrayList lists = new ArrayList<>();
- lists.addAll(Arrays.asList((T[]) list));
- return lists;
- }
-
- /**
- * Read from a URL
- *
- * @param
- * @param content
- * @param clazz
- * @return
- * @throws IOException
- */
- static List fromToList(URL content, Class clazz) throws IOException
- {
- T list = GuiceContext.get(DefaultObjectMapper)
- .reader()
- .forType(clazz)
- .readValue(content);
- ArrayList lists = new ArrayList<>();
- lists.addAll(Arrays.asList((T[]) list));
- return lists;
- }
-
- /**
- * Read from a file
- *
- * @param
- * @param file
- * @param clazz
- * @return
- * @throws IOException
- */
- static List fromToList(File file, Class clazz) throws IOException
- {
- T list = GuiceContext.get(DefaultObjectMapper)
- .reader()
- .forType(clazz)
- .readValue(file);
- ArrayList lists = new ArrayList<>();
- lists.addAll(Arrays.asList((T[]) list));
- return lists;
- }
-
- /**
- * Read from a reader
- *
- * @param
- * @param file
- * @param clazz
- * @return
- * @throws IOException
- */
- static List fromToList(Reader file, Class clazz) throws IOException
- {
- T list = GuiceContext.get(DefaultObjectMapper)
- .reader()
- .forType(clazz)
- .readValue(file);
- ArrayList lists = new ArrayList<>();
- lists.addAll(Arrays.asList((T[]) list));
- return lists;
- }
-
- /**
- * Read from a content string
- *
- * @param
- * @param content
- * @param clazz
- * @return
- * @throws IOException
- */
- static List fromToList(String content, Class clazz) throws IOException
- {
- T list = GuiceContext.get(DefaultObjectMapper)
- .reader()
- .forType(clazz)
- .readValue(content);
- ArrayList lists = new ArrayList<>();
- lists.addAll(Arrays.asList((T[]) list));
- return lists;
- }
-
-}
diff --git a/src/main/java/com/guicedee/guicedinjection/representations/IXmlRepresentation.java b/src/main/java/com/guicedee/guicedinjection/representations/IXmlRepresentation.java
deleted file mode 100644
index 9c430ea..0000000
--- a/src/main/java/com/guicedee/guicedinjection/representations/IXmlRepresentation.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package com.guicedee.guicedinjection.representations;
-
-import com.guicedee.guicedinjection.exceptions.XmlRenderException;
-import com.guicedee.guicedinjection.pairing.Pair;
-import jakarta.xml.bind.*;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.lang.reflect.InvocationTargetException;
-/**
- * Makes any object representable as XML
- *
- * @param
- */
-public interface IXmlRepresentation {
-
- @SuppressWarnings("unchecked")
- default J fromXml(String xml, Class type) {
- try {
- J instance = type.getDeclaredConstructor()
- .newInstance();
- JAXBContext context = null;
- if (XmlContexts.JAXB.containsKey(type)) {
- context = XmlContexts.JAXB.get(type);
- } else {
- context = JAXBContext.newInstance(type);
- XmlContexts.JAXB.put(type, context);
- }
- JAXBIntrospector introspector = context.createJAXBIntrospector();
- Unmarshaller unmarshaller = context.createUnmarshaller();
- if (null == introspector.getElementName(instance)) {
- XMLInputFactory factory = XMLInputFactory.newFactory();
- factory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE);
- factory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
-
- XMLStreamReader streamReader = factory.createXMLStreamReader(
- new StringReader(xml));
- JAXBElement customer = unmarshaller.unmarshal(streamReader, type);
- instance = customer.getValue();
- } else {
- instance = (J) unmarshaller.unmarshal(new StringReader(xml));
- }
- return instance;
- } catch (IllegalAccessException T) {
- throw new XmlRenderException("Unable to IllegalAccessException ", T);
- } catch (IllegalArgumentException T) {
- throw new XmlRenderException("Unable to IllegalArgumentException ", T);
- } catch (InstantiationException T) {
- throw new XmlRenderException("Unable to InstantiationException ", T);
- } catch (NoSuchMethodException T) {
- throw new XmlRenderException("Unable to NoSuchMethodException ", T);
- } catch (SecurityException T) {
- throw new XmlRenderException("Unable to SecurityException ", T);
- } catch (InvocationTargetException T) {
- throw new XmlRenderException("Unable to InvocationTargetException ", T);
- } catch (JAXBException T) {
- throw new XmlRenderException("Unable to JAXBException ", T);
- } catch (XMLStreamException T) {
- throw new XmlRenderException("Unable to XMLStreamException ", T);
- }
- }
-
- @SuppressWarnings("unchecked")
- default String toXml() {
- Object requestObject = this;
- try (StringWriter stringWriter = new StringWriter()) {
- JAXBContext context = null;
- if (XmlContexts.JAXB.containsKey(requestObject.getClass())) {
- context = XmlContexts.JAXB.get(requestObject.getClass());
- } else {
- context = JAXBContext.newInstance(requestObject.getClass());
- XmlContexts.JAXB.put(requestObject.getClass(), context);
- }
- if (requestObject instanceof Pair) {
- Pair, ?> p = (Pair, ?>) requestObject;
- Class> keyType = p.getKey()
- .getClass();
- Class> valueType = p.getValue()
- .getClass();
- context = JAXBContext.newInstance(requestObject.getClass(), keyType, valueType);
- }
- JAXBIntrospector introspector = context.createJAXBIntrospector();
- Marshaller marshaller = context.createMarshaller();
- if (null == introspector.getElementName(requestObject)) {
-
- @SuppressWarnings("rawtypes")
- JAXBElement> jaxbElement = new JAXBElement(new QName(requestObject.getClass()
- .getSimpleName()),
- requestObject.getClass(), requestObject);
- marshaller.setProperty("com.sun.xml.bind.xmlDeclaration", Boolean.FALSE);
- marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
- marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
- marshaller.marshal(jaxbElement, stringWriter);
- } else {
- marshaller.marshal(requestObject, stringWriter);
- }
- return stringWriter.toString();
- } catch (Exception e) {
- throw new XmlRenderException("Unable to marshal string writer from log intercepter", e);
- }
- }
-}
diff --git a/src/main/java/com/guicedee/guicedinjection/representations/XmlContexts.java b/src/main/java/com/guicedee/guicedinjection/representations/XmlContexts.java
deleted file mode 100644
index 87e0c45..0000000
--- a/src/main/java/com/guicedee/guicedinjection/representations/XmlContexts.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package com.guicedee.guicedinjection.representations;
-
-import jakarta.xml.bind.JAXBContext;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-class XmlContexts {
- public static final Map, JAXBContext> JAXB = new ConcurrentHashMap<>();
-
- private XmlContexts(){}
-}
diff --git a/src/main/java/com/guicedee/guicedinjection/representations/excel/ExcelReader.java b/src/main/java/com/guicedee/guicedinjection/representations/excel/ExcelReader.java
deleted file mode 100644
index 12ce15c..0000000
--- a/src/main/java/com/guicedee/guicedinjection/representations/excel/ExcelReader.java
+++ /dev/null
@@ -1,463 +0,0 @@
-package com.guicedee.guicedinjection.representations.excel;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.guicedee.guicedinjection.GuiceContext;
-import com.guicedee.guicedinjection.exceptions.ExcelRenderingException;
-import lombok.extern.java.Log;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-import org.json.JSONObject;
-
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.math.BigDecimal;
-import java.sql.Timestamp;
-import java.util.*;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import static com.guicedee.guicedinjection.interfaces.ObjectBinderKeys.*;
-import static com.guicedee.guicedinjection.json.StaticStrings.*;
-import static java.math.BigDecimal.*;
-
-/**
- * This class is used when a spreadsheet needs to be generated dynamically
- *
- * @author Ernst Created:23 Oct 2013
- */
-@SuppressWarnings({"WeakerAccess", "unused"})
-@Log
-public class ExcelReader
- implements AutoCloseable
-{
- private InputStream inputStream;
-
- private HSSFWorkbook oldStyle;
- private XSSFWorkbook xwb;
- private boolean isH;
- private Sheet currentSheet;
-
- /**
- * Constructs with a file to read
- */
- public ExcelReader(InputStream inputStream, String extension) throws ExcelRenderingException
- {
- this(inputStream, extension, 0);
- }
-
- /**
- * Constructs with a file to create
- */
- public ExcelReader(InputStream inputStream, String extension, int sheet) throws ExcelRenderingException
- {
- if (inputStream == null)
- {
- throw new ExcelRenderingException("Inputstream for document is null");
- }
- this.inputStream = inputStream;
- if (extension.equalsIgnoreCase("xls"))
- {
- try
- {
- oldStyle = new HSSFWorkbook(inputStream);
- }
- catch (Throwable e)
- {
- log.log(Level.SEVERE,"Unable to excel ",e);
- throw new ExcelRenderingException("Cannot open xls workbook",e);
- }
- this.currentSheet = oldStyle.getSheetAt(sheet);
- isH = true;
- }
- else
- {
- try
- {
- xwb = new XSSFWorkbook(inputStream);
- }
- catch (Throwable e)
- {
- log.log(Level.SEVERE,"Unable to excel ",e);
- throw new ExcelRenderingException("Cannot open xlsx workbook", e);
- }
- this.currentSheet = xwb.getSheetAt(sheet);
- isH = false;
- }
- }
-
- public Workbook getWorkbook()
- {
- if (isH)
- {
- return oldStyle;
- }
- else
- {
- return xwb;
- }
- }
-
- /**
- * Creates the cell headers
- */
- public void writeHeader(List headers)
- {
- Row row = currentSheet.createRow(0);
- int counter = 0;
- for (String item : headers)
- {
- Cell cell = row.createCell(counter);
- cell.setCellValue(item);
- counter++;
- }
- }
-
- /**
- * Fetches a sheets complete data for the given number of records
- *
- * @param sheetNumber
- * The sheet number starts at 0
- * @param start
- * How many rows to skip
- * @param records
- * The number of rows to return
- *
- * @return
- */
- public Object[][] fetchRows(int sheetNumber, int start, int records)
- {
- int totalSheetRows = getRowCount(sheetNumber) + 1;
- int totalRowColumns = getColCount(sheetNumber);
- if (records > totalSheetRows)
- {
- records = totalSheetRows;
- }
- int arraySize = records - start;
- if (arraySize == 0)
- {
- arraySize = 1;
- }
- else if (arraySize < 0)
- {
- arraySize = arraySize * -1;
- }
- Object[][] tableOut = new Object[arraySize][getColCount(sheetNumber)];
- Sheet sheet;
- if (isH)
- {
- sheet = oldStyle.getSheetAt(sheetNumber);
- }
- else
- {
- sheet = xwb.getSheetAt(sheetNumber);
- }
- int rowN = 0;
- int cellN = 0;
- int skip = 0;
- try
- {
- for (Row row : sheet)
- {
- if (skip < start)
- {
- skip++;
- continue;
- }
- cellN = 0;
- int tCs = getColCount(sheetNumber);
- for (int cn = 0; cn < tCs; cn++)
- {
- Cell cell = row.getCell(cn, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
- CellType cellType = cell.getCellType();
- switch (cellType)
- {
- case BLANK:
- {
- tableOut[rowN][cellN] = STRING_EMPTY;
- break;
- }
- case NUMERIC:
- {
- tableOut[rowN][cellN] = cell.getNumericCellValue();
- if (tableOut[rowN][cellN] instanceof Double)
- {
- Double d = (Double) tableOut[rowN][cellN];
- if (new BigDecimal(d).equals(ZERO))
- {
- tableOut[rowN][cellN] = 0;
- }
- }
- break;
- }
- case STRING:
- {
- tableOut[rowN][cellN] = cell.getStringCellValue();
- break;
- }
- case FORMULA:
- {
- FormulaEvaluator evaluator;
- if (isH)
- {
- evaluator = oldStyle.getCreationHelper()
- .createFormulaEvaluator();
- }
- else
- {
- evaluator = xwb.getCreationHelper()
- .createFormulaEvaluator();
- }
- CellValue cellValue = evaluator.evaluate(cell);
- Double valueD = cellValue.getNumberValue();
- tableOut[rowN][cellN] = valueD;
- break;
- }
- case BOOLEAN:
- {
- tableOut[rowN][cellN] = cell.getBooleanCellValue();
- break;
- }
- default:
- {
- break;
- }
- }
- cellN++;
- if (totalRowColumns == cellN)
- {
- break;
- }
- }
- rowN++;
- if (records == rowN)
- {
- break;
- }
- }
- }
- catch (ArrayIndexOutOfBoundsException e)
- {
- log.log(Level.WARNING, "Reached the end of the file before hitting the max results. logic error.", e);
- }
- catch (Exception e)
- {
- log.log(Level.WARNING, "Couldn't go through the whole excel file - ", e);
- }
- return tableOut;
- }
-
- /**
- * Returns the number of columns
- *
- * @param sheetNo
- *
- * @return
- */
- public int getColCount(int sheetNo)
- {
- Sheet sheet;
- if (isH)
- {
- sheet = oldStyle.getSheetAt(sheetNo);
- }
- else
- {
- sheet = xwb.getSheetAt(sheetNo);
- }
-
- Row row = sheet.getRow(sheetNo);
- return row.getLastCellNum();
- }
-
- public int getRowCount(int sheetNo)
- {
- if (isH)
- {
- return oldStyle.getSheetAt(sheetNo)
- .getLastRowNum() + 1;
- }
- else
- {
- return xwb.getSheetAt(sheetNo)
- .getLastRowNum() + 1;
- }
- }
-
- /**
- * Writes a row of strings to the given row number (created)
- */
- public void writeRow(int rowNumber, List headers)
- {
- Row row = currentSheet.createRow(rowNumber);
- int counter = 0;
- for (String item : headers)
- {
- Cell cell = row.createCell(counter);
- cell.setCellValue(item);
- counter++;
- }
- }
-
- /**
- * Writes data to a spreadsheet row
- */
- @SuppressWarnings("ConstantConditions")
- public void writeRow(int rowNumber, Object[] rowData)
- {
- Row row = currentSheet.createRow(rowNumber);
- int counter = 0;
- for (Object item : rowData)
- {
- Cell cell = row.createCell(counter);
- if (item == null)
- {
- item = "";
- }
- String ftype = item.getClass()
- .getName();
- if (ftype.equals("java.lang.String"))
- {
- cell.setCellValue((String) item);
- }
- else if (ftype.equals("java.lang.Boolean") || ftype.equals("boolean"))
- {
- cell.setCellValue((Boolean) item);
- }
- else if (ftype.equals("java.util.Date"))
- {
- cell.setCellValue((Date) item);
- }
- else if (ftype.equals("java.sql.Timestamp"))
- {
- Timestamp obj = (Timestamp) item;
- Date temp = new Date(obj.getTime());
- cell.setCellValue(temp);
- }
- else if (ftype.equals("int") || ftype.equals("java.lang.Integer"))
- {
- cell.setCellValue((Integer) item);
- }
- else if (ftype.equals("long") || ftype.equals("java.lang.Long") || ftype.equals("java.math.BigInteger"))
- {
- cell.setCellValue((Long) item);
- }
- else if (ftype.equals("java.math.BigDecimal"))
- {
- cell.setCellValue(((BigDecimal) item).doubleValue());
- }
- else
- {
- cell.setCellValue((Double) item);
- }
- counter++;
- }
- }
-
- public Row getRow(int rowNumber)
- {
- return currentSheet.getRow(rowNumber);
- }
-
- public Cell getCell(int rowNumber, int cellNumber)
- {
- return currentSheet.getRow(rowNumber)
- .getCell(cellNumber);
- }
-
- public byte[] get()
- {
- byte[] output = null;
- try (ByteArrayOutputStream baos = new ByteArrayOutputStream())
- {
- if (isH)
- {
- oldStyle.write(baos);
- }
- else
- {
- xwb.write(baos);
- }
- output = baos.toByteArray();
- }
- catch (Exception e)
- {
- log.log(Level.SEVERE, "Unable to get the byte array for the excel file", e);
- }
- return output;
- }
-
- @SuppressWarnings("unchecked")
- public List getRecords(String sheetName, Class type)
- {
- int sheetLocation = getWorkbook().getSheetIndex(sheetName);
- Object[][] rows = this.fetchRows(sheetLocation, 0, getRowCount(sheetLocation));
- Object[] headerRow = rows[0];
- List output = new ArrayList<>();
- Map> cells = new TreeMap<>();
- for (int i = 1; i < rows.length; i++)
- {
- //Cell
- cells.put(i, new LinkedHashMap<>());
- JSONObject rowData = new JSONObject();
- for (int j = 0; j < getColCount(sheetLocation); j++)
- {
- if (rows[i][j] instanceof BigDecimal)
- {
- rowData.put(headerRow[j].toString(), ((BigDecimal) rows[i][j]).toPlainString());
- }
- else
- {
- rowData.put(headerRow[j].toString(), rows[i][j])
- .toString();
- }
- if(rows[i][j] != null)
- {
- cells.get(i)
- .put(headerRow[j].toString(), rows[i][j].toString());
- }
- else
- {
- //end of row?
- }
- //cells.put(i, rows[i][j].toString().trim());
- }
- String outcome = rowData.toString();
- try
- {
- ObjectMapper om = GuiceContext.get(DefaultObjectMapper);
- T typed = om.readValue(outcome, type);
- output.add(typed);
- }
- catch (Exception e)
- {
- log.log(Level.SEVERE, "Unable to build an object from the references - " + outcome, e);
- }
- }
- return output;
- }
-
- @Override
- public void close() throws Exception
- {
- try
- {
- if (isH)
- {
- oldStyle.close();
- }
- else
- {
- xwb.close();
- }
-
- }
- catch (Exception e)
- {
- log.log(Level.SEVERE, "Unable to write the excel file out", e);
- }
- inputStream.close();
- }
-
-
-}
diff --git a/src/jre11/java/com/guicedee/guicedinjection/urls/JrtUrlConnection.java b/src/main/java/com/guicedee/guicedinjection/urls/JrtUrlConnection.java
similarity index 100%
rename from src/jre11/java/com/guicedee/guicedinjection/urls/JrtUrlConnection.java
rename to src/main/java/com/guicedee/guicedinjection/urls/JrtUrlConnection.java
diff --git a/src/jre11/java/com/guicedee/guicedinjection/urls/JrtUrlHandler.java b/src/main/java/com/guicedee/guicedinjection/urls/JrtUrlHandler.java
similarity index 100%
rename from src/jre11/java/com/guicedee/guicedinjection/urls/JrtUrlHandler.java
rename to src/main/java/com/guicedee/guicedinjection/urls/JrtUrlHandler.java
diff --git a/src/jre11/java/module-info.java b/src/main/java/module-info.java
similarity index 78%
rename from src/jre11/java/module-info.java
rename to src/main/java/module-info.java
index 7131fbb..f7de039 100644
--- a/src/jre11/java/module-info.java
+++ b/src/main/java/module-info.java
@@ -1,36 +1,21 @@
-import com.guicedee.guicedinjection.json.*;
-
module com.guicedee.guicedinjection {
-
requires transitive com.guicedee.client;
requires transitive com.google.guice;
requires transitive io.github.classgraph;
- requires transitive com.fasterxml.jackson.databind;
- requires transitive com.fasterxml.jackson.annotation;
- requires transitive com.fasterxml.jackson.datatype.jsr310;
//requires transitive com.guicedee.logmaster;
requires transitive org.apache.commons.lang3;
- requires transitive jakarta.xml.bind;
-
- requires static java.sql;
- requires static org.json;
- requires static org.apache.poi.ooxml;
- requires static org.apache.poi.poi;
-
- requires static java.xml;
requires static org.slf4j;
requires static lombok;
-
exports com.guicedee.guicedinjection;
- exports com.guicedee.guicedinjection.exceptions;
+ //exports com.guicedee.guicedinjection.exceptions;
exports com.guicedee.guicedinjection.abstractions;
exports com.guicedee.guicedinjection.pairing;
- exports com.guicedee.guicedinjection.json;
+ //exports com.guicedee.services.jsonrepresentation.json;
exports com.guicedee.guicedinjection.properties;
exports com.guicedee.guicedinjection.representations;
@@ -54,14 +39,13 @@
provides com.guicedee.guicedinjection.interfaces.IGuiceScanModuleExclusions with com.guicedee.guicedinjection.implementations.GuiceDefaultModuleExclusions;
provides com.guicedee.guicedinjection.interfaces.IGuiceScanJarExclusions with com.guicedee.guicedinjection.implementations.GuiceDefaultModuleExclusions;
- provides com.guicedee.guicedinjection.interfaces.IGuiceModule with com.guicedee.guicedinjection.injections.ContextBinderGuice, ObjectMapperBinder;
+ provides com.guicedee.guicedinjection.interfaces.IGuiceModule with com.guicedee.guicedinjection.injections.ContextBinderGuice;
//provides com.guicedee.guicedinjection.interfaces.IGuiceModule with com.guicedee.guicedinjection.abstractions.GuiceInjectorModule;
provides java.net.spi.URLStreamHandlerProvider with com.guicedee.guicedinjection.urls.JrtUrlHandler;
opens com.guicedee.guicedinjection to com.fasterxml.jackson.databind;
opens com.guicedee.guicedinjection.properties to com.fasterxml.jackson.databind;
- opens com.guicedee.guicedinjection.json to com.fasterxml.jackson.databind;
-
+
opens com.guicedee.guicedinjection.pairing;
}
diff --git a/src/main/resources/META-INF/services/com.guicedee.guicedinjection.interfaces.IGuiceModule b/src/main/resources/META-INF/services/com.guicedee.guicedinjection.interfaces.IGuiceModule
index e69de29..fd77f94 100644
--- a/src/main/resources/META-INF/services/com.guicedee.guicedinjection.interfaces.IGuiceModule
+++ b/src/main/resources/META-INF/services/com.guicedee.guicedinjection.interfaces.IGuiceModule
@@ -0,0 +1 @@
+com.guicedee.guicedinjection.injections.ContextBinderGuice
\ No newline at end of file
diff --git a/src/main/resources/META-INF/services/com.guicedee.guicedinjection.interfaces.IGuiceScanModuleInclusions b/src/main/resources/META-INF/services/com.guicedee.guicedinjection.interfaces.IGuiceScanModuleInclusions
index e69de29..b4ebcda 100644
--- a/src/main/resources/META-INF/services/com.guicedee.guicedinjection.interfaces.IGuiceScanModuleInclusions
+++ b/src/main/resources/META-INF/services/com.guicedee.guicedinjection.interfaces.IGuiceScanModuleInclusions
@@ -0,0 +1 @@
+com.guicedee.guicedinjection.implementations.GuiceDefaultModuleInclusions
\ No newline at end of file
diff --git a/src/test/java/com/guicedee/guicedinjection/IGuiceConfigTest.java b/src/test/java/com/guicedee/guicedinjection/IGuiceConfigTest.java
index e9ecc92..aa03d6a 100644
--- a/src/test/java/com/guicedee/guicedinjection/IGuiceConfigTest.java
+++ b/src/test/java/com/guicedee/guicedinjection/IGuiceConfigTest.java
@@ -22,7 +22,8 @@ public void testConfig()
.add(new IGuiceConfigTest());
GuiceContext.inject();
GuiceConfig config = GuiceContext.get(GuiceConfig.class);
-
+ config = GuiceContext.instance().getConfig();
+
assertTrue(config.isServiceLoadWithClassPath());
assertTrue(config.isAnnotationScanning());
assertTrue(config.isFieldInfo());
@@ -38,7 +39,6 @@ public IGuiceConfig configure(IGuiceConfig config)
{
config.setIgnoreMethodVisibility(true)
.setExcludeModulesAndJars(true)
- .setServiceLoadWithClassPath(true)
.setExcludePaths(true)
.setAllowPaths(true)
.setIncludePackages(true)
diff --git a/src/test/java/com/guicedee/guicedinjection/LocalDateTimeDeserializationTest.java b/src/test/java/com/guicedee/guicedinjection/LocalDateTimeDeserializationTest.java
deleted file mode 100644
index 604dc3d..0000000
--- a/src/test/java/com/guicedee/guicedinjection/LocalDateTimeDeserializationTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package com.guicedee.guicedinjection;
-
-import com.guicedee.guicedinjection.json.LocalDateTimeDeserializer;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-import java.io.IOException;
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
-import java.time.format.DateTimeFormatterBuilder;
-import java.time.format.DateTimeParseException;
-import java.time.format.FormatStyle;
-import java.time.temporal.ChronoField;
-
-import static com.guicedee.guicedinjection.json.LocalDateTimeDeserializer.formats;
-
-public class LocalDateTimeDeserializationTest
-{
- @Test
- public void testLdt() throws IOException
- {
-
- LocalDateTime ldt = LocalDateTime.parse("2020-05-11T04:59:20.052125", formats[4]);
- LocalDateTime ldt4 = LocalDateTime.parse("2020-05-11 04:59:20.052125", formats[4]);
- LocalDateTime ldt5 = LocalDateTime.parse("2020-05-11T07:53:52.467080", formats[4]);
- LocalDateTime ldt2 = LocalDateTime.parse("2020-05-11T04:59:20.052", formats[4]);
- LocalDateTime ldt3 = LocalDateTime.parse("2020-05-11T04:59:20.052123456", formats[4]);
- LocalDateTime ldt33 = LocalDateTime.parse("2020/05/11T04", formats[4]);
- LocalDateTime ldt43 = LocalDateTime.parse("2020/05/11T04:30", formats[4]);
- LocalDateTime ldt53 = LocalDateTime.parse("2020/05/11T04:30:00", formats[4]);
- LocalDateTime ldt73 = LocalDateTime.parse("2020/05/11 04:30", formats[4]);
- LocalDateTime ldt83 = LocalDateTime.parse("2020/05/11 04:30:00", formats[4]);
-
- LocalDateTime.parse("2020-05-11", formats[4]);
- LocalDateTime.parse("2020/05/11 04", formats[4]);
- LocalDateTime.parse("2020/05/11", formats[4]);
-
- //this must be local time -> it must fail
- Assertions.assertThrows(DateTimeParseException.class, () -> LocalDateTime.parse("04:14", formats[4]));
- Assertions.assertThrows(DateTimeParseException.class, () -> LocalDateTime.parse("04:14:20", formats[4]));
- Assertions.assertThrows(DateTimeParseException.class, () -> LocalDateTime.parse("04", formats[4]));
-
- //direct access conversion
- new LocalDateTimeDeserializer().convert("2020-05-11T04:59:20.052125");
- new LocalDateTimeDeserializer().convert("2020-05-11T07:53:52.467080");
- new LocalDateTimeDeserializer().convert("2020-05-11T04:59:20.052");
- new LocalDateTimeDeserializer().convert("2016-10-02T20:15:30-06:00");
- new LocalDateTimeDeserializer().convert("2020-05-11T04:59:20.052+01:00");
- new LocalDateTimeDeserializer().convert("2016-12-02T11:15:30-05:00");
- new LocalDateTimeDeserializer().convert("2016-12-02T11:15:30Z");
- new LocalDateTimeDeserializer().convert("2020-05-11T04:59:20.052123456");
-
- System.out.println("all parsed");
- }
-}
diff --git a/src/test/java/com/guicedee/guicedinjection/ParallelPostStartupTest1.java b/src/test/java/com/guicedee/guicedinjection/ParallelPostStartupTest1.java
new file mode 100644
index 0000000..4fc1271
--- /dev/null
+++ b/src/test/java/com/guicedee/guicedinjection/ParallelPostStartupTest1.java
@@ -0,0 +1,18 @@
+package com.guicedee.guicedinjection;
+
+import com.guicedee.guicedinjection.interfaces.IGuicePostStartup;
+
+public class ParallelPostStartupTest1 implements IGuicePostStartup
+{
+ @Override
+ public void postLoad()
+ {
+ System.out.println("Starting 1");
+ }
+
+ @Override
+ public Integer sortOrder()
+ {
+ return 200;
+ }
+}
diff --git a/src/test/java/com/guicedee/guicedinjection/ParallelPostStartupTest2.java b/src/test/java/com/guicedee/guicedinjection/ParallelPostStartupTest2.java
new file mode 100644
index 0000000..a900b44
--- /dev/null
+++ b/src/test/java/com/guicedee/guicedinjection/ParallelPostStartupTest2.java
@@ -0,0 +1,18 @@
+package com.guicedee.guicedinjection;
+
+import com.guicedee.guicedinjection.interfaces.IGuicePostStartup;
+
+public class ParallelPostStartupTest2 implements IGuicePostStartup
+{
+ @Override
+ public void postLoad()
+ {
+ System.out.println("Starting 2");
+ }
+
+ @Override
+ public Integer sortOrder()
+ {
+ return 200;
+ }
+}
diff --git a/src/test/resources/META-INF/services/com.guicedee.guicedinjection.interfaces.IGuicePostStartup b/src/test/resources/META-INF/services/com.guicedee.guicedinjection.interfaces.IGuicePostStartup
new file mode 100644
index 0000000..f480432
--- /dev/null
+++ b/src/test/resources/META-INF/services/com.guicedee.guicedinjection.interfaces.IGuicePostStartup
@@ -0,0 +1,2 @@
+com.guicedee.guicedinjection.ParallelPostStartupTest1
+com.guicedee.guicedinjection.ParallelPostStartupTest2
\ No newline at end of file
diff --git a/src/test/resources/logback.xml b/src/test/resources/logback.xml
new file mode 100644
index 0000000..d59ef06
--- /dev/null
+++ b/src/test/resources/logback.xml
@@ -0,0 +1,7 @@
+
+
+
+ %d %highlight(%-5level) [%thread] %cyan(%logger{15}): %msg%n
+
+
\ No newline at end of file