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:com.jaspersoft.studio.editor.preview.input.BigNumericInput.java

protected Number getNumber(String number) throws NumberFormatException {
    if (param.getValueClass().equals(Long.class)) {
        return new Long(number);
    } else if (param.getValueClass().equals(BigInteger.class)) {
        return new BigInteger(number);
    } else if (param.getValueClass().equals(Float.class)) {
        return new Float(number);
    } else if (param.getValueClass().equals(Double.class)) {
        return new Double(number);
    } else if (param.getValueClass().equals(Integer.class)) {
        return new Integer(number);
    } else if (param.getValueClass().equals(Short.class)) {
        return new Short(number);
    } else if (param.getValueClass().equals(Byte.class)) {
        return new Byte(number);
    } else if (param.getValueClass().equals(BigDecimal.class)) {
        return new BigDecimal(number);
    }/*  w  w  w . j  a va 2s.c  o m*/
    return null;
}

From source file:hermes.providers.messages.MessageImpl.java

public void setByteProperty(String arg0, byte arg1) throws JMSException {
    header.put(arg0, new Byte(arg1));
}

From source file:org.apache.struts.action.DynaActionForm.java

/**
 * <p>Return the value of a simple property with the specified name.</p>
 *
 * @param name Name of the property whose value is to be retrieved
 * @return The value of a simple property with the specified name.
 * @throws IllegalArgumentException if there is no property of the
 *                                  specified name
 * @throws NullPointerException     if the type specified for the property
 *                                  is invalid
 *///from   ww  w. j  a va  2s . c  o m
public Object get(String name) {
    // Return any non-null value for the specified property
    Object value = dynaValues.get(name);

    if (value != null) {
        return (value);
    }

    // Return a null value for a non-primitive property
    Class type = getDynaProperty(name).getType();

    if (type == null) {
        throw new NullPointerException("The type for property " + name + " is invalid");
    }

    if (!type.isPrimitive()) {
        return (value);
    }

    // Manufacture default values for primitive properties
    if (type == Boolean.TYPE) {
        return (Boolean.FALSE);
    } else if (type == Byte.TYPE) {
        return (new Byte((byte) 0));
    } else if (type == Character.TYPE) {
        return (new Character((char) 0));
    } else if (type == Double.TYPE) {
        return (new Double(0.0));
    } else if (type == Float.TYPE) {
        return (new Float((float) 0.0));
    } else if (type == Integer.TYPE) {
        return (new Integer(0));
    } else if (type == Long.TYPE) {
        return (new Long(0));
    } else if (type == Short.TYPE) {
        return (new Short((short) 0));
    } else {
        return (null);
    }
}

From source file:jp.terasoluna.fw.web.struts.reset.ResetterImpl.java

/**
 * ANVtH?[wv?peBZbg?B//from  w w w.  j  av a 2s .c o m
 * v?peB^boolean^?ABoolean^??false??B
 * v~eBu^bp?[^???A0??B
 * v?peB^bp?[^OObject^??null??B<br>
 * ??A?entrynulln?B
 *
 * @param form ?NGXggpANVtH?[
 * @param entry Zbg?v?peB?lGg
 * @throws PropertyAccessException v?peBl?s??
 */
protected void resetValue(FormEx form, Entry<String, Object> entry) {
    if (log.isDebugEnabled()) {
        log.debug("resetValue(" + form + ", " + entry.getKey() + ") called.");
    }
    String propName = entry.getKey();
    try {
        Object value = entry.getValue();
        if (value == null) {
            return;
        }
        Class type = null;
        type = value.getClass();
        if (type != null) {
            // ^???B
            if (type == Boolean.TYPE || type == Boolean.class) {
                BeanUtil.setBeanProperty(form, propName, Boolean.FALSE);
            } else if (type == Byte.TYPE || type == Byte.class) {
                BeanUtil.setBeanProperty(form, propName, new Byte((byte) 0));
            } else if (type == Character.TYPE || type == Character.class) {
                BeanUtil.setBeanProperty(form, propName, new Character((char) 0));
            } else if (type == Double.TYPE || type == Double.class) {
                BeanUtil.setBeanProperty(form, propName, new Double(0.0));
            } else if (type == Float.TYPE || type == Float.class) {
                BeanUtil.setBeanProperty(form, propName, new Float((float) 0.0));
            } else if (type == Integer.TYPE || type == Integer.class) {
                BeanUtil.setBeanProperty(form, propName, new Integer(0));
            } else if (type == Long.TYPE || type == Long.class) {
                BeanUtil.setBeanProperty(form, propName, new Long(0));
            } else if (type == Short.TYPE || type == Short.class) {
                BeanUtil.setBeanProperty(form, propName, new Short((short) 0));
            } else {
                // v~eBu^?Abp?[^??null?
                BeanUtil.setBeanProperty(form, propName, null);
            }
        }
    } catch (PropertyAccessException e) {
        log.error("cannot access property " + form + "." + propName, e);
    }
}

