Example usage for java.lang Byte Byte

List of usage examples for java.lang Byte Byte

Introduction

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

Prototype

@Deprecated(since = "9")
public Byte(String s) throws NumberFormatException 

Source Link

Document

Constructs a newly allocated Byte object that represents the byte value indicated by the String parameter.

Usage

From source file:mx.edu.um.mateo.general.dao.impl.OrganizacionDaoHibernate.java

@Override
public Organizacion crea(Organizacion organizacion, Usuario usuario) {
    Session session = currentSession();/*from ww w. j  ava 2 s.  co  m*/
    session.save(organizacion);
    Calendar cal = Calendar.getInstance();
    StringBuilder idEjercicio = new StringBuilder();
    idEjercicio.append("001-");
    idEjercicio.append(cal.get(Calendar.YEAR));
    EjercicioPK ejercicioPK = new EjercicioPK(idEjercicio.toString(), organizacion);
    Byte x = new Byte("0");
    Ejercicio ejercicio = new Ejercicio(ejercicioPK, idEjercicio.toString(), "A", StringUtils.EMPTY,
            StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY, x, x);
    session.save(ejercicio);
    log.debug("Ejercicio creado {}", ejercicio);
    Empresa empresa = new Empresa("MTZ", "MATRIZ", "MATRIZ", "000000000001", organizacion);
    if (usuario != null) {
        usuario.setEmpresa(empresa);
    }
    empresaDao.crea(empresa, usuario);
    reporteDao.inicializaOrganizacion(organizacion);
    session.refresh(organizacion);
    session.flush();
    return organizacion;
}

From source file:fr.in2p3.cc.storage.treqs.persistence.mysql.dao.MySQLConfigurationDAO.java

@Override
public MultiMap getResourceAllocation() throws TReqSException {
    LOGGER.trace("> getResourceAllocation");

    // Allocations maps a media type to a pair (user,share)
    final MultiMap allocations = new MultiValueMap();

    final Object[] objects = MySQLBroker.getInstance().executeSelect(MySQLStatements.SQL_ALLOCATIONS_SELECT);

    // Store result
    final ResultSet result = (ResultSet) objects[1];
    try {/*from w w w .j a  v  a  2s  .  c om*/
        while (result.next()) {
            int index = 1;
            final byte id = result.getByte(index++);
            final String userName = result.getString(index++);
            final float share = result.getFloat(index++);
            final PersistenceHelperResourceAllocation helper = new PersistenceHelperResourceAllocation(userName,
                    share);
            allocations.put(new Byte(id), helper);
            LOGGER.debug("Allocation on mediatype: '" + id + "', user: '" + userName + "', share: " + share);
        }
    } catch (final SQLException exception) {
        throw new MySQLExecuteException(exception);
    } finally {
        MySQLBroker.getInstance().terminateExecution(objects);
    }
    if (allocations.size() == 0) {
        // No entry in table, something wrong with configuration.
        LOGGER.warn("No media type allocations found. Please define them " + "in the database.");
    }

    LOGGER.trace("< getResourceAllocation");

    return allocations;
}

From source file:org.jbpm.context.exe.VariableInstanceDbTest.java

public void testByte() {
    contextInstance.setVariable("a", new Byte("3"));
    processInstance = saveAndReload(processInstance);
    contextInstance = processInstance.getContextInstance();
    assertEquals(new Byte("3"), contextInstance.getVariable("a"));
}

From source file:com.sun.honeycomb.admin.mgmt.server.HCCellAdapterBase.java

public Byte getCellId() throws MgmtException {
    return new Byte(localCellid);
}

From source file:ConversionUtil.java

public static Object convertToValue(Class aClass, byte[] inputArray) throws Exception {

    Object returnValue = null;/*from   w  ww . jav  a  2  s.  com*/
    String className = aClass.getName();
    if (className.equals(Integer.class.getName())) {
        returnValue = new Integer(convertToInt(inputArray));
    } else if (className.equals(String.class.getName())) {
        returnValue = convertToString(inputArray);
    } else if (className.equals(Byte.class.getName())) {
        returnValue = new Byte(convertToByte(inputArray));
    } else if (className.equals(Long.class.getName())) {
        returnValue = new Long(convertToLong(inputArray));
    } else if (className.equals(Short.class.getName())) {
        returnValue = new Short(convertToShort(inputArray));
    } else if (className.equals(Boolean.class.getName())) {
        returnValue = new Boolean(convertToBoolean(inputArray));
    } else {
        throw new Exception("Cannot convert object of type " + className);
    }
    return returnValue;
}

From source file:com.enonic.esl.containers.ExtendedMap.java

public Object putByte(Object key, byte value) {
    return put(key, new Byte(value));
}

From source file:NumberUtils.java

/**
 * Convert the given number into an instance of the given target class.
 * @param number the number to convert// w w w .ja va 2 s .  co m
 * @param targetClass the target class to convert to
 * @return the converted number
 * @throws IllegalArgumentException if the target class is not supported
 * (i.e. not a standard Number subclass as included in the JDK)
 * @see java.lang.Byte
 * @see java.lang.Short
 * @see java.lang.Integer
 * @see java.lang.Long
 * @see java.math.BigInteger
 * @see java.lang.Float
 * @see java.lang.Double
 * @see java.math.BigDecimal
 */
public static Number convertNumberToTargetClass(Number number, Class<?> targetClass)
        throws IllegalArgumentException {

    //   Assert.notNull(number, "Number must not be null");
    //   Assert.notNull(targetClass, "Target class must not be null");

    if (targetClass.isInstance(number)) {
        return number;
    } else if (targetClass.equals(Byte.class)) {
        long value = number.longValue();
        if (value < Byte.MIN_VALUE || value > Byte.MAX_VALUE) {
            raiseOverflowException(number, targetClass);
        }
        return new Byte(number.byteValue());
    } else if (targetClass.equals(Short.class)) {
        long value = number.longValue();
        if (value < Short.MIN_VALUE || value > Short.MAX_VALUE) {
            raiseOverflowException(number, targetClass);
        }
        return new Short(number.shortValue());
    } else if (targetClass.equals(Integer.class)) {
        long value = number.longValue();
        if (value < Integer.MIN_VALUE || value > Integer.MAX_VALUE) {
            raiseOverflowException(number, targetClass);
        }
        return new Integer(number.intValue());
    } else if (targetClass.equals(Long.class)) {
        return new Long(number.longValue());
    } else if (targetClass.equals(Float.class)) {
        return new Float(number.floatValue());
    } else if (targetClass.equals(Double.class)) {
        return new Double(number.doubleValue());
    } else if (targetClass.equals(BigInteger.class)) {
        return BigInteger.valueOf(number.longValue());
    } else if (targetClass.equals(BigDecimal.class)) {
        // using BigDecimal(String) here, to avoid unpredictability of BigDecimal(double)
        // (see BigDecimal javadoc for details)
        return new BigDecimal(number.toString());
    } else {
        throw new IllegalArgumentException("Could not convert number [" + number + "] of type ["
                + number.getClass().getName() + "] to unknown target class [" + targetClass.getName() + "]");
    }
}

From source file:com.iLabs.spice.common.config.ConfigurationHandler.java

/**
 * This method returns the property value as Byte
 * //from w  ww  . j  a v a 2  s  .c  o m
 * @return Byte
 */
public Byte getPropertyAsByte(String propertyName) {
    propertyName = preProcessPropertyName(propertyName);
    if (configSubset != null) {
        return configSubset.getByte(propertyName, new Byte(""));
    } else {
        return compositeConfig.getByte(propertyName, new Byte(""));
    }
}