Well done ;-) I'll use it in JOE
...since I don't see any copyright ;-p

Cheers,
Lo�c



Extranet
[EMAIL PROTECTED] - 07/11/2002 17:14


Veuillez r�pondre � [EMAIL PROTECTED]
Pour : ant-dev

cc :


Objet :     RE: R�f. : RE: R�f. : Re: Commons Validator


Well, if you really want it faster, don't new an object ;-)
And static and final are redundant too... It's also cleaner IMHO to catch
the right exception (also thrown for null values BTW). And to make it still
faster, use the overload that takes a radix of 10, which will avoid still
one indirection. Cheers, --DD

public static boolean isByte(String value) {
    try {
        Byte.parseByte(value, 10);
        return true;
    } catch (NumberFormatException e) {
        return false;
    }
}

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Thursday, November 07, 2002 10:03 AM
To: [EMAIL PROTECTED]
Subject: R�f. : RE: R�f. : Re: Commons Validator

    public static final boolean isByte( String value )
    {
        try
        {
            new Byte( value );
            return true;
        }
        catch( Exception e )
        {
            return false;
        }
    }

Cheer,
Lo�c

ps: don't have the time to make a patch (sorry)

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>










This message and any attachments (the "message") is
intended solely for the addressees and is confidential. 
If you receive this message in error, please delete it and 
immediately notify the sender. Any use not in accord with 
its purpose, any dissemination or disclosure, either whole 
or partial, is prohibited except formal approval. The internet
can not guarantee the integrity of this message. 
BNP PARIBAS (and its subsidiaries) shall (will) not 
therefore be liable for the message if modified. 

                ---------------------------------------------

Ce message et toutes les pieces jointes (ci-apres le 
"message") sont etablis a l'intention exclusive de ses 
destinataires et sont confidentiels. Si vous recevez ce 
message par erreur, merci de le detruire et d'en avertir 
immediatement l'expediteur. Toute utilisation de ce 
message non conforme a sa destination, toute diffusion 
ou toute publication, totale ou partielle, est interdite, sauf 
autorisation expresse. L'internet ne permettant pas 
d'assurer l'integrite de ce message, BNP PARIBAS (et ses
filiales) decline(nt) toute responsabilite au titre de ce 
message, dans l'hypothese ou il aurait ete modifie.


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to