From source file:org.openvpms.component.system.common.jxpath.OpenVPMSTypeConverter.java

/**
 * Convert a {@link BigDecimal} to another type
 * /*  w  w  w.  j  a v  a 2 s.  c  om*/
 * @param type
 *            the class to convert too
 * @param value
 *            the value to convert
 * @return Number
 *            the converted number of null.
 *            
 */
protected Number allocateNumber(Class type, BigDecimal value) {
    if (type == Byte.class || type == byte.class) {
        return new Byte(value.byteValue());
    }
    if (type == Short.class || type == short.class) {
        return new Short(value.shortValue());
    }
    if (type == Integer.class || type == int.class) {
        return new Integer(value.intValue());
    }
    if (type == Long.class || type == long.class) {
        return new Long(value.longValue());
    }
    if (type == Float.class || type == float.class) {
        return new Float(value.floatValue());
    }
    if (type == Double.class || type == double.class) {
        return new Double(value.doubleValue());
    }
    if (type == BigDecimal.class) {
        return value;
    }
    if (type == BigInteger.class) {
        return BigInteger.valueOf(value.longValue());
    }

    if (type == Money.class) {
        return new Money((BigDecimal) value);
    }

    return null;
}

From source file:org.jboss.dashboard.factory.PropertyChangeProcessingInstruction.java

protected Object getValueForParameter(String paramValue, Class expectedClass) throws Exception {
    if (log.isDebugEnabled())
        log.debug("Getting value with class " + expectedClass + ", parsing " + paramValue);
    Object object = null;//from  w  ww  . j  av  a2  s . c  o m
    if (expectedClass.isArray()) {
        Class componentClass = expectedClass.getComponentType();
        if (componentClass.isArray())
            throw new Exception("Nested array properties are not supported.");
        List objectValue = new ArrayList();
        StringTokenizer stk = new StringTokenizer(paramValue, ARRAYS_DELIMITER, true);
        while (stk.hasMoreTokens()) {
            String token = stk.nextToken();
            int delimiterCount = 0;
            boolean addTrailingToken = true;
            while (ARRAYS_DELIMITER.equals(token)) {
                addTrailingToken = false;
                delimiterCount++;
                if (delimiterCount % 2 == 0) {
                    String lastToken = (String) objectValue.get(objectValue.size() - 1);
                    objectValue.set(objectValue.size() - 1, lastToken + ARRAYS_DELIMITER);
                    if (stk.hasMoreTokens()) {
                        token = stk.nextToken();
                        if (!ARRAYS_DELIMITER.equals(token)) {
                            lastToken = (String) objectValue.get(objectValue.size() - 1);
                            objectValue.remove(objectValue.size() - 1);
                            objectValue.add(lastToken + token);
                        }
                    } else {
                        addTrailingToken = false;
                        break;
                    }
                } else if (delimiterCount % 2 == 1 && !stk.hasMoreTokens()) {
                    objectValue.add("");
                } else if (stk.hasMoreTokens()) {
                    token = stk.nextToken();
                    addTrailingToken = true;
                }
            }
            if (addTrailingToken) {
                objectValue.add(token);
            }
        }
        for (int i = 0; i < objectValue.size(); i++) {
            String s = (String) objectValue.get(i);
            objectValue.set(i, getValueForParameter(s, componentClass));
        }

        Object baseObjectArray = getBaseArray(componentClass, objectValue.size());
        object = objectValue.toArray((Object[]) baseObjectArray);
    } else {
        if (String.class.equals(expectedClass)) {
            object = paramValue;
        } else if (expectedClass.equals(int.class)) {
            object = new Integer(toInt(paramValue));
        } else if (expectedClass.equals(boolean.class)) {
            object = (toBoolean(paramValue)) ? Boolean.TRUE : Boolean.FALSE;
        } else if (expectedClass.equals(long.class)) {
            object = new Long(toLong(paramValue));
        } else if (expectedClass.equals(char.class)) {
            object = new Character(toChar(paramValue));
        } else if (expectedClass.equals(double.class)) {
            object = new Double(toDouble(paramValue));
        } else if (expectedClass.equals(float.class)) {
            object = new Float(toFloat(paramValue));
        } else if (expectedClass.equals(byte.class)) {
            object = new Byte(toByte(paramValue));
        } else if (expectedClass.equals(short.class)) {
            object = new Short(toShort(paramValue));
        } else if (expectedClass.equals(File.class)) {
            object = toFile(paramValue);
        } else if (expectedClass.equals(Integer.class)) {
            object = new Integer(toInt(paramValue));
        } else if (expectedClass.equals(Boolean.class)) {
            object = (toBoolean(paramValue)) ? Boolean.TRUE : Boolean.FALSE;
        } else if (expectedClass.equals(Long.class)) {
            object = new Long(toLong(paramValue));
        } else if (expectedClass.equals(Character.class)) {
            object = new Character(toChar(paramValue));
        } else if (expectedClass.equals(Double.class)) {
            object = new Double(toDouble(paramValue));
        } else if (expectedClass.equals(Float.class)) {
            object = new Float(toFloat(paramValue));
        } else if (expectedClass.equals(Byte.class)) {
            object = new Byte(toByte(paramValue));
        } else if (expectedClass.equals(Short.class)) {
            object = new Short(toShort(paramValue));
        } else { //It will be a component
            object = toComponent(paramValue);
        }
    }
    return object;
}

