List of usage examples for java.lang Byte valueOf
public static Byte valueOf(String s) throws NumberFormatException
From source file:org.sofun.platform.web.rest.resource.ejb.TeamResourceBean.java
@Override public Response addTeamKup(long teamId, Map<String, String> params) throws ReSTException { final Team team = getTeamService().getTeam(teamId); if (team == null) { return Response.status(400).entity("Team not found").build(); }/*from ww w . j a v a 2s . c o m*/ final long metaKupId = Long.valueOf(params.get("metaKupId")); Kup kup = getKupService().getKupById(metaKupId); if (kup == null) { return Response.status(400).entity("Kup not found").build(); } final float stake = Float.valueOf(params.get("stake")); final byte repartitionType = Byte.valueOf(params.get("repartitionType")); if (team.getKupByName(kup.getName()) != null) { return Response.status(500).entity("Your room is already registered to this Kup.").build(); } Kup newKup; try { newKup = getKupService().createKupFromMeta(kup, team, stake, repartitionType); } catch (CoreException e) { return Response.status(500).entity("Internal error").build(); } return Response.status(202).entity(new ReSTKup(newKup)).build(); }
From source file:com.healthmarketscience.jackcess.Column.java
/** * Deserialize a raw byte value for this column into an Object * @param data The raw byte value/*w ww.j a va 2 s .c o m*/ * @param order Byte order in which the raw value is stored * @return The deserialized Object * @usage _advanced_method_ */ public Object read(byte[] data, ByteOrder order) throws IOException { ByteBuffer buffer = ByteBuffer.wrap(data); buffer.order(order); if (_type == DataType.BOOLEAN) { throw new IOException("Tried to read a boolean from data instead of null mask."); } else if (_type == DataType.BYTE) { return Byte.valueOf(buffer.get()); } else if (_type == DataType.INT) { return Short.valueOf(buffer.getShort()); } else if (_type == DataType.LONG) { return Integer.valueOf(buffer.getInt()); } else if (_type == DataType.DOUBLE) { return Double.valueOf(buffer.getDouble()); } else if (_type == DataType.FLOAT) { return Float.valueOf(buffer.getFloat()); } else if (_type == DataType.SHORT_DATE_TIME) { return readDateValue(buffer); } else if (_type == DataType.BINARY) { return data; } else if (_type == DataType.TEXT) { return decodeTextValue(data); } else if (_type == DataType.MONEY) { return readCurrencyValue(buffer); } else if (_type == DataType.OLE) { if (data.length > 0) { return readLongValue(data); } return null; } else if (_type == DataType.MEMO) { if (data.length > 0) { return readLongStringValue(data); } return null; } else if (_type == DataType.NUMERIC) { return readNumericValue(buffer); } else if (_type == DataType.GUID) { return readGUIDValue(buffer, order); } else if ((_type == DataType.UNKNOWN_0D) || (_type == DataType.UNKNOWN_11)) { // treat like "binary" data return data; } else if (_type == DataType.COMPLEX_TYPE) { return new ComplexValueForeignKey(this, buffer.getInt()); } else if (_type.isUnsupported()) { return rawDataWrapper(data); } else { throw new IOException("Unrecognized data type: " + _type); } }
From source file:com.mimp.controllers.main.java
@RequestMapping(value = "/inscSesInd", method = RequestMethod.GET) public ModelAndView inscSesInd_GET(ModelMap map, HttpSession session) { long turno = 0; String estado = ""; String nombre = ""; String apellidoP = ""; String apellidoM = ""; String paisNac = ""; String depNac = ""; String proNac = ""; String fechaNac = ""; String edad = ""; String doc = ""; String numDoc = ""; String profesion = ""; String cel = ""; String correo = ""; String pais = ""; String dep = ""; String prov = ""; String dist = ""; String dir = ""; String telf = ""; try {/*from w w w .j a v a2s . co m*/ turno = Long.parseLong(session.getAttribute("turno").toString()); estado = session.getAttribute("estado").toString(); nombre = session.getAttribute("nombre").toString(); apellidoP = session.getAttribute("apellidoP").toString(); apellidoM = session.getAttribute("apellidoM").toString(); paisNac = session.getAttribute("paisNac").toString(); depNac = session.getAttribute("depNac").toString(); proNac = session.getAttribute("proNac").toString(); fechaNac = session.getAttribute("fechaNac").toString(); edad = session.getAttribute("edad").toString(); doc = session.getAttribute("doc").toString(); numDoc = session.getAttribute("numDoc").toString(); profesion = session.getAttribute("profesion").toString(); cel = session.getAttribute("cel").toString(); correo = session.getAttribute("correo").toString(); pais = session.getAttribute("pais").toString(); dep = session.getAttribute("dep").toString(); prov = session.getAttribute("prov").toString(); dist = session.getAttribute("dist").toString(); dir = session.getAttribute("dir").toString(); telf = session.getAttribute("telf").toString(); } catch (Exception ex) { return new ModelAndView("redirect:/", map); } session.removeAttribute("estado"); session.removeAttribute("turno"); session.removeAttribute("nombre"); session.removeAttribute("apellidoP"); session.removeAttribute("apellidoM"); session.removeAttribute("paisNac"); session.removeAttribute("depNac"); session.removeAttribute("proNac"); session.removeAttribute("fechaNac"); session.removeAttribute("edad"); session.removeAttribute("doc"); session.removeAttribute("numDoc"); session.removeAttribute("profesion"); session.removeAttribute("cel"); session.removeAttribute("correo"); session.removeAttribute("pais"); session.removeAttribute("dep"); session.removeAttribute("prov"); session.removeAttribute("dist"); session.removeAttribute("dir"); session.removeAttribute("telf"); Turno temp = ServicioMain.getTurno(turno); FormularioSesion fs = new FormularioSesion(); Asistente asis = new Asistente(); AsistenciaFT aft = new AsistenciaFT(); fs.setSesion(temp.getSesion()); aft.setTurno(temp); String asistencia = "F"; char asist = asistencia.charAt(0); aft.setAsistencia(asist); String inajust = "1"; Short i = Short.valueOf(inajust); aft.setInasJus(i); Date today = new Date(); fs.setFechaSol(today); fs.setPaisRes(pais); fs.setDepRes(dep); fs.setProvRes(prov); fs.setDistritoRes(dist); fs.setDireccionRes(dir); fs.setTelefono(telf); fs.setEstadoCivil(estado); String sexo = ""; if (estado.equals("soltero") || estado.equals("viudo") || estado.equals("divorciado")) { sexo = "m"; } if (estado.equals("soltera") || estado.equals("viuda") || estado.equals("divorciada")) { sexo = "f"; } char s = sexo.charAt(0); asis.setSexo(s); asis.setNombre(nombre); asis.setApellidoP(apellidoP); asis.setApellidoM(apellidoM); asis.setPaisNac(paisNac); asis.setDepNac(depNac); asis.setProvNac(proNac); short b = Byte.valueOf(edad); asis.setEdad(b); if (fechaNac != null && !fechaNac.equals("")) { asis.setFechaNac(df.stringToDate(fechaNac)); } char c = doc.charAt(0); asis.setTipoDoc(c); asis.setNDoc(numDoc); asis.setProfesion(profesion); asis.setCelular(cel); asis.setCorreo(correo); ArrayList<Asistente> tempList = new ArrayList(); tempList = ServicioMain.listaAsistentes(temp.getSesion().getIdsesion()); if (!tempList.isEmpty()) { for (Asistente asistente : tempList) { if (asistente.getNDoc().equals(numDoc)) { map.put("mensaje", "inscrito"); return new ModelAndView("/Inscripcion/inscripcion_sesion1b", map); } } } if (temp.getVacantes() > temp.getAsistenciaFTs().size()) { map.put("ts", ts); map.put("turno", temp); ServicioMain.InsertFormInd(asis, fs, aft); return new ModelAndView("/Inscripcion/inscripcion_sesion4", map); } else { map.put("ts", ts); map.put("turno", temp); //ServicioMain.InsertFormInd(asis, fs, aft); return new ModelAndView("/Inscripcion/inscripcion_sesion1b", map); } //return new ModelAndView("contacto", map); }
From source file:org.apache.openjpa.enhance.Reflection.java
/** * Invoke the given setter on the given object. *///from w w w. ja va2 s.c o m public static void set(Object target, Method setter, byte value) { set(target, setter, Byte.valueOf(value)); }
From source file:edu.ku.brc.af.ui.forms.validation.ValFormattedTextFieldSingle.java
/** * @param value/* w w w . java 2 s. c om*/ * @return */ protected UIValidatable.ErrorType validateNumeric(final String value) { Class<?> cls = formatter.getDataClass(); try { if (cls == BigDecimal.class) { if (bdValidator == null) { bdValidator = CurrencyValidator.getInstance(); } Number maxVal = formatter.getMaxValue(); Number minVal = formatter.getMinValue(); BigDecimal fooAmount = bdValidator.validate(value, Locale.getDefault()); // XXX FINAL RELEASE if (fooAmount == null) { // error...not a valid currency amount return UIValidatable.ErrorType.Error; } if (!bdValidator.minValue(fooAmount, minVal) || !bdValidator.maxValue(fooAmount, maxVal)) { // valid...in the specified range return UIValidatable.ErrorType.Error; } return UIValidatable.ErrorType.Valid; } else { try { if (cls == Long.class) { Number num = numIntFormatter.parse(value); Long val = Long.valueOf(num.toString()); return !isMinMaxOK(val) ? UIValidatable.ErrorType.Error : UIValidatable.ErrorType.Valid; } else if (cls == Integer.class) { Number num = numIntFormatter.parse(value); Integer val = Integer.valueOf(num.toString()); return !isMinMaxOK(val) ? UIValidatable.ErrorType.Error : UIValidatable.ErrorType.Valid; } else if (cls == Short.class) { Number num = numIntFormatter.parse(value); Short val = Short.valueOf(num.toString()); return !isMinMaxOK(val) ? UIValidatable.ErrorType.Error : UIValidatable.ErrorType.Valid; } else if (cls == Byte.class) { Number num = numIntFormatter.parse(value); Byte val = Byte.valueOf(num.toString()); return !isMinMaxOK(val) ? UIValidatable.ErrorType.Error : UIValidatable.ErrorType.Valid; } else if (cls == Double.class) { Number num = numberFormatter.parse(value); Double val = Double.valueOf(num.toString()); return !isMinMaxOK(val) ? UIValidatable.ErrorType.Error : UIValidatable.ErrorType.Valid; } else if (cls == Float.class) { Number num = numberFormatter.parse(value); Float val = Float.valueOf(num.toString()); return !isMinMaxOK(val) ? UIValidatable.ErrorType.Error : UIValidatable.ErrorType.Valid; } else { throw new RuntimeException("Missing case for numeric class [" + cls.getName() + "]"); } } catch (NumberFormatException fex) { return UIValidatable.ErrorType.Error; } } } catch (Exception ex) { } return UIValidatable.ErrorType.Error; }
From source file:org.op4j.functions.FnObject.java
/** * <p>//from w w w.java2s . c o m * Determines whether the target object is less or equal to the specified object * in value, this is, whether <tt>target.compareTo(object) <= 0</tt>. Both * the target and the specified object have to implement {@link Comparable}. * </p> * * @param object the object to compare to the target * @return true if target is less or equal to the specified object, false if not */ public static final Function<Object, Boolean> lessOrEqTo(final byte object) { return new LessOrEqualTo(Byte.valueOf(object)); }
From source file:org.op4j.functions.FnBigInteger.java
/** * <p>/* w w w . j av a 2 s. c o m*/ * It adds the given number to the target and returns the result * </p> * * @param add value to be added to the target * @return the result of the addition of add to the target number */ public final static Function<BigInteger, BigInteger> add(byte add) { return add(Byte.valueOf(add)); }
From source file:net.sf.json.TestJSONObject.java
public void testFromObject_ObjectBean() { // FR 1611204 ObjectBean bean = new ObjectBean(); bean.setPbyte(Byte.valueOf("1")); bean.setPshort(Short.valueOf("1")); bean.setPint(Integer.valueOf("1")); bean.setPlong(Long.valueOf("1")); bean.setPfloat(Float.valueOf("1")); bean.setPdouble(Double.valueOf("1")); bean.setPchar(new Character('1')); bean.setPboolean(Boolean.TRUE); bean.setPstring("json"); bean.setParray(new String[] { "a", "b" }); bean.setPbean(new BeanA()); List list = new ArrayList(); list.add("1"); list.add("2"); bean.setPlist(list);/*from w ww. j a v a 2 s. com*/ Map map = new HashMap(); map.put("string", "json"); bean.setPmap(map); bean.setPfunction(new JSONFunction("this;")); JSONObject json = JSONObject.fromObject(bean); assertEquals(1, json.getInt("pbyte")); assertEquals(1, json.getInt("pshort")); assertEquals(1, json.getInt("pint")); assertEquals(1, json.getInt("plong")); assertEquals(1d, json.getDouble("pfloat"), 0d); assertEquals(1d, json.getDouble("pdouble"), 0d); assertTrue(json.getBoolean("pboolean")); assertEquals("json", json.get("pstring")); Assertions.assertEquals(JSONArray.fromObject("['a','b']"), json.getJSONArray("parray")); Assertions.assertEquals(JSONArray.fromObject("['1','2']"), json.getJSONArray("plist")); assertEquals("1", json.getString("pchar")); JSONObject b = new JSONObject().element("string", "json").element("integer", "42").element("bool", "true"); Assertions.assertEquals(b, json.getJSONObject("pbean")); b = new JSONObject().element("string", "json"); Assertions.assertEquals(b, json.getJSONObject("pmap")); }
From source file:org.paxle.gui.impl.servlets.ConfigView.java
@SuppressWarnings("unchecked") private static Object convertAttributeValues(final AttributeDefinition attribute, final String[] attributeValueStrings, final Context context) { // getting metadata String attributeID = attribute.getID(); int attributeType = attribute.getType(); int cardinality = attribute.getCardinality(); // init result structure Object finalAttributeValues = null; if (cardinality != 0) { if (cardinality >= 1) { int valueArraySize = Math.min(Math.abs(cardinality), (attributeValueStrings == null) ? 0 : attributeValueStrings.length); // the attribute-value-list must be an array of .... switch (attributeType) { case AttributeDefinition.BOOLEAN: finalAttributeValues = new boolean[valueArraySize]; break; case AttributeDefinition.BYTE: finalAttributeValues = new byte[valueArraySize]; break; case AttributeDefinition.CHARACTER: finalAttributeValues = new char[valueArraySize]; break; case AttributeDefinition.DOUBLE: finalAttributeValues = new double[valueArraySize]; break; case AttributeDefinition.FLOAT: finalAttributeValues = new float[valueArraySize]; break; case AttributeDefinition.INTEGER: finalAttributeValues = new int[valueArraySize]; break; case AttributeDefinition.LONG: finalAttributeValues = new long[valueArraySize]; break; case AttributeDefinition.SHORT: finalAttributeValues = new short[valueArraySize]; break; case AttributeDefinition.STRING: finalAttributeValues = new String[valueArraySize]; break; default: break; }//from w w w . j a v a 2 s.c om } else { // the attribute-value list must be a vector finalAttributeValues = new Vector<Object>(); } } if (attributeValueStrings != null) { try { int counter = 0; for (String attributeValueString : attributeValueStrings) { if (cardinality != 0 && (counter + 1 > Math.abs(cardinality))) { context.put(ERROR_MSG, String.format("Too many values found for parameter '%s': %d", attributeID, Integer.valueOf(counter + 1))); return null; } // validate value String validationProblem = attribute.validate(attributeValueString); if (validationProblem != null && validationProblem.length() > 0) { context.put(ERROR_MSG, String.format("Parameter '%s' has a wrong value: %s", attributeID, validationProblem)); return null; } // convert value Object finalAttributeValue = null; switch (attributeType) { case AttributeDefinition.BOOLEAN: finalAttributeValue = Boolean.valueOf(attributeValueString); if (cardinality >= 1) ((boolean[]) finalAttributeValues)[counter] = ((Boolean) finalAttributeValue) .booleanValue(); else if (cardinality <= -1) ((Vector<Boolean>) finalAttributeValues).add((Boolean) finalAttributeValue); break; case AttributeDefinition.BYTE: finalAttributeValue = Byte.valueOf(attributeValueString); if (cardinality >= 1) ((byte[]) finalAttributeValues)[counter] = ((Byte) finalAttributeValue).byteValue(); else if (cardinality <= -1) ((Vector<Byte>) finalAttributeValues).add((Byte) finalAttributeValue); break; case AttributeDefinition.CHARACTER: // attributeValue = Character. break; case AttributeDefinition.DOUBLE: finalAttributeValue = Double.valueOf(attributeValueString); if (cardinality >= 1) ((double[]) finalAttributeValues)[counter] = ((Double) finalAttributeValue) .doubleValue(); else if (cardinality <= -1) ((Vector<Double>) finalAttributeValues).add((Double) finalAttributeValue); break; case AttributeDefinition.FLOAT: finalAttributeValue = Float.valueOf(attributeValueString); if (cardinality >= 1) ((float[]) finalAttributeValues)[counter] = ((Float) finalAttributeValue).floatValue(); else if (cardinality <= -1) ((Vector<Float>) finalAttributeValues).add((Float) finalAttributeValue); break; case AttributeDefinition.INTEGER: finalAttributeValue = Integer.valueOf(attributeValueString); if (cardinality >= 1) ((int[]) finalAttributeValues)[counter] = ((Integer) finalAttributeValue).intValue(); else if (cardinality <= -1) ((Vector<Integer>) finalAttributeValues).add((Integer) finalAttributeValue); break; case AttributeDefinition.LONG: finalAttributeValue = Long.valueOf(attributeValueString); if (cardinality >= 1) ((long[]) finalAttributeValues)[counter] = ((Long) finalAttributeValue).longValue(); else if (cardinality <= -1) ((Vector<Long>) finalAttributeValues).add((Long) finalAttributeValue); break; case AttributeDefinition.SHORT: finalAttributeValue = Short.valueOf(attributeValueString); if (cardinality >= 1) ((short[]) finalAttributeValues)[counter] = ((Short) finalAttributeValue).shortValue(); else if (cardinality <= -1) ((Vector<Short>) finalAttributeValues).add((Short) finalAttributeValue); break; case AttributeDefinition.STRING: finalAttributeValue = attributeValueString; if (cardinality >= 1) ((String[]) finalAttributeValues)[counter] = attributeValueString; else if (cardinality <= -1) ((Vector<String>) finalAttributeValues).add((String) finalAttributeValue); break; default: break; } if (cardinality == 0) { finalAttributeValues = finalAttributeValue; } counter++; } } catch (NumberFormatException e) { context.put(ERROR_MSG, String.format("The supplied parameter has a wrong format: %s", e.getMessage())); return null; } } return finalAttributeValues; }
From source file:com.icesoft.faces.renderkit.dom_html_basic.MenuRenderer.java
private boolean isConversionMatched(String sentinel, Object selectedValue) { boolean match = false; if (sentinel.length() == 0) { if (selectedValue == null) { match = true;/* ww w . ja va 2 s . co m*/ } } else if (selectedValue instanceof Long) { if (selectedValue.equals(Long.valueOf(sentinel))) { match = true; } } else if (selectedValue instanceof Byte) { if (selectedValue.equals(Byte.valueOf(sentinel))) { match = true; } } else if (selectedValue instanceof Integer) { if (selectedValue.equals(Integer.valueOf(sentinel))) { match = true; } } else if (selectedValue instanceof Short) { if (selectedValue.equals(Short.valueOf(sentinel))) { match = true; } } else if (selectedValue instanceof Double) { if (selectedValue.equals(Double.valueOf(sentinel))) { match = true; } } else if (selectedValue instanceof Float) { if (selectedValue.equals(Float.valueOf(sentinel))) { match = true; } } else if (selectedValue instanceof Boolean) { if (selectedValue.equals(Boolean.valueOf(sentinel))) { match = true; } } return match; }