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.sf.jasperreports.engine.xml.JRXmlConstants.java

/**
 * @deprecated Replaced by {@link SortOrderEnum}.
 *///  ww  w . j  a v  a2  s . c om
public static Map getCrosstabBucketOrderMap() {
    if (crosstabBucketOrderMap == null) {
        Map map = new HashMap(6);
        map.put(CROSSTAB_BUCKET_ORDER_ASCENDING, new Byte(BucketDefinition.ORDER_ASCENDING));
        map.put(CROSSTAB_BUCKET_ORDER_DESCENDING, new Byte(BucketDefinition.ORDER_DESCENDING));
        map.put(new Byte(BucketDefinition.ORDER_ASCENDING), CROSSTAB_BUCKET_ORDER_ASCENDING);
        map.put(new Byte(BucketDefinition.ORDER_DESCENDING), CROSSTAB_BUCKET_ORDER_DESCENDING);
        crosstabBucketOrderMap = Collections.unmodifiableMap(map);
    }

    return crosstabBucketOrderMap;
}

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

/**
 * @deprecated Replaced by {@link CrosstabPercentageEnum}.
 *//*from w  ww  . j  a  v  a2 s. c  o  m*/
public static Map getCrosstabPercentageMap() {
    if (crosstabPercentageMap == null) {
        Map map = new HashMap(6);
        map.put(CROSSTAB_PERCENTAGE_NONE, new Byte(JRCrosstabMeasure.PERCENTAGE_TYPE_NONE));
        map.put(CROSSTAB_PERCENTAGE_GRAND_TOTAL, new Byte(JRCrosstabMeasure.PERCENTAGE_TYPE_GRAND_TOTAL));
        map.put(new Byte(JRCrosstabMeasure.PERCENTAGE_TYPE_NONE), CROSSTAB_PERCENTAGE_NONE);
        map.put(new Byte(JRCrosstabMeasure.PERCENTAGE_TYPE_GRAND_TOTAL), CROSSTAB_PERCENTAGE_GRAND_TOTAL);
        crosstabPercentageMap = Collections.unmodifiableMap(map);
    }

    return crosstabPercentageMap;
}

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

/**
 * @deprecated Replaced by {@link CrosstabTotalPositionEnum}.
 *//*from  w  ww .  j a v  a  2  s .  c o  m*/
public static Map getCrosstabTotalPositionMap() {
    if (crosstabTotalPositionMap == null) {
        Map map = new HashMap(8);
        map.put(CROSSTAB_TOTAL_POSITION_NONE, new Byte(BucketDefinition.TOTAL_POSITION_NONE));
        map.put(CROSSTAB_TOTAL_POSITION_START, new Byte(BucketDefinition.TOTAL_POSITION_START));
        map.put(CROSSTAB_TOTAL_POSITION_END, new Byte(BucketDefinition.TOTAL_POSITION_END));
        map.put(new Byte(BucketDefinition.TOTAL_POSITION_NONE), CROSSTAB_TOTAL_POSITION_NONE);
        map.put(new Byte(BucketDefinition.TOTAL_POSITION_START), CROSSTAB_TOTAL_POSITION_START);
        map.put(new Byte(BucketDefinition.TOTAL_POSITION_END), CROSSTAB_TOTAL_POSITION_END);
        crosstabTotalPositionMap = Collections.unmodifiableMap(map);
    }

    return crosstabTotalPositionMap;
}

From source file:org.openbaton.clients.interfaces.client.openstack.OpenstackClient.java

