Java Code Examples for java.lang.Short

Following code examples demonstrate how to use java.lang.Short from java. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use java.lang.Short and various code implementation of this class.
Example 1
Project : java Source File : getMethods.java View Source Code on GitHub

    
    public void test(TestHarness harness)
    {
        Map<String, String> testedMethods = null;

        Map<String, String> testedMethods_jdk6 = new HashMap<String, String>();

        Map<String, String> testedMethods_jdk7 = new HashMap<String, String>();

        testedMethods_jdk6.put("public boolean java.lang.Short.equals(java.lang.Object)", "equals");
        testedMethods_jdk6.put("public java.lang.String java.lang.Short.toString()", "toString");
        testedMethods_jdk6.put("public static java.lang.String java.lang.Short.toString(short)", "toString");
        testedMethods_jdk6.put("public int java.lang.Short.hashCode()", "hashCode");
        testedMethods_jdk6.put("public static short java.lang.Short.reverseBytes(short)", "reverseBytes");
        testedMethods_jdk6.put("public int java.lang.Short.compareTo(java.lang.Object)", "compareTo");
        testedMethods_jdk6.put("public int java.lang.Short.compareTo(java.lang.Short)", "compareTo");
        testedMethods_jdk6.put("public byte java.lang.Short.byteValue()", "byteValue");
        testedMethods_jdk6.put("public short java.lang.Short.shortValue()", "shortValue");
        testedMethods_jdk6.put("public int java.lang.Short.intValue()", "intValue");
        testedMethods_jdk6.put("public long java.lang.Short.longValue()", "longValue");
        testedMethods_jdk6.put("public float java.lang.Short.floatValue()", "floatValue");
        testedMethods_jdk6.put("public double java.lang.Short.doubleValue()", "doubleValue");
        testedMethods_jdk6.put("public static java.lang.Short java.lang.Short.valueOf(java.lang.String) throws java.lang.NumberFormatException", "valueOf");
        testedMethods_jdk6.put("public static java.lang.Short java.lang.Short.valueOf(short)", "valueOf");
        testedMethods_jdk6.put("public static java.lang.Short java.lang.Short.valueOf(java.lang.String,int) throws java.lang.NumberFormatException", "valueOf");
        testedMethods_jdk6.put("public static java.lang.Short java.lang.Short.decode(java.lang.String) throws java.lang.NumberFormatException", "decode");
        testedMethods_jdk6.put("public static short java.lang.Short.parseShort(java.lang.String,int) throws java.lang.NumberFormatException", "parseShort");
        testedMethods_jdk6.put("public static short java.lang.Short.parseShort(java.lang.String) throws java.lang.NumberFormatException", "parseShort");
        testedMethods_jdk6.put("public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException", "wait");
        testedMethods_jdk6.put("public final void java.lang.Object.wait(long) throws java.lang.InterruptedException", "wait");
        testedMethods_jdk6.put("public final void java.lang.Object.wait() throws java.lang.InterruptedException", "wait");
        testedMethods_jdk6.put("public final java.lang.Class java.lang.Object.getClass()", "getClass");
        testedMethods_jdk6.put("public final void java.lang.Object.notify()", "notify");
        testedMethods_jdk6.put("public final void java.lang.Object.notifyAll()", "notifyAll");

        testedMethods_jdk7.put("public boolean java.lang.Short.equals(java.lang.Object)", "equals");
        testedMethods_jdk7.put("public java.lang.String java.lang.Short.toString()", "toString");
        testedMethods_jdk7.put("public static java.lang.String java.lang.Short.toString(short)", "toString");
        testedMethods_jdk7.put("public int java.lang.Short.hashCode()", "hashCode");
        testedMethods_jdk7.put("public static short java.lang.Short.reverseBytes(short)", "reverseBytes");
        testedMethods_jdk7.put("public int java.lang.Short.compareTo(java.lang.Object)", "compareTo");
        testedMethods_jdk7.put("public int java.lang.Short.compareTo(java.lang.Short)", "compareTo");
        testedMethods_jdk7.put("public byte java.lang.Short.byteValue()", "byteValue");
        testedMethods_jdk7.put("public short java.lang.Short.shortValue()", "shortValue");
        testedMethods_jdk7.put("public int java.lang.Short.intValue()", "intValue");
        testedMethods_jdk7.put("public long java.lang.Short.longValue()", "longValue");
        testedMethods_jdk7.put("public float java.lang.Short.floatValue()", "floatValue");
        testedMethods_jdk7.put("public double java.lang.Short.doubleValue()", "doubleValue");
        testedMethods_jdk7.put("public static java.lang.Short java.lang.Short.valueOf(java.lang.String,int) throws java.lang.NumberFormatException", "valueOf");
        testedMethods_jdk7.put("public static java.lang.Short java.lang.Short.valueOf(java.lang.String) throws java.lang.NumberFormatException", "valueOf");
        testedMethods_jdk7.put("public static java.lang.Short java.lang.Short.valueOf(short)", "valueOf");
        testedMethods_jdk7.put("public static int java.lang.Short.compare(short,short)", "compare");
        testedMethods_jdk7.put("public static java.lang.Short java.lang.Short.decode(java.lang.String) throws java.lang.NumberFormatException", "decode");
        testedMethods_jdk7.put("public static short java.lang.Short.parseShort(java.lang.String,int) throws java.lang.NumberFormatException", "parseShort");
        testedMethods_jdk7.put("public static short java.lang.Short.parseShort(java.lang.String) throws java.lang.NumberFormatException", "parseShort");
        testedMethods_jdk7.put("public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException", "wait");
        testedMethods_jdk7.put("public final void java.lang.Object.wait(long) throws java.lang.InterruptedException", "wait");
        testedMethods_jdk7.put("public final void java.lang.Object.wait() throws java.lang.InterruptedException", "wait");
        testedMethods_jdk7.put("public final java.lang.Class java.lang.Object.getClass()", "getClass");
        testedMethods_jdk7.put("public final void java.lang.Object.notify()", "notify");
        testedMethods_jdk7.put("public final void java.lang.Object.notifyAll()", "notifyAll");

        final Object o = new Short("42");

        final Class c = o.getClass();

        testedMethods = getJavaVersion() < 7 ? testedMethods_jdk6 : testedMethods_jdk7;

        java.lang.reflect.Method[] methods = c.getMethods();

        final int expectedNumberOfMethods = testedMethods.size();

        harness.check(methods.length, expectedNumberOfMethods);

        for (java.lang.reflect.Method method : methods) {
            String methodName = method.getName();
            String methodString = method.toString().replaceAll(" native ", " ");
            harness.check(testedMethods.containsKey(methodString));
            harness.check(testedMethods.get(methodString), methodName);
        }
    }
			
