Example usage for java.lang NumberFormatException toString

List of usage examples for java.lang NumberFormatException toString

Introduction

In this page you can find the example usage for java.lang NumberFormatException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:no.abmu.questionnaire.domain.data.BigDecimalFieldData.java

@Transient
private void setValueAsString(String value) {
    //        logger.debug("Executing setValueAsString as String code=[" +  getCode() + "] value=[" + value + "]");
    if (value == null) {
        if (this.bigDecimalValue != null) {
            this.bigDecimalValue = null;
        }/*from  w w  w .  j a  va 2  s.co  m*/
        return;
    }
    String trimmedStringValue = value.trim();
    if (trimmedStringValue.isEmpty()) {
        if (this.bigDecimalValue != null) {
            this.bigDecimalValue = null;
        }
        return;
    }

    if (trimmedStringValue.contains(".")) {
        throw new NumberFormatException("Not valid number, use ',' not '.'");
    }

    DecimalFormat formatter = getNumberFormat();

    BigDecimal newBigDecimal;
    try {
        newBigDecimal = (BigDecimal) formatter.parse(trimmedStringValue);
    } catch (NumberFormatException e) {
        logger.error("Error on converting string value=[" + value + "]", e);
        throw new NumberFormatException(e.toString());
    } catch (ParseException e) {
        logger.error("Error on converting string value=[" + value + "]", e);
        throw new NumberFormatException(e.toString());
    }
    setBigDecimalValue(bigDecimalWithCorrectScaling(newBigDecimal));
}

From source file:com.orange.datavenue.StreamDetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.stream_detail_fragment_layout, container, false);

    getActivity().setTitle(R.string.stream);
    final LinearLayout callbackLayout = (LinearLayout) view.findViewById(R.id.callback_layout);
    final TextView id = (TextView) view.findViewById(R.id.id);
    final EditText name = (EditText) view.findViewById(R.id.name);
    final EditText description = (EditText) view.findViewById(R.id.description);
    final EditText unit = (EditText) view.findViewById(R.id.unit);
    final EditText symbol = (EditText) view.findViewById(R.id.symbol);
    final EditText callback = (EditText) view.findViewById(R.id.callback);
    final EditText latitude = (EditText) view.findViewById(R.id.latitude);
    final EditText longitude = (EditText) view.findViewById(R.id.longitude);
    final TextView created = (TextView) view.findViewById(R.id.created);
    final TextView updated = (TextView) view.findViewById(R.id.updated);

    /**//  w  w  w  .ja v  a 2  s  .co m
     * Set fields with current data
     */
    id.setText(Model.instance.currentStream.getId());
    name.setText(Model.instance.currentStream.getName());
    description.setText(Model.instance.currentStream.getDescription());
    if (Model.instance.currentStream.getUnit() != null) {
        unit.setText(Model.instance.currentStream.getUnit().getName());
        symbol.setText(Model.instance.currentStream.getUnit().getSymbol());
    }

    if (Model.instance.currentStream.getCallback() != null) {
        callback.setText(Model.instance.currentStream.getCallback().getUrl().toString());
    }

    if (Model.instance.currentStream.getLocation() != null) {
        if (Model.instance.currentStream.getLocation().length >= 2) {
            latitude.setText("" + Model.instance.currentStream.getLocation()[0]);
            longitude.setText("" + Model.instance.currentStream.getLocation()[1]);
        }
    }

    created.setText(Model.instance.currentStream.getCreated());
    updated.setText(Model.instance.currentStream.getUpdated());

    Button actionButton = (Button) view.findViewById(R.id.update_button);

    actionButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Log.d(TAG_NAME, "name : " + name.getText().toString());
            Log.d(TAG_NAME, "description : " + description.getText().toString());

            Stream newStream = new Stream();

            /**
             * update fields with no value will be deleted !
             */
            newStream.setId(Model.instance.currentStream.getId()); // set the previous ID
            newStream.setName(name.getText().toString());
            newStream.setDescription(description.getText().toString());

            /**
             * Allocate new Location
             */
            Double[] location = null;

            String strLatitude = latitude.getText().toString();
            String strLongitude = longitude.getText().toString();

            try {
                if ((!"".equals(strLatitude)) && (!"".equals(strLongitude))) {
                    location = new Double[2];
                    location[0] = Double.parseDouble(strLatitude);
                    location[1] = Double.parseDouble(strLongitude);
                }
            } catch (NumberFormatException e) {
                Log.e(TAG_NAME, e.toString());
                location = null;
            }

            if (location != null) {
                newStream.setLocation(location);
            }

            /**
             * Allocate new Unit & Symbol
             */
            Unit newUnit = null;
            String strUnit = unit.getText().toString();
            String strSymbol = symbol.getText().toString();

            if (!"".equals(strUnit)) {
                if (newUnit == null) {
                    newUnit = new Unit();
                }
                newUnit.setName(strUnit);
            }

            if (!"".equals(strSymbol)) {
                if (newUnit == null) {
                    newUnit = new Unit();
                }
                newUnit.setSymbol(strSymbol);
            }

            if (newUnit != null) {
                newStream.setUnit(newUnit);
            }

            /**
             * Allocate new Callback
             */
            Callback newCallback = null;
            String callbackUrl = callback.getText().toString();

            if (!"".equals(callbackUrl)) {
                try {
                    URL url = new URL(callbackUrl);
                    newCallback = new Callback();
                    newCallback.setUrl(url.toString());
                    newCallback.setName("Callback");
                    newCallback.setDescription("application callback");
                    newCallback.setStatus("activated");
                } catch (MalformedURLException e) {
                    Log.e(TAG_NAME, e.toString());
                    callback.setText("");
                }
            }

            if (newCallback != null) {
                newStream.setCallback(newCallback);
            }

            UpdateStreamOperation updateStreamOperation = new UpdateStreamOperation(Model.instance.oapiKey,
                    Model.instance.key, Model.instance.currentDatasource, newStream, new OperationCallback() {
                        @Override
                        public void process(Object object, Exception exception) {
                            if (exception == null) {
                                Model.instance.currentStream = (Stream) object; // update current Datasource
                            } else {
                                Errors.displayError(getActivity(), exception);
                            }
                        }
                    });

            updateStreamOperation.execute("");
        }
    });

    Button valueButton = (Button) view.findViewById(R.id.value_button);

    valueButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getActivity(), ValueActivity.class);
            startActivity(intent);
        }
    });

    return view;
}

