~ubuntu-branches/ubuntu/raring/eucalyptus/raring

« back to all changes in this revision

Viewing changes to clc/modules/authentication/src/main/java/com/eucalyptus/auth/policy/condition/NumericLessThan.java

  • Committer: Package Import Robot
  • Author(s): Brian Thomason
  • Date: 2011-11-29 13:17:52 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 185.
  • Revision ID: package-import@ubuntu.com-20111129131752-rq31al3ntutv2vvl
Tags: upstream-3.0.999beta1
ImportĀ upstreamĀ versionĀ 3.0.999beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package com.eucalyptus.auth.policy.condition;
 
2
 
 
3
import org.apache.log4j.Logger;
 
4
 
 
5
@PolicyCondition( { Conditions.NUMERICLESSTHAN, Conditions.NUMERICLESSTHAN_S } )
 
6
public class NumericLessThan implements NumericConditionOp {
 
7
  
 
8
  private static final Logger LOG = Logger.getLogger( NumericEquals.class );
 
9
 
 
10
  @Override
 
11
  public boolean check( String key, String value ) {
 
12
    try {
 
13
      return Integer.valueOf( key ).compareTo( Integer.valueOf( value ) ) < 0;
 
14
    } catch ( NumberFormatException e ) {
 
15
      try {
 
16
        return Double.valueOf( key ).compareTo( Double.valueOf( value ) ) < 0;
 
17
      } catch ( NumberFormatException e1 ) {
 
18
        // It does not make sense to check the equality of two floats.
 
19
        LOG.error( "Invalid number format", e1 );        
 
20
      }
 
21
    }
 
22
    return false;
 
23
  }
 
24
  
 
25
}