private static String translateToNAT(String floatingIp) throws UnknownHostException {

    Properties natRules = new Properties();
    try {//from w  w w  .  ja  va 2  s  . c  om
        File file = new File("/etc/openbaton/plugin/openstack/nat-translation-rules.properties");
        if (file.exists()) {
            natRules.load(new FileInputStream(file));
        } else {
            natRules.load(OpenstackClient.class.getResourceAsStream("/nat-translation-rules.properties"));
        }
    } catch (IOException e) {
        log.warn("no translation rules!");
        return floatingIp;
    }

    for (Map.Entry<Object, Object> entry : natRules.entrySet()) {
        String fromCidr = (String) entry.getKey();
        String toCidr = (String) entry.getValue();
        log.debug("cidr is: " + fromCidr);
        SubnetUtils utilsFrom = new SubnetUtils(fromCidr);
        SubnetUtils utilsTo = new SubnetUtils(toCidr);

        SubnetUtils.SubnetInfo subnetInfoFrom = utilsFrom.getInfo();
        SubnetUtils.SubnetInfo subnetInfoTo = utilsTo.getInfo();
        InetAddress floatingIpNetAddr = InetAddress.getByName(floatingIp);
        if (subnetInfoFrom.isInRange(floatingIp)) { //translation!

            log.debug("From networkMask " + subnetInfoFrom.getNetmask());
            log.debug("To networkMask " + subnetInfoTo.getNetmask());
            if (!subnetInfoFrom.getNetmask().equals(subnetInfoTo.getNetmask())) {
                log.error("Not translation possible, netmasks are different");
                return floatingIp;
            }
            byte[] host = new byte[4];
            for (int i = 0; i < floatingIpNetAddr.getAddress().length; i++) {
                byte value = (byte) (floatingIpNetAddr.getAddress()[i]
                        | InetAddress.getByName(subnetInfoFrom.getNetmask()).getAddress()[i]);
                if (value == -1) {
                    host[i] = 0;
                } else {
                    host[i] = value;
                }
            }

            byte[] netaddress = InetAddress.getByName(subnetInfoTo.getNetworkAddress()).getAddress();
            String[] result = new String[4];
            for (int i = 0; i < netaddress.length; i++) {
                int intValue = new Byte((byte) (netaddress[i] | Byte.valueOf(host[i]))).intValue();
                if (intValue < 0) {
                    intValue = intValue & 0xFF;
                }
                result[i] = String.valueOf(intValue);
            }

            return StringUtils.join(result, ".");
        }
    }
    return floatingIp;
}

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

/**
 * @deprecated Replaced by {@link CrosstabRowPositionEnum}.
 */// w  ww . j a v  a 2  s  . co m
public static Map getCrosstabRowPositionMap() {
    if (crosstabRowPositionMap == null) {
        Map map = new HashMap(11);
        map.put(CROSSTAB_ROW_POSITION_TOP, new Byte(JRCellContents.POSITION_Y_TOP));
        map.put(CROSSTAB_ROW_POSITION_MIDDLE, new Byte(JRCellContents.POSITION_Y_MIDDLE));
        map.put(CROSSTAB_ROW_POSITION_BOTTOM, new Byte(JRCellContents.POSITION_Y_BOTTOM));
        map.put(CROSSTAB_ROW_POSITION_STRETCH, new Byte(JRCellContents.POSITION_Y_STRETCH));
        map.put(new Byte(JRCellContents.POSITION_Y_TOP), CROSSTAB_ROW_POSITION_TOP);
        map.put(new Byte(JRCellContents.POSITION_Y_MIDDLE), CROSSTAB_ROW_POSITION_MIDDLE);
        map.put(new Byte(JRCellContents.POSITION_Y_BOTTOM), CROSSTAB_ROW_POSITION_BOTTOM);
        map.put(new Byte(JRCellContents.POSITION_Y_STRETCH), CROSSTAB_ROW_POSITION_STRETCH);
        crosstabRowPositionMap = Collections.unmodifiableMap(map);
    }

    return crosstabRowPositionMap;
}