From source file:org.warlock.spine.connection.Transmitter.java

@Override
public void run() {
    ConnectionManager c = ConnectionManager.getInstance();
    if (!sendable.recordTry()) {
        if (sendable.getMessageId() != null) {
            c.removeRequest(sendable.getMessageId());
            sendable.expire();//  www.  j  av a2s  .  c o m
        }
        return;
    }

    SpineSecurityContext tlsContext = c.getSecurityContext();
    //        SSLSocketFactory sf = tlsContext.getSocketFactory();
    String h = sendable.getResolvedUrl();
    String host = null;
    int port = 443;
    try {
        if (h == null) {
            // Retry of persisted reliable message from previous MHS session
            //
            host = ((org.warlock.spine.messaging.EbXmlMessage) sendable).getHost();
        } else {
            sendable.persist();
            URL u = new URL(h);
            host = u.getHost();
            port = (u.getPort() == -1) ? u.getDefaultPort() : u.getPort();
        }
        //Override host and port when using Proxy
        String proxyhost = System.getProperty(PROXYHOST);
        if (proxyhost != null && (proxyhost.trim().length() != 0)) {
            host = proxyhost;
        }
        String p = System.getProperty(PROXYPORT);
        if ((p != null) && (p.trim().length() != 0)) {
            try {
                int proxyport = Integer.parseInt(p);
                port = proxyport;
            } catch (NumberFormatException e) {
                System.err.println("Asynchronous wait period not a valid integer - " + e.toString());
            }
        }
        try (Socket s = tlsContext.createSocket(host, port)) {
            int replyLength = -1;
            SessionCaptor sc = c.getSessionCaptor();
            if (sc == null) {
                sendable.write(s.getOutputStream());
                replyLength = getHeader(s.getInputStream());
                if (replyLength == -1) {
                    SpineToolsLogger.getInstance().log("org.warlock.spine.connection.Transmitter.noResponse",
                            "Could not read response sending " + sendable.getMessageId());
                    s.close();
                    return;
                }
                if (replyLength > 0)
                    readSynchronousReply(s.getInputStream(), replyLength);
            } else {
                ByteArrayOutputStream outStream = new ByteArrayOutputStream();
                TeeOutputStream tos = new TeeOutputStream(s.getOutputStream(), outStream);
                sendable.write(tos);
                sendable.setOnTheWireRequest(outStream.toByteArray());
                ByteArrayOutputStream inStream = new ByteArrayOutputStream();
                TeeInputStream tis = new TeeInputStream(s.getInputStream(), inStream);
                replyLength = getHeader(tis);
                if (replyLength == -1) {
                    SpineToolsLogger.getInstance().log("org.warlock.spine.connection.Transmitter.noResponse",
                            "Could not read response sending " + sendable.getMessageId());
                    s.close();
                    sc.capture(sendable);
                    return;
                }
                if (replyLength > 0) {
                    readSynchronousReply(tis, replyLength);
                    sendable.setOnTheWireResponse(inStream.toByteArray());
                }
                sc.capture(sendable);
            }
        }
        if (sendable.getType() == Sendable.SOAP) {
            if (sendable.getSynchronousResponse() == null) {
                SpineToolsLogger.getInstance().log(
                        "org.warlock.spine.connection.Transmitter.noResponseReceived",
                        "No response to " + sendable.getMessageId());
                return;
            }
            SynchronousResponseHandler handler = c.getSynchronousResponseHandler(sendable.getSoapAction());
            handler.handle((SpineSOAPRequest) sendable);
            return;
        }
        if (sendable.getMessageId() != null) { // Don't do this for asynchronous acks
            if (sendable.getSynchronousResponse() != null) {
                if ((responseHeader != null) && (responseHeader.contains("HTTP 5"))) {
                    SpineToolsLogger.getInstance().log(
                            "org.warlock.spine.connection.Transmitter.HTTP500received",
                            "HTTP 500 received sending " + sendable.getMessageId());
                    c.removeRequest(sendable.getMessageId());

                } else {
                    if (sendable.getSynchronousResponse().contains(sendable.getMessageId())) {
                        c.registerAck(sendable.getMessageId());
                    }
                    if (sendable.getSynchronousResponse().contains("Bad request")) {
                        c.registerAck(sendable.getMessageId());
                        SpineToolsLogger.getInstance().log(
                                "org.warlock.spine.connection.Transmitter.HTTP500received",
                                "Bad request received sending " + sendable.getMessageId());
                    }
                }
            }
        }
    } catch (Exception eIo) {
        SpineToolsLogger.getInstance().log("org.warlock.spine.connection.Transmitter.IOException",
                "IOException sending " + sendable.getMessageId() + eIo.getMessage());
    }
}

