@Override protected String doBackward(Short value) { return value.toString(); }
/** * Helper method called by {@link #toString()} in order to convert a single map key into a string. * This is protected to allow subclasses to override the appearance of a given key. */ protected String keyToString(short key) { return Short.toString(key); }
public static String formatShort(short s) { if (s == Short.MAX_VALUE) { return "Short.MAX_VALUE"; } if (s == Short.MIN_VALUE) { return "Short.MIN_VALUE"; } return "(short) " + Short.toString(s); }
/** * Represents the supplied {@code short} value as a {@link String}. * * @param value The {@code short} value to render. * @return An appropriate {@link String} representation. */ public String toSourceString(short value) { return Short.toString(value); }
/** * Helper method called by {@link #toString()} in order to convert a single map key into a string. * This is protected to allow subclasses to override the appearance of a given key. */ protected String keyToString(short key) { return Short.toString(key); }
@Override protected String doBackward(Short value) { return value.toString(); }
@Override public String prettyPrint() { return Short.toString( value ); }
@Override protected String doBackward(Short value) { return value.toString(); }
@Override public String toString(Short value) { return value == null ? null : value.toString(); } @Override
@Override public String objectToSQLString(Short value, Dialect dialect) throws Exception { return value.toString(); }
@Override public void setShort(Text text, Short value) { text.set(value.toString().getBytes(UTF_8)); }
public void arrays(short... ss) { s = ""; if (ss != null) { s = ""; for (short s: ss) { this.s += Short.toString(s); } } }
/** * Obtains the string representation of this object. */ public String toString() { return Short.toString(getValue()); }
/** * Appends short value. */ public StringBand append(short s) { return append(Short.toString(s)); }
@Override public void writeInteger( short value ) { append( Short.toString( value ) ); }
/** * Appends short value. */ public StringBand append(final short s) { return append(Short.toString(s)); }
/** * Returns the Short value for the given key. If the key does not exists it will return the default value given. * The method fails if the value is not a Short. */ public short getShort(String key, short defaultValue) { addToDefaults(key, Short.toString(defaultValue)); String value = get(key); if (value == null) { return defaultValue; } else { return Short.valueOf(value); } }
@Override public void setShort(int parameterIndex, short x) throws SQLException { checkOpen(); setParameter(parameterIndex, formatLiteral("SMALLINT", Short.toString(x))); }
@Test public void testBoxShort() throws Exception { assertEquals("0", Unbox.box((short) 0).toString()); assertEquals("1", Unbox.box((short) 1).toString()); assertEquals("127", Unbox.box((short) 127).toString()); assertEquals("-1", Unbox.box((short) -1).toString()); assertEquals("-128", Unbox.box((short) -128).toString()); assertEquals(new Short(Short.MAX_VALUE).toString(), Unbox.box(Short.MAX_VALUE).toString()); assertEquals(new Short(Short.MIN_VALUE).toString(), Unbox.box(Short.MIN_VALUE).toString()); }
@Test public void read() throws IOException { Short shortValue = Short.valueOf((short) 781); MockHttpServletRequest request = new MockHttpServletRequest(); request.setContentType(MediaType.TEXT_PLAIN_VALUE); request.setContent(shortValue.toString().getBytes(StringHttpMessageConverter.DEFAULT_CHARSET)); assertEquals(shortValue, this.converter.read(Short.class, new ServletServerHttpRequest(request))); Float floatValue = Float.valueOf(123); request = new MockHttpServletRequest(); request.setContentType(MediaType.TEXT_PLAIN_VALUE); request.setCharacterEncoding("UTF-16"); request.setContent(floatValue.toString().getBytes("UTF-16")); assertEquals(floatValue, this.converter.read(Float.class, new ServletServerHttpRequest(request))); Long longValue = Long.valueOf(55819182821331L); request = new MockHttpServletRequest(); request.setContentType(MediaType.TEXT_PLAIN_VALUE); request.setCharacterEncoding("UTF-8"); request.setContent(longValue.toString().getBytes("UTF-8")); assertEquals(longValue, this.converter.read(Long.class, new ServletServerHttpRequest(request))); }