From 30fbc6d290c667d4bdef1a2ddc83cd36c7880218 Mon Sep 17 00:00:00 2001 From: Douglas Gillespie <50671166+douggillespie@users.noreply.github.com> Date: Thu, 6 Apr 2023 21:43:20 +0100 Subject: [PATCH] Database float unpack Better unpacking checks of floats coming back from the database --- .../fileprocessing/ReprocessStoreChoice.java | 2 +- src/generalDatabase/PamTableItem.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/PamController/fileprocessing/ReprocessStoreChoice.java b/src/PamController/fileprocessing/ReprocessStoreChoice.java index 0a6835db..6a6bd019 100644 --- a/src/PamController/fileprocessing/ReprocessStoreChoice.java +++ b/src/PamController/fileprocessing/ReprocessStoreChoice.java @@ -16,7 +16,7 @@ public enum ReprocessStoreChoice { public String toString() { switch (this) { case STARTNORMAL: - return "Start normally. No risk of overwriting"; + return "Start normally. Note risk of overwriting!"; case CONTINUECURRENTFILE: return "Continue from start of last input file processed"; case CONTINUENEXTFILE: diff --git a/src/generalDatabase/PamTableItem.java b/src/generalDatabase/PamTableItem.java index e329cc9e..2a046623 100644 --- a/src/generalDatabase/PamTableItem.java +++ b/src/generalDatabase/PamTableItem.java @@ -488,6 +488,15 @@ public class PamTableItem implements Cloneable { if (value == null) { return Float.NaN; } + if (value instanceof String) { + try { + double val = Double.valueOf((String) value); + return (float) val; + } + catch (NumberFormatException ex) { + return Float.NaN; + } + } if (value.getClass() == Double.class) { double dVal = (Double) value; return (float) dVal;