From source file:us.mn.state.health.lims.result.action.ResultUpdateAction.java

protected ActionMessages validateAll(HttpServletRequest request, ActionMessages errors, BaseActionForm dynaForm)
        throws Exception {

    // validate for result D -> value must be dictionary ID
    String resultType = (String) dynaForm.get("resultType");

    if (resultType.equals("D")) {
        String val = (String) dynaForm.get("value");
        String messageKey = "result.value";
        try {// w  w w  . j a  va  2s. co  m
            Integer.parseInt(val);

            Dictionary dictionary = new Dictionary();
            dictionary.setId(val);
            DictionaryDAO dictDAO = new DictionaryDAOImpl();
            List dictionarys = dictDAO.getAllDictionarys();

            boolean found = false;
            for (int i = 0; i < dictionarys.size(); i++) {
                Dictionary d = (Dictionary) dictionarys.get(i);
                if (dictionary.getId().equals(d.getId())) {
                    found = true;
                }
            }

            if (!found) {
                ActionError error = new ActionError("errors.invalid", getMessageForKey(messageKey), null);
                errors.add(ActionMessages.GLOBAL_MESSAGE, error);
            }
        } catch (NumberFormatException nfe) {
            //bugzilla 2154
            LogEvent.logError("ResultUpdateAction", "performAction()", nfe.toString());
            ActionError error = new ActionError("errors.invalid", getMessageForKey(messageKey), null);
            errors.add(ActionMessages.GLOBAL_MESSAGE, error);
        }
    }

    return errors;
}

