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:edu.ku.brc.dbsupport.ImportExportDB.java

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

                // find element with compareme.getName()
                DBFieldInfo fieldInfo = info.getFieldByName(compareMe.getName());
                // if the element is an id, ignore it

                // if( !compareMe.getName().equals( lowerFirstChar(dbTable) + "Id") )
                // {
                // if(!primaryKey.equals(compareMe.getName()))
                // {
                // if it is a normal field
                if (fieldInfo != null || primaryKey.equals(compareMe.getName()))
                // if(fieldInfo != null )
                {//from ww w .j av a2 s  .c o m
                    String type = new String();
                    if (fieldInfo == null) {// it is an id
                        type = "java.lang.Integer"; //$NON-NLS-1$
                        System.out.println(compareMe.getStringValue());
                    } else {
                        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:de.juwimm.cms.remote.EditionServiceSpringImpl.java

/**
 * @param fulldeploy//ww  w  . j av  a 2 s . c  om
 *            means, if this is an import of an Full-Edition, Unit-Edition or Live-Deploy
 *            <ul>
 *            <li>0 - means LiveDeploy</li>
 *            <li>1 - means Fulldeploy of an FullEdition</li>
 *            <li>2 - means Fulldeploy of an UnitEdition</li>
 *            </ul>
 */
private ViewComponentHbm createViewComponent(Integer unitId, ViewDocumentHbm viewDocument,
        ArrayList<ViewComponentHbm> savedUnits, Element nde, ViewComponentHbm parent, ViewComponentHbm prev,
        boolean livedeploy, int fulldeploy, boolean useNewIds) throws Exception {
    boolean reusePrimaryKey = (fulldeploy == 0);
    ViewComponentHbm viewComponent = null;
    try {
        Integer myUnitId = new Integer(nde.getAttribute("unitId"));
        Integer vcId = new Integer(nde.getAttribute("id"));
        if (fulldeploy == 2 && !myUnitId.equals(unitId)) {
            return null;
        } else if (fulldeploy > 0 || myUnitId.equals(unitId)) {
            String reference = XercesHelper.getNodeValue(nde, "./reference");
            String linkName = XercesHelper.getNodeValue(nde, "./linkName");
            String approvedLinkName = XercesHelper.getNodeValue(nde, "./approvedLinkName");
            String statusInfo = XercesHelper.getNodeValue(nde, "./statusInfo");
            String urlLinkName = XercesHelper.getNodeValue(nde, "./urlLinkName");

            byte viewType = new Byte(XercesHelper.getNodeValue(nde, "./viewType")).byteValue();
            boolean visible = Boolean.valueOf(XercesHelper.getNodeValue(nde, "./visible")).booleanValue();
            if (livedeploy
                    && (viewType == Constants.VIEW_TYPE_CONTENT || viewType == Constants.VIEW_TYPE_UNIT)) {
                Node publsh = XercesHelper.findNode(nde, "./content/contentVersion/version[string()='PUBLS']");

                if (log.isDebugEnabled())
                    log.debug("viewType " + viewType);
                if (publsh == null) {
                    if (log.isDebugEnabled())
                        log.debug("Haven't found a Cool-Online-Version (PUBLS), does not create VC " + vcId);
                    return null;
                }
            }
            if (fulldeploy > 0) {
                if (useNewIds) {
                    viewComponent = getViewComponentHbmDao().create(viewDocument, reference, linkName,
                            statusInfo, urlLinkName, null);
                    viewComponent.setApprovedLinkName(approvedLinkName);
                    mappingVCs.put(vcId, viewComponent.getViewComponentId());
                } else {
                    // viewDocs can only be crated with viewComps 
                    if (viewDocument.getViewComponent().getViewComponentId().compareTo(vcId) == 0) {
                        viewComponent = viewDocument.getViewComponent();
                    } else {
                        viewComponent = getViewComponentHbmDao().load(vcId);
                    }
                    if (viewComponent == null) {
                        viewComponent = getViewComponentHbmDao().create(viewDocument, reference, linkName,
                                statusInfo, urlLinkName, vcId);
                    } else {
                        viewComponent.setDisplayLinkName(linkName);
                        viewComponent.setViewDocument(viewDocument);
                        viewComponent.setReference(reference);
                        viewComponent.setUrlLinkName(urlLinkName);
                        viewComponent.setLinkDescription(statusInfo);
                    }
                    viewComponent.setApprovedLinkName(approvedLinkName);
                    mappingVCs.put(vcId, vcId);
                }
                if (fulldeploy == 1) {
                    Integer newUnitId = mappingUnits.get(myUnitId);
                    if (newUnitId == null) {
                        newUnitId = myUnitId;
                    }
                    if (unitId == null || !newUnitId.equals(unitId)) {
                        if (log.isDebugEnabled())
                            log.debug("newUnitId " + newUnitId + " myUnitId " + myUnitId);
                        UnitHbm unit = getUnitHbmDao().load(newUnitId);
                        viewComponent.setAssignedUnit(unit);
                        unitId = unit.getUnitId();
                    }
                }
            } else {
                try {
                    if (log.isDebugEnabled())
                        log.debug("searching ViewComponent: " + vcId);
                    viewComponent = getViewComponentHbmDao().load(vcId);
                    viewComponent.setViewDocument(viewDocument);
                    viewComponent.setReference(reference);
                    viewComponent.setDisplayLinkName(linkName);
                    viewComponent.setLinkDescription(statusInfo);
                    viewComponent.setUrlLinkName(urlLinkName);
                    viewComponent.setApprovedLinkName(approvedLinkName);
                } catch (Exception e) {
                    if (log.isDebugEnabled())
                        log.debug("error, creating ViewComponent: " + vcId);
                    ViewComponentHbm tempVC = new ViewComponentHbmImpl();
                    tempVC.setViewDocument(viewDocument);
                    tempVC.setReference(reference);
                    tempVC.setLinkDescription(linkName);
                    tempVC.setStatus(Integer.parseInt(statusInfo));
                    tempVC.setUrlLinkName(urlLinkName);
                    tempVC.setViewComponentId(vcId);
                    viewComponent = getViewComponentHbmDao().create(tempVC);
                    viewComponent.setApprovedLinkName(approvedLinkName);
                }
                viewComponent.setOnline((byte) 1);
            }
            viewComponent.setPrevNode(prev);
            if (prev != null)
                prev.setNextNode(viewComponent);
            viewComponent.setParentViewComponent(parent);
            viewComponent.setMetaData(XercesHelper.getNodeValue(nde, "./metaKeywords"));
            viewComponent.setMetaDescription(XercesHelper.getNodeValue(nde, "./metaDescription"));
            String onlineStart = XercesHelper.getNodeValue(nde, "./onlineStart");
            if (!onlineStart.equals("")) {
                if (log.isDebugEnabled())
                    log.debug("OnlineStart: " + onlineStart);
                viewComponent.setOnlineStart(Long.parseLong(onlineStart));
            }
            String onlineStop = XercesHelper.getNodeValue(nde, "./onlineStop");
            if (!onlineStop.equals("")) {
                if (log.isDebugEnabled())
                    log.debug("OnlineStop: " + onlineStop);
                viewComponent.setOnlineStop(Long.parseLong(onlineStop));
            }
            viewComponent.setViewLevel(XercesHelper.getNodeValue(nde, "./viewLevel"));
            viewComponent.setViewIndex(XercesHelper.getNodeValue(nde, "./viewIndex"));
            viewComponent
                    .setDisplaySettings(Byte.parseByte(XercesHelper.getNodeValue(nde, "./displaySettings")));
            viewComponent.setShowType(Byte.parseByte(XercesHelper.getNodeValue(nde, "./showType")));
            viewComponent.setViewType(viewType);
            viewComponent.setVisible(visible);
            viewComponent.setSearchIndexed(
                    Boolean.valueOf(XercesHelper.getNodeValue(nde, "./searchIndexed")).booleanValue());
            viewComponent.setXmlSearchIndexed(
                    Boolean.valueOf(XercesHelper.getNodeValue(nde, "./xmlSearchIndexed")).booleanValue());
            byte status = -1;
            try {
                status = new Byte(XercesHelper.getNodeValue(nde, "./status")).byteValue();
            } catch (Exception e) {
                if (log.isDebugEnabled())
                    log.debug("Status was not set...");
            }
            // on import set deploy-state to "edited"
            if (!livedeploy)
                status = Constants.DEPLOY_STATUS_EDITED;
            viewComponent.setStatus(status);
            byte onlineState = -1;
            try {
                onlineState = new Byte(XercesHelper.getNodeValue(nde, "./online")).byteValue();
            } catch (Exception e) {
                if (log.isDebugEnabled())
                    log.debug("OnlineState was not set...");
            }
            // on import set online-state to offline
            if (!livedeploy)
                onlineState = Constants.ONLINE_STATUS_OFFLINE;
            viewComponent.setOnline(onlineState);
            if (fulldeploy == 0 && viewComponent.getStatus() == Constants.DEPLOY_STATUS_APPROVED) {
                // this only occures on new pages that are deployed for the first time
                // (they dont have the state online on workserver because of different transactions)
                if (log.isDebugEnabled())
                    log.debug("setting online: " + viewComponent.getDisplayLinkName());
                viewComponent.setOnline((byte) 1);
            }
            {
                // realm2viewComponent
                Node nodeRealm = XercesHelper.findNode(nde, "realm2viewComponent");
                if (nodeRealm != null) {
                    // this ViewComponent is protected by a realm
                    if (fulldeploy > 0) {
                        // use new ids
                        String neededrole = XercesHelper.getNodeValue(nodeRealm, "roleNeeded");
                        String loginPage = XercesHelper.getNodeValue(nodeRealm, "loginPageId");
                        if (loginPage != null && !"".equalsIgnoreCase(loginPage)) {
                            Integer loginPageId = null;
                            try {
                                loginPageId = Integer.valueOf(loginPage);
                            } catch (Exception e) {
                            }
                            if (loginPageId != null)
                                loginPagesRealm2vc.put(vcId, loginPageId);
                        }
                        Node relNode = XercesHelper.findNode(nodeRealm, "jdbcRealmId");
                        if (relNode != null) {
                            Integer id = new Integer(XercesHelper.getNodeValue(relNode));
                            RealmJdbcHbm sqlrealm = null;
                            if (useNewIds) {
                                sqlrealm = getRealmJdbcHbmDao().load(mappingRealmsJdbc.get(id));
                            } else {
                                sqlrealm = getRealmJdbcHbmDao().load(id);
                            }
                            Realm2viewComponentHbm tempRealm = createTempRealm(viewComponent, neededrole,
                                    sqlrealm, null, null, null);
                            Realm2viewComponentHbm r = getRealm2viewComponentHbmDao().create(tempRealm);
                            viewComponent.setRealm2vc(r);
                        } else {
                            relNode = XercesHelper.findNode(nodeRealm, "simplePwRealmId");
                            if (relNode != null) {
                                Integer id = new Integer(XercesHelper.getNodeValue(relNode));
                                RealmSimplePwHbm realm = null;
                                if (useNewIds) {
                                    realm = getRealmSimplePwHbmDao().load(mappingRealmsSimplePw.get(id));
                                } else {
                                    realm = getRealmSimplePwHbmDao().load(id);
                                }
                                Realm2viewComponentHbm tempRealm = createTempRealm(viewComponent, neededrole,
                                        null, realm, null, null);
                                Realm2viewComponentHbm r = getRealm2viewComponentHbmDao().create(tempRealm);
                                viewComponent.setRealm2vc(r);
                            } else {
                                relNode = XercesHelper.findNode(nodeRealm, "ldapRealmId");
                                if (relNode != null) {
                                    Integer id = new Integer(XercesHelper.getNodeValue(relNode));
                                    RealmLdapHbm realm = null;
                                    if (useNewIds) {
                                        realm = getRealmLdapHbmDao().load(mappingRealmsLdap.get(id));
                                    } else {
                                        realm = getRealmLdapHbmDao().load(id);
                                    }
                                    Realm2viewComponentHbm tempRealm = createTempRealm(viewComponent,
                                            neededrole, null, null, realm, null);
                                    Realm2viewComponentHbm r = getRealm2viewComponentHbmDao().create(tempRealm);
                                    viewComponent.setRealm2vc(r);
                                } else {
                                    relNode = XercesHelper.findNode(nodeRealm, "jaasRealmId");
                                    if (relNode != null) {
                                        Integer id = new Integer(XercesHelper.getNodeValue(relNode));
                                        RealmJaasHbm realm = null;
                                        if (useNewIds) {
                                            realm = getRealmJaasHbmDao().load(mappingRealmsJaas.get(id));
                                        } else {
                                            realm = getRealmJaasHbmDao().load(id);
                                        }
                                        Realm2viewComponentHbm tempRealm = createTempRealm(viewComponent,
                                                neededrole, null, null, null, realm);
                                        Realm2viewComponentHbm r = getRealm2viewComponentHbmDao()
                                                .create(tempRealm);
                                        viewComponent.setRealm2vc(r);
                                    }
                                }
                            }
                        }
                    } else {
                        Realm2viewComponentHbm tempRealm = new Realm2viewComponentHbmImpl();
                        tempRealm.setViewComponent(viewComponent);
                        Realm2viewComponentHbm r = getRealm2viewComponentHbmDao().create(tempRealm);
                        viewComponent.setRealm2vc(r);
                        String loginPage = XercesHelper.getNodeValue(nodeRealm, "loginPageId");
                        if (loginPage != null && !"".equalsIgnoreCase(loginPage)) {
                            Integer loginPageId = null;
                            try {
                                loginPageId = Integer.valueOf(loginPage);
                            } catch (Exception e) {
                            }
                            if (loginPageId != null)
                                loginPagesRealm2vc.put(vcId, loginPageId);
                        }
                    }
                }
            }
            // CONTENT
            Element cnde = (Element) XercesHelper.findNode(nde, "./content");
            if (cnde != null) {
                ContentHbm content = getContentHbmDao().createFromXml(cnde, reusePrimaryKey, livedeploy, null,
                        null, null, null);
                viewComponent.setReference(content.getContentId().toString());
            }
            // CHILDREN
            Iterator it = XercesHelper.findNodes(nde, "./viewcomponent");
            ViewComponentHbm childprev = null;
            ViewComponentHbm tmp = null;
            while (it.hasNext()) {
                Element childnode = (Element) it.next();
                tmp = createViewComponent(unitId, viewDocument, savedUnits, childnode, viewComponent, childprev,
                        livedeploy, fulldeploy, useNewIds);
                if (childprev != null) {
                    childprev.setNextNode(tmp);
                } else {
                    viewComponent.setFirstChild(tmp);
                }
                if (tmp != null)
                    childprev = tmp;
            }
        } else {
            // Im a ViewComponent from another Unit. This must be inside the Array... HEY ARRAY !!!
            boolean found = false;
            Iterator it = savedUnits.iterator();
            while (it.hasNext()) {
                ViewComponentHbm savedvc = (ViewComponentHbm) it.next();
                if (myUnitId.equals(savedvc.getAssignedUnit().getUnitId())) {
                    viewComponent = savedvc;
                    viewComponent.setPrevNode(prev);
                    byte showtype = viewComponent.getShowType();
                    viewComponent.setParentViewComponent(parent);
                    viewComponent.setShowType(showtype);
                    savedUnits.remove(savedvc);
                    found = true;
                    if (log.isDebugEnabled())
                        log.debug("MOVING BACK: " + viewComponent.getDisplayLinkName());
                    break;
                }
            }
            if (!found) {
                // This means: We are importing a Edition, where we suggest, that there is already this
                // Unit deployed, what we have as child-Unit.
                // It is possible, that we are deploying a unit, where this child-Unis haven't deployed yet -
                // f.e. initial-deploy or this child-unit has been new created and never deployed at this special
                // moment.
                // Therefor we will create a DUMMY entry with a "DUMMY"-Reference, so we can map the child-unit to
                // this place, if the child-Unit Editor wants to deploy his unit.
                try {
                    // FIRST we will take a look, if there is already this Unit - but wasn't found here.
                    // This could be possible, if this unit was been "outtaked" and this is an old Edition,
                    // we will find this Unit anywhere else.
                    viewComponent = getViewComponentHbmDao().find4Unit(myUnitId,
                            viewDocument.getViewDocumentId());
                } catch (Exception exe) {
                    try {
                        UnitHbm unit = getUnitHbmDao().load(myUnitId);
                        ViewComponentHbm tempVC = new ViewComponentHbmImpl();
                        tempVC.setViewDocument(viewDocument);
                        tempVC.setReference("DUMMY");
                        tempVC.setDisplayLinkName("SUB_ENTRY_NOT_DEPLOYED");
                        tempVC.setLinkDescription("SUB_ENTRY_NOT_DEPLOYED");
                        tempVC.setViewComponentId(vcId);
                        viewComponent = getViewComponentHbmDao().create(tempVC);
                        viewComponent.setViewType(Constants.VIEW_TYPE_UNIT);
                        viewComponent.setVisible(false);
                        viewComponent.setAssignedUnit(unit);
                    } catch (Exception ex) {
                        // Jens - ??
                        // context.setRollbackOnly();
                        throw new UserException("UnitWasNeverDeployed");
                    }
                }
                viewComponent.setPrevNode(prev);
                viewComponent.setParentViewComponent(parent);
            }
        }
    } catch (Exception exe) {
        // Jens - ??
        // context.setRollbackOnly();
        log.error("Error occured", exe);
        throw exe;
    }
    // IMPORT END
    return viewComponent;
}

From source file:lasige.steeldb.jdbc.BFTRowSet.java

/**
 * Converts the given <code>Object</code> in the Java programming language
 * to the standard mapping for the specified SQL target data type.
 * The conversion must be to a string or numeric type, but there are no
 * restrictions on the type to be converted.  If the source type and target
 * type are the same, the given object is simply returned.
 *
 * @param srcObj the <code>Object</code> in the Java programming language
 *               that is to be converted to the target type
 * @param srcType the data type that is the standard mapping in SQL of the
 *                object to be converted; must be one of the constants in
 *                <code>java.sql.Types</code>
 * @param trgType the SQL data type to which to convert the given object;
 *                must be one of the following constants in
 *                <code>java.sql.Types</code>: <code>NUMERIC</code>,
 *         <code>DECIMAL</code>, <code>BIT</code>, <code>TINYINT</code>,
 *         <code>SMALLINT</code>, <code>INTEGER</code>, <code>BIGINT</code>,
 *         <code>REAL</code>, <code>DOUBLE</code>, <code>FLOAT</code>,
 *         <code>VARCHAR</code>, <code>LONGVARCHAR</code>, or <code>CHAR</code>
 * @return an <code>Object</code> value.that is
 *         the standard object mapping for the target SQL type
 * @throws SQLException if the given target type is not one of the string or
 *         numeric types in <code>java.sql.Types</code>
 *//*ww  w . j  a  va2  s. c om*/
private Object convertNumeric(Object srcObj, int srcType, int trgType) throws SQLException {

    if (srcType == trgType) {
        return srcObj;
    }

    if (isNumeric(trgType) == false && isString(trgType) == false) {
        throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.dtypemismt").toString() + trgType);
    }

    try {
        switch (trgType) {
        case java.sql.Types.BIT:
            Integer i = new Integer(srcObj.toString().trim());
            return i.equals(new Integer((int) 0)) ? new Boolean(false) : new Boolean(true);
        case java.sql.Types.TINYINT:
            return new Byte(srcObj.toString().trim());
        case java.sql.Types.SMALLINT:
            return new Short(srcObj.toString().trim());
        case java.sql.Types.INTEGER:
            return new Integer(srcObj.toString().trim());
        case java.sql.Types.BIGINT:
            return new Long(srcObj.toString().trim());
        case java.sql.Types.NUMERIC:
        case java.sql.Types.DECIMAL:
            return new BigDecimal(srcObj.toString().trim());
        case java.sql.Types.REAL:
        case java.sql.Types.FLOAT:
            return new Float(srcObj.toString().trim());
        case java.sql.Types.DOUBLE:
            return new Double(srcObj.toString().trim());
        case java.sql.Types.CHAR:
        case java.sql.Types.VARCHAR:
        case java.sql.Types.LONGVARCHAR:
            return new String(srcObj.toString());
        default:
            throw new SQLException(
                    resBundle.handleGetObject("cachedrowsetimpl.dtypemismt").toString() + trgType);
        }
    } catch (NumberFormatException ex) {
        throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.dtypemismt").toString() + trgType);
    }
}

From source file:lasige.steeldb.jdbc.BFTRowSet.java

/**
 * Sets the designated column in either the current row or the insert
 * row of this <code>CachedRowSetImpl</code> object with the given
 * <code>byte</code> value./*from w w w  .  j a va2  s.  c  om*/
 * <P>
 * This method updates a column value in the current row or the insert
 * row of this rowset, but it does not update the database.
 * If the cursor is on a row in the rowset, the
 * method {@link #updateRow} must be called to update the database.
 * If the cursor is on the insert row, the method {@link #insertRow}
 * must be called, which will insert the new row into both this rowset
 * and the database. Both of these methods must be called before the
 * cursor moves to another row.
 *
 * @param columnIndex the first column is <code>1</code>, the second
 *        is <code>2</code>, and so on; must be <code>1</code> or larger
 *        and equal to or less than the number of columns in this rowset
 * @param x the new column value
 * @throws SQLException if (1) the given column index is out of bounds,
 *            (2) the cursor is not on one of this rowset's rows or its
 *            insert row, or (3) this rowset is
 *            <code>ResultSet.CONCUR_READ_ONLY</code>
 */
public void updateByte(int columnIndex, byte x) throws SQLException {
    // sanity check.
    checkIndex(columnIndex);
    // make sure the cursor is on a valid row
    checkCursor();

    Object obj = convertNumeric(new Byte(x), java.sql.Types.TINYINT, RowSetMD.getColumnType(columnIndex));

    getCurrentRow().setColumnObject(columnIndex, obj);
}