public Object[] getDataAccordingToSchema(SpreadSheetCellDAO[] dataRow) {
		if (dataRow == null) {
			return new Object[this.schemaRow.size()];
		}
		if (dataRow.length > this.schemaRow.size()) {
			LOG.warn("Data row is larger than schema. Will return String for everything that is not specified. ");
		}
		List<Object> returnList = new ArrayList<>();
		for (int i = 0; i < this.schemaRow.size(); i++) { // fill up with schema rows
			returnList.add(null);
		}
		for (int i = 0; i < dataRow.length; i++) {
			SpreadSheetCellDAO currentCell = dataRow[i];

			if (currentCell != null) {
				// determine real position
				int j = new CellAddress(currentCell.getAddress()).getColumn();
				if (j >= returnList.size()) {
					// fill up
					for (int x = returnList.size(); x <= j; x++) {
						returnList.add(null);
					}
				}
				GenericDataType applyDataType = null;
				if (j >= this.schemaRow.size()) {
					LOG.warn(
							"No further schema row for column defined: " + String.valueOf(j) + ". Will assume String.");
				} else {
					applyDataType = this.schemaRow.get(j);
				}
				if (applyDataType == null) {
					returnList.set(j, currentCell.getFormattedValue());
				} else if (applyDataType instanceof GenericStringDataType) {
					returnList.set(j, currentCell.getFormattedValue());
				} else if (applyDataType instanceof GenericBooleanDataType) {
					if (!"".equals(currentCell.getFormattedValue())) {
						if (currentCell.getFormattedValue().equalsIgnoreCase("true")
								|| currentCell.getFormattedValue().equalsIgnoreCase("false")) {
							returnList.set(j, Boolean.valueOf(currentCell.getFormattedValue()));
						}
					}
				} 
				else if (applyDataType instanceof GenericTimestampDataType) {
					if (!"".equals(currentCell.getFormattedValue())) {
						boolean timestampFound=false;
						if (this.dateTimeFormat!=null) { // check first dateTimeFormat
							Date theDate = this.dateTimeFormat.parse(currentCell.getFormattedValue(), new ParsePosition(0));
							if (theDate != null) {
								returnList.set(j, new java.sql.Timestamp(theDate.getTime()));
								timestampFound=true;
							} else {
								returnList.set(j, null);
								LOG.warn("Could not identify timestamp using Date.parse using provided dateTime format. Trying Timestamp.valueOf. Original value: "+currentCell.getFormattedValue());
							}
						} 
						if (!timestampFound) {
							try {
								returnList.set(j, java.sql.Timestamp.valueOf(currentCell.getFormattedValue()));
								timestampFound=true;
							} catch (IllegalArgumentException e) {
								returnList.set(j, null);
								LOG.warn("Could not identify timestamp using TimeStamp.valueOf. Trying last resort Date parsing. Original value: "+currentCell.getFormattedValue());
							}
						}
						if (!timestampFound) {
							Date theDate = this.dateFormat.parse(currentCell.getFormattedValue(), new ParsePosition(0));
							if (theDate != null) {
								returnList.set(j, new java.sql.Timestamp(theDate.getTime()));
	
							} else {
								returnList.set(j, null);
								LOG.warn("Could not identify timestamp using Date.parse using provided date format");
							}
						}
					
					}
				}
				else if (applyDataType instanceof GenericDateDataType) {
					if (!"".equals(currentCell.getFormattedValue())) {
						Date theDate = this.dateFormat.parse(currentCell.getFormattedValue(), new ParsePosition(0));
						
						if (theDate != null) {
							returnList.set(j, theDate);

						} else {
							returnList.set(j, null);
						}
					}
				} 

				else if (applyDataType instanceof GenericNumericDataType) {
					if (!"".equals(currentCell.getFormattedValue())) {
						BigDecimal bd = null;
						try {
							if (!"".equals(currentCell.getFormattedValue())) {
								// check scientific notation
								if (currentCell.getFormattedValue().toUpperCase().contains("E")) { // parse scientific notation
									// remove any characters that could cause issues
									String sanitizedCellContent = currentCell.getFormattedValue().replace(",", ".");
									bd = new BigDecimal(sanitizedCellContent);
								} else {
									bd = (BigDecimal) this.decimalFormat.parse(currentCell.getFormattedValue());
								}
							}
						} catch (ParseException p) {
							LOG.warn(
									"Could not parse decimal in spreadsheet cell, although type was detected as decimal");
						}
						if (bd != null) {
							BigDecimal bdv = bd.stripTrailingZeros();
							if (applyDataType instanceof GenericByteDataType) {
								returnList.set(j, (byte) bdv.byteValueExact());
							} else if (applyDataType instanceof GenericShortDataType) {
								returnList.set(j, (short) bdv.shortValueExact());
							} else if (applyDataType instanceof GenericIntegerDataType) {
								returnList.set(j, (int) bdv.intValueExact());
							} else if (applyDataType instanceof GenericLongDataType) {
								returnList.set(j, (long) bdv.longValueExact());
							} else if (applyDataType instanceof GenericDoubleDataType) {
								returnList.set(j, (double) bdv.doubleValue());
							} else if (applyDataType instanceof GenericFloatDataType) {
								returnList.set(j, (float) bdv.floatValue());
							} else if (applyDataType instanceof GenericBigDecimalDataType) {
								returnList.set(j, bd);
							} else {
								returnList.set(j, null);
							}
						}
					}
				} else {
					returnList.set(j, null);
					LOG.warn("Could not convert object in spreadsheet cellrow. Did you add a new datatype?");
				}
			}
		}
		Object[] result = new Object[returnList.size()];
		returnList.toArray(result);
		return result;
	}
