Revision 3526

View differences:

trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/utils/Utilities.java
371 371
    */
372 372
   public static boolean isNumber(String s) 
373 373
    {
374
      int pointCount = 0;
375
      int commaCount = 0;
376
      
377
      char[] c = s.toCharArray();
378
      for (int i = c.length; --i >= 0; ) 
379
      {
380
        char cc = c[i];
381

  
382
        if (Character.isDigit(cc))
383
        {
384
          continue;
385
        }
386
        else
387
        {
388
          /* 'cc' is not a digit. */
389

  
390
          if (cc == '.')
391
          {
392
            pointCount++;
393
            if (pointCount > 1)
394
            {
395
              return false;
396
            }
397
          }
398
          else if (cc == ',')
399
          {
400
            commaCount++;
401
            if (commaCount > 1)
402
            {
403
              return false;
404
            }
405
          }
406
          else if (cc != '-')
407
          {
408
            return false;
409
          }
410
        }
411
      }
412
      return true;
374
	   try
375
	   {
376
		   double d = Double.parseDouble(s);
377
		   return true;
378
	   }
379
	   catch(NumberFormatException e)
380
	   {
381
		   return false;
382
	   }
383
//      int pointCount = 0;
384
//      int commaCount = 0;
385
//      
386
//      char[] c = s.toCharArray();
387
//      for (int i = c.length; --i >= 0; ) 
388
//      {
389
//        char cc = c[i];
390
//
391
//        if (Character.isDigit(cc))
392
//        {
393
//          continue;
394
//        }
395
//        else
396
//        {
397
//          /* 'cc' is not a digit. */
398
//
399
//          if (cc == '.')
400
//          {
401
//            pointCount++;
402
//            if (pointCount > 1)
403
//            {
404
//              return false;
405
//            }
406
//          }
407
//          else if (cc == ',')
408
//          {
409
//            commaCount++;
410
//            if (commaCount > 1)
411
//            {
412
//              return false;
413
//            }
414
//          }
415
//          else if (cc != '-')
416
//          {
417
//            return false;
418
//          }
419
//        }
420
//      }
421
//      return true;
413 422
    }   
414 423
	/**
415 424
	 * Parses the String containing different items [character] separated and

Also available in: Unified diff