From source file:org.hyperic.hq.plugin.sybase.SybaseSysmonCollector.java

public void collect() {
    Properties props = getProperties();
    log.debug("[collect] props=" + props);

    try {/*  w w w. j  a va  2s .co m*/
        setAvailability(Metric.AVAIL_DOWN);
        if (conn == null) {
            conn = createConnection(props);
        }
        stmt = conn.prepareCall("{call sp_sysmon '" + props.getProperty(INTERVAL) + "'}");
        stmt.executeUpdate();

        StringBuffer response = new StringBuffer();
        SQLWarning war = stmt.getWarnings();
        do {
            response.append(war.getMessage()).append("\n");
            war = war.getNextWarning();
        } while (war != null);
        trace.debug(response);

        String res = response.toString();

        Pattern pat = Pattern.compile("\n +Cache:(.*)\n");
        Matcher m = pat.matcher(res);
        while (m.find()) {
            final String cacheName = m.group(1).trim().replaceAll(" ", "_");
            if (trace.isDebugEnabled()) {
                trace.debug("->'" + cacheName + "'");
                trace.debug("->" + m.start());
            }
            String sec = res.substring(m.start());
            setValue(cacheName + ".Availability", Metric.AVAIL_UP);
            setValue(cacheName + ".CacheHitsRatio", get(sec, "Cache Hits", 5) / 100);
            setValue(cacheName + ".CacheMissesRatio", get(sec, "Cache Misses", 5) / 100);
        }

        // output per engine:
        // Engine 0                        0.0 %      0.0 %    100.0 %
        //
        // regex should only find lines starting with "Engine X                        X.X %"
        // engineid and percentage are in regex groups 1 and 2
        pat = Pattern.compile("\n +Engine (\\d)+\\s+(\\d+\\.\\d+) %.*");
        m = pat.matcher(res);
        while (m.find()) {
            try {
                final String engineId = m.group(1);
                final String cpuBusyVal = m.group(2);
                if (engineId != null && cpuBusyVal != null) {
                    setValue("EngineUtilization" + engineId.trim(),
                            Double.parseDouble(cpuBusyVal.trim()) / 100);
                }
                if (trace.isDebugEnabled()) {
                    trace.debug("Found Engine Utilization for engineid=" + engineId.trim() + " with value "
                            + Double.parseDouble(cpuBusyVal.trim()) / 100);
                }
            } catch (NumberFormatException e) {
                if (trace.isDebugEnabled()) {
                    trace.debug("Unable to parse number from: " + e.toString());
                }
            } catch (IndexOutOfBoundsException e) {
                if (trace.isDebugEnabled()) {
                    trace.debug("Unable to find group from matcher: " + e.toString());
                }
            }
        }

        setValue("Deadlocks", get(res, "Deadlock Percentage", 5));
        setValue("TotalLockReqs", get(res, "Total Lock Requests", 5));
        setValue("AvgLockContention", get(res, "Avg Lock Contention", 5));
        setValue("TotalCacheHitsRatio", get(res, "Total Cache Hits", 6) / 100);
        setValue("TotalCacheMissesRatio", get(res, "Total Cache Misses", 6) / 100);
        setValue("TDSPacketsReceived", get(res, "Total TDS Packets Rec'd", 6) / 100);
        setValue("TDSPacketsSent", get(res, "Total Bytes Rec'd", 5) / 100);
        setAvailability(Metric.AVAIL_UP);

    } catch (SQLException e) {
        setValue("Availability", Metric.AVAIL_DOWN);
        log.debug("[collect] Error " + e.getMessage());
        log.debug("[collect] Error " + getResult().toString());
        if (conn != null) {
            DBUtil.closeJDBCObjects(log, conn, null, null);
            conn = null;
        }
    } finally {
        if (conn != null) {
            DBUtil.closeJDBCObjects(log, null, stmt, null);
        }
    }

}