public Object [ ] getDataAccordingToSchema ( SpreadSheetCellDAO [ ] dataRow ) { if ( dataRow == null ) { return new Object [ this . schemaRow . size ( ) ] ; } if ( dataRow . length > this . schemaRow . size ( ) ) { LOG . warn ( "Data row is larger than schema. Will return String for everything that is not specified. " ) ; } List < Object > returnList = new ArrayList < > ( ) ; for ( int i = 0 ; i < this . schemaRow . size ( ) ; i ++ ) { returnList . add ( null ) ; } for ( int i = 0 ; i < dataRow . length ; i ++ ) { SpreadSheetCellDAO currentCell = dataRow [ i ] ; if ( currentCell != null ) { int j = new CellAddress ( currentCell . getAddress ( ) ) . getColumn ( ) ; if ( j >= returnList . size ( ) ) { for ( int x = returnList . size ( ) ; x <= j ; x ++ ) { returnList . add ( null ) ; } } GenericDataType applyDataType = null ; if ( j >= this . schemaRow . size ( ) ) { LOG . warn ( "No further schema row for column defined: " + String . valueOf ( j ) + ". Will assume String." ) ; } else { applyDataType = this . schemaRow . get ( j ) ; } if ( applyDataType == null ) { returnList . set ( j , currentCell . getFormattedValue ( ) ) ; } else if ( applyDataType instanceof GenericStringDataType ) { returnList . set ( j , currentCell . getFormattedValue ( ) ) ; } else if ( applyDataType instanceof GenericBooleanDataType ) { if ( ! "" . equals ( currentCell . getFormattedValue ( ) ) ) { if ( currentCell . getFormattedValue ( ) . equalsIgnoreCase ( "true" ) || currentCell . getFormattedValue ( ) . equalsIgnoreCase ( "false" ) ) { returnList . set ( j , Boolean . valueOf ( currentCell . getFormattedValue ( ) ) ) ; } } } else if ( applyDataType instanceof GenericTimestampDataType ) { if ( ! "" . equals ( currentCell . getFormattedValue ( ) ) ) { boolean timestampFound = false ; if ( this . dateTimeFormat != null ) { Date theDate = this . dateTimeFormat . parse ( currentCell . getFormattedValue ( ) , new ParsePosition ( 0 ) ) ; if ( theDate != null ) { returnList . set ( j , new java . sql . Timestamp ( theDate . getTime ( ) ) ) ; timestampFound = true ; } else { returnList . set ( j , null ) ; LOG . warn ( "Could not identify timestamp using Date.parse using provided dateTime format. Trying Timestamp.valueOf. Original value: " + currentCell . getFormattedValue ( ) ) ; } } if ( ! timestampFound ) { try { returnList . set ( j , java . sql . Timestamp . valueOf ( currentCell . getFormattedValue ( ) ) ) ; timestampFound = true ; } catch ( IllegalArgumentException e ) { returnList . set ( j , null ) ; LOG . warn ( "Could not identify timestamp using TimeStamp.valueOf. Trying last resort Date parsing. Original value: " + currentCell . getFormattedValue ( ) ) ; } } if ( ! timestampFound ) { Date theDate = this . dateFormat . parse ( currentCell . getFormattedValue ( ) , new ParsePosition ( 0 ) ) ; if ( theDate != null ) { returnList . set ( j , new java . sql . Timestamp ( theDate . getTime ( ) ) ) ; } else { returnList . set ( j , null ) ; LOG . warn ( "Could not identify timestamp using Date.parse using provided date format" ) ; } } } } else if ( applyDataType instanceof GenericDateDataType ) { if ( ! "" . equals ( currentCell . getFormattedValue ( ) ) ) { Date theDate = this . dateFormat . parse ( currentCell . getFormattedValue ( ) , new ParsePosition ( 0 ) ) ; if ( theDate != null ) { returnList . set ( j , theDate ) ; } else { returnList . set ( j , null ) ; } } } else if ( applyDataType instanceof GenericNumericDataType ) { if ( ! "" . equals ( currentCell . getFormattedValue ( ) ) ) { BigDecimal bd = null ; try { if ( ! "" . equals ( currentCell . getFormattedValue ( ) ) ) { if ( currentCell . getFormattedValue ( ) . toUpperCase ( ) . contains ( "E" ) ) { String sanitizedCellContent = currentCell . getFormattedValue ( ) . replace ( "," , "." ) ; bd = new BigDecimal ( sanitizedCellContent ) ; } else { bd = ( BigDecimal ) this . decimalFormat . parse ( currentCell . getFormattedValue ( ) ) ; } } } catch ( ParseException p ) { LOG . warn ( "Could not parse decimal in spreadsheet cell, although type was detected as decimal" ) ; } if ( bd != null ) { BigDecimal bdv = bd . stripTrailingZeros ( ) ; if ( applyDataType instanceof GenericByteDataType ) { returnList . set ( j , ( byte ) bdv . byteValueExact ( ) ) ; } else if ( applyDataType instanceof GenericShortDataType ) { returnList . set ( j , ( short ) bdv . shortValueExact ( ) ) ; } else if ( applyDataType instanceof GenericIntegerDataType ) { returnList . set ( j , ( int ) bdv . intValueExact ( ) ) ; } else if ( applyDataType instanceof GenericLongDataType ) { returnList . set ( j , ( long ) bdv . longValueExact ( ) ) ; } else if ( applyDataType instanceof GenericDoubleDataType ) { returnList . set ( j , ( double ) bdv . doubleValue ( ) ) ; } else if ( applyDataType instanceof GenericFloatDataType ) { returnList . set ( j , ( float ) bdv . floatValue ( ) ) ; } else if ( applyDataType instanceof GenericBigDecimalDataType ) { returnList . set ( j , bd ) ; } else { returnList . set ( j , null ) ; } } } } else { returnList . set ( j , null ) ; LOG . warn ( "Could not convert object in spreadsheet cellrow. Did you add a new datatype?" ) ; } } } Object [ ] result = new Object [ returnList . size ( ) ] ; returnList . toArray ( result ) ; return result ; }
Translate a data row according to the currently defined schema.

@param dataRow cells containing data
@return an array of objects of primitive datatypes (boolean, int, byte, etc.)
containing the data of datarow, null if dataRow does not fit into
schema. Note: single elements can be null depending on the original
Excel