List of usage examples for java.lang Byte Byte
@Deprecated(since = "9") public Byte(String s) throws NumberFormatException
From source file:mx.edu.um.mateo.general.dao.UsuarioDaoTest.java
/** * Test of crea method, of class UsuarioDao. *//*ww w .j a v a 2 s .c o m*/ @Test public void debieraCrearUsuario() { log.debug("Debiera crear usuario"); Organizacion organizacion = new Organizacion("TEST01", "TEST01", "TEST01"); currentSession().save(organizacion); Rol rol = new Rol("ROLE_TEST"); currentSession().save(rol); Empresa empresa = new Empresa("TEST01", "TEST01", "TEST01", "000000000001", organizacion); currentSession().save(empresa); Almacen almacen = new Almacen("TST", "TEST01", empresa); currentSession().save(almacen); EjercicioPK ejercicioPK = new EjercicioPK("TEST", organizacion); Byte x = new Byte("0"); Ejercicio ejercicio = new Ejercicio(ejercicioPK, "TEST", "A", StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY, x, x); currentSession().save(ejercicio); currentSession().flush(); Usuario usuario = new Usuario("bugs@um.edu.mx", "apPaterno", "apMaterno", "TEST-01", "TEST-01"); usuario.setEjercicio(ejercicio); usuario = instance.crea(usuario, almacen.getId(), new String[] { rol.getAuthority() }); Long id = usuario.getId(); assertNotNull(id); }
From source file:de.unibayreuth.bayeos.goat.table.MassenTableModel.java
public boolean updateRows(final ObjektNode objektNode, final int rows[], final Vector values) { boolean bol = false; try {/* w w w.j av a 2s . c o m*/ // get update columns Integer status = (Integer) values.elementAt(0); // get keys Vector vonDates = new Vector(); for (int r = 0; r < rows.length; r++) { vonDates.add(getValueAt(rows[r], 0)); } Vector params = new Vector(); params.add(objektNode.getId()); params.add(vonDates); params.add(status); bol = ((Boolean) xmlClient.execute("MassenTableHandler.updateRows", params)).booleanValue(); // Update display values for (int r = 0; r < rows.length; r++) { setValueAt(new Byte(status.byteValue()), rows[r], 2); } fireTableDataChanged(); } catch (XmlRpcException x) { MsgBox.error(x.getMessage()); return false; } return bol; }
From source file:mx.edu.um.mateo.general.web.EmpresaControllerTest.java
@Test public void debieraActualizarEmpresa() throws Exception { Organizacion organizacion = new Organizacion("TEST01", "TEST01", "TEST01"); currentSession().save(organizacion); EjercicioPK ejercicioPK = new EjercicioPK("TEST", organizacion); Byte x = new Byte("0"); Ejercicio ejercicio = new Ejercicio(ejercicioPK, "TEST", "A", StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY, x, x); currentSession().save(ejercicio);/* w w w. ja v a 2 s . co m*/ Empresa otraEmpresa = new Empresa("tst-01", "test-01", "test-01", "000000000001", organizacion); currentSession().save(otraEmpresa); Almacen almacen = new Almacen("TST", "TEST01", otraEmpresa); currentSession().save(almacen); Rol rol = new Rol("ROLE_TEST"); currentSession().save(rol); Set<Rol> roles = new HashSet<>(); roles.add(rol); Usuario usuario = new Usuario("bugs@um.edu.mx", "apPaterno", "apMaterno", "TEST-01", "TEST-01"); usuario.setEmpresa(otraEmpresa); usuario.setAlmacen(almacen); usuario.setRoles(roles); usuario.setEjercicio(ejercicio); currentSession().save(usuario); this.authenticate(usuario, usuario.getPassword(), new ArrayList<GrantedAuthority>(usuario.getAuthorities())); Empresa empresa = otraEmpresa; this.mockMvc .perform(post("/admin/empresa/actualiza").param("id", empresa.getId().toString()) .param("version", empresa.getVersion().toString()).param("codigo", "PRUEBA") .param("nombre", empresa.getNombre()).param("nombreCompleto", empresa.getNombreCompleto()) .param("rfc", "000000000001")) .andExpect(status().isOk()).andExpect(flash().attributeExists("message")) .andExpect(flash().attribute("message", "empresa.actualizada.message")); currentSession().refresh(empresa); assertEquals("PRUEBA", empresa.getCodigo()); }
From source file:MathUtils.java
/** * Convert a String in Double, Float, Integer, Long, Short or Byte, depending on the T exemple * For exemple convert("2", 0f) will return 2.0 as a float * @param <T> type returned//from w ww . j ava 2s . c om * @param str String to convert * @param exemple exemple of the type * @return a number representation of the String * @throws IllegalArgumentException if the T type is not Double, Float, Integer, Long, Short or Byte * @throws NumberFormatException if the conversion fails */ public static <T extends Number> T convert(String str, T exemple) throws NumberFormatException, IllegalArgumentException { T result = null; if (exemple instanceof Double) { result = (T) new Double(str); } else if (exemple instanceof Float) { result = (T) new Float(str); } else if (exemple instanceof Integer) { result = (T) new Integer(str); } else if (exemple instanceof Long) { result = (T) new Long(str); } else if (exemple instanceof Short) { result = (T) new Short(str); } else if (exemple instanceof Byte) { result = (T) new Byte(str); } else { throw new IllegalArgumentException("Conversion is not possible with class " + exemple.getClass() + "; only allowing Double, Float, integer, Long, Short & Byte"); } return result; }
From source file:org.apache.axis2.corba.idl.values.AbstractValue.java
protected Object read(DataType dataType, InputStream inputStream) { TCKind kind = dataType.getTypeCode().kind(); Object ret = null;//www . j ava2s .com switch (kind.value()) { case TCKind._tk_long: ret = new Integer(inputStream.read_long()); break; case TCKind._tk_ulong: ret = new Integer(inputStream.read_ulong()); break; case TCKind._tk_longlong: ret = new Long(inputStream.read_longlong()); break; case TCKind._tk_ulonglong: ret = new Long(inputStream.read_ulonglong()); break; case TCKind._tk_short: ret = new Short(inputStream.read_short()); break; case TCKind._tk_ushort: ret = new Short(inputStream.read_ushort()); break; case TCKind._tk_float: ret = new Float(inputStream.read_float()); break; case TCKind._tk_double: ret = new Double(inputStream.read_double()); break; case TCKind._tk_char: ret = new Character(inputStream.read_char()); break; case TCKind._tk_wchar: ret = new Character(inputStream.read_wchar()); break; case TCKind._tk_boolean: ret = Boolean.valueOf(inputStream.read_boolean()); break; case TCKind._tk_octet: ret = new Byte(inputStream.read_octet()); break; case TCKind._tk_string: ret = inputStream.read_string(); break; case TCKind._tk_wstring: ret = inputStream.read_wstring(); break; case TCKind._tk_any: ret = inputStream.read_any(); break; case TCKind._tk_value: ret = inputStream.read_value(); break; //case TCKind._tk_longdouble : case TCKind._tk_struct: StructValue structValue = new StructValue((Struct) dataType); structValue.read(inputStream); ret = structValue; break; case TCKind._tk_enum: EnumValue enumValue = new EnumValue((EnumType) dataType); enumValue.read(inputStream); ret = enumValue; break; case TCKind._tk_union: UnionValue unionValue = new UnionValue((UnionType) dataType); unionValue.read(inputStream); ret = unionValue; break; case TCKind._tk_alias: AliasValue aliasValue = new AliasValue((Typedef) dataType); aliasValue.read(inputStream); ret = aliasValue; break; case TCKind._tk_sequence: SequenceValue sequenceValue = new SequenceValue((SequenceType) dataType); sequenceValue.read(inputStream); ret = sequenceValue; break; case TCKind._tk_array: ArrayValue arrayValue = new ArrayValue((ArrayType) dataType); arrayValue.read(inputStream); ret = arrayValue; break; case TCKind._tk_except: ExceptionValue exValue = new ExceptionValue((ExceptionType) dataType); exValue.read(inputStream); ret = exValue; break; default: log.error("ERROR! Invalid dataType"); break; } return ret; }
From source file:org.openbravo.base.MultipartRequest.java
protected void readSubmittedFile(InputStream in) throws IOException { Vector<FieldProvider> vector = new Vector<FieldProvider>(); int result = 0; String linea = ""; Vector<Byte> vectorInt = new Vector<Byte>(); boolean isFirstRow = true; while ((result = in.read()) != -1) { if (result == 13 || result == 10) { if (vectorInt.size() > 0) { byte[] b = new byte[vectorInt.size()]; for (int i = 0; i < vectorInt.size(); i++) { Byte bAux = vectorInt.elementAt(i); b[i] = bAux.byteValue(); }//from www . ja v a 2 s.c o m vectorInt = new Vector<Byte>(); linea = new String(b, "UTF-8"); if (!isFirstRow || !firstRowHeads) { FieldProvider fieldProvider = setFieldProvider(linea); vector.addElement(fieldProvider); } } isFirstRow = false; } else { byte aux = new Integer(result).byteValue(); vectorInt.addElement(new Byte(aux)); } } if (vectorInt.size() > 0 && (!isFirstRow || !firstRowHeads)) { byte[] b = new byte[vectorInt.size()]; for (int i = 0; i < vectorInt.size(); i++) { Byte bAux = vectorInt.elementAt(i); b[i] = bAux.byteValue(); } vectorInt = new Vector<Byte>(); linea = new String(b); FieldProvider fieldProvider = setFieldProvider(linea); vector.addElement(fieldProvider); } objectFieldProvider = new FieldProvider[vector.size()]; vector.copyInto(objectFieldProvider); }
From source file:hermes.providers.messages.MapMessageImpl.java
public void setByte(String arg0, byte arg1) throws JMSException { body.put(arg0, new Byte(arg1)); }
From source file:com.ms.commons.summer.web.util.json.JsonNumberMorpher.java
private Object morphToByte(String str) { try {/* w ww . ja va 2 s .co m*/ return new Byte(str); } catch (Exception e) { throw new ConvertErrorException(str, this.type); } }
From source file:io.nuun.plugin.configuration.common.ConfigurationMembersInjector.java
@Override public void injectMembers(T instance) { NuunProperty injectConfigAnnotation = null; // The annotation is actual NuunProperty.class if (clonedAnno.annotationType() == NuunProperty.class) { injectConfigAnnotation = field.getAnnotation(NuunProperty.class); } else { // The annotation has the NuunProperty annotation on it we proxy it injectConfigAnnotation = AssertUtils.annotationProxyOf(NuunProperty.class, clonedAnno); }//from w w w .j av a 2 s . co m String configurationParameterName = injectConfigAnnotation.value(); // Pre verification // if (StringUtils.isEmpty(configurationParameterName)) { log.error("Value for annotation {} on field {} can not be null or empty.", clonedAnno.annotationType(), field.toGenericString()); throw new PluginException("Value for annotation %s on field %s can not be null or empty.", clonedAnno.annotationType(), field.toGenericString()); } if (!configuration.containsKey(configurationParameterName) && injectConfigAnnotation.mandatory()) { throw new PluginException("\"%s\" must be in one properties file for field %s.", configurationParameterName, field.toGenericString()); } try { this.field.setAccessible(true); Class<?> type = field.getType(); if (type == Integer.TYPE) { if (configuration.containsKey(configurationParameterName)) { field.setInt(instance, configuration.getInt(configurationParameterName)); } else { log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); field.setInt(instance, injectConfigAnnotation.defaultIntValue()); } } else if (type == Integer.class) { if (configuration.containsKey(configurationParameterName)) { field.set(instance, new Integer(configuration.getInt(configurationParameterName))); } else { log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); field.set(instance, new Integer(injectConfigAnnotation.defaultIntValue())); } } else if (type == Boolean.TYPE) { if (configuration.containsKey(configurationParameterName)) { field.setBoolean(instance, configuration.getBoolean(configurationParameterName)); } else { log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); field.setBoolean(instance, injectConfigAnnotation.defaultBooleanValue()); } } else if (type == Boolean.class) { if (configuration.containsKey(configurationParameterName)) { field.set(instance, new Boolean(configuration.getBoolean(configurationParameterName))); } else { log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); field.set(instance, new Boolean(injectConfigAnnotation.defaultBooleanValue())); } } else if (type == Short.TYPE) { if (configuration.containsKey(configurationParameterName)) { field.setShort(instance, configuration.getShort(configurationParameterName)); } else { log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); field.setShort(instance, injectConfigAnnotation.defaultShortValue()); } } else if (type == Short.class) { if (configuration.containsKey(configurationParameterName)) { field.set(instance, new Short(configuration.getShort(configurationParameterName))); } else { log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); field.set(instance, new Short(injectConfigAnnotation.defaultShortValue())); } } else if (type == Byte.TYPE) { if (configuration.containsKey(configurationParameterName)) { field.setByte(instance, configuration.getByte(configurationParameterName)); } else { log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); field.setByte(instance, injectConfigAnnotation.defaultByteValue()); } } else if (type == Byte.class) { if (configuration.containsKey(configurationParameterName)) { field.set(instance, new Byte(configuration.getByte(configurationParameterName))); } else { log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); field.set(instance, new Byte(injectConfigAnnotation.defaultByteValue())); } } else if (type == Long.TYPE) { if (configuration.containsKey(configurationParameterName)) { field.setLong(instance, configuration.getLong(configurationParameterName)); } else { log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); field.setLong(instance, injectConfigAnnotation.defaultLongValue()); } } else if (type == Long.class) { if (configuration.containsKey(configurationParameterName)) { field.set(instance, new Long(configuration.getLong(configurationParameterName))); } else { log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); field.set(instance, new Long(injectConfigAnnotation.defaultLongValue())); } } else if (type == Float.TYPE) { if (configuration.containsKey(configurationParameterName)) { field.setFloat(instance, configuration.getFloat(configurationParameterName)); } else { log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); field.setFloat(instance, injectConfigAnnotation.defaultFloatValue()); } } else if (type == Float.class) { if (configuration.containsKey(configurationParameterName)) { field.set(instance, new Float(configuration.getFloat(configurationParameterName))); } else { log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); field.set(instance, new Float(injectConfigAnnotation.defaultFloatValue())); } } else if (type == Double.TYPE) { if (configuration.containsKey(configurationParameterName)) { field.setDouble(instance, configuration.getDouble(configurationParameterName)); } else { log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); field.setDouble(instance, injectConfigAnnotation.defaultDoubleValue()); } } else if (type == Double.class) { if (configuration.containsKey(configurationParameterName)) { field.set(instance, new Double(configuration.getDouble(configurationParameterName))); } else { log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); field.set(instance, new Double(injectConfigAnnotation.defaultDoubleValue())); } } else if (type == Character.TYPE) { if (configuration.containsKey(configurationParameterName)) { field.setChar(instance, configuration.getString(configurationParameterName).charAt(0)); } } else if (type == Character.class) { if (configuration.containsKey(configurationParameterName)) { field.set(instance, new Character(configuration.getString(configurationParameterName).charAt(0))); } } else { Object property = getProperty(configurationParameterName, injectConfigAnnotation); field.set(instance, property); } } catch (IllegalArgumentException ex) { log.error("Wrong argument or argument type during configuration injection", ex); } catch (IllegalAccessException ex) { log.error("Illegal access during configuration injection", ex); } catch (InstantiationException ex) { log.error("Impossible to instantiate value converter", ex); } finally { this.field.setAccessible(false); } }