Tabnine Logo
Short
Code IndexAdd Tabnine to your IDE (free)

How to use
Short
in
java.lang

Best Java code snippets using java.lang.Short (Showing top 20 results out of 33,786)

origin: apache/incubator-dubbo

public static Short boxed(short v) {
  return Short.valueOf(v);
}
origin: ctripcorp/apollo

 @Override
 public Short apply(String input) {
  return Short.parseShort(input);
 }
};
origin: apache/incubator-dubbo

public static short unboxed(Short v) {
  return v == null ? 0 : v.shortValue();
}
origin: log4j/log4j

/**
 * Returns a Short instance representing the specified short.
 * Short.valueOf was added in JDK 1.5.
 *
 * @param b a short value.
 * @return a Byte instance representing b.
 */
protected static Short valueOf(final short b) {
  return new Short(b);
}
origin: apache/flink

/**
 * 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);
  }
}
origin: spring-projects/spring-framework

@Test
public void parseNumberAsHex() {
  String aByte = "0x" + Integer.toHexString(Byte.valueOf(Byte.MAX_VALUE).intValue());
  String aShort = "0x" + Integer.toHexString(Short.valueOf(Short.MAX_VALUE).intValue());
  String anInteger = "0x" + Integer.toHexString(Integer.MAX_VALUE);
  String aLong = "0x" + Long.toHexString(Long.MAX_VALUE);
  String aReallyBigInt = "FEBD4E677898DFEBFFEE44";
  assertByteEquals(aByte);
  assertShortEquals(aShort);
  assertIntegerEquals(anInteger);
  assertLongEquals(aLong);
  assertEquals("BigInteger did not parse",
      new BigInteger(aReallyBigInt, 16), NumberUtils.parseNumber("0x" + aReallyBigInt, BigInteger.class));
}
origin: google/guava

public void testCompare() {
 for (short x : VALUES) {
  for (short y : VALUES) {
   // Only compare the sign of the result of compareTo().
   int expected = Short.valueOf(x).compareTo(y);
   int actual = Shorts.compare(x, y);
   if (expected == 0) {
    assertEquals(x + ", " + y, expected, actual);
   } else if (expected < 0) {
    assertTrue(
      x + ", " + y + " (expected: " + expected + ", actual" + actual + ")", actual < 0);
   } else {
    assertTrue(
      x + ", " + y + " (expected: " + expected + ", actual" + actual + ")", actual > 0);
   }
  }
 }
}
origin: google/guava

@Override
protected String doBackward(Short value) {
 return value.toString();
}
origin: CalebFenton/simplify

@Test
public void canGetWithShortIndex() {
  Short index = 0;
  initial.setRegisters(0, new int[] { 0x42 }, "[I", 1, index, "S");
  expected.setRegisters(index.intValue(), 0x42, "I", 1, Short.valueOf(index.shortValue()), "S");
  VMTester.test(CLASS_NAME, "get()V", initial, expected);
}
origin: square/moshi

@Override public void toJson(JsonWriter writer, Short value) throws IOException {
 writer.value(value.intValue());
}
origin: commons-lang/commons-lang

/**
 * Gets the value as a Short instance.
 * 
 * @return the value as a Short, never null
 */
public Object getValue() {
  return new Short(this.value);
}
origin: spring-projects/spring-framework

@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)));
}
origin: netty/netty

/**
 * 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);
}
origin: CalebFenton/simplify

@Test
public void canCreateIntegerArrayWithShortTypeLengthValue() {
  Short length = 1;
  initial.setRegisters(0, length, "S");
  expected.setRegisters(0, new int[length.intValue()], "[I");
  VMTester.test(CLASS_NAME, "createIntegerArray()V", initial, expected);
}
origin: apache/incubator-dubbo

public static Short boxed(short v) {
  return Short.valueOf(v);
}
origin: org.apache.commons/commons-lang3

/**
 * Constructs a new MutableShort parsing the given string.
 *
 * @param value  the string to parse, not null
 * @throws NumberFormatException if the string cannot be parsed into a short
 * @since 2.5
 */
public MutableShort(final String value) {
  super();
  this.value = Short.parseShort(value);
}
origin: apache/incubator-dubbo

public static short unboxed(Short v) {
  return v == null ? 0 : v.shortValue();
}
origin: google/j2objc

/**
 * Asserts that two shorts are equal. If they are not
 * an AssertionFailedError is thrown with the given message.
 */
static public void assertEquals(String message, short expected, short actual) {
  assertEquals(message, new Short(expected), new Short(actual));
}
origin: skylot/jadx

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);
}
origin: CalebFenton/simplify

@Test
public void testIntToCharWithShort() {
  Short value = 0x62;
  initial.setRegisters(0, value, "S");
  expected.setRegisters(0, (char) value.intValue(), "C");
  VMTester.test(CLASS_NAME, "intToChar()V", initial, expected);
}
java.langShort

Javadoc

The wrapper for the primitive type short.

Most used methods

  • valueOf
    Returns a Short instance representing the specified short value. If a new Short instance is not requ
  • parseShort
    Parses the string argument as a signed short in the radix specified by the second argument. The char
  • shortValue
    Returns the value of this Short as a short.
  • <init>
    Constructs a newly allocated Short object that represents the specified short value.
  • toString
    Returns a new String object representing the specified short. The radix is assumed to be 10.
  • intValue
    Returns the value of this Short as an int.
  • longValue
    Returns the value of this Short as a long.
  • equals
    Compares this object to the specified object. The result is true if and only if the argument is not
  • reverseBytes
    Returns the value obtained by reversing the order of the bytes in the two's complement representatio
  • decode
    Decodes a String into a Short. Accepts decimal, hexadecimal, and octal numbers given by the followin
  • hashCode
  • compareTo
    Compares two Short objects numerically.
  • hashCode,
  • compareTo,
  • byteValue,
  • doubleValue,
  • compare,
  • floatValue,
  • toUnsignedInt,
  • toUnsignedLong,
  • checkDecode

Popular in Java

  • Updating database using SQL prepared statement
  • setContentView (Activity)
  • putExtra (Intent)
  • requestLocationUpdates (LocationManager)
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now