private String trimMoney(String s) { if (s == null) { return null; } // if we don't have at least 2 characters it can't be money. if (s.length() < 2) { return s; } // Handle Money char ch = s.charAt(0); // optimise for non-money type: return immediately with one check // if the first char cannot be '(', '$' or '-' if (ch > '-') { return s; } if (ch == '(') { s = "-" + PGtokenizer.removePara(s).substring(1); } else if (ch == '$') { s = s.substring(1); } else if (ch == '-' && s.charAt(1) == '$') { s = "-" + s.substring(2); } return s; }
public void setValue(String s) throws SQLException { try { String s1; boolean negative; negative = (s.charAt(0) == '('); // Remove any () (for negative) & currency symbol s1 = PGtokenizer.removePara(s).substring(1); // Strip out any , in currency int pos = s1.indexOf(','); while (pos != -1) { s1 = s1.substring(0, pos) + s1.substring(pos + 1); pos = s1.indexOf(','); } val = Double.parseDouble(s1); val = negative ? -val : val; } catch (NumberFormatException e) { throw new PSQLException(GT.tr("Conversion of money failed."), PSQLState.NUMERIC_CONSTANT_OUT_OF_RANGE, e); } }
s = "-" + PGtokenizer.removePara(s).substring(1);
public void setValue(String s) throws SQLException { try { String s1; boolean negative; negative = (s.charAt(0) == '(') ; // Remove any () (for negative) & currency symbol s1 = PGtokenizer.removePara(s).substring(1); // Strip out any , in currency int pos = s1.indexOf(','); while (pos != -1) { s1 = s1.substring(0, pos) + s1.substring(pos + 1); pos = s1.indexOf(','); } val = Double.valueOf(s1).doubleValue(); val = negative ? -val : val; } catch (NumberFormatException e) { throw new PSQLException(GT.tr("Conversion of money failed."), PSQLState.NUMERIC_CONSTANT_OUT_OF_RANGE, e); } }
/** * @param s Definition of this point in PostgreSQL's syntax * @exception SQLException on conversion failure */ public void setValue(String s) throws SQLException { PGtokenizer t = new PGtokenizer(PGtokenizer.removePara(s), ','); try { x = Double.valueOf(t.getToken(0)).doubleValue(); y = Double.valueOf(t.getToken(1)).doubleValue(); } catch (NumberFormatException e) { throw new PSQLException(GT.tr("Conversion to type {0} failed: {1}.", new Object[]{type,s}), PSQLState.DATA_TYPE_MISMATCH, e); } }
/** * @param s Definition of this point in PostgreSQL's syntax * @throws SQLException on conversion failure */ @Override public void setValue(String s) throws SQLException { PGtokenizer t = new PGtokenizer(PGtokenizer.removePara(s), ','); try { x = Double.parseDouble(t.getToken(0)); y = Double.parseDouble(t.getToken(1)); } catch (NumberFormatException e) { throw new PSQLException(GT.tr("Conversion to type {0} failed: {1}.", type, s), PSQLState.DATA_TYPE_MISMATCH, e); } }
/** * @param s Definition of the polygon in PostgreSQL's syntax * @throws SQLException on conversion failure */ public void setValue(String s) throws SQLException { PGtokenizer t = new PGtokenizer(PGtokenizer.removePara(s), ','); int npoints = t.getSize(); points = new PGpoint[npoints]; for (int p = 0; p < npoints; p++) { points[p] = new PGpoint(t.getToken(p)); } }
/** * @param s Definition of the path in PostgreSQL's syntax * @throws SQLException on conversion failure */ public void setValue(String s) throws SQLException { // First test to see if were open if (s.startsWith("[") && s.endsWith("]")) { open = true; s = PGtokenizer.removeBox(s); } else if (s.startsWith("(") && s.endsWith(")")) { open = false; s = PGtokenizer.removePara(s); } else { throw new PSQLException(GT.tr("Cannot tell if path is open or closed: {0}.", s), PSQLState.DATA_TYPE_MISMATCH); } PGtokenizer t = new PGtokenizer(s, ','); int npoints = t.getSize(); points = new PGpoint[npoints]; for (int p = 0; p < npoints; p++) { points[p] = new PGpoint(t.getToken(p)); } }
/** * @param s Definition of the polygon in PostgreSQL's syntax * @exception SQLException on conversion failure */ public void setValue(String s) throws SQLException { PGtokenizer t = new PGtokenizer(PGtokenizer.removePara(s), ','); int npoints = t.getSize(); points = new PGpoint[npoints]; for (int p = 0;p < npoints;p++) points[p] = new PGpoint(t.getToken(p)); }
/** * @param s Definition of the path in PostgreSQL's syntax * @exception SQLException on conversion failure */ public void setValue(String s) throws SQLException { // First test to see if were open if (s.startsWith("[") && s.endsWith("]")) { open = true; s = PGtokenizer.removeBox(s); } else if (s.startsWith("(") && s.endsWith(")")) { open = false; s = PGtokenizer.removePara(s); } else throw new PSQLException(GT.tr("Cannot tell if path is open or closed: {0}.", s), PSQLState.DATA_TYPE_MISMATCH); PGtokenizer t = new PGtokenizer(s, ','); int npoints = t.getSize(); points = new PGpoint[npoints]; for (int p = 0;p < npoints;p++) points[p] = new PGpoint(t.getToken(p)); }
s = "-" + PGtokenizer.removePara(s).substring(1);
public void setValue(String s) throws SQLException { try { String s1; boolean negative; negative = (s.charAt(0) == '(') ; // Remove any () (for negative) & currency symbol s1 = PGtokenizer.removePara(s).substring(1); // Strip out any , in currency int pos = s1.indexOf(','); while (pos != -1) { s1 = s1.substring(0, pos) + s1.substring(pos + 1); pos = s1.indexOf(','); } val = Double.valueOf(s1).doubleValue(); val = negative ? -val : val; } catch (NumberFormatException e) { throw new PSQLException(GT.tr("Conversion of money failed."), PSQLState.NUMERIC_CONSTANT_OUT_OF_RANGE, e); } }
s = "-" + PGtokenizer.removePara(s).substring(1);
public void setValue(String s) throws SQLException { try { String s1; boolean negative; negative = (s.charAt(0) == '(') ; // Remove any () (for negative) & currency symbol s1 = PGtokenizer.removePara(s).substring(1); // Strip out any , in currency int pos = s1.indexOf(','); while (pos != -1) { s1 = s1.substring(0, pos) + s1.substring(pos + 1); pos = s1.indexOf(','); } val = Double.valueOf(s1).doubleValue(); val = negative ? -val : val; } catch (NumberFormatException e) { throw new PSQLException(GT.tr("Conversion of money failed."), PSQLState.NUMERIC_CONSTANT_OUT_OF_RANGE, e); } }
/** * @param s Definition of this point in PostgreSQL's syntax * @exception SQLException on conversion failure */ public void setValue(String s) throws SQLException { PGtokenizer t = new PGtokenizer(PGtokenizer.removePara(s), ','); try { x = Double.valueOf(t.getToken(0)).doubleValue(); y = Double.valueOf(t.getToken(1)).doubleValue(); } catch (NumberFormatException e) { throw new PSQLException(GT.tr("Conversion to type {0} failed: {1}.", new Object[]{type,s}), PSQLState.DATA_TYPE_MISMATCH, e); } }
/** * @param s Definition of this point in PostgreSQL's syntax * @exception SQLException on conversion failure */ public void setValue(String s) throws SQLException { PGtokenizer t = new PGtokenizer(PGtokenizer.removePara(s), ','); try { x = Double.valueOf(t.getToken(0)).doubleValue(); y = Double.valueOf(t.getToken(1)).doubleValue(); } catch (NumberFormatException e) { throw new PSQLException(GT.tr("Conversion to type {0} failed: {1}.", new Object[]{type,s}), PSQLState.DATA_TYPE_MISMATCH, e); } }
/** * @param s Definition of the polygon in PostgreSQL's syntax * @exception SQLException on conversion failure */ public void setValue(String s) throws SQLException { PGtokenizer t = new PGtokenizer(PGtokenizer.removePara(s), ','); int npoints = t.getSize(); points = new PGpoint[npoints]; for (int p = 0;p < npoints;p++) points[p] = new PGpoint(t.getToken(p)); }
/** * @param s Definition of the polygon in PostgreSQL's syntax * @exception SQLException on conversion failure */ public void setValue(String s) throws SQLException { PGtokenizer t = new PGtokenizer(PGtokenizer.removePara(s), ','); int npoints = t.getSize(); points = new PGpoint[npoints]; for (int p = 0;p < npoints;p++) points[p] = new PGpoint(t.getToken(p)); }
/** * @param s Definition of the path in PostgreSQL's syntax * @exception SQLException on conversion failure */ public void setValue(String s) throws SQLException { // First test to see if were open if (s.startsWith("[") && s.endsWith("]")) { open = true; s = PGtokenizer.removeBox(s); } else if (s.startsWith("(") && s.endsWith(")")) { open = false; s = PGtokenizer.removePara(s); } else throw new PSQLException(GT.tr("Cannot tell if path is open or closed: {0}.", s), PSQLState.DATA_TYPE_MISMATCH); PGtokenizer t = new PGtokenizer(s, ','); int npoints = t.getSize(); points = new PGpoint[npoints]; for (int p = 0;p < npoints;p++) points[p] = new PGpoint(t.getToken(p)); }
/** * @param s Definition of the path in PostgreSQL's syntax * @exception SQLException on conversion failure */ public void setValue(String s) throws SQLException { // First test to see if were open if (s.startsWith("[") && s.endsWith("]")) { open = true; s = PGtokenizer.removeBox(s); } else if (s.startsWith("(") && s.endsWith(")")) { open = false; s = PGtokenizer.removePara(s); } else throw new PSQLException(GT.tr("Cannot tell if path is open or closed: {0}.", s), PSQLState.DATA_TYPE_MISMATCH); PGtokenizer t = new PGtokenizer(s, ','); int npoints = t.getSize(); points = new PGpoint[npoints]; for (int p = 0;p < npoints;p++) points[p] = new PGpoint(t.getToken(p)); }