/** * Updates the expected size according to the current string value. */ protected void updateSize() { if (getText() != null) { try { if (getCharacterSet() != null) { setSize(getText().getBytes(getCharacterSet().getName()).length); } else { setSize(getText().getBytes().length); } } catch (UnsupportedEncodingException e) { Context.getCurrentLogger().log(Level.WARNING, "Unable to update size", e); setSize(UNKNOWN_SIZE); } } else { setSize(UNKNOWN_SIZE); } }
/** * Updates the expected size according to the current string value. */ protected void updateSize() { if (getText() != null) { try { if (getCharacterSet() != null) { setSize(getText().getBytes(getCharacterSet().getName()).length); } else { setSize(getText().getBytes().length); } } catch (UnsupportedEncodingException e) { Context.getCurrentLogger().log(Level.WARNING, "Unable to update size", e); setSize(UNKNOWN_SIZE); } } else { setSize(UNKNOWN_SIZE); } }