Example 2
Project : java Source File : getDeclaredMethods.java View Source Code on GitHub

    
    public void test(TestHarness harness)
    {
        Map<String, String> testedDeclaredMethods = null;

        Map<String, String> testedDeclaredMethods_jdk6 = new HashMap<String, String>();

        Map<String, String> testedDeclaredMethods_jdk7 = new HashMap<String, String>();

        testedDeclaredMethods_jdk6.put("public boolean java.lang.Short.equals(java.lang.Object)", "equals");
        testedDeclaredMethods_jdk6.put("public java.lang.String java.lang.Short.toString()", "toString");
        testedDeclaredMethods_jdk6.put("public static java.lang.String java.lang.Short.toString(short)", "toString");
        testedDeclaredMethods_jdk6.put("public int java.lang.Short.hashCode()", "hashCode");
        testedDeclaredMethods_jdk6.put("public static short java.lang.Short.reverseBytes(short)", "reverseBytes");
        testedDeclaredMethods_jdk6.put("public int java.lang.Short.compareTo(java.lang.Object)", "compareTo");
        testedDeclaredMethods_jdk6.put("public int java.lang.Short.compareTo(java.lang.Short)", "compareTo");
        testedDeclaredMethods_jdk6.put("public byte java.lang.Short.byteValue()", "byteValue");
        testedDeclaredMethods_jdk6.put("public short java.lang.Short.shortValue()", "shortValue");
        testedDeclaredMethods_jdk6.put("public int java.lang.Short.intValue()", "intValue");
        testedDeclaredMethods_jdk6.put("public long java.lang.Short.longValue()", "longValue");
        testedDeclaredMethods_jdk6.put("public float java.lang.Short.floatValue()", "floatValue");
        testedDeclaredMethods_jdk6.put("public double java.lang.Short.doubleValue()", "doubleValue");
        testedDeclaredMethods_jdk6.put("public static java.lang.Short java.lang.Short.valueOf(java.lang.String) throws java.lang.NumberFormatException", "valueOf");
        testedDeclaredMethods_jdk6.put("public static java.lang.Short java.lang.Short.valueOf(short)", "valueOf");
        testedDeclaredMethods_jdk6.put("public static java.lang.Short java.lang.Short.valueOf(java.lang.String,int) throws java.lang.NumberFormatException", "valueOf");
        testedDeclaredMethods_jdk6.put("public static java.lang.Short java.lang.Short.decode(java.lang.String) throws java.lang.NumberFormatException", "decode");
        testedDeclaredMethods_jdk6.put("public static short java.lang.Short.parseShort(java.lang.String,int) throws java.lang.NumberFormatException", "parseShort");
        testedDeclaredMethods_jdk6.put("public static short java.lang.Short.parseShort(java.lang.String) throws java.lang.NumberFormatException", "parseShort");

        testedDeclaredMethods_jdk7.put("public boolean java.lang.Short.equals(java.lang.Object)", "equals");
        testedDeclaredMethods_jdk7.put("public java.lang.String java.lang.Short.toString()", "toString");
        testedDeclaredMethods_jdk7.put("public static java.lang.String java.lang.Short.toString(short)", "toString");
        testedDeclaredMethods_jdk7.put("public int java.lang.Short.hashCode()", "hashCode");
        testedDeclaredMethods_jdk7.put("public static short java.lang.Short.reverseBytes(short)", "reverseBytes");
        testedDeclaredMethods_jdk7.put("public int java.lang.Short.compareTo(java.lang.Object)", "compareTo");
        testedDeclaredMethods_jdk7.put("public int java.lang.Short.compareTo(java.lang.Short)", "compareTo");
        testedDeclaredMethods_jdk7.put("public byte java.lang.Short.byteValue()", "byteValue");
        testedDeclaredMethods_jdk7.put("public short java.lang.Short.shortValue()", "shortValue");
        testedDeclaredMethods_jdk7.put("public int java.lang.Short.intValue()", "intValue");
        testedDeclaredMethods_jdk7.put("public long java.lang.Short.longValue()", "longValue");
        testedDeclaredMethods_jdk7.put("public float java.lang.Short.floatValue()", "floatValue");
        testedDeclaredMethods_jdk7.put("public double java.lang.Short.doubleValue()", "doubleValue");
        testedDeclaredMethods_jdk7.put("public static java.lang.Short java.lang.Short.valueOf(java.lang.String,int) throws java.lang.NumberFormatException", "valueOf");
        testedDeclaredMethods_jdk7.put("public static java.lang.Short java.lang.Short.valueOf(java.lang.String) throws java.lang.NumberFormatException", "valueOf");
        testedDeclaredMethods_jdk7.put("public static java.lang.Short java.lang.Short.valueOf(short)", "valueOf");
        testedDeclaredMethods_jdk7.put("public static int java.lang.Short.compare(short,short)", "compare");
        testedDeclaredMethods_jdk7.put("public static java.lang.Short java.lang.Short.decode(java.lang.String) throws java.lang.NumberFormatException", "decode");
        testedDeclaredMethods_jdk7.put("public static short java.lang.Short.parseShort(java.lang.String,int) throws java.lang.NumberFormatException", "parseShort");
        testedDeclaredMethods_jdk7.put("public static short java.lang.Short.parseShort(java.lang.String) throws java.lang.NumberFormatException", "parseShort");

        final Object o = new Short("42");

        final Class c = o.getClass();

        testedDeclaredMethods = getJavaVersion() < 7 ? testedDeclaredMethods_jdk6 : testedDeclaredMethods_jdk7;

        java.lang.reflect.Method[] declaredMethods = c.getDeclaredMethods();

        final int expectedNumberOfDeclaredMethods = testedDeclaredMethods.size();

        harness.check(declaredMethods.length, expectedNumberOfDeclaredMethods);

        for (java.lang.reflect.Method declaredMethod : declaredMethods) {
            String methodName = declaredMethod.getName();
            String methodString = declaredMethod.toString().replaceAll(" native ", " ");
            harness.check(testedDeclaredMethods.containsKey(methodString));
            harness.check(testedDeclaredMethods.get(methodString), methodName);
        }
    }