List of usage examples for java.lang Short valueOf
@HotSpotIntrinsicCandidate public static Short valueOf(short s)
From source file:org.apache.kylin.rest.service.QueryService.java
/** * @param preparedState//from w w w .j a v a2s . c om * @param param * @throws SQLException */ private void setParam(PreparedStatement preparedState, int index, PrepareSqlRequest.StateParam param) throws SQLException { boolean isNull = (null == param.getValue()); Class<?> clazz; try { clazz = Class.forName(param.getClassName()); } catch (ClassNotFoundException e) { throw new InternalErrorException(e); } Rep rep = Rep.of(clazz); switch (rep) { case PRIMITIVE_CHAR: case CHARACTER: case STRING: preparedState.setString(index, isNull ? null : String.valueOf(param.getValue())); break; case PRIMITIVE_INT: case INTEGER: preparedState.setInt(index, isNull ? 0 : Integer.valueOf(param.getValue())); break; case PRIMITIVE_SHORT: case SHORT: preparedState.setShort(index, isNull ? 0 : Short.valueOf(param.getValue())); break; case PRIMITIVE_LONG: case LONG: preparedState.setLong(index, isNull ? 0 : Long.valueOf(param.getValue())); break; case PRIMITIVE_FLOAT: case FLOAT: preparedState.setFloat(index, isNull ? 0 : Float.valueOf(param.getValue())); break; case PRIMITIVE_DOUBLE: case DOUBLE: preparedState.setDouble(index, isNull ? 0 : Double.valueOf(param.getValue())); break; case PRIMITIVE_BOOLEAN: case BOOLEAN: preparedState.setBoolean(index, !isNull && Boolean.parseBoolean(param.getValue())); break; case PRIMITIVE_BYTE: case BYTE: preparedState.setByte(index, isNull ? 0 : Byte.valueOf(param.getValue())); break; case JAVA_UTIL_DATE: case JAVA_SQL_DATE: preparedState.setDate(index, isNull ? null : java.sql.Date.valueOf(param.getValue())); break; case JAVA_SQL_TIME: preparedState.setTime(index, isNull ? null : Time.valueOf(param.getValue())); break; case JAVA_SQL_TIMESTAMP: preparedState.setTimestamp(index, isNull ? null : Timestamp.valueOf(param.getValue())); break; default: preparedState.setObject(index, isNull ? null : param.getValue()); } }
From source file:fr.cls.atoll.motu.processor.wps.MotuWPSProcess.java
/** * Gets the request priority./* w ww.j a v a 2 s. c om*/ * * @param in the in * * @return the request priority * * @throws ProcessletException the processlet exception */ protected int getRequestPriority(ProcessletInputs in) throws ProcessletException { short priority = getQueueServerManagement().getDefaultPriority(); MotuWPSProcessData motuWPSProcessData = getMotuWPSProcessData(in); LiteralInput priorityParam = motuWPSProcessData.getPriorityParamIn(); if (WPSUtils.isNullOrEmpty(priorityParam)) { return priority; } try { priority = Short.valueOf(priorityParam.getValue()); } catch (NumberFormatException e) { priority = getQueueServerManagement().getDefaultPriority(); } return priority; }
From source file:de.uniwue.info2.generator.TestcaseGenerator.java
/** * Function to replace one PlaceHolder-String in current unit-test. * * @param original// w w w . j a v a 2 s .com * original string, to replace PlaceHolder in. * @param placeholder * PlaceHolder-string * @param insert * new string to replace PlaceHolder with. * @return new modified string */ private String replacePlaceHolder(String original, String placeholder, String insert) { Pattern variable = Pattern.compile( "\\" + getID() + "(\\{[st]{1}_[0-9]*\\})?" + placeholder.replace(getID(), "") + "\\" + getID(), Pattern.CASE_INSENSITIVE); Matcher variableMatcher = variable.matcher(original); while (variableMatcher.find()) { String var = variableMatcher.group(); Pattern spacePattern = Pattern.compile("\\{[st]{1}_[0-9]*\\}", Pattern.CASE_INSENSITIVE); Matcher spaceMatcher = spacePattern.matcher(var); if (spaceMatcher.find()) { String spaceIndicator = spaceMatcher.group(); String spaceVar = spaceIndicator.replaceAll("[\\{\\}ts_]", ""); String space = ""; if (spaceIndicator.contains("{t_")) { space = StringUtils.repeat("\t", Short.valueOf(spaceVar)); } else if (spaceIndicator.contains("{s_")) { space = StringUtils.repeat(" ", Short.valueOf(spaceVar)); } insert = space + insert.replace("\n", "\n" + space); if (insert.endsWith(space)) { insert = insert.substring(0, insert.length() - space.length()); } } original = original.replace(var, insert); } return original; }
From source file:de.minigameslib.mclib.api.config.ConfigurationValueInterface.java
/** * Sets the value to this configuration variable. * //w w w . j ava 2s .c om * @param value * value to set. * @param subpath * the sub path */ default void setShort(short value, String subpath) { ConfigurationTool.consume(this, subpath, (val, configs, config, lib, minigame, path) -> { minigame.getConfig(configs.file()).set(path, Short.valueOf(value)); }); }
From source file:org.apache.velocity.util.ExtProperties.java
/** * Get a short associated with the given configuration key. * * @param key The configuration key. * @param defaultValue The default value. * @return The associated short./*ww w .j av a2 s. c o m*/ * @throws ClassCastException is thrown if the key maps to an * object that is not a Short. * @throws NumberFormatException is thrown if the value mapped * by the key has not a valid number format. */ public short getShort(String key, short defaultValue) { return getShort(key, Short.valueOf(defaultValue)).shortValue(); }
From source file:com.shvet.poi.hssf.usermodel.HSSFWorkbook.java
/** * Get the font at the given index number * * @param idx index number//from w w w. j a v a 2s.co m * @return HSSFFont at the index */ @Override public HSSFFont getFontAt(short idx) { if (fonts == null) fonts = new Hashtable<Short, HSSFFont>(); // So we don't confuse users, give them back // the same object every time, but create // them lazily Short sIdx = Short.valueOf(idx); if (fonts.containsKey(sIdx)) { return fonts.get(sIdx); } FontRecord font = workbook.getFontRecordAt(idx); HSSFFont retval = new HSSFFont(idx, font); fonts.put(sIdx, retval); return retval; }
From source file:de.minigameslib.mclib.api.config.ConfigurationValueInterface.java
@Override default void setShort(short value) { ConfigurationTool.consume(this, ConfigurationShort.class, ConfigurationTool.shortPath(), (val, configs, config, lib, minigame, path) -> { minigame.getConfig(configs.file()).set(path, Short.valueOf(value)); });//from w w w . j a v a 2 s . co m }
From source file:org.apache.poi.hssf.usermodel.HSSFWorkbook.java
/** * Get the font at the given index number * @param idx index number// w w w. j a v a2s .com * @return HSSFFont at the index */ @Override public HSSFFont getFontAt(short idx) { if (fonts == null) fonts = new Hashtable<Short, HSSFFont>(); // So we don't confuse users, give them back // the same object every time, but create // them lazily Short sIdx = Short.valueOf(idx); if (fonts.containsKey(sIdx)) { return fonts.get(sIdx); } FontRecord font = workbook.getFontRecordAt(idx); HSSFFont retval = new HSSFFont(idx, font); fonts.put(sIdx, retval); return retval; }
From source file:de.minigameslib.mclib.api.config.ConfigurationValueInterface.java
@Override default void setShortList(short[] value) { final List<Short> list = new ArrayList<>(); for (int i = 0; i < value.length; i++) { list.add(Short.valueOf(value[i])); }/*from w w w .ja v a 2 s . c o m*/ ConfigurationTool.consume(this, ConfigurationShortList.class, ConfigurationTool.shortListPath(), (val, configs, config, lib, minigame, path) -> { minigame.getConfig(configs.file()).setPrimitiveList(path, list); }); }
From source file:org.apache.velocity.util.ExtProperties.java
/** * Get a short associated with the given configuration key. * * @param key The configuration key. * @param defaultValue The default value. * @return The associated short if key is found and has valid * format, default value otherwise.//w ww . j a v a2s . c o m * @throws ClassCastException is thrown if the key maps to an * object that is not a Short. * @throws NumberFormatException is thrown if the value mapped * by the key has not a valid number format. */ public Short getShort(String key, Short defaultValue) { Object value = get(key); if (value instanceof Short) { return (Short) value; } else if (value instanceof String) { Short s = Short.valueOf((String) value); put(key, s); return s; } else if (value == null) { if (defaults != null) { return defaults.getShort(key, defaultValue); } else { return defaultValue; } } else { throw new ClassCastException('\'' + key + "' doesn't map to a Short object"); } }