From source file:netcap.JcaptureConfiguration.java

/**
 * ??//w  w w  .  j a va  2 s  .  c  om
 */
private void saveConfiguration() {
    try {
        int caplen = Integer.parseInt(caplenTextField.getText());
        if (caplen < 68 || caplen > 1514) {
            ViewModules.showMessageDialog(null, "? 68  1514");
            return;
        }
        NetworkInterface netInter = devices[netJComboBox.getSelectedIndex()];
        boolean isPromisc = checkBox.isSelected();
        jpcap = JpcapCaptor.openDevice(netInter, caplen, isPromisc, 50);
        if (!TextUtils.isEmpty(proFilterField.getText()))
            jpcap.setFilter(proFilterField.getText(), true);
        if (!TextUtils.isEmpty(domainFilterField.getText()))
            domain = domainFilterField.getText().trim();
    } catch (NumberFormatException e) {
        ViewModules.showMessageDialog(null, "?");
    } catch (java.io.IOException e) {
        ViewModules.showMessageDialog(null, e.toString());
        jpcap = null;
    } finally {
        dispose();
    }
}

From source file:com.hijacker.SendLogActivity.java

public void stopAll() {
    ArrayList<Integer> pids = new ArrayList<>();
    String processes[] = { "airodump-ng", "aireplay-ng", "aircrack-ng", "mdk3", "reaver", "reaver-wash" };
    String cmd = busybox + " pidof";
    for (String process_name : processes) {
        cmd += ' ' + process_name;
    }/*from  w  ww  .jav a  2  s  . c om*/
    cmd += "; echo ENDOFPIDOF\n";
    shell_in.print(cmd);
    shell_in.flush();
    String buffer = null;
    try {
        while (buffer == null)
            buffer = shell_out.readLine();
        while (!buffer.equals("ENDOFPIDOF")) {
            String[] temp = buffer.split(" ");
            try {
                for (String tmp : temp) {
                    pids.add(Integer.parseInt(tmp));
                }
            } catch (NumberFormatException e) {
                Log.e("HIJACKER/SendLog", "Exception: " + e.toString());
            }
            buffer = shell_out.readLine();
        }
    } catch (IOException e) {
        Log.e("HIJACKER/SendLog", "Exception: " + e.toString());
    }
    if (pids.isEmpty())
        Log.d("HIJACKER/stopAll", "Nothing found");
    else {
        for (int i = 0; i < pids.size(); i++) {
            Log.d("HIJACKER/Killing...", Integer.toString(pids.get(i)));
            shell_in.print("kill " + pids.get(i) + "\n");
            shell_in.flush();
        }
    }
}

From source file:com.nesscomputing.syslog4j.impl.log4j.Syslog4jAppenderSkeleton.java