From source file:edu.ku.brc.dbsupport.ImportExportDB.java

    protected Object findTypeRecordSet(Element compareMe, String dbTable, @SuppressWarnings("unused") long parentId,
                String parentName) {
            try { // get the fieldinfo
                String lowerdbTable = dbTable.toLowerCase();
                DBTableInfo info = DBTableIdMgr.getInstance().getInfoByTableName(lowerdbTable);

                // find element with compareme.getName()
                DBFieldInfo fieldInfo = info.getFieldByName(compareMe.getName());
                // if the element is an id, ignore it
                // TODO: shouldl check for primary key
                if (!compareMe.getName().equals(lowerFirstChar(dbTable) + "Id")) //$NON-NLS-1$
                {//w  ww .j a v a 2  s  .com
                    // if it is a normal field
                    if (fieldInfo != null) {
                        String type = fieldInfo.getType();
                        // check the type
                        if (type.equals("java.lang.String") || type.equals("text")) //$NON-NLS-1$ //$NON-NLS-2$
                        {
                            return compareMe.getStringValue();

                        } else if (type.equals("java.util.Date")) //$NON-NLS-1$
                        {
                            Date dtTmp = new SimpleDateFormat("yy-MM-dd H:mm:ss").parse(compareMe //$NON-NLS-1$
                                    .getStringValue());
                            return dtTmp;

                        } else if (type.equals("java.sql.Timestamp")) //$NON-NLS-1$
                        {
                            Timestamp tmstmp = Timestamp.valueOf(compareMe.getStringValue());
                            return tmstmp;
                        } else if (type.equals("java.lang.Integer")) //$NON-NLS-1$
                        {
                            int num = new Integer(compareMe.getStringValue()).intValue();
                            return num;

                        } else if (type.equals("java.lang.Boolean")) //$NON-NLS-1$
                        {
                            Boolean bool = Boolean.valueOf(compareMe.getStringValue());
                            return bool;
                        } else if (type.equals("java.math.BigDecimal")) //$NON-NLS-1$
                        {
                            BigDecimal num = UIHelper.parseDoubleToBigDecimal(compareMe.getStringValue());
                            return num;
                        } else if (type.equals("java.lang.Double")) //$NON-NLS-1$
                        {
                            double num = new Double(compareMe.getStringValue()).doubleValue();
                            return num;
                        } else if (type.equals("java.lang.Float")) //$NON-NLS-1$
                        {
                            float num = new Float(compareMe.getStringValue()).floatValue();
                            return num;
                        } else if (type.equals("java.lang.Long")) //$NON-NLS-1$
                        {
                            long num = new Long(compareMe.getStringValue()).longValue();
                            return num;
                        } else if (type.equals("java.lang.Short")) //$NON-NLS-1$
                        {
                            short num = new Short(compareMe.getStringValue()).shortValue();
                            return num;
                        } else if (type.equals("java.lang.Byte")) //$NON-NLS-1$
                        {
                            byte num = new Byte(compareMe.getStringValue()).byteValue();
                            return num;
                        } else if (type.equals("java.util.Calendar")) //$NON-NLS-1$
                        {
                            Calendar date = dateString2Calendar(compareMe.getStringValue());
                            return date;
                        }
                    } else
                    // check if it is a many-to-one
                    {
                        DBRelationshipInfo tablerel = info.getRelationshipByName(compareMe.getName());
                        // check for many to one, and make sure it has a value
                        if (tablerel != null && tablerel.getType().name() == "ManyToOne" //$NON-NLS-1$
                                && !compareMe.getStringValue().equals("")) //$NON-NLS-1$
                        {
                            long num = new Long(compareMe.getStringValue()).longValue();

                            String className = tablerel.getClassName().substring(29);// strip working
                                                                                     // set
                                                                                     // TODO: remove this condition for agent
                            if (className.equals("Agent")) //$NON-NLS-1$
                            {
                                className = className.toLowerCase();
                                Object tableObject = genericDBObject2(className, num);
                                return tableObject;
                            }
                            Object tableObject = getParentDBObject(className, num);
                            return tableObject;
                            // check if its a collection (one-to-many)
                        } else if ((tablerel != null && tablerel.getType().name() == "OneToMany") //$NON-NLS-1$
                                || (tablerel != null && tablerel.getType().name() == "ManyToMany")) //$NON-NLS-1$
                        {
                            // if many-to-many
                            if (compareMe.getName().equals(parentName + "s")) {
//$NON-NLS-0$
                                return "ManyToMany"; //$NON-NLS-1$
                            }
                            // else one-to-many
                            return "OneToMany"; //$NON-NLS-1$
                        } else {
                            log.debug("could not import element: " + compareMe.getName() //$NON-NLS-1$
                                    + ", with data:" + compareMe.getData()); //$NON-NLS-1$
                        }
                    }
                }
            } catch (Exception ex) {
                edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ImportExportDB.class, ex);
                if (ex.toString().startsWith("java.lang.NumberFormatException")) {
//$NON-NLS-0$
                    return null;
                }
                // else
                ex.printStackTrace();
            }
            return null;
        }

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

