@Override public String toString() { return getText(); }
@Override public String toString() { return getText(); }
@Override public InputStream getStream() throws IOException { CharacterSet charset = getCharacterSet() == null ? CharacterSet.ISO_8859_1 : getCharacterSet(); ByteArrayInputStream result = new ByteArrayInputStream(getText() .getBytes(charset.getName())); return result; }
@Override public InputStream getStream() throws IOException { CharacterSet charset = getCharacterSet() == null ? CharacterSet.ISO_8859_1 : getCharacterSet(); ByteArrayInputStream result = new ByteArrayInputStream(getText() .getBytes(charset.getName())); return result; }
ClientResource cr = new ClientResource("http://<same-domain>/war2-rootpath/dateformatter"); Representation repr = cr.put(new StringRepresentation(...)); StringRepresentation sRepr = new StringRepresentation(repr); String returnedText = sRepr.getText();
/** * 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); } }