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:net.sourceforge.msscodefactory.cfensyntax.v2_2.CFEnSyntaxMSSql.CFEnSyntaxMSSqlSchema.java

public static Byte getNullableByte(ResultSet reader, int colidx) {
    try {/*  w w w  .j ava2s  . com*/
        byte val = reader.getByte(colidx);
        if (reader.wasNull()) {
            return (null);
        } else {
            return (new Byte(val));
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(CFEnSyntaxMSSqlSchema.class, "getNullableByte",
                e);
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccMySql.CFAccMySqlSchema.java

public static Byte getNullableByte(ResultSet reader, int colidx) {
    try {//from  w  w  w .  j a  v  a 2s .c om
        byte val = reader.getByte(colidx);
        if (reader.wasNull()) {
            return (null);
        } else {
            return (new Byte(val));
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(CFAccMySqlSchema.class, "getNullableByte", e);
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWSchema.java

public static Byte getNullableByte(ResultSet reader, int colidx) {
    try {/* w  ww.  ja v a2 s  .c o  m*/
        byte val = reader.getByte(colidx);
        if (reader.wasNull()) {
            return (null);
        } else {
            return (new Byte(val));
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(CFAccDb2LUWSchema.class, "getNullableByte", e);
    }
}

From source file:net.sf.jasperreports.engine.xml.JRXmlConstants.java

/**
 * @deprecated Replaced by {@link LineStyleEnum}.
 *///from  w  ww .  j  av a  2s  .c o m
public static Map getLineStyleMap() {
    if (lineStyleMap == null) {
        Map map = new HashMap(11);
        map.put(LINE_STYLE_SOLID, new Byte(JRPen.LINE_STYLE_SOLID));
        map.put(LINE_STYLE_DASHED, new Byte(JRPen.LINE_STYLE_DASHED));
        map.put(LINE_STYLE_DOTTED, new Byte(JRPen.LINE_STYLE_DOTTED));
        map.put(lINE_STYLE_DOUBLE, new Byte(JRPen.LINE_STYLE_DOUBLE));
        map.put(new Byte(JRPen.LINE_STYLE_SOLID), LINE_STYLE_SOLID);
        map.put(new Byte(JRPen.LINE_STYLE_DASHED), LINE_STYLE_DASHED);
        map.put(new Byte(JRPen.LINE_STYLE_DOTTED), LINE_STYLE_DOTTED);
        map.put(new Byte(JRPen.LINE_STYLE_DOUBLE), lINE_STYLE_DOUBLE);
        lineStyleMap = Collections.unmodifiableMap(map);
    }

    return lineStyleMap;
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccOracle.CFAccOracleSchema.java

public static Byte getNullableByte(ResultSet reader, int colidx) {
    try {//from  w  ww .  ja v a2 s .c  o m
        byte val = reader.getByte(colidx);
        if (reader.wasNull()) {
            return (null);
        } else {
            return (new Byte(val));
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(CFAccOracleSchema.class, "getNullableByte", e);
    }
}

From source file:com.draagon.meta.manager.db.driver.GenericSQLDriver.java

protected void parseField(Object o, MetaField f, ResultSet rs, int j) throws SQLException {
    switch (f.getType()) {
    case MetaField.BOOLEAN: {
        boolean bv = rs.getBoolean(j);
        if (rs.wasNull()) {
            f.setBoolean(o, null);//  w w w . j a va2 s.  c  o  m
        } else {
            f.setBoolean(o, new Boolean(bv));
        }
    }
        break;

    case MetaField.BYTE: {
        byte bv = rs.getByte(j);
        if (rs.wasNull()) {
            f.setByte(o, null);
        } else {
            f.setByte(o, new Byte(bv));
        }
    }
        break;

    case MetaField.SHORT: {
        short sv = rs.getShort(j);
        if (rs.wasNull()) {
            f.setShort(o, null);
        } else {
            f.setShort(o, new Short(sv));
        }
    }
        break;

    case MetaField.INT: {
        int iv = rs.getInt(j);
        if (rs.wasNull()) {
            f.setInt(o, null);
        } else {
            f.setInt(o, new Integer(iv));
        }
    }
        break;

    case MetaField.DATE: {
        Timestamp tv = rs.getTimestamp(j);
        if (rs.wasNull()) {
            f.setDate(o, null);
        } else {
            f.setDate(o, new java.util.Date(tv.getTime()));
        }
    }
        break;

    case MetaField.LONG: {
        long lv = rs.getLong(j);
        if (rs.wasNull()) {
            f.setLong(o, null);
        } else {
            f.setLong(o, new Long(lv));
        }
    }
        break;

    case MetaField.FLOAT: {
        float fv = rs.getFloat(j);
        if (rs.wasNull()) {
            f.setFloat(o, null);
        } else {
            f.setFloat(o, new Float(fv));
        }
    }
        break;

    case MetaField.DOUBLE: {
        double dv = rs.getDouble(j);
        if (rs.wasNull()) {
            f.setDouble(o, null);
        } else {
            f.setDouble(o, new Double(dv));
        }
    }
        break;

    case MetaField.STRING:
        f.setString(o, rs.getString(j));
        break;

    case MetaField.OBJECT:
        f.setObject(o, rs.getObject(j));
        break;
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskMSSql.CFAsteriskMSSqlSchema.java

public static Byte getNullableByte(ResultSet reader, int colidx) {
    try {//from ww w  .  j a  v  a 2s.c o m
        byte val = reader.getByte(colidx);
        if (reader.wasNull()) {
            return (null);
        } else {
            return (new Byte(val));
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(CFAsteriskMSSqlSchema.class, "getNullableByte",
                e);
    }
}

From source file:org.plasma.sdo.helper.DataConverter.java

/**
 * Converts the given string value to an object appropriate
 * for the target property and its type. If the given property is a 'many' property,
 * java.util.Arrays formatting is expected.
 * Any java.util.Arrays formatting is/*w w  w.java  2  s  .com*/
 * removed and the arrays converted into a list
 * of elements appropriate for the target type.
 * @param targetType the target data type
 * @param value the value to convert from string
 * @return the converted value
 * @throws IllegalArgumentException if the given property is a 'many' property and no  
 * java.util.Arrays formatting is detected for the given value.
 */
public Object fromString(Property targetProperty, String value) {
    DataType targetDataType = DataType.valueOf(targetProperty.getType().getName());
    switch (targetDataType) {
    case String:
        if (!targetProperty.isMany()) {
            if (!value.startsWith("[")) {
                return value;
            } else { // ignore arrays formatting for singular properties as these are allowed to contain '['
                return value;
            }
        } else {
            if (value.startsWith("[")) {
                String[] strings = value.replaceAll("[\\[\\]\\s]", "").split(",");
                List<String> list = new ArrayList<String>();
                for (String arrayValue : strings)
                    list.add(arrayValue);
                return list;
            } else {
                throw new IllegalArgumentException(
                        "no java.util.Arrays formatting detected for the given value, for the given 'many' property, "
                                + targetProperty.toString());
            }
        }
    case Decimal:
        if (!targetProperty.isMany()) {
            if (!value.startsWith("[")) {
                return new BigDecimal(value);
            } else {
                throw new IllegalArgumentException(
                        "no java.util.Arrays formatting expected for the given value, for the given singular property, "
                                + targetProperty.toString());
            }
        } else {
            if (value.startsWith("[")) {
                String[] strings = value.replaceAll("[\\[\\]\\s]", "").split(",");
                List<BigDecimal> list = new ArrayList<BigDecimal>();
                for (String arrayValue : strings)
                    list.add(new BigDecimal(arrayValue));
                return list;
            } else {
                throw new IllegalArgumentException(
                        "no java.util.Arrays formatting detected for the given value, for the given 'many' property, "
                                + targetProperty.toString());
            }
        }
    case Bytes:
        if (!targetProperty.isMany()) {
            return value.getBytes(); // FIXME: charset?
        } else {
            if (value.startsWith("[")) {
                String[] strings = value.replaceAll("[\\[\\]\\s]", "").split(",");
                List<byte[]> list = new ArrayList<byte[]>();
                for (String arrayValue : strings)
                    list.add(value.getBytes()); // FIXME: charset?
                return list;
            } else {
                throw new IllegalArgumentException(
                        "no java.util.Arrays formatting detected for the given value, for the given 'many' property, "
                                + targetProperty.toString());
            }
        }
    case Byte:
        if (!targetProperty.isMany()) {
            byte[] byteArray = value.getBytes(); // FIXME: charset?
            return new Byte(byteArray[0]); //TODO: truncation warning?
        } else {
            if (value.startsWith("[")) {
                String[] strings = value.replaceAll("[\\[\\]\\s]", "").split(",");
                List<Byte> list = new ArrayList<Byte>();
                byte[] byteArray = null;
                for (String arrayValue : strings) {
                    byteArray = arrayValue.getBytes();
                    list.add(new Byte(byteArray[0]));
                }
                return list;
            } else {
                throw new IllegalArgumentException(
                        "no java.util.Arrays formatting detected for the given value, for the given 'many' property, "
                                + targetProperty.toString());
            }
        }
    case Boolean:
        if (!targetProperty.isMany()) {
            if (!value.startsWith("[")) {
                return Boolean.valueOf(value);
            } else {
                throw new IllegalArgumentException(
                        "no java.util.Arrays formatting expected for the given value, for the given singular property, "
                                + targetProperty.toString());
            }
        } else {
            if (value.startsWith("[")) {
                String[] strings = value.replaceAll("[\\[\\]\\s]", "").split(",");
                List<Boolean> list = new ArrayList<Boolean>();
                for (String arrayValue : strings)
                    list.add(Boolean.valueOf(arrayValue));
                return list;
            } else {
                throw new IllegalArgumentException(
                        "no java.util.Arrays formatting detected for the given value, for the given 'many' property, "
                                + targetProperty.toString());
            }
        }
    case Character:
        if (!targetProperty.isMany()) {
            return Character.valueOf(value.charAt(0)); // TODO: truncation warning?
        } else {
            if (value.startsWith("[")) {
                String[] strings = value.replaceAll("[\\[\\]\\s]", "").split(",");
                List<Character> list = new ArrayList<Character>();
                for (String arrayValue : strings)
                    list.add(Character.valueOf(arrayValue.charAt(0)));
                return list;
            } else {
                throw new IllegalArgumentException(
                        "no java.util.Arrays formatting detected for the given value, for the given 'many' property, "
                                + targetProperty.toString());
            }
        }
    case Double:
        if (!targetProperty.isMany()) {
            if (!value.startsWith("[")) {
                return Double.valueOf(value);
            } else {
                throw new IllegalArgumentException(
                        "no java.util.Arrays formatting expected for the given value, for the given singular property, "
                                + targetProperty.toString());
            }
        } else {
            if (value.startsWith("[")) {
                String[] strings = value.replaceAll("[\\[\\]\\s]", "").split(",");
                List<Double> list = new ArrayList<Double>();
                for (String arrayValue : strings)
                    list.add(Double.valueOf(arrayValue));
                return list;
            } else {
                throw new IllegalArgumentException(
                        "no java.util.Arrays formatting detected for the given value, for the given 'many' property, "
                                + targetProperty.toString());
            }
        }
    case Float:
        if (!targetProperty.isMany()) {
            if (!value.startsWith("[")) {
                return Float.valueOf(value);
            } else {
                throw new IllegalArgumentException(
                        "no java.util.Arrays formatting expected for the given value, for the given singular property, "
                                + targetProperty.toString());
            }
        } else {
            if (value.startsWith("[")) {
                String[] strings = value.replaceAll("[\\[\\]\\s]", "").split(",");
                List<Float> list = new ArrayList<Float>();
                for (String arrayValue : strings)
                    list.add(Float.valueOf(arrayValue));
                return list;
            } else {
                throw new IllegalArgumentException(
                        "no java.util.Arrays formatting detected for the given value, for the given 'many' property, "
                                + targetProperty.toString());
            }
        }
    case Int:
        if (!targetProperty.isMany()) {
            if (!value.startsWith("[")) {
                return Integer.valueOf(value);
            } else {
                throw new IllegalArgumentException(
                        "no java.util.Arrays formatting expected for the given value, for the given singular property, "
                                + targetProperty.toString());
            }
        } else {
            if (value.startsWith("[")) {
                String[] strings = value.replaceAll("[\\[\\]\\s]", "").split(",");
                List<Integer> list = new ArrayList<Integer>();
                for (String arrayValue : strings)
                    list.add(Integer.valueOf(arrayValue));
                return list;
            } else {
                throw new IllegalArgumentException(
                        "no java.util.Arrays formatting detected for the given value, for the given 'many' property, "
                                + targetProperty.toString());
            }
        }
    case Integer:
        if (!targetProperty.isMany()) {
            if (!value.startsWith("[")) {
                return new BigInteger(value);
            } else {
                throw new IllegalArgumentException(
                        "no java.util.Arrays formatting expected for the given value, for the given singular property, "
                                + targetProperty.toString());
            }
        } else {
            if (value.startsWith("[")) {
                String[] strings = value.replaceAll("[\\[\\]\\s]", "").split(",");
                List<BigInteger> list = new ArrayList<BigInteger>();
                for (String arrayValue : strings)
                    list.add(new BigInteger(arrayValue));
                return list;
            } else {
                throw new IllegalArgumentException(
                        "no java.util.Arrays formatting detected for the given value, for the given 'many' property, "
                                + targetProperty.toString());
            }
        }
    case Long:
        if (!targetProperty.isMany()) {
            if (!value.startsWith("[")) {
                return Long.valueOf(value);
            } else {
                throw new IllegalArgumentException(
                        "no java.util.Arrays formatting expected for the given value, for the given singular property, "
                                + targetProperty.toString());
            }
        } else {
            if (value.startsWith("[")) {
                String[] strings = value.replaceAll("[\\[\\]\\s]", "").split(",");
                List<Long> list = new ArrayList<Long>();
                for (String arrayValue : strings)
                    list.add(Long.valueOf(arrayValue));
                return list;
            } else {
                throw new IllegalArgumentException(
                        "no java.util.Arrays formatting detected for the given value, for the given 'many' property, "
                                + targetProperty.toString());
            }
        }
    case Short:
        if (!targetProperty.isMany()) {
            if (!value.startsWith("[")) {
                return Short.valueOf(value);
            } else {
                throw new IllegalArgumentException(
                        "no java.util.Arrays formatting expected for the given value, for the given singular property, "
                                + targetProperty.toString());
            }
        } else {
            if (value.startsWith("[")) {
                String[] strings = value.replaceAll("[\\[\\]\\s]", "").split(",");
                List<Short> list = new ArrayList<Short>();
                for (String arrayValue : strings)
                    list.add(Short.valueOf(arrayValue));
                return list;
            } else {
                throw new IllegalArgumentException(
                        "no java.util.Arrays formatting detected for the given value, for the given 'many' property, "
                                + targetProperty.toString());
            }
        }
    case Strings:
        if (!targetProperty.isMany()) {
            String[] values = value.split("\\s");
            List<String> list = new ArrayList<String>(values.length);
            for (int i = 0; i < values.length; i++)
                list.add(values[i]);
            return list;
        } else {
            if (value.startsWith("[")) {
                // don't replace whitespace internal to individual 'strings' value
                String tempValue = value.replaceAll("[\\[\\]]", "");
                tempValue.trim(); // just trim Arrays formatting
                String[] strings = tempValue.split(",");
                List<List<String>> list = new ArrayList<List<String>>();
                for (String arrayValue : strings) {
                    String[] values = arrayValue.split("\\s");
                    List<String> subList = new ArrayList<String>(values.length);
                    for (int i = 0; i < values.length; i++)
                        subList.add(values[i]);
                    list.add(subList);
                }
                return list;
            } else {
                throw new IllegalArgumentException(
                        "no java.util.Arrays formatting detected for the given value, for the given 'many' property, "
                                + targetProperty.toString());
            }
        }
    case Date:
        try {
            if (!targetProperty.isMany()) {
                return getDateFormat().parse(value);
            } else {
                if (value.startsWith("[")) {
                    String[] strings = value.replaceAll("[\\[\\]\\s]", "").split(",");
                    List<Date> list = new ArrayList<Date>();
                    for (String arrayValue : strings)
                        list.add(getDateFormat().parse(arrayValue));
                    return list;
                } else {
                    throw new IllegalArgumentException(
                            "no java.util.Arrays formatting detected for the given value, for the given 'many' property, "
                                    + targetProperty.toString());
                }
            }
        } catch (ParseException e) {
            throw new PlasmaDataObjectException(e);
        }
    case DateTime:
    case Month:
    case MonthDay:
    case URI:
    case Day:
    case Duration:
    case Time:
    case Year:
    case YearMonth:
    case YearMonthDay:
        if (!targetProperty.isMany()) {
            if (!value.startsWith("[")) {
                // TODO: See lexical XML Schema string representation for these types
                return value;
            } else {
                throw new IllegalArgumentException(
                        "no java.util.Arrays formatting expected for the given value, for the given singular property, "
                                + targetProperty.toString());
            }
        } else {
            if (value.startsWith("[")) {
                String[] strings = value.replaceAll("[\\[\\]\\s]", "").split(",");
                List<String> list = new ArrayList<String>();
                for (String arrayValue : strings)
                    list.add(arrayValue);
                return list;
            } else {
                throw new IllegalArgumentException(
                        "no java.util.Arrays formatting detected for the given value, for the given 'many' property, "
                                + targetProperty.toString());
            }
        }
    default:
        throw new InvalidDataConversionException(targetDataType, DataType.String, value);
    }
}

From source file:net.sf.jasperreports.engine.xml.JRXmlConstants.java

/**
 * @deprecated Replaced by {@link PenEnum}.
 *//*from   w  ww  .j  a va2s . c om*/
public static Map getPenMap() {
    if (penMap == null) {
        Map map = new HashMap(16);
        map.put(PEN_NONE, new Byte(JRGraphicElement.PEN_NONE));
        map.put(PEN_THIN, new Byte(JRGraphicElement.PEN_THIN));
        map.put(PEN_1_POINT, new Byte(JRGraphicElement.PEN_1_POINT));
        map.put(PEN_2_POINT, new Byte(JRGraphicElement.PEN_2_POINT));
        map.put(PEN_4_POINT, new Byte(JRGraphicElement.PEN_4_POINT));
        map.put(PEN_DOTTED, new Byte(JRGraphicElement.PEN_DOTTED));
        map.put(new Byte(JRGraphicElement.PEN_NONE), PEN_NONE);
        map.put(new Byte(JRGraphicElement.PEN_THIN), PEN_THIN);
        map.put(new Byte(JRGraphicElement.PEN_1_POINT), PEN_1_POINT);
        map.put(new Byte(JRGraphicElement.PEN_2_POINT), PEN_2_POINT);
        map.put(new Byte(JRGraphicElement.PEN_4_POINT), PEN_4_POINT);
        map.put(new Byte(JRGraphicElement.PEN_DOTTED), PEN_DOTTED);
        penMap = Collections.unmodifiableMap(map);
    }

    return penMap;
}

From source file:net.sf.jasperreports.engine.xml.JRXmlConstants.java

/**
 * @deprecated Replaced by {@link FillEnum}.
 *//*  ww  w  .ja v a  2  s  .  c  o m*/
public static Map getFillMap() {
    if (fillMap == null) {
        Map map = new HashMap(3);
        map.put(FILL_SOLID, new Byte(JRGraphicElement.FILL_SOLID));
        map.put(new Byte(JRGraphicElement.FILL_SOLID), FILL_SOLID);
        fillMap = Collections.unmodifiableMap(map);
    }

    return fillMap;
}