You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by lo...@bnpparibas.com on 2002/11/07 17:25:35 UTC

Réf. : RE: Réf. : RE: Réf. : Re: Commons Validator

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

Cheers,
Loïc



Extranet
DDevienne@lgc.com - 07/11/2002 17:14


Veuillez répondre à ant-dev@jakarta.apache.org
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: loic.lefevre@bnpparibas.com [mailto:loic.lefevre@bnpparibas.com]
Sent: Thursday, November 07, 2002 10:03 AM
To: ant-dev@jakarta.apache.org
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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>










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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>