protected void _initialize() {
    String initializedProtocol = initialize();

    if (initializedProtocol != null && this.protocol == null) {
        this.protocol = initializedProtocol;
    }//w  w  w  .j a va  2 s .co m

    if (this.protocol != null) {
        try {
            this.syslog = Syslog.getInstance(this.protocol);
            if (this.host != null) {
                this.syslog.getConfig().setHost(this.host);
            }
            if (this.facility != null) {
                this.syslog.getConfig().setFacility(this.facility);
            }
            if (this.port != null) {
                try {
                    int i = Integer.parseInt(this.port);
                    this.syslog.getConfig().setPort(i);

                } catch (NumberFormatException nfe) {
                    LogLog.error(nfe.toString());
                }
            }
            if (this.charSet != null) {
                this.syslog.getConfig().setCharSet(this.charSet);
            }
            if (this.ident != null) {
                this.syslog.getConfig().setIdent(this.ident);
            }
            if (this.localName != null) {
                this.syslog.getConfig().setLocalName(this.localName);
            }

            this.syslog.getConfig()
                    .setTruncateMessage(isTrueOrOn(StringUtils.trimToEmpty(this.truncateMessage)));

            try {
                int i = Integer.parseInt(StringUtils.trimToEmpty(this.maxMessageLength));
                this.syslog.getConfig().setMaxMessageLength(i);

            } catch (NumberFormatException nfe) {
                LogLog.error(nfe.toString());
            }

            if (this.useStructuredData != null) {
                this.syslog.getConfig().setUseStructuredData(isTrueOrOn(this.useStructuredData));
            }
            if (this.syslog.getConfig() instanceof AbstractSyslogConfigIF) {
                AbstractSyslogConfigIF abstractSyslogConfig = (AbstractSyslogConfigIF) this.syslog.getConfig();

                abstractSyslogConfig.setThreaded(isTrueOrOn(StringUtils.trimToEmpty(this.threaded)));

                try {
                    long l = Long.parseLong(StringUtils.trimToEmpty(this.threadLoopInterval));
                    abstractSyslogConfig.setThreadLoopInterval(l);
                } catch (NumberFormatException nfe) {
                    LogLog.error(nfe.toString());
                }

                if (this.splitMessageBeginText != null) {
                    abstractSyslogConfig.setSplitMessageBeginText(
                            SyslogUtility.getBytes(abstractSyslogConfig, this.splitMessageBeginText));
                }

                if (this.splitMessageEndText != null) {
                    abstractSyslogConfig.setSplitMessageEndText(
                            SyslogUtility.getBytes(abstractSyslogConfig, this.splitMessageEndText));
                }

                try {
                    int i = Integer.parseInt(StringUtils.trimToEmpty(this.maxShutdownWait));
                    abstractSyslogConfig.setMaxShutdownWait(i);

                } catch (NumberFormatException nfe) {
                    LogLog.error(nfe.toString());
                }

                try {
                    int i = Integer.parseInt(StringUtils.trimToEmpty(this.writeRetries));
                    abstractSyslogConfig.setWriteRetries(i);

                } catch (NumberFormatException nfe) {
                    LogLog.error(nfe.toString());
                }
            }

            this.initialized = true;

        } catch (SyslogRuntimeException sre) {
            LogLog.error(sre.toString());
        }
    }
}

From source file:org.apache.axis2.transport.http.ListingAgent.java

protected void initTransportListener(HttpServletRequest httpServletRequest) {
    // httpServletRequest.getLocalPort() , giving me a build error so I had to use the followin
    String filePart;//from  w ww .ja  v  a2  s  . c  o  m
    try {
        filePart = httpServletRequest.getRequestURL().toString();
    } catch (Throwable t) {
        log.info("Old Servlet API (fallback to HttpServletRequest.getRequestURI) :" + t);
        filePart = httpServletRequest.getRequestURI();
    }
    int ipindex = filePart.indexOf("//");
    String ip;
    if (ipindex >= 0) {
        ip = filePart.substring(ipindex + 2, filePart.length());
        int seperatorIndex = ip.indexOf(":");
        int slashIndex = ip.indexOf("/");
        String portstr;
        if (seperatorIndex >= 0) {
            portstr = ip.substring(seperatorIndex + 1, slashIndex);
        } else {
            portstr = "80";
        }
        try {
            addTransportListener(httpServletRequest.getScheme(), Integer.parseInt(portstr));
        } catch (NumberFormatException e) {
            log.debug(e.toString(), e);
        }
    }
}

From source file:org.opendatakit.common.persistence.engine.gae.StringFieldLengthMapping.java

/**
 * Called when asserting the existence of a table.
 * Upon completion, the maximum lengths of all STRING
 * and URI columns will have been set.// w  ww  .  j  a  v  a 2s. c o m
 * 
 * @param gaeEntityKind -- entity kind being asserted 
 * @param relation
 * @param dam
 * @param datastore
 * @param user
 * @throws ODKDatastoreException
 */