From source file:org.ncbo.stanford.manager.impl.OntologyLoaderProtegeImplTest.java

private OntologyBean createOntolgyBeanBase() {
    OntologyBean bean = new OntologyBean(false);
    // bean.setOntologyId(3000);
    // OntologyId gets automatically generated.
    bean.setIsManual(ApplicationConstants.FALSE);
    bean.setFormat(ApplicationConstants.FORMAT_OWL_DL);
    bean.setDisplayLabel(TEST_PIZZA_DISPLAY_NAME);
    bean.setUserIds(Arrays.asList(1000));
    //bean.setVersionNumber("1.0");
    bean.setStatusId(StatusEnum.STATUS_WAITING.getStatus());
    bean.setVersionStatus("pre-production");
    bean.setIsRemote(new Byte("0"));
    bean.setIsReviewed(new Byte("1"));
    bean.setDateCreated(new Date());
    bean.setDateReleased(new Date());
    bean.setContactEmail("protege@email.com");
    bean.setContactName("Protege Name");
    bean.setIsFoundry(new Byte("0"));
    return bean;//ww  w  . j ava2s  .c  o  m
}

From source file:jp.co.ntts.vhut.util.Ipv4ConversionUtil.java

/**
 * byteint?????./*from ww w  . j a  v a  2s  .com*/
 * @param b 
 * @return ?
 */
static int convertToInt(byte b) {
    Integer intValue = new Byte(b).intValue();
    if (intValue < 0) {
        intValue += 256;
    }
    return intValue;
}

From source file:javadz.beanutils.ConvertUtilsBean.java

/**
 * Sets the default value for Byte conversions.
 * @param newDefaultByte The default Byte value
 * @deprecated Register replacement converters for Byte.TYPE and
 *  Byte.class instead/* w  w  w .  j a  v  a 2  s  .  c  o  m*/
 */
public void setDefaultByte(byte newDefaultByte) {
    defaultByte = new Byte(newDefaultByte);
    register(new ByteConverter(defaultByte), Byte.TYPE);
    register(new ByteConverter(defaultByte), Byte.class);
}

From source file:com.germinus.easyconf.ComponentProperties.java

public byte getByte(String key, Filter filter, byte defaultValue) {
    return getByte(key, filter, new Byte(defaultValue)).byteValue();
}