List of usage examples for java.lang Short valueOf
@HotSpotIntrinsicCandidate public static Short valueOf(short s)
From source file:com.adaptris.core.services.jdbc.ShortStatementParameter.java
Short toShort(Object value) throws ServiceException { if (isBlank((String) value) && convertNull()) { return Short.valueOf(NumberUtils.toShort((String) value)); } else {/* w ww. jav a2 s . c o m*/ return Short.valueOf((String) value); } }
From source file:IndexService.IndexMergeIFormatWriter.java
public IndexMergeIFormatWriter(String fileName, JobConf job) throws IOException { this.conf = job; ifdf = new IFormatDataFile(job); ihead = new IHead(); String[] fieldStrings = job.getStrings(ConstVar.HD_fieldMap); IFieldMap fieldMap = new IFieldMap(); for (int i = 0; i < fieldStrings.length; i++) { String[] def = fieldStrings[i].split(ConstVar.RecordSplit); byte type = Byte.valueOf(def[0]); int index = Short.valueOf(def[1]); fieldMap.addFieldType(new IRecord.IFType(type, index)); }//from www . j a va 2 s. c om ihead.setFieldMap(fieldMap); String[] files = job.getStrings(ConstVar.HD_index_filemap); IUserDefinedHeadInfo iudhi = new IUserDefinedHeadInfo(); iudhi.addInfo(123456, job.get("datafiletype")); for (int i = 0; i < files.length; i++) { iudhi.addInfo(i, files[i]); } ihead.setUdi(iudhi); ihead.setPrimaryIndex(0); ifdf.create(fileName, ihead); record = ifdf.getIRecordObj(); }
From source file:IndexService.IndexIFormatOutputWriter.java
public IndexIFormatOutputWriter(String fileName, JobConf job) throws IOException { this.conf = job; ifdf = new IFormatDataFile(job); ihead = new IHead(); String[] fieldStrings = job.getStrings(ConstVar.HD_fieldMap); IFieldMap fieldMap = new IFieldMap(); for (int i = 0; i < fieldStrings.length; i++) { String[] def = fieldStrings[i].split(ConstVar.RecordSplit); byte type = Byte.valueOf(def[0]); int index = Short.valueOf(def[1]); fieldMap.addFieldType(new IRecord.IFType(type, index)); }/*from ww w . j a v a 2s . com*/ ihead.setFieldMap(fieldMap); String[] files = job.getStrings(ConstVar.HD_index_filemap); IUserDefinedHeadInfo iudhi = new IUserDefinedHeadInfo(); iudhi.addInfo(123456, job.get("datafiletype")); for (int i = 0; i < files.length; i++) { iudhi.addInfo(i, files[i]); } ihead.setUdi(iudhi); ihead.setPrimaryIndex(0); ifdf.create(fileName, ihead); record = ifdf.getIRecordObj(); }
From source file:com.wabacus.system.datatype.ShortType.java
public Object label2value(String label) { if (label == null || label.trim().equals("")) return null; int idxdot = label.indexOf("."); if (idxdot == 0) { label = "0"; } else if (idxdot > 0) { label = label.substring(0, idxdot).trim(); if (label.equals("")) label = "0"; }/*from w ww . jav a 2s. com*/ return Short.valueOf(label.trim()); }
From source file:org.hyperic.hq.plugin.jboss.MBeanUtil.java
private static void initConverters() { addConverter(Object.class, new Converter() { public Object convert(String param) { return param; }/*w ww.ja v a 2s. c o m*/ }); addConverter(Short.class, new Converter() { public Object convert(String param) { return Short.valueOf(param); } }); addConverter(Integer.class, new Converter() { public Object convert(String param) { return Integer.valueOf(param); } }); addConverter(Long.class, new Converter() { public Object convert(String param) { return Long.valueOf(param); } }); addConverter(Double.class, new Converter() { public Object convert(String param) { return Double.valueOf(param); } }); addConverter(Boolean.class, new Converter() { public Object convert(String param) { return Boolean.valueOf(param); } }); addConverter(File.class, new Converter() { public Object convert(String param) { return new File(param); } }); addConverter(URL.class, new Converter() { public Object convert(String param) { try { return new URL(param); } catch (MalformedURLException e) { throw invalid(param, e); } } }); addConverter(ObjectName.class, new Converter() { public Object convert(String param) { try { return new ObjectName(param); } catch (MalformedObjectNameException e) { throw invalid(param, e); } } }); addConverter(List.class, new ListConverter() { public Object convert(String[] params) { return Arrays.asList(params); } }); addConverter(String[].class, new ListConverter() { public Object convert(String[] params) { return params; } }); Class[][] aliases = { { String.class, Object.class }, { Short.TYPE, Short.class }, { Integer.TYPE, Integer.class }, { Long.TYPE, Long.class }, { Double.TYPE, Double.class }, { Boolean.TYPE, Boolean.class }, }; for (int i = 0; i < aliases.length; i++) { addConverter(aliases[i][0], aliases[i][1]); } }
From source file:org.apache.kylin.common.debug.BackdoorToggles.java
public static Pair<Short, Short> getShardAssignment() { String v = getString(DEBUG_TOGGLE_SHARD_ASSIGNMENT); if (v == null) { return null; } else {//from w ww.ja va 2s .com String[] parts = StringUtils.split(v, "#"); return Pair.newPair(Short.valueOf(parts[0]), Short.valueOf(parts[1])); } }
From source file:com.base.dao.sql.ReflectionUtils.java
public static Object convertValue(Object value, Class toType) { Object result = null;//from ww w .j av a 2 s . c o m if (value != null) { if (value.getClass().isArray() && toType.isArray()) { Class componentType = toType.getComponentType(); result = Array.newInstance(componentType, Array.getLength(value)); for (int i = 0, icount = Array.getLength(value); i < icount; i++) { Array.set(result, i, convertValue(Array.get(value, i), componentType)); } } else { if ((toType == Integer.class) || (toType == Integer.TYPE)) result = Integer.valueOf((int) longValue(value)); if ((toType == Double.class) || (toType == Double.TYPE)) result = new Double(doubleValue(value)); if ((toType == Boolean.class) || (toType == Boolean.TYPE)) result = booleanValue(value) ? Boolean.TRUE : Boolean.FALSE; if ((toType == Byte.class) || (toType == Byte.TYPE)) result = Byte.valueOf((byte) longValue(value)); if ((toType == Character.class) || (toType == Character.TYPE)) result = new Character((char) longValue(value)); if ((toType == Short.class) || (toType == Short.TYPE)) result = Short.valueOf((short) longValue(value)); if ((toType == Long.class) || (toType == Long.TYPE)) result = Long.valueOf(longValue(value)); if ((toType == Float.class) || (toType == Float.TYPE)) result = new Float(doubleValue(value)); if (toType == BigInteger.class) result = bigIntValue(value); if (toType == BigDecimal.class) result = bigDecValue(value); if (toType == String.class) result = stringValue(value); if (toType == Date.class) { result = DateUtils.toDate(stringValue(value)); } if (Enum.class.isAssignableFrom(toType)) result = enumValue((Class<Enum>) toType, value); } } else { if (toType.isPrimitive()) { result = primitiveDefaults.get(toType); } } return result; }
From source file:com.ning.metrics.goodwill.store.CSVFileStore.java
public void parseFile() throws IOException { CSVReader reader = new CSVReader(new FileReader(fileName)); log.info(String.format("Read CSV file: %s", fileName)); List<String[]> entries = reader.readAll(); GoodwillSchema currentSchema = null; String currentSchemaName = null; /**//from w ww. j ava2 s.c om * CSV file format: * * "TermFrequency",1,"i64","app_id",1,2147483647 * "TermFrequency",2,"string","subdomain",1,2147483647 * "TermFrequency",3,"string","term_freq_json",1,2147483647 * "SpamMarkEvent",19,"string","abuse_type",8,2147483647 * ... * * TODO: extend file format with extra sql fields */ HashMap<String, GoodwillSchema> schemata = new HashMap<String, GoodwillSchema>(); for (Object entry : entries) { short position; GoodwillSchemaField thriftField; String[] line = (String[]) entry; try { position = Short.valueOf(line[1]); } catch (NumberFormatException e) { log.warn(String.format("Ignoring malformed line: %s", StringUtils.join(line, ","))); continue; } try { thriftField = new GoodwillSchemaField(line[3], line[2], position, null, null, null, null, null); } catch (IllegalArgumentException e) { log.warn(String.format("Ignoring unsupported type <%s>: %s", line[2], StringUtils.join(line, ","))); continue; } if (currentSchemaName == null || !line[0].equals(currentSchemaName)) { currentSchemaName = line[0]; currentSchema = new GoodwillSchema(currentSchemaName, new ArrayList<GoodwillSchemaField>()); schemata.put(currentSchemaName, currentSchema); log.debug(String.format("Found new ThriftType thriftField to: %s", currentSchemaName)); } currentSchema.addThriftField(thriftField); log.debug(String.format("Added ThriftField to %s: %s", currentSchemaName, thriftField.toString())); } this.goodwillSchemata = schemata; }
From source file:br.interactive.ecm.gerais.service.UsuarioService.java
public LoginDTO login(LoginDTO user, HttpServletRequest request) { if (!StringUtil.notEmpty(user.getSenha())) { throw new BusinessException(new ErrorMessage("seguranca.login.naoencontrado")); }//from w w w . j a v a 2s . c o m // Usuario usua = usuarioDAO.getUsuarioByLoginSenha(user.getLogin(), user.getSenha()); // FIXME Obter usuario Usuario usua = new Usuario(); Pessoa p = new Pessoa(); p.setTxNome("Nome do Usuario"); p.setUsuario(usua); usua.setPessoa(p); // this.validarUsuarioParaAutenticacao(usua); UserSession userSession = userSessionDAO.getUserSessionLoginBrowserIp(usua.getTxLogin(), request.getHeader("user-agent"), request.getRemoteAddr()); if (userSession != null) { userSessionDAO.remove(userSession); } String token = UUID.randomUUID().toString(); UserSession session = new UserSession(); session.setTxLogin(usua.getTxLogin()); session.setTxToken(token); session.setDtStartOrRefreshSession(new Date()); session.setDtExpiredSession(DateUtils.addMinutes(new Date(), 120)); session.setTxBrowser(request.getHeader("user-agent")); session.setTxIpAdress(request.getRemoteAddr()); userSessionDAO.persist(session); user.sethToken(token); usua.setNbTentativas(Short.valueOf("0")); usua.setDtDataAcesso(Calendar.getInstance()); usuarioDAO.merge(usua); return user; }
From source file:com.dituiba.excel.SimpleExportService.java
/** * ?/* w w w . j av a 2 s . com*/ */ private void createHead() { log.debug("?"); Row hashRow = sheet.createRow(HASH_ROW); addTitle(sheet, TITLE_ROW, fieldNames.length, language.translate(title)); Row row = createRow(sheet, HIDDEN_FIELD_HEAD, fieldNames.length); List<String> columns = new ArrayList(fieldNames.length); for (String fieldName : fieldNames) { columns.add(language.translate(fieldName)); } addRow(sheet, COLUMN_ROW, columns.toArray(new String[] {})); hashRow.setHeight(Short.valueOf("0")); row.setHeight(Short.valueOf("0")); log.debug("?"); }