Example usage for java.lang Short valueOf

List of usage examples for java.lang Short valueOf

Introduction

In this page you can find the example usage for java.lang Short valueOf.

Prototype

@HotSpotIntrinsicCandidate
public static Short valueOf(short s) 

Source Link

Document

Returns a Short instance representing the specified short value.

Usage

From source file:org.executequery.databaseobjects.impl.TableColumnConstraint.java

private Short shortValue(String value) {

    return Short.valueOf(value);
}

From source file:net.sf.ezmorph.bean.BeanMorpherTest.java

public void testMorph_PrimitiveBean_to_TypedBean() {
    PrimitiveBean primitiveBean = new PrimitiveBean();
    primitiveBean.setPclass(Object.class);
    primitiveBean.setPstring("MORPH");
    morpherRegistry.registerMorpher(new BeanMorpher(TypedBean.class, morpherRegistry));
    TypedBean typedBean = (TypedBean) morpherRegistry.morph(TypedBean.class, primitiveBean);
    assertNotNull(typedBean);/*from www  . jav a 2s  .  co  m*/
    assertEquals(Boolean.FALSE, typedBean.getPboolean());
    assertEquals(Byte.valueOf("0"), typedBean.getPbyte());
    assertEquals(Short.valueOf("0"), typedBean.getPshort());
    assertEquals(Integer.valueOf("0"), typedBean.getPint());
    assertEquals(Long.valueOf("0"), typedBean.getPlong());
    assertEquals(Float.valueOf("0"), typedBean.getPfloat());
    assertEquals(Double.valueOf("0"), typedBean.getPdouble());
    assertEquals(new Character('\0'), typedBean.getPchar());
    assertEquals(null, typedBean.getParray());
    assertEquals(null, typedBean.getPlist());
    assertEquals(null, typedBean.getPbean());
    assertEquals(null, typedBean.getPmap());
    assertEquals("MORPH", typedBean.getPstring());
    assertEquals(Object.class, typedBean.getPclass());
}

From source file:org.codice.ddf.spatial.ogc.csw.catalog.common.source.CswFilterDelegate.java

@Override
public FilterType propertyIsGreaterThan(String propertyName, short literal) {
    isComparisonOperationSupported(ComparisonOperatorType.GREATER_THAN);
    propertyName = mapPropertyName(propertyName);
    if (isPropertyQueryable(propertyName)) {
        return cswFilterFactory.buildPropertyIsGreaterThanFilter(propertyName, Short.valueOf(literal));
    } else {//from   w ww  .j a v  a  2  s . c o m
        return new FilterType();
    }
}

From source file:com.domain.java.util.IDCardUtils.java

/**
 * ???//from   www. j  a v  a 2 s  .  c om
 * @param idCard ?
 * @return (yyyy)
 */
public static Short getYearByIdCard(String idCard) {

    Integer len = idCard.length();
    if (len == CHINA_ID_MIN_LENGTH) {
        idCard = convert15CardTo18(idCard);
    }
    if (idCard == null) {
        return null;
    }
    return Short.valueOf(idCard.substring(6, 10));
}

From source file:com.hanuor.sapphire.utils.intentation.IntentationPrime.java