/**
 * @deprecated Replaced by {@link CrosstabColumnPositionEnum}.
 *//*  w  w  w  .  j  a va  2 s .  c  o m*/
public static Map getCrosstabColumnPositionMap() {
    if (crosstabColumnPositionMap == null) {
        Map map = new HashMap(11);
        map.put(CROSSTAB_COLUMN_POSITION_LEFT, new Byte(JRCellContents.POSITION_X_LEFT));
        map.put(CROSSTAB_COLUMN_POSITION_CENTER, new Byte(JRCellContents.POSITION_X_CENTER));
        map.put(CROSSTAB_COLUMN_POSITION_RIGHT, new Byte(JRCellContents.POSITION_X_RIGHT));
        map.put(CROSSTAB_COLUMN_POSITION_STRETCH, new Byte(JRCellContents.POSITION_X_STRETCH));
        map.put(new Byte(JRCellContents.POSITION_X_LEFT), CROSSTAB_COLUMN_POSITION_LEFT);
        map.put(new Byte(JRCellContents.POSITION_X_CENTER), CROSSTAB_COLUMN_POSITION_CENTER);
        map.put(new Byte(JRCellContents.POSITION_X_RIGHT), CROSSTAB_COLUMN_POSITION_RIGHT);
        map.put(new Byte(JRCellContents.POSITION_X_STRETCH), CROSSTAB_COLUMN_POSITION_STRETCH);
        crosstabColumnPositionMap = Collections.unmodifiableMap(map);
    }

    return crosstabColumnPositionMap;
}

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

/**
 * @deprecated Replaced by {@link BandTypeEnum}.
 *//*from   ww  w. ja  v a 2s .c om*/
public static Map getBandTypeMap() {
    if (bandTypeMap == null) {
        Map map = new HashMap(35);
        map.put(UNKNOWN, new Byte(JROrigin.UNKNOWN));
        map.put(BACKGROUND, new Byte(JROrigin.BACKGROUND));
        map.put(TITLE, new Byte(JROrigin.TITLE));
        map.put(PAGE_HEADER, new Byte(JROrigin.PAGE_HEADER));
        map.put(COLUMN_HEADER, new Byte(JROrigin.COLUMN_HEADER));
        map.put(GROUP_HEADER, new Byte(JROrigin.GROUP_HEADER));
        map.put(DETAIL, new Byte(JROrigin.DETAIL));
        map.put(GROUP_FOOTER, new Byte(JROrigin.GROUP_FOOTER));
        map.put(COLUMN_FOOTER, new Byte(JROrigin.COLUMN_FOOTER));
        map.put(PAGE_FOOTER, new Byte(JROrigin.PAGE_FOOTER));
        map.put(LAST_PAGE_FOOTER, new Byte(JROrigin.LAST_PAGE_FOOTER));
        map.put(SUMMARY, new Byte(JROrigin.SUMMARY));
        map.put(NO_DATA, new Byte(JROrigin.NO_DATA));
        map.put(new Byte(JROrigin.UNKNOWN), UNKNOWN);
        map.put(new Byte(JROrigin.BACKGROUND), BACKGROUND);
        map.put(new Byte(JROrigin.TITLE), TITLE);
        map.put(new Byte(JROrigin.PAGE_HEADER), PAGE_HEADER);
        map.put(new Byte(JROrigin.COLUMN_HEADER), COLUMN_HEADER);
        map.put(new Byte(JROrigin.GROUP_HEADER), GROUP_HEADER);
        map.put(new Byte(JROrigin.DETAIL), DETAIL);
        map.put(new Byte(JROrigin.GROUP_FOOTER), GROUP_FOOTER);
        map.put(new Byte(JROrigin.COLUMN_FOOTER), COLUMN_FOOTER);
        map.put(new Byte(JROrigin.PAGE_FOOTER), PAGE_FOOTER);
        map.put(new Byte(JROrigin.LAST_PAGE_FOOTER), LAST_PAGE_FOOTER);
        map.put(new Byte(JROrigin.SUMMARY), SUMMARY);
        map.put(new Byte(JROrigin.NO_DATA), NO_DATA);
        bandTypeMap = Collections.unmodifiableMap(map);
    }

    return bandTypeMap;
}

