Package org.apache.turbine.om

Examples of org.apache.turbine.om.NumberKey


    /**
     * Compares request data with constraints and sets the valid flag.
     */
    private NumberKey checkString(String val)
    {
        NumberKey ival = (NumberKey)onError;
        try
        {
            ival = new NumberKey(val);
        }
        catch (RuntimeException e)
        {
            valid_flag = false;
            ival = (NumberKey)onError;
        }

        boolean b;
        if ( maxLength > 0 )
        {
            b = val.length() > maxLength;
            if ( maxLengthForce  && b )
            {
                val = val.substring(0, maxLength);
                try
                {
                    ival = new NumberKey(val);
                }
                catch (RuntimeException e)
                {
                    valid_flag = false;
                    ival = (NumberKey)onError;
                }
            }
            else
            {
                valid_flag &= !b;
            }
            if (maxLengthMessage != null && b)
            {
                message = maxLengthMessage;
            }
        }

        if ( minValue != null )
        {
            b = ival.compareTo(minValue) < 0;
            if ( minValueForce  && b )
            {
                ival = minValue;
            }
            else
            {
                valid_flag &= !b;
            }
            if (minValueForce  && b)
            {
                message = minValueMessage;
            }
        }

        if ( maxValue != null  )
        {
            b = ival.compareTo(maxValue) > 0;
            if ( maxValueForce  && b )
            {
                ival = maxValue;
            }
            else
View Full Code Here


        {
            User obj = TurbineSecurity.getUserInstance();
            Record row = (Record)rows.elementAt(i);
           
            // FIXME!! use ObjectKey
            ((BaseObject)obj).setPrimaryKey( new NumberKey(row.getValue(idPosition).asBigDecimal()) );

            // Restore the Permanent Storage Hashtable.  First the
            // Hashtable is restored, then any explicit table columns
            // which should be included in the Hashtable are added.
            byte[] objectData = (byte[])row.getValue(objectDataPosition).asBytes();
View Full Code Here

            .add(JobEntryPeer.DAY_OF_MONTH, getDay_of_month())
            .add(JobEntryPeer.TASK, getTask())
            .add(JobEntryPeer.EMAIL, getEmail())
            .add(JobEntryPeer.PROPERTY, getProperty());

        NumberKey nk = (NumberKey)getPrimaryKey();
        long key = 0;
        if (nk != null)
        {
            key = ((NumberKey)getPrimaryKey()).getBigDecimal().longValue();
        }
View Full Code Here

        Constraint constraint = (Constraint)paramMap.get("minValue");
        if ( constraint != null )
        {
            String param = constraint.getValue();
            minValue = new NumberKey(param);
            minValueMessage = constraint.getMessage();
        }

        constraint = (Constraint)paramMap.get("maxValue");
        if ( constraint != null )
        {
            String param = constraint.getValue();
            maxValue = new NumberKey(param);
            maxValueMessage = constraint.getMessage();
        }
    }
View Full Code Here

     * testValue did not pass the validation tests.
     */
    protected void doAssertValidity(String testValue)
        throws ValidationException
    {
        NumberKey nk = null;
        try
        {
            nk = new NumberKey(testValue);
        }
        catch (RuntimeException e)
        {
            message = invalidNumberMessage;
            throw new ValidationException(invalidNumberMessage);
        }
        if ( minValue != null && nk.compareTo(minValue) < 0 )
        {
            message = minValueMessage;
            throw new ValidationException(minValueMessage);
        }
        if ( maxValue != null && nk.compareTo(maxValue) > 0 )
        {
            message = maxValueMessage;
            throw new ValidationException(maxValueMessage);
        }
    }
View Full Code Here

            if (columnNames[i].equals(OBJECT_DATA_COLUMN))
                objectDataPosition = i+1;
        }

        ((Persistent)obj).setPrimaryKey(
            new NumberKey(row.getValue(idPosition).asBigDecimal()) );

        // Restore the Permanent Storage Hashtable.  First the
        // Hashtable is restored, then any explicit table columns
        // which should be included in the Hashtable are added.
        byte[] objectData = (byte[])row.getValue(objectDataPosition).asBytes();
View Full Code Here

            if (keyGen.isPriorToInsert())
            {
                if ( pk.getType() instanceof Number )
                {
                    id = new NumberKey( tableMap.getIdGenerator()
                        .getIdAsBigDecimal(dbCon.getConnection(), keyInfo) );
                }
                else
                {
                    id = new StringKey( tableMap.getIdGenerator()
                        .getIdAsString(dbCon.getConnection(), keyInfo) );
                }
                criteria.add( pk.getFullyQualifiedName(), id );
            }
        }

        // Set up Village for the insert.
        TableDataSet tds = null;
        try
        {
            tds = new TableDataSet(dbCon.getConnection(), tableName );
            Record rec = tds.addRecord();
            insertOrUpdateRecord(rec, tableName, criteria);
        }
        finally
        {
            if (tds != null) tds.close();
        }

        // If the primary key column is auto-incremented, get the id
        // now.
        if ((keyGen != null) && (keyGen.isPostInsert()))
        {
            if ( pk.getType() instanceof Number )
            {
                id = new NumberKey( tableMap.getIdGenerator()
                    .getIdAsBigDecimal(dbCon.getConnection(), keyInfo) );
            }
            else
            {
                id = new StringKey( tableMap.getIdGenerator()
View Full Code Here

            Object object = parameters.get(convert(name));
            if (object != null)
            {
                value = ((String[])object)[0];
            }
            return (StringUtils.isValid(value) ? new NumberKey(value) : null);
        }
        catch ( ClassCastException e )
        {
            return null;
        }
View Full Code Here

        if(prop == null)
            return;

        try
        {
            defaultValue = new NumberKey(prop);
        }
        catch(RuntimeException e)
        {
            Log.error("Could not convert "+prop+" into a NumberKey. ("+name+")");
        }
View Full Code Here

        {
            String[] ss = pp.getStrings(getKey());
            NumberKey[] ival = new NumberKey[ss.length];
            for (int i=0; i<ss.length; i++)
            {
                ival[i] = new NumberKey(ss[i]);
            }
            setTestValue(ival);
        }
        else
        {
            setTestValue( new NumberKey(pp.getString(getKey())) );
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.turbine.om.NumberKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.