public synchronized void assertStringFieldLengths(String gaeEntityKind, CommonFieldsBase relation,
        DatastoreAccessMetrics dam, DatastoreImpl datastore, User user) throws ODKDatastoreException {

    Map<String, Long> lenMap = new HashMap<String, Long>();

    logger.info(gaeEntityKind);
    Key key = KeyFactory.createKey(TABLE_NAME, gaeEntityKind);

    try {
        dam.recordGetUsage(TABLE_NAME);
        Entity e = datastore.getDatastoreService().get(key);
        // we have a record of this -- get the mapping value...
        Object o = e.getProperty(LENGTH_MAPPING);
        if (!(o instanceof Text)) {
            throw new ODKDatastoreException("Expected Text object but found " + o.getClass().getName());
        }
        Text t = (Text) o;

        // for convenience, the last element of the split array
        // will be an extraneous empty string.  Confirm this!
        String[] splits = t.getValue().split(" ");
        if (splits.length % 2 != 0) {
            throw new ODKDatastoreException("Unexpected non-even-element-count " + splits.length
                    + " for string lengths map: " + t.getValue());
        }

        for (int i = 0; i < splits.length; i = i + 2) {
            String k = splits[i];
            String vStr = splits[i + 1];

            try {
                Long v = Long.parseLong(vStr);
                lenMap.put(k, v);
            } catch (NumberFormatException ex) {
                throw new ODKDatastoreException(
                        "column name: " + k + " length: " + vStr + " could not be parsed: " + ex.toString());
            }
        }

        // we now have the lenMap as saved in the database.
        // Update the relation with the values from this list
        // and detect any new or changed values.
        // 
        // For migrations, we trust any incoming value over 
        // any the saved value.  Track whether the saved
        // value should be updated with additions, but don't
        // change it if there is a change that alters an 
        // existing (specified) length.
        boolean changed = false;
        for (DataField f : relation.getFieldList()) {
            if (f.getDataType() == DataType.STRING || f.getDataType() == DataType.URI) {
                // string field -- get what GAE thinks
                // the length should be...
                Long len = lenMap.get(f.getName());
                Long reqLen = f.getMaxCharLen();
                if (len == null) {
                    // GAE doesn't know -- we need to update GAE
                    changed = true;
                    if (reqLen == null) {
                        // we're using the default length -- set field too...
                        reqLen = PersistConsts.DEFAULT_MAX_STRING_LENGTH;
                        f.setMaxCharLen(reqLen);
                    }
                    lenMap.put(f.getName(), reqLen);
                } else {
                    if (reqLen == null) {
                        // GAE knows the length -- set field now...
                        f.setMaxCharLen(len);
                    } else if (reqLen != len) {
                        // length differs -- update GAE
                        changed = true;
                        lenMap.put(f.getName(), reqLen);
                    }
                }
            }
        }

        if (changed) {
            // we changed something in lenMap -- update GAE
            putEntity(e, lenMap, dam, datastore, user);
        }

    } catch (EntityNotFoundException ex) {
        // no record of this entity...
        // ensure all default lengths are imposed.
        // build up length map.
        for (DataField f : relation.getFieldList()) {
            if ((f.getDataType() == DataType.STRING || f.getDataType() == DataType.URI)) {
                Long len = f.getMaxCharLen();
                if (len == null) {
                    len = PersistConsts.DEFAULT_MAX_STRING_LENGTH;
                    f.setMaxCharLen(len);
                }
                lenMap.put(f.getName(), f.getMaxCharLen());
            }
        }

        // define a new entity...
        Entity e = new Entity(TABLE_NAME, gaeEntityKind);
        // set and insert it into GAE...
        putEntity(e, lenMap, dam, datastore, user);
    }

    // And verify that the invariant condition holds...
    // Everything should have a length
    for (DataField f : relation.getFieldList()) {
        if ((f.getDataType() == DataType.STRING || f.getDataType() == DataType.URI)
                && f.getMaxCharLen() == null) {
            throw new ODKDatastoreException("Failed to set all lengths!");
        }
    }
}