public Intent jsonToINTENT(String JSONString) throws JSONException {

    JSONObject jsonObject = new JSONObject(JSONString.toString());
    String toArray = jsonObject.get("intentExtras").toString();
    String contextName = jsonObject.get("context").toString();
    String className = jsonObject.get("className").toString();
    Log.d("Insass", className.toString());

    Intent setIntent = new Intent();
    setIntent.setClassName(contextName, className);
    HashMap<String, String> extrasHash = new HashMap<String, String>();
    JSONObject issueObj = new JSONObject(toArray);
    for (int i = 0; i < issueObj.length(); i++) {
        extrasHash.put(issueObj.names().getString(i), issueObj.get(issueObj.names().getString(i)).toString());
    }//from w ww.j  a v  a 2s .co  m
    Iterator it = extrasHash.entrySet().iterator();
    while (it.hasNext()) {
        //add conditions  and checks here

        Map.Entry pair = (Map.Entry) it.next();
        String currentKey = (String) pair.getKey();
        Log.d("HAHA", "" + currentKey);
        String[] getValuethroughSplit = pair.getValue().toString().split(LibraryDatabase.JSONSEPERATOR);
        String dataType = getValuethroughSplit[0];
        String value = (String) getValuethroughSplit[2];
        Log.d("Insamareen", getValuethroughSplit.length + " " + dataType + " " + value.toString());
        switch (dataType) {
        case "String":
            setIntent.putExtra(currentKey, (String) value);
            break;
        case "String[]":
            String comp1 = value.substring(1, value.length() - 1);
            String[] comp2 = comp1.split(",");
            setIntent.putExtra(currentKey, comp2);
            break;
        case "Integer":
            setIntent.putExtra(currentKey, Integer.parseInt(value));
            break;
        case "Double":

            setIntent.putExtra(currentKey, Double.parseDouble(value));

            break;
        case "double[]":
            String compDouble1 = value.substring(1, value.length() - 1);
            String[] compDoub2 = compDouble1.split(",");
            double[] db = new double[compDoub2.length];
            for (int i = 0; i < compDoub2.length; i++) {
                db[i] = Double.parseDouble(compDoub2[i]);
            }
            setIntent.putExtra(currentKey, db);
            break;
        case "int[]":
            String compInt1 = value.substring(1, value.length() - 1);
            String[] compInt2 = compInt1.split(",");
            int[] intVal = new int[compInt2.length];
            for (int i = 0; i < compInt2.length; i++) {
                intVal[i] = Integer.parseInt(compInt2[i]);
            }
            Log.d("Hankey", intVal.toString());
            setIntent.putExtra(currentKey, intVal);

            break;
        case "Boolean":
            setIntent.putExtra(currentKey, Boolean.valueOf(value));

            break;
        case "boolean[]":
            String compB1 = value.substring(1, value.length() - 1);
            String[] compB2 = compB1.split(",");
            boolean[] BVal = new boolean[compB2.length];
            for (int i = 0; i < compB2.length; i++) {
                BVal[i] = Boolean.parseBoolean(compB2[i]);
            }
            setIntent.putExtra(currentKey, value);

            break;
        case "Char":
            setIntent.putExtra(currentKey, value);

            break;
        case "char[]":

            String ch1 = value.substring(1, value.length() - 1);
            String[] ch2 = ch1.split(",");
            String newS = null;
            for (int i = 0; i < ch2.length; i++) {
                newS = newS + ch2[i];
            }
            setIntent.putExtra(currentKey, newS.toCharArray());

            break;
        case "CharSequence":
            setIntent.putExtra(currentKey, (CharSequence) value);

            break;
        case "Charsequence[]":
            setIntent.putExtra(currentKey, value.toString());

            break;
        case "Byte":
            setIntent.putExtra(currentKey, Byte.valueOf(value));

            break;
        case "byte[]":
            String by = value.substring(1, value.length() - 1);
            String[] by2 = by.split(",");
            byte[] by3 = new byte[by2.length];
            for (int i = 0; i < by2.length; i++) {
                by3[i] = Byte.parseByte(by2[i]);
            }
            setIntent.putExtra(currentKey, by3);

            break;
        case "Float":
            setIntent.putExtra(currentKey, Float.valueOf(value));

            break;
        case "float[]":
            String fl = value.substring(1, value.length() - 1);
            String[] fl2 = fl.split(",");
            float[] fl3 = new float[fl2.length];
            for (int i = 0; i < fl2.length; i++) {
                fl3[i] = Float.parseFloat(fl2[i]);
            }
            setIntent.putExtra(currentKey, fl3);

            break;
        case "Short":
            setIntent.putExtra(currentKey, Short.valueOf(value));

            break;
        case "short[]":
            String sh = value.substring(1, value.length() - 1);
            String[] sh2 = sh.split(",");
            short[] sh3 = new short[sh2.length];
            for (int i = 0; i < sh2.length; i++) {
                sh3[i] = Short.parseShort(sh2[i]);
            }
            setIntent.putExtra(currentKey, sh3);

            break;
        case "Long":
            setIntent.putExtra(currentKey, Long.valueOf(value));

            break;
        case "long[]":
            String ll = value.substring(1, value.length() - 1);
            String[] ll2 = ll.split(",");
            long[] ll3 = new long[ll2.length];
            for (int i = 0; i < ll2.length; i++) {
                ll3[i] = Long.parseLong(ll2[i]);
            }
            setIntent.putExtra(currentKey, ll3);

            break;

        case "ArrayListString":
            Log.d("Hankey", currentKey + " ");
            String arrL = value.substring(1, value.length() - 1);
            String[] arrl2 = arrL.split(",");
            ArrayList<String> arrStr = new ArrayList<String>();
            for (int i = 0; i < arrl2.length; i++) {
                arrStr.add(arrl2[i]);
            }
            setIntent.putStringArrayListExtra(currentKey, arrStr);

            break;
        case "ArrayListInteger":
            String arL = value.substring(1, value.length() - 1);
            String[] arl2 = arL.split(",");
            ArrayList<Integer> arrInt = new ArrayList<Integer>();
            for (int i = 0; i < arl2.length; i++) {
                arrInt.add(Integer.parseInt(arl2[i]));
            }

            setIntent.putIntegerArrayListExtra(currentKey, arrInt);

            break;
        default:
            // whatever
        }
    }
    return setIntent;
}