From source file:edu.ku.brc.dbsupport.ImportExportDB.java

    protected Object findTypeDataBase(Element compareMe, String dbTable, @SuppressWarnings("unused") long parentId,
                String parentName) {
            try { // get the fieldinfo
                String lowerdbTable = dbTable.toLowerCase();
                DBTableInfo info = DBTableIdMgr.getInstance().getInfoByTableName(lowerdbTable);

                // find element with compareme.getName()
                DBFieldInfo fieldInfo = info.getFieldByName(compareMe.getName());
                // if the element is an id, ignore it
                // TODO: shouldl check for primary key
                if (!compareMe.getName().equals(lowerFirstChar(dbTable) + "Id")) //$NON-NLS-1$
                {/*from  w ww.j  a v a 2 s .co  m*/
                    // if it is a normal field
                    if (fieldInfo != null) {
                        String type = fieldInfo.getType();
                        // check the type
                        if (type.equals("java.lang.String") || type.equals("text")) //$NON-NLS-1$ //$NON-NLS-2$
                        {
                            return compareMe.getStringValue();

                        } else if (type.equals("java.util.Date")) //$NON-NLS-1$
                        {
                            Date dtTmp = new SimpleDateFormat("yy-MM-dd H:mm:ss").parse(compareMe //$NON-NLS-1$
                                    .getStringValue());
                            return dtTmp;

                        } else if (type.equals("java.sql.Timestamp")) //$NON-NLS-1$
                        {
                            Timestamp tmstmp = Timestamp.valueOf(compareMe.getStringValue());
                            return tmstmp;
                        } else if (type.equals("java.lang.Integer")) //$NON-NLS-1$
                        {
                            int num = new Integer(compareMe.getStringValue()).intValue();
                            return num;

                        } else if (type.equals("java.lang.Boolean")) //$NON-NLS-1$
                        {
                            Boolean bool = Boolean.valueOf(compareMe.getStringValue());
                            return bool;
                        } else if (type.equals("java.math.BigDecimal")) //$NON-NLS-1$
                        {
                            BigDecimal num = UIHelper.parseDoubleToBigDecimal(compareMe.getStringValue());
                            return num;
                        } else if (type.equals("java.lang.Double")) //$NON-NLS-1$
                        {
                            double num = new Double(compareMe.getStringValue()).doubleValue();
                            return num;
                        } else if (type.equals("java.lang.Float")) //$NON-NLS-1$
                        {
                            float num = new Float(compareMe.getStringValue()).floatValue();
                            return num;
                        } else if (type.equals("java.lang.Long")) //$NON-NLS-1$
                        {
                            long num = new Long(compareMe.getStringValue()).longValue();
                            return num;
                        } else if (type.equals("java.lang.Short")) //$NON-NLS-1$
                        {
                            short num = new Short(compareMe.getStringValue()).shortValue();
                            return num;
                        } else if (type.equals("java.lang.Byte")) //$NON-NLS-1$
                        {
                            byte num = new Byte(compareMe.getStringValue()).byteValue();
                            return num;
                        } else if (type.equals("java.util.Calendar")) //$NON-NLS-1$
                        {
                            Calendar date = dateString2Calendar(compareMe.getStringValue());
                            return date;
                        }
                    } else
                    // check if it is a many-to-one
                    {
                        DBRelationshipInfo tablerel = info.getRelationshipByName(compareMe.getName());
                        // check for many to one, and make sure it has a value
                        if (tablerel != null && tablerel.getType().name() == "ManyToOne" //$NON-NLS-1$
                                && !compareMe.getStringValue().equals("")) //$NON-NLS-1$
                        {
                            long num = new Long(compareMe.getStringValue()).longValue();

                            String className = tablerel.getClassName().substring(29);// strip working
                                                                                     // set
                                                                                     // TODO: remove this condition for agent
                            if (className.equals("Agent")) //$NON-NLS-1$
                            {
                                className = className.toLowerCase();
                                Object tableObject = genericDBObject2(className, num);
                                return tableObject;
                            } else {
                                Object tableObject = loadOrCreateParentDataBaseObject(className, num);
                                return tableObject;
                            }
                            // check if its a collection (one-to-many)
                        } else if ((tablerel != null && tablerel.getType().name() == "OneToMany") //$NON-NLS-1$
                                || (tablerel != null && tablerel.getType().name() == "ManyToMany")) //$NON-NLS-1$
                        {
                            // if many-to-many
                            if (compareMe.getName().equals(parentName + "s")) {
//$NON-NLS-0$
                                return "ManyToMany"; //$NON-NLS-1$
                            }
                            // else one-to-many
                            return "OneToMany"; //$NON-NLS-1$
                        } else {
                            log.debug("could not import element: " + compareMe.getName() //$NON-NLS-1$
                                    + ", with data:" + compareMe.getData()); //$NON-NLS-1$
                        }
                    }
                }
            } catch (Exception ex) {
                edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ImportExportDB.class, ex);
                if (ex.toString().startsWith("java.lang.NumberFormatException")) {
//$NON-NLS-0$
                    return null;
                }
                // else
                ex.printStackTrace();
            }
            return null;
        }

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