From source file:org.mifos.application.servicefacade.CenterServiceFacadeWebTier.java

private List<PositionEntity> populateWithNonCenterRelatedPositions(List<PositionEntity> allCustomerPositions) {
    List<PositionEntity> nonCenterRelatedPositions = new ArrayList<PositionEntity>();
    for (PositionEntity positionEntity : allCustomerPositions) {
        if (!(positionEntity.getId().equals(Short.valueOf("1"))
                || positionEntity.getId().equals(Short.valueOf("2")))) {
            nonCenterRelatedPositions.add(positionEntity);
        }/*ww  w.  jav  a2s. c  o m*/
    }
    return nonCenterRelatedPositions;
}

From source file:org.apache.hadoop.hive.ql.exec.vector.VectorRandomRowSource.java

public static Object randomObject(int column, Random r, PrimitiveCategory[] primitiveCategories,
        PrimitiveTypeInfo[] primitiveTypeInfos, String[] alphabets, boolean addEscapables,
        String needsEscapeStr) {/*from   ww  w .  j ava 2 s  . c om*/
    PrimitiveCategory primitiveCategory = primitiveCategories[column];
    PrimitiveTypeInfo primitiveTypeInfo = primitiveTypeInfos[column];
    try {
        switch (primitiveCategory) {
        case BOOLEAN:
            return Boolean.valueOf(r.nextInt(1) == 1);
        case BYTE:
            return Byte.valueOf((byte) r.nextInt());
        case SHORT:
            return Short.valueOf((short) r.nextInt());
        case INT:
            return Integer.valueOf(r.nextInt());
        case LONG:
            return Long.valueOf(r.nextLong());
        case DATE:
            return RandomTypeUtil.getRandDate(r);
        case FLOAT:
            return Float.valueOf(r.nextFloat() * 10 - 5);
        case DOUBLE:
            return Double.valueOf(r.nextDouble() * 10 - 5);
        case STRING:
        case CHAR:
        case VARCHAR: {
            String result;
            if (alphabets != null && alphabets[column] != null) {
                result = RandomTypeUtil.getRandString(r, alphabets[column], r.nextInt(10));
            } else {
                result = RandomTypeUtil.getRandString(r);
            }
            if (addEscapables && result.length() > 0) {
                int escapeCount = 1 + r.nextInt(2);
                for (int i = 0; i < escapeCount; i++) {
                    int index = r.nextInt(result.length());
                    String begin = result.substring(0, index);
                    String end = result.substring(index);
                    Character needsEscapeChar = needsEscapeStr.charAt(r.nextInt(needsEscapeStr.length()));
                    result = begin + needsEscapeChar + end;
                }
            }
            switch (primitiveCategory) {
            case STRING:
                return result;
            case CHAR:
                return new HiveChar(result, ((CharTypeInfo) primitiveTypeInfo).getLength());
            case VARCHAR:
                return new HiveChar(result, ((VarcharTypeInfo) primitiveTypeInfo).getLength());
            default:
                throw new Error("Unknown primitive category " + primitiveCategory);
            }
        }
        case BINARY:
            return getRandBinary(r, 1 + r.nextInt(100));
        case TIMESTAMP:
            return RandomTypeUtil.getRandTimestamp(r);
        case INTERVAL_YEAR_MONTH:
            return getRandIntervalYearMonth(r);
        case INTERVAL_DAY_TIME:
            return getRandIntervalDayTime(r);
        case DECIMAL:
            return getRandHiveDecimal(r, (DecimalTypeInfo) primitiveTypeInfo);
        default:
            throw new Error("Unknown primitive category " + primitiveCategory);
        }
    } catch (Exception e) {
        throw new RuntimeException("randomObject failed on column " + column + " type " + primitiveCategory, e);
    }
}

From source file:de.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderTest.java

@DataProvider(name = "typesAsSessionAttributesProvider")
protected Object[][] createTypesAsSessionAttributesData() {
    return new Object[][] { { int.class, 42 }, { long.class, 42 }, { Boolean.class, Boolean.TRUE },
            { String.class, "42" }, { StringBuilder.class, new StringBuilder("42") },
            { StringBuffer.class, new StringBuffer("42") }, { Class.class, String.class },
            { Long.class, Long.valueOf(42) }, { Integer.class, Integer.valueOf(42) },
            { Character.class, Character.valueOf('c') }, { Byte.class, Byte.valueOf("b".getBytes()[0]) },
            { Double.class, Double.valueOf(42d) }, { Float.class, Float.valueOf(42f) },
            { Short.class, Short.valueOf((short) 42) }, { BigDecimal.class, new BigDecimal(42) },
            { AtomicInteger.class, new AtomicInteger(42) }, { AtomicLong.class, new AtomicLong(42) },
            { MutableInt.class, new MutableInt(42) }, { Integer[].class, new Integer[] { 42 } },
            { Date.class, new Date(System.currentTimeMillis() - 10000) },
            { Calendar.class, Calendar.getInstance() }, { Currency.class, Currency.getInstance("EUR") },
            { ArrayList.class, new ArrayList<String>(Arrays.asList("foo")) },
            { int[].class, new int[] { 1, 2 } }, { long[].class, new long[] { 1, 2 } },
            { short[].class, new short[] { 1, 2 } }, { float[].class, new float[] { 1, 2 } },
            { double[].class, new double[] { 1, 2 } }, { int[].class, new int[] { 1, 2 } },
            { byte[].class, "42".getBytes() }, { char[].class, "42".toCharArray() },
            { String[].class, new String[] { "23", "42" } },
            { Person[].class, new Person[] { createPerson("foo bar", Gender.MALE, 42) } } };
}

From source file:org.mifos.customers.personnel.business.PersonnelBO.java

private Short passwordChangedShortValue() {
    return Short.valueOf("1");
}

From source file:org.kalypso.observation.result.TupleResultUtilities.java

public static void setNumberValue(final IRecord record, final IComponent component, final Number value) {
    final QName qname = component.getValueTypeName();
    if (XmlTypes.XS_DECIMAL.equals(qname))
        record.setValue(component, BigDecimal.valueOf(value.doubleValue()));
    else if (XmlTypes.XS_DOUBLE.equals(qname))
        record.setValue(component, Double.valueOf(value.doubleValue()));
    else if (XmlTypes.XS_FLOAT.equals(qname))
        record.setValue(component, Float.valueOf(value.floatValue()));
    else if (XmlTypes.XS_INT.equals(qname))
        record.setValue(component, Integer.valueOf(value.intValue()));
    else if (XmlTypes.XS_INTEGER.equals(qname))
        record.setValue(component, BigInteger.valueOf(value.longValue()));
    else if (XmlTypes.XS_LONG.equals(qname))
        record.setValue(component, Long.valueOf(value.longValue()));
    else if (XmlTypes.XS_SHORT.equals(qname))
        record.setValue(component, Short.valueOf(value.shortValue()));
    else/*from   www.  j av a  2 s  .co m*/
        throw new UnsupportedOperationException();

}