/**
 * @deprecated Replaced by {@link FooterPositionEnum}.
 *///from  w  w w  .  j a  va2  s  .c  om
public static Map getFooterPositionMap() {
    if (footerPositionMap == null) {
        Map map = new HashMap(11);
        map.put(FOOTER_POSITION_NORMAL, new Byte(JRGroup.FOOTER_POSITION_NORMAL));
        map.put(FOOTER_POSITION_STACK_AT_BOTTOM, new Byte(JRGroup.FOOTER_POSITION_STACK_AT_BOTTOM));
        map.put(FOOTER_POSITION_FORCE_AT_BOTTOM, new Byte(JRGroup.FOOTER_POSITION_FORCE_AT_BOTTOM));
        map.put(FOOTER_POSITION_COLLATE_AT_BOTTOM, new Byte(JRGroup.FOOTER_POSITION_COLLATE_AT_BOTTOM));
        map.put(new Byte(JRGroup.FOOTER_POSITION_NORMAL), FOOTER_POSITION_NORMAL);
        map.put(new Byte(JRGroup.FOOTER_POSITION_STACK_AT_BOTTOM), FOOTER_POSITION_STACK_AT_BOTTOM);
        map.put(new Byte(JRGroup.FOOTER_POSITION_FORCE_AT_BOTTOM), FOOTER_POSITION_FORCE_AT_BOTTOM);
        map.put(new Byte(JRGroup.FOOTER_POSITION_COLLATE_AT_BOTTOM), FOOTER_POSITION_COLLATE_AT_BOTTOM);
        footerPositionMap = Collections.unmodifiableMap(map);
    }

    return footerPositionMap;
}