RE: [functor] Iterator and Generator

2003-07-19 Thread Jason Horman
I think there are a few reasons that generators may be 
better than or a compliment to iterators.

They are somewhat easier to write. You literally just 
write a loop that calls a function on each iteration. Writing
a generator as an anon inner class is easier since there is
only 1 method to implement. The notion of generators
is taken from Python where you can write something like
this:

def loop
  for x in range(0, 100):
if x % 2:
  yield(x);

for x in loop(): .

If not for stop(), generators have no state and could be
re-run/re-used, even in a multithreaded env. Some generators
may not even care about stop() and could be reused as is.
Iterators require state.

One of the best things about the generators is the ability
to nest algorithms.

gen.apply(func).filter(pred).apply(func2);

And the best part is that no intermediate collections need
to be created.

I think the we may find that the iterator approach doesn't
handle this very well. Think about how the new select would 
work. It would look something like this:

public static final Generator select(gen, pred) {
  return new BaseGenerator {
public Object next() {
  Object obj = gen.next();
  while(!pred.test(obj)  gen.hasNext()) {
obj = gen.next();
  }

  // i guess stop here if done
  if (!gen.hasNext()) {
stop();
  }

  return obj;
}

// if no pred's match in next() hasNext will have lied.
public boolean hasNext() {
   return pred.hasNext();
} 

// responsibility to stop() is put back on the client.
public void stop() {
   stopped = true;
   gen.stop();
}
  }
}

hasNext() may have lied if the predicate matched no elements.

The client has to worry about calling stop(), don't they?
The code changes from:

Collection rlines = Algorithms.apply(new Lines(file), 
  new SomeFunc()).toCollection();

to:

Lines lines = new Lines(file);
Collection rlines = null;
try {
  rlines = Algorithms.apply(lines, 
 new SomeFunc()).toCollection();
} finally {
  lines.stop(); // to close the file
}

You can't really depend on stop() being called without the finally
block with the iterator. Compare the above code with the current 
Algorithms.select() and the old EachLine that handled its own 
try/finally and closed the file. I think the generator version is easier.

I like the inversion of control that generators introduce. Generators
control the pace of iteration. This may be important in some
applications. I can imagine a multithreaded webspider Generator 
for example.

I think that the IteratorToGenerator adapter provides the
iterator support many will need/want, and in addition we
have the benefit of keeping generators as well. Why not
support both?


Other points:

For iterators, in some cases (NumberRanges, Collections) stop() 
makes more sense than close(), but for databases and files close() 
definitely makes more sense. For generators stop() always makes
sense I think. Minor detail.

I do like having the algorithms in both Algorithms and in
BaseGenerator. For some reason I prefer:

Algorithms.apply(new gen(), new func()).filter(pred) 
over: gen.from(something).apply(func).filter(pred)

Anyway, since I wrote it I support it. I am definitely not against
iterators. I do see value in both approaches, and in supporting both.

-jason horman
 [EMAIL PROTECTED]


-Original Message-
From: Rodney Waldhoff [mailto:[EMAIL PROTECTED]
Sent: Friday, July 18, 2003 8:05 PM
To: [EMAIL PROTECTED]
Subject: [functor] Iterator and Generator


As far as I can tell, the role of generator is essentially that of an
Iterator, it provides a mechanism for doing something to each element in a
collection (not necessarily a Collection).  The major differences being:

* Generator has a close method (currently stop()).  This is used for
things that need to clean up after themselves a little bit, like closing
files or sockets.  EachLine was an example of this.

* Generator has convenience methods for internal iteration
(Algorithms.*)

* Generator doesn't have a next() function, currently it only exposes the
internal iteration methods like run(UnaryProcedure)

It seems to me that it is possible to simplify and unify these two
concepts with an implementation like the following:

interface Generator extends Iterator {
  /** stops this Generator, freeing any associated resources */
  void stop();

  // the convenience methods, if desired at this level
  Generator apply(UnaryFunction f);
  boolean contains(UnaryPredicate p);
  Object detect(UnaryPredicate p);
  // etc.
}

abstract class BaseGenerator implements Generator {
  public abstract Object next();

  public void remove() {
throw new UnsupportedOperationException();
  }

  public boolean hasNext() {
return !(isStopped());
  }

  public void stop() {
closed = true;
  }

  // insert implementations of the convenience methods here, e.g.,

  public void foreach(UnaryProcedure 

cvs commit: jakarta-commons/httpclient/src/test/org/apache/commons/httpclient TestCookie.java

2003-07-19 Thread olegk
olegk   2003/07/19 01:46:59

  Modified:httpclient/src/java/org/apache/commons/httpclient/cookie
NetscapeDraftSpec.java
   httpclient/src/test/org/apache/commons/httpclient
TestCookie.java
  Log:
  Bug fix #11240 (Cookies with ',' in the value string is not parsed correctly in some 
cases)
  
  Contributed by Oleg Kalnichevski
  Reviewed by Michael Becke  Laura Werner
  
  Revision  ChangesPath
  1.8   +92 -3 
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/cookie/NetscapeDraftSpec.java
  
  Index: NetscapeDraftSpec.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/cookie/NetscapeDraftSpec.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- NetscapeDraftSpec.java28 Jan 2003 04:40:23 -  1.7
  +++ NetscapeDraftSpec.java19 Jul 2003 08:46:59 -  1.8
  @@ -69,6 +69,8 @@
   import java.text.DateFormat; 
   import java.text.SimpleDateFormat;  
   import java.text.ParseException; 
  +
  +import org.apache.commons.httpclient.HeaderElement;
   import org.apache.commons.httpclient.NameValuePair;
   import org.apache.commons.httpclient.Cookie;
   
  @@ -94,6 +96,93 @@
   /** Default constructor */
   public NetscapeDraftSpec() {
   super();
  +}
  +
  +/**
  +  * Parses the Set-Cookie value into an array of ttCookie/tts.
  +  *
  +  * pSyntax of the Set-Cookie HTTP Response Header:/p
  +  * 
  +  * pThis is the format a CGI script would use to add to 
  +  * the HTTP headers a new piece of data which is to be stored by 
  +  * the client for later retrieval./p
  +  *  
  +  * PRE
  +  *  Set-Cookie: NAME=VALUE; expires=DATE; path=PATH; domain=DOMAIN_NAME; secure
  +  * /PRE
  +  *
  +  * pPlease note that Netscape draft specification does not fully 
  +  * conform to the HTTP header format. Netscape draft does not specify 
  +  * whether multiple cookies may be sent in one header. Hence, comma 
  +  * character may be present in unquoted cookie value or unquoted 
  +  * parameter value./p
  +  * 
  +  * @link http://wp.netscape.com/newsref/std/cookie_spec.html
  +  * 
  +  * @param host the host from which the ttSet-Cookie/tt value was
  +  * received
  +  * @param port the port from which the ttSet-Cookie/tt value was
  +  * received
  +  * @param path the path from which the ttSet-Cookie/tt value was
  +  * received
  +  * @param secure tttrue/tt when the ttSet-Cookie/tt value was
  +  * received over secure conection
  +  * @param header the ttSet-Cookie/tt received from the server
  +  * @return an array of ttCookie/tts parsed from the Set-Cookie value
  +  * @throws MalformedCookieException if an exception occurs during parsing
  +  */
  +public Cookie[] parse(String host, int port, String path, 
  +boolean secure, final String header) 
  +throws MalformedCookieException {
  +
  +LOG.trace(enter NetscapeDraftSpec.parse(String, port, path, boolean, 
Header));
  +
  +if (host == null) {
  +throw new IllegalArgumentException(Host of origin may not be null);
  +}
  +if (host.trim().equals()) {
  +throw new IllegalArgumentException(Host of origin may not be blank);
  +}
  +if (port  0) {
  +throw new IllegalArgumentException(Invalid port:  + port);
  +}
  +if (path == null) {
  +throw new IllegalArgumentException(Path of origin may not be null.);
  +}
  +if (header == null) {
  +throw new IllegalArgumentException(Header may not be null.);
  +}
  +
  +if (path.trim().equals()) {
  +path = PATH_DELIM;
  +}
  +host = host.toLowerCase();
  +
  +String defaultPath = path;
  +int lastSlashIndex = defaultPath.lastIndexOf(PATH_DELIM);
  +if (lastSlashIndex = 0) {
  +if (lastSlashIndex == 0) {
  +//Do not remove the very first slash
  +lastSlashIndex = 1;
  +}
  +defaultPath = defaultPath.substring(0, lastSlashIndex);
  +}
  +HeaderElement headerelement = new HeaderElement(header.toCharArray());
  +Cookie cookie = new Cookie(host,
  +   headerelement.getName(),
  +   headerelement.getValue(),
  +   defaultPath, 
  +   null,
  +   false);
  +// cycle through the parameters
  +NameValuePair[] parameters = headerelement.getParameters();
  +// could be null. In case only a header element and no parameters.
  +if (parameters != null) {
  +for 

cvs commit: jakarta-commons/httpclient/src/test/org/apache/commons/httpclient TestURI.java

2003-07-19 Thread olegk
olegk   2003/07/19 02:41:38

  Modified:httpclient/src/examples CustomHttpConnection.java
   httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java URI.java
   httpclient/src/test/org/apache/commons/httpclient
TestURI.java
  Log:
  Bug fix #19618 (URI class constructors need revision, optimization)
  
  Contributed by Oleg Kalnichevski
  Reviewed by Michael Becke  Laura Werner
  
  Revision  ChangesPath
  1.4   +4 -4  
jakarta-commons/httpclient/src/examples/CustomHttpConnection.java
  
  Index: CustomHttpConnection.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/examples/CustomHttpConnection.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CustomHttpConnection.java 22 Apr 2003 18:11:01 -  1.3
  +++ CustomHttpConnection.java 19 Jul 2003 09:41:37 -  1.4
  @@ -89,7 +89,7 @@
   System.exit(1);
   }
   
  -URI uri = new URI(args[0].toCharArray()); // i like this constructor :)
  +URI uri = new URI(args[0], true);
   
   String schema = uri.getScheme();
   if ((schema == null) || (schema.equals()))
  
  
  
  1.170 +6 -6  
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java
  
  Index: HttpMethodBase.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
  retrieving revision 1.169
  retrieving revision 1.170
  diff -u -r1.169 -r1.170
  --- HttpMethodBase.java   16 Jul 2003 20:48:27 -  1.169
  +++ HttpMethodBase.java   19 Jul 2003 09:41:37 -  1.170
  @@ -266,7 +266,7 @@
   if (uri == null || uri.equals()) {
   uri = /;
   }
  -URI parsedURI = new URI(uri.toCharArray());
  +URI parsedURI = new URI(uri, true);
   
   // only set the host if specified by the URI
   if (parsedURI.isAbsoluteURI()) {
  @@ -1120,7 +1120,7 @@
   conn.getPort(), 
   this.getPath()
   );
  -redirectUri = new URI(location.toCharArray());
  +redirectUri = new URI(location, true);
   if (redirectUri.isRelativeURI()) {
   if (isStrictMode()) {
   LOG.warn(Redirected location ' + location 
  
  
  
  1.39  +66 -4 
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/URI.java
  
  Index: URI.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/URI.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- URI.java  11 Jul 2003 21:55:09 -  1.38
  +++ URI.java  19 Jul 2003 09:41:38 -  1.39
  @@ -154,6 +154,43 @@
   protected URI() {
   }
   
  +/**
  + * Construct a URI from a string with the given charset. The input string can 
  + * be either in escaped or unescaped form. 
  + *
  + * @param s URI character sequence
  + * @param escaped tttrue/tt if URI character sequence is in escaped form. 
  + *ttfalse/tt otherwise. 
  + * @param charset the charset string to do escape encoding, if required
  + * 
  + * @throws URIException If the URI cannot be created.
  + * @throws NullPointerException if input string is codenull/code
  + * 
  + * @see #getProtocolCharset
  + */
  +public URI(String s, boolean escaped, String charset)
  +throws URIException, NullPointerException {
  +protocolCharset = charset;
  +parseUriReference(s, escaped);
  +}
  +
  +/**
  + * Construct a URI from a string with the given charset. The input string can 
  + * be either in escaped or unescaped form. 
  + *
  + * @param s URI character sequence
  + * @param escaped tttrue/tt if URI character sequence is in escaped form. 
  + *ttfalse/tt otherwise. 
  + * 
  + * @throws URIException If the URI cannot be created.
  + * @throws NullPointerException if input string is codenull/code
  + * 
  + * @see #getProtocolCharset
  + */
  +public URI(String s, boolean escaped)
  +throws URIException, NullPointerException {
  +parseUriReference(s, escaped);
  +}
   
   /**
* Construct a URI as an escaped form of a character array with the given
  @@ -164,6 +201,8 @@
* @throws URIException If the URI cannot be created.
* @throws NullPointerException if codeescaped/code is codenull/code
* @see #getProtocolCharset
  + * 
  + * @deprecated Use #URI(String, boolean, String)

cvs commit: jakarta-commons/codec project.xml

2003-07-19 Thread olegk
olegk   2003/07/19 03:11:16

  Modified:codecproject.xml
  Log:
  With the permission of Tim O'Brien I am adding myself to the list of Codec 
contributors
  
  Oleg Kalnichevski
  
  Revision  ChangesPath
  1.17  +5 -0  jakarta-commons/codec/project.xml
  
  Index: project.xml
  ===
  RCS file: /home/cvs/jakarta-commons/codec/project.xml,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- project.xml   8 Jul 2003 16:31:56 -   1.16
  +++ project.xml   19 Jul 2003 10:11:15 -  1.17
  @@ -97,6 +97,11 @@
nameBenjamin Walstrum/name
email[EMAIL PROTECTED]/email
  /contributor
  +   contributor
  + nameOleg Kalnichevski/name
  + email[EMAIL PROTECTED]/email
  + rolesrepresenting http-client/roles
  +   /contributor
 /contributors  
   
 dependencies
  
  
  

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



RE: [lang] Proposal (2): isEmpty

2003-07-19 Thread Howard M. Lewis Ship
(I've switched my subscription over from digest back to full so I don't miss these).

Thanks for re-posting this.  I can see that this change will not affect me; if there 
are any places
where the difference between isEmpty() and isBlank() will affect me, my test suite 
should find them.

--
Howard M. Lewis Ship
Creator, Tapestry: Java Web Components
http://jakarta.apache.org/tapestry



 -Original Message-
 From: Stephen Colebourne [mailto:[EMAIL PROTECTED] 
 Sent: Friday, July 18, 2003 6:33 PM
 To: Jakarta Commons Developers List
 Subject: [lang] Proposal (2): isEmpty
 
 
 Proposal for methods:
 
 - isEmpty() - true for  or null
 - isNotEmpty() - opposite
 - isEmptyNN() - true for 
 
 - isBlank() - trims - true for   ,  or null
 - isNotBlank() - opposite
 - isBlankNN() - trims - true foror 
 
 - isWhitespace() - true for all whitespace,  or null
 - isNotWhitespace() - opposite
 - isWhitespaceNN() - true for all whitespace or 
 
 Where NN means NotNull.
 This covers all the cases, and takes the working premise that 
 more people want null to be true than false.
 
 
 Proposal for location:
 1) In StringUtils. Incompatable change to isEmpty() (no 
 longer trims) and
 isWhitespace() (null now true).
 
 2) In StringTests (new class). Deprecate StringUtils 
 isEmpty/isNotEmpty.
 
 
 I prefer the incompatable change #1. We are offering a simply 
 named alternative. Also, some people already don't expect 
 isEmpty to trim. And Tapestry and Turbine should both be OK.
 
 Stephen
 
 PS. If no agreement is forthcoming, then we shall have to 
 revert to the 1.0 methods in order to get a release.
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 


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



RE: [lang] Proposal (2): isEmpty

2003-07-19 Thread Laird J. Nelson
 -Original Message-
 From: Stephen Colebourne [mailto:[EMAIL PROTECTED]
 It isn't. My preference is now for

 isEmpty() -  or null
 isBlank() - whitespace only,  or null
 and maybe:
 isEmptyTrimmed() - trim() then  or null

 (plus isNotEmpty, isNotBlank, isEmptyNN, isBlankNN)

Delurking for a moment, but why not have an extra parameter?

Something like: isEmpty(String, boolean) where the boolean indicates
whether trim() should be performed or not?  Then isEmpty(String) could
default to calling it with false as the second parameter.

See, for example,
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/foundry/foundry/foundry/t
ext/Strings.java?rev=1.13content-type=text/vnd.viewcvs-markup (the
isEmptyOrNull(Object, boolean)) method.

Cheers,
Laird


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



RE: [lang] Proposal (2): isEmpty

2003-07-19 Thread Henri Yandell

I think I prefer [was it Gary's?] the idea of having StringUtils being
usable as an instance in which you setup general strategies to overloading
with a boolean variable. No insult intended, but that always seems like a
confusing hack to me.

Hen

On Sat, 19 Jul 2003, Laird J. Nelson wrote:

  -Original Message-
  From: Stephen Colebourne [mailto:[EMAIL PROTECTED]
  It isn't. My preference is now for
 
  isEmpty() -  or null
  isBlank() - whitespace only,  or null
  and maybe:
  isEmptyTrimmed() - trim() then  or null
 
  (plus isNotEmpty, isNotBlank, isEmptyNN, isBlankNN)

 Delurking for a moment, but why not have an extra parameter?

 Something like: isEmpty(String, boolean) where the boolean indicates
 whether trim() should be performed or not?  Then isEmpty(String) could
 default to calling it with false as the second parameter.

 See, for example,
 http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/foundry/foundry/foundry/t
 ext/Strings.java?rev=1.13content-type=text/vnd.viewcvs-markup (the
 isEmptyOrNull(Object, boolean)) method.

 Cheers,
 Laird


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



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



Re: [lang] Proposal (2): isEmpty

2003-07-19 Thread Henri Yandell


On Sat, 19 Jul 2003, Stephen Colebourne wrote:

 From: Henri Yandell [EMAIL PROTECTED]
   Having just updated the whitespace processing, I now think that
 isBlank()
   should be fully Unicode compliant and trim using
 Character.isWhitespace()
   not String.trim().
 
  So how is it different from StringUtils.isWhitespace?

 It isn't. My preference is now for

 isEmpty() -  or null
 isBlank() - whitespace only,  or null

Could just tell people to do isWhitespace  isEmpty  ? :)

 and maybe:
 isEmptyTrimmed() - trim() then  or null

I'm not sure there's any need for this. I wonder how much of the chars
less than 32 count as whitespace? But it seems that isWhitespace is for
most people's usage a superset of isEmptyTrimmed.

 (plus isNotEmpty, isNotBlank, isEmptyNN, isBlankNN)

Still hard to decide how far to go with all these. isEmptyNN is a
single-atom method. isNotEmpty just replaces a ! sign etc etc.

Does anyone actually want isEmptyNN, or is it just that people are unhappy
with the null-handling in StringUtils? In which case I think the NN is the
wrong solution, we need to be thinking about an ability to create a
StringUtils with a strategy or having an underlying hidden class and 3
facade's for the different strategies. All 3.0.

I think removing the trim from isEmpty is good, it's not expected by
users. I think the isEmpty-w/ trim people can just use isWhitespace [we
can javadoc them over].

Sorry to take so while to wake up on this,

Hen


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



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang/time FastDateFormat.java

2003-07-19 Thread scolebourne
scolebourne2003/07/19 12:54:24

  Modified:lang/src/java/org/apache/commons/lang/time
FastDateFormat.java
  Log:
  Update author tags
  
  Revision  ChangesPath
  1.9   +2 -3  
jakarta-commons/lang/src/java/org/apache/commons/lang/time/FastDateFormat.java
  
  Index: FastDateFormat.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/time/FastDateFormat.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- FastDateFormat.java   14 Jul 2003 22:25:05 -  1.8
  +++ FastDateFormat.java   19 Jul 2003 19:54:24 -  1.9
  @@ -85,8 +85,7 @@
* This introduces a minor incompatability with Java 1.4, but at a gain of
* useful functionality./p
*
  - * pNOTE: Code originally taken from the open source TreeTrove project./p
  - *
  + * @author TeaTrove project
* @author Brian S O'Neill
* @author Sean Schofield
* @author Gary Gregory
  
  
  

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



Re: [lang] Proposal (2): isEmpty

2003-07-19 Thread Stephen Colebourne
From: Henri Yandell [EMAIL PROTECTED]
  It isn't. My preference is now for
 
  isEmpty() -  or null
  isBlank() - whitespace only,  or null

 Could just tell people to do isWhitespace  isEmpty  ? :)

I feel  isBlank() is more expressive than  isWhitespace(). It just feels
more inclusive of null and empty.

if (isNotBlank()) {
  ...process data
}
OR
if (isNotWhitespace()) {
  ...process data
}

Then again isWhitespace follows our naming definitions.

---
  isEmptyTrimmed() - trim() then  or null

 I'm not sure there's any need for this. I wonder how much of the chars
 less than 32 count as whitespace? But it seems that isWhitespace is for
 most people's usage a superset of isEmptyTrimmed.

Yeh, I'm happy to miss it out.

---
  (plus isNotEmpty, isNotBlank, isEmptyNN, isBlankNN)

 Still hard to decide how far to go with all these. isEmptyNN is a
 single-atom method. isNotEmpty just replaces a ! sign etc etc.

The Nots are very useful for these cases as they are so frequent.

---
 Does anyone actually want isEmptyNN, or is it just that people are unhappy
 with the null-handling in StringUtils? In which case I think the NN is the
 wrong solution, we need to be thinking about an ability to create a
 StringUtils with a strategy or having an underlying hidden class and 3
 facade's for the different strategies. All 3.0.

+1. Leave out NN for now. Its a bit of a hack.

Stephen


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



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang BooleanUtils.java ClassUtils.java ArrayUtils.java

2003-07-19 Thread scolebourne
scolebourne2003/07/19 13:17:12

  Modified:lang/src/java/org/apache/commons/lang BooleanUtils.java
ClassUtils.java ArrayUtils.java
  Log:
  Document null behaviour
  
  Revision  ChangesPath
  1.8   +13 -8 
jakarta-commons/lang/src/java/org/apache/commons/lang/BooleanUtils.java
  
  Index: BooleanUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/BooleanUtils.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- BooleanUtils.java 14 Jul 2003 22:25:02 -  1.7
  +++ BooleanUtils.java 19 Jul 2003 20:17:12 -  1.8
  @@ -59,6 +59,10 @@
* pcodeBooleanUtils/code contains utility methods for working for
* boolean and Boolean objects./p
*
  + * pThis class tries to handle codenull/code input gracefully.
  + * An exception will not be thrown for a codenull/code input.
  + * Each method documents its behaviour in more detail./p
  + * 
* @author Stephen Colebourne
* @author Matthew Hawthorne
* @since 2.0
  @@ -84,7 +88,7 @@
* pIf codenull/code is passed in, codenull/code will be returned./p
* 
* @param bool  the Boolean to negate, may be null
  - * @return the negated Boolean, or codenull/code if codenull/code 
passed in
  + * @return the negated Boolean, or codenull/code if codenull/code input
*/
   public static Boolean negate(Boolean bool) {
   if (bool == null) {
  @@ -112,7 +116,8 @@
* by returning codefalse/code./p
* 
* @param bool  the boolean to convert
  - * @return codetrue/code or codefalse/code
  + * @return codetrue/code or codefalse/code, 
  + *  codenull/code returns codefalse/code
*/
   public static boolean toBoolean(Boolean bool) {
   if (bool == null) {
  @@ -169,7 +174,7 @@
* 
* @param value  the Integer to convert
* @return Boolean.TRUE if non-zero, Boolean.FALSE if zero,
  - *  codenull/code if codenull/code
  + *  codenull/code if codenull/code input
*/
   public static Boolean toBooleanObject(Integer value) {
   if (value == null) {
  @@ -392,8 +397,8 @@
* Otherwise, codenull/code is returned./p
*
* @param str  the String to check
  - * @return the Boolean value of the string, codenull/code
  - *  if no match or codenull/code input
  + * @return the Boolean value of the string,
  + *  codenull/code if no match or codenull/code input
*/
   public static Boolean toBooleanObject(String str) {
   if (true.equalsIgnoreCase(str)) {
  @@ -423,8 +428,8 @@
*  (case sensitive), may be codenull/code
* @param nullString  the String to match for codenull/code
*  (case sensitive), may be codenull/code
  - * @return the Boolean value of the string, codenull/code
  - *  if no match or codenull/code input
  + * @return the Boolean value of the string,
  + *  codenull/code if no match or codenull/code input
*/
   public static Boolean toBooleanObject(String str, String trueString, String 
falseString, String nullString) {
   if (str == null) {
  
  
  
  1.16  +4 -1  
jakarta-commons/lang/src/java/org/apache/commons/lang/ClassUtils.java
  
  Index: ClassUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/ClassUtils.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- ClassUtils.java   16 Jul 2003 21:19:22 -  1.15
  +++ ClassUtils.java   19 Jul 2003 20:17:12 -  1.16
  @@ -59,6 +59,9 @@
   /**
* pProvides utility methods for working for classes without using reflection./p
*
  + * pThis class throws exceptions for invalid codenull/code inputs.
  + * Each method documents its behaviour in more detail./p
  + *
* @author Stephen Colebourne
* @author a href=mailto:[EMAIL PROTECTED]Gary Gregory/a
* @since 2.0
  
  
  
  1.19  +218 -206  
jakarta-commons/lang/src/java/org/apache/commons/lang/ArrayUtils.java
  
  Index: ArrayUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/ArrayUtils.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- ArrayUtils.java   14 Jul 2003 22:25:02 -  1.18
  +++ ArrayUtils.java   19 Jul 2003 20:17:12 -  1.19
  @@ -63,6 +63,11 @@
   /**
* pcodeArrayUtils/code contains utility methods for working with
* arrays./p
  + * 
  + * pThis class tries to handle codenull/code input gracefully.
  + * An exception will not be thrown for a codenull/code
  + * array input. However, an Object array that contains a codenull/code
  + * element may throw an 

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang NullArgumentException.java

2003-07-19 Thread scolebourne
scolebourne2003/07/19 13:19:24

  Modified:lang/src/test/org/apache/commons/lang
NullArgumentExceptionTest.java
   lang/src/java/org/apache/commons/lang
NullArgumentException.java
  Log:
  Change error text to be more clear
  
  Revision  ChangesPath
  1.2   +4 -3  
jakarta-commons/lang/src/test/org/apache/commons/lang/NullArgumentExceptionTest.java
  
  Index: NullArgumentExceptionTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/NullArgumentExceptionTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- NullArgumentExceptionTest.java15 May 2003 04:05:11 -  1.1
  +++ NullArgumentExceptionTest.java19 Jul 2003 20:19:24 -  1.2
  @@ -62,6 +62,7 @@
* JUnit tests.
* 
* @author Matthew Hawthorne
  + * @author Stephen Colebourne
* @version $Id$
* @see NullArgumentException
*/
  @@ -89,13 +90,13 @@
   
   public void testGetMessage_nullConstructorInput() {
   final Throwable t = new NullArgumentException(null);
  -assertEquals(null cannot be null., t.getMessage());
  +assertEquals(null must not be null., t.getMessage());
   }
   
   public void testGetMessage_validConstructorInput() {
   final String argName = name;
   final Throwable t = new NullArgumentException(argName);
  -assertEquals(argName +  cannot be null., t.getMessage());
  +assertEquals(argName +  must not be null., t.getMessage());
   }
   
   } // NullArgumentExceptionTest
  
  
  
  1.4   +4 -3  
jakarta-commons/lang/src/java/org/apache/commons/lang/NullArgumentException.java
  
  Index: NullArgumentException.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/NullArgumentException.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- NullArgumentException.java14 Jul 2003 22:25:02 -  1.3
  +++ NullArgumentException.java19 Jul 2003 20:19:24 -  1.4
  @@ -58,6 +58,7 @@
* not have been./p
* 
* @author Matthew Hawthorne
  + * @author Stephen Colebourne
* @since 2.0
* @version $Id$
*/
  @@ -65,11 +66,11 @@
   
/**
 * pInstantiates with the given argument name./p
  - *
  + * 
 * @param argName  the name of the argument that was codenull/code.
 */
public NullArgumentException(String argName) {
  - super(argName +  cannot be null.);
  + super(argName +  must not be null.);
}
   
   }
  
  
  

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



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang RandomStringUtils.java

2003-07-19 Thread scolebourne
scolebourne2003/07/19 13:21:08

  Modified:lang/src/java/org/apache/commons/lang RandomStringUtils.java
  Log:
  Update original file location to author tag for consistency
  
  Revision  ChangesPath
  1.17  +2 -3  
jakarta-commons/lang/src/java/org/apache/commons/lang/RandomStringUtils.java
  
  Index: RandomStringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/RandomStringUtils.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- RandomStringUtils.java16 Jul 2003 00:39:05 -  1.16
  +++ RandomStringUtils.java19 Jul 2003 20:21:08 -  1.17
  @@ -57,8 +57,7 @@
   /**
* pCommon random codeString/code manipulation routines./p
*
  - * pOriginally from the GenerationJava Core library./p
  - *
  + * @author GenerationJava Core library
* @author a href=mailto:[EMAIL PROTECTED]Henri Yandell/a
* @author a href=mailto:[EMAIL PROTECTED]Steven Caswell/a
* @author Stephen Colebourne
  
  
  

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



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang ObjectUtils.java

2003-07-19 Thread scolebourne
scolebourne2003/07/19 13:21:39

  Modified:lang/src/java/org/apache/commons/lang ObjectUtils.java
  Log:
  Document null behaviour
  
  Revision  ChangesPath
  1.12  +8 -3  
jakarta-commons/lang/src/java/org/apache/commons/lang/ObjectUtils.java
  
  Index: ObjectUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/ObjectUtils.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ObjectUtils.java  16 Jul 2003 01:47:39 -  1.11
  +++ ObjectUtils.java  19 Jul 2003 20:21:39 -  1.12
  @@ -54,8 +54,13 @@
   package org.apache.commons.lang;
   
   import java.io.Serializable;
  +
   /**
* pCommon codeObject/code manipulation routines./p
  + * 
  + * pThis class tries to handle codenull/code input gracefully.
  + * An exception will generally not be thrown for a codenull/code input.
  + * Each method documents its behaviour in more detail./p
*
* @author a href=mailto:[EMAIL PROTECTED]Nissim Karpenstein/a
* @author a href=mailto:[EMAIL PROTECTED]Janek Bogucki/a
  @@ -130,7 +135,7 @@
   
   /**
* pGets the toString that would be produced by codeObject/code
  - * if a class did not override toString itself. codeNull/code
  + * if a class did not override toString itself. codenull/code
* will return codenull/code./p
*
* @param object  the object to create a toString for, may be
  @@ -147,7 +152,7 @@
   
   /**
* pAppends the toString that would be produced by codeObject/code
  - * if a class did not override toString itself. codeNull/code
  + * if a class did not override toString itself. codenull/code
* will return codenull/code./p
*
* @param buffer  the buffer to append to, may not be
  
  
  

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



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang WordWrapUtils.java StringEscapeUtils.java CharSetUtils.java SerializationUtils.java

2003-07-19 Thread scolebourne
scolebourne2003/07/19 13:22:36

  Modified:lang/src/test/org/apache/commons/lang
SerializationUtilsTest.java CharSetUtilsTest.java
StringEscapeUtilsTest.java WordWrapUtilsTest.java
   lang/src/java/org/apache/commons/lang WordWrapUtils.java
StringEscapeUtils.java CharSetUtils.java
SerializationUtils.java
  Log:
  Update null behaviour for consistency and clarity
  Doument null behaviour
  
  Revision  ChangesPath
  1.3   +5 -5  
jakarta-commons/lang/src/test/org/apache/commons/lang/SerializationUtilsTest.java
  
  Index: SerializationUtilsTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/SerializationUtilsTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SerializationUtilsTest.java   23 Mar 2003 21:50:58 -  1.2
  +++ SerializationUtilsTest.java   19 Jul 2003 20:22:36 -  1.3
  @@ -157,7 +157,7 @@
   ByteArrayOutputStream streamTest = new ByteArrayOutputStream();
   try {
   SerializationUtils.serialize(iMap, null);
  -} catch (NullPointerException ex) {
  +} catch (IllegalArgumentException ex) {
   return;
   }
   fail();
  @@ -167,7 +167,7 @@
   ByteArrayOutputStream streamTest = new ByteArrayOutputStream();
   try {
   SerializationUtils.serialize(null, null);
  -} catch (NullPointerException ex) {
  +} catch (IllegalArgumentException ex) {
   return;
   }
   fail();
  @@ -210,7 +210,7 @@
   public void testDeserializeStreamNull() throws Exception {
   try {
   SerializationUtils.deserialize((InputStream) null);
  -} catch (NullPointerException ex) {
  +} catch (IllegalArgumentException ex) {
   return;
   }
   fail();
  @@ -304,7 +304,7 @@
   public void testDeserializeBytesNull() throws Exception {
   try {
   SerializationUtils.deserialize((byte[]) null);
  -} catch (NullPointerException ex) {
  +} catch (IllegalArgumentException ex) {
   return;
   }
   fail();
  
  
  
  1.8   +60 -66
jakarta-commons/lang/src/test/org/apache/commons/lang/CharSetUtilsTest.java
  
  Index: CharSetUtilsTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/CharSetUtilsTest.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- CharSetUtilsTest.java 23 Mar 2003 21:47:30 -  1.7
  +++ CharSetUtilsTest.java 19 Jul 2003 20:22:36 -  1.8
  @@ -63,10 +63,11 @@
*
* @author a href=mailto:[EMAIL PROTECTED]Henri Yandell/a
* @author a href=mailto:[EMAIL PROTECTED]Ringo De Smet/a
  + * @author Stephen Colebourne
* @version $Id$
*/
  -public class CharSetUtilsTest extends TestCase
  -{
  +public class CharSetUtilsTest extends TestCase {
  +
   public CharSetUtilsTest(String name) {
   super(name);
   }
  @@ -76,8 +77,8 @@
   }
   
   public static Test suite() {
  - TestSuite suite = new TestSuite(CharSetUtilsTest.class);
  - suite.setName(CharSetUtils Tests);
  +TestSuite suite = new TestSuite(CharSetUtilsTest.class);
  +suite.setName(CharSetUtils Tests);
   return suite;
   }
   
  @@ -91,66 +92,59 @@
   
   //---
   
  -public void testSqueeze()
  -{
  -assertEquals(squeeze(String,String[]) failed,
  - helo, CharSetUtils.squeeze(hello, new String[] {el}));
  -assertEquals(squeeze(String,String[]) failed,
  - , CharSetUtils.squeeze(, new String[] {el}));
  -assertEquals(squeeze(String,String[]) failed,
  - hello, CharSetUtils.squeeze(hello, new String[] {e}));
  -assertEquals(squeeze(String,String[]) failed,
  - fofof, CharSetUtils.squeeze(fooffooff, new String[] 
{of}));
  -assertEquals(squeeze(String,String[]) failed,
  - fof, CharSetUtils.squeeze(fff, new String[] {fo}));
  -}
  -
  -public void testCount()
  -{
  -assertEquals(count(String,String[]) failed,
  - 3, CharSetUtils.count(hello, new String[] {el}));
  -assertEquals(count(String,String[]) failed,
  - 0, CharSetUtils.count(, new String[] {el}));
  -assertEquals(count(String,String[]) failed,
  - 0, CharSetUtils.count(hello, new String[] {x}));
  -assertEquals(count(String,String[]) failed,
  - 2, 

Re: [lang] Proposal (2): isEmpty

2003-07-19 Thread Henri Yandell

So what's our 2.0 state with regard to this? What needs to be changed?

Do we want to release tight with the following removed from current HEAD:

isEmptyOrNull
isNotEmptyOrNull
isEmptyTrimmed
isNotEmptyTrimmed
isEmptyTrimmedOrNull
isNotEmptyTrimmedOrNull

Hen

On Sat, 19 Jul 2003, Stephen Colebourne wrote:

 From: Henri Yandell [EMAIL PROTECTED]
   It isn't. My preference is now for
  
   isEmpty() -  or null
   isBlank() - whitespace only,  or null
 
  Could just tell people to do isWhitespace  isEmpty  ? :)

 I feel  isBlank() is more expressive than  isWhitespace(). It just feels
 more inclusive of null and empty.

 if (isNotBlank()) {
   ...process data
 }
 OR
 if (isNotWhitespace()) {
   ...process data
 }

 Then again isWhitespace follows our naming definitions.

 ---
   isEmptyTrimmed() - trim() then  or null
 
  I'm not sure there's any need for this. I wonder how much of the chars
  less than 32 count as whitespace? But it seems that isWhitespace is for
  most people's usage a superset of isEmptyTrimmed.

 Yeh, I'm happy to miss it out.

 ---
   (plus isNotEmpty, isNotBlank, isEmptyNN, isBlankNN)
 
  Still hard to decide how far to go with all these. isEmptyNN is a
  single-atom method. isNotEmpty just replaces a ! sign etc etc.

 The Nots are very useful for these cases as they are so frequent.

 ---
  Does anyone actually want isEmptyNN, or is it just that people are unhappy
  with the null-handling in StringUtils? In which case I think the NN is the
  wrong solution, we need to be thinking about an ability to create a
  StringUtils with a strategy or having an underlying hidden class and 3
  facade's for the different strategies. All 3.0.

 +1. Leave out NN for now. Its a bit of a hack.

 Stephen


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



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



cvs commit: jakarta-commons/lang RELEASE-NOTES.txt

2003-07-19 Thread scolebourne
scolebourne2003/07/19 14:55:05

  Modified:lang/src/java/org/apache/commons/lang/enum Enum.java
   lang/src/java/org/apache/commons/lang/reflect
ReflectionUtils.java
   lang/src/test/org/apache/commons/lang
StringUtilsTrimEmptyTest.java
   lang/src/java/org/apache/commons/lang ClassUtils.java
StringUtils.java
   lang RELEASE-NOTES.txt
  Log:
  Rework isEmpty and isNotEmpty following user feedback
  
  Revision  ChangesPath
  1.14  +2 -2  
jakarta-commons/lang/src/java/org/apache/commons/lang/enum/Enum.java
  
  Index: Enum.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/enum/Enum.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Enum.java 16 Jul 2003 21:19:21 -  1.13
  +++ Enum.java 19 Jul 2003 21:55:04 -  1.14
  @@ -251,7 +251,7 @@
   protected Enum(String name) {
   super();
   
  -if (StringUtils.isEmptyOrNull(name)) {
  +if (StringUtils.isEmpty(name)) {
   throw new IllegalArgumentException(The Enum name must not be empty or 
null);
   }
   iName = name;
  
  
  
  1.9   +2 -2  
jakarta-commons/lang/src/java/org/apache/commons/lang/reflect/ReflectionUtils.java
  
  Index: ReflectionUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/reflect/ReflectionUtils.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ReflectionUtils.java  16 Jul 2003 21:19:22 -  1.8
  +++ ReflectionUtils.java  19 Jul 2003 21:55:05 -  1.9
  @@ -174,7 +174,7 @@
* @throws IllegalArgumentException if the class name is empty
*/
   public static Class getClass(String className) throws ReflectionException {
  -if (StringUtils.isEmptyOrNull(className)) {
  +if (StringUtils.isEmpty(className)) {
   throw new IllegalArgumentException(The class name must not be null);
   }
   try {
  
  
  
  1.12  +21 -53
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTrimEmptyTest.java
  
  Index: StringUtilsTrimEmptyTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTrimEmptyTest.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- StringUtilsTrimEmptyTest.java 19 Jul 2003 18:10:30 -  1.11
  +++ StringUtilsTrimEmptyTest.java 19 Jul 2003 21:55:05 -  1.12
  @@ -139,67 +139,35 @@
   }
   
   public void testIsEmpty() {
  +assertEquals(true, StringUtils.isEmpty(null));
  +assertEquals(true, StringUtils.isEmpty());
  +assertEquals(false, StringUtils.isEmpty( ));
   assertEquals(false, StringUtils.isEmpty(foo));
   assertEquals(false, StringUtils.isEmpty(  foo  ));
  -assertEquals(false, StringUtils.isEmpty( ));
  -assertEquals(true, StringUtils.isEmpty());
  -assertEquals(false, StringUtils.isEmpty(null));
   }
   
   public void testIsNotEmpty() {
  +assertEquals(false, StringUtils.isNotEmpty(null));
  +assertEquals(false, StringUtils.isNotEmpty());
  +assertEquals(true, StringUtils.isNotEmpty( ));
   assertEquals(true, StringUtils.isNotEmpty(foo));
   assertEquals(true, StringUtils.isNotEmpty(  foo  ));
  -assertEquals(true, StringUtils.isNotEmpty( ));
  -assertEquals(false, StringUtils.isNotEmpty());
  -assertEquals(true, StringUtils.isNotEmpty(null));
  -}
  -
  -public void testIsEmptyOrNull() {
  -assertEquals(false, StringUtils.isEmptyOrNull(foo));
  -assertEquals(false, StringUtils.isEmptyOrNull(  foo  ));
  -assertEquals(false, StringUtils.isEmptyOrNull( ));
  -assertEquals(true, StringUtils.isEmptyOrNull());
  -assertEquals(true, StringUtils.isEmptyOrNull(null));
  -}
  -
  -public void testIsNotEmptyOrNull() {
  -assertEquals(true, StringUtils.isNotEmptyOrNull(foo));
  -assertEquals(true, StringUtils.isNotEmptyOrNull(  foo  ));
  -assertEquals(true, StringUtils.isNotEmptyOrNull( ));
  -assertEquals(false, StringUtils.isNotEmptyOrNull());
  -assertEquals(false, StringUtils.isNotEmptyOrNull(null));
  -}
  -
  -public void testIsEmptyTrimmed() {
  -assertEquals(false, StringUtils.isEmptyTrimmed(foo));
  -assertEquals(false, StringUtils.isEmptyTrimmed(  foo  ));
  -assertEquals(true, StringUtils.isEmptyTrimmed( ));
  -assertEquals(true, StringUtils.isEmptyTrimmed());
  -

Re: [lang] Proposal (2): isEmpty - commits

2003-07-19 Thread Stephen Colebourne
I have updated CVS HEAD as follows:

Removed:
isEmptyOrNull
isNotEmptyOrNull
isEmptyTrimmed
isNotEmptyTrimmed
isEmptyTrimmedOrNull
isNotEmptyTrimmedOrNull

Changed:
isEmpty - true for  or null
isNotEmpty - opposite (no change from 1.0)

Added:
isBlank - true for all whitespace,  or null
isNotBlank - opposite

I suggest that committers think if they want to -1 veto this change.

Stephen

- Original Message -
From: Henri Yandell [EMAIL PROTECTED]
To: Jakarta Commons Developers List [EMAIL PROTECTED]
Sent: Saturday, July 19, 2003 9:54 PM
Subject: Re: [lang] Proposal (2): isEmpty



 So what's our 2.0 state with regard to this? What needs to be changed?

 Do we want to release tight with the following removed from current HEAD:

 isEmptyOrNull
 isNotEmptyOrNull
 isEmptyTrimmed
 isNotEmptyTrimmed
 isEmptyTrimmedOrNull
 isNotEmptyTrimmedOrNull

 Hen

 On Sat, 19 Jul 2003, Stephen Colebourne wrote:

  From: Henri Yandell [EMAIL PROTECTED]
It isn't. My preference is now for
   
isEmpty() -  or null
isBlank() - whitespace only,  or null
  
   Could just tell people to do isWhitespace  isEmpty  ? :)
 
  I feel  isBlank() is more expressive than  isWhitespace(). It just feels
  more inclusive of null and empty.
 
  if (isNotBlank()) {
...process data
  }
  OR
  if (isNotWhitespace()) {
...process data
  }
 
  Then again isWhitespace follows our naming definitions.
 
  ---
isEmptyTrimmed() - trim() then  or null
  
   I'm not sure there's any need for this. I wonder how much of the chars
   less than 32 count as whitespace? But it seems that isWhitespace is
for
   most people's usage a superset of isEmptyTrimmed.
 
  Yeh, I'm happy to miss it out.
 
  ---
(plus isNotEmpty, isNotBlank, isEmptyNN, isBlankNN)
  
   Still hard to decide how far to go with all these. isEmptyNN is a
   single-atom method. isNotEmpty just replaces a ! sign etc etc.
 
  The Nots are very useful for these cases as they are so frequent.
 
  ---
   Does anyone actually want isEmptyNN, or is it just that people are
unhappy
   with the null-handling in StringUtils? In which case I think the NN is
the
   wrong solution, we need to be thinking about an ability to create a
   StringUtils with a strategy or having an underlying hidden class and 3
   facade's for the different strategies. All 3.0.
 
  +1. Leave out NN for now. Its a bit of a hack.
 
  Stephen
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 


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



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



RE: [functor] Iterator and Generator

2003-07-19 Thread Rodney Waldhoff
Maybe that post came out with the wrong emphasis.

I'm not trying to say we should prefer external iterators to internal
ones, indeed much of the value of commons-functor comes from replacing
external iteration with internal iteration.  It just seems that if you add
a next() method to Generator, then Generator extends Iterator, and that
seemed like a reasonable thing to add.  Given that the
java.util.Collections are external iterator based, they will remain a
force to be reckoned with in Java.

I'm still trying to wrap my head around bits of the Generator package and
how and why it's implemented in certain ways.  Let me hold off on any sort
of Generator extends Iterator changes for the time being, and work through
some other concerns.


- Rod http://radio.weblogs.com/0122027/


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



cvs commit: jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/generator/util TestEachElement.java

2003-07-19 Thread rwaldhoff
rwaldhoff2003/07/19 15:12:25

  Modified:functor/src/java/org/apache/commons/functor/generator/util
EachElement.java
   functor/src/test/org/apache/commons/functor/generator
TestGenerator.java
   functor/src/test/org/apache/commons/functor/generator/util
TestEachElement.java
  Log:
  simplify EachElement implementation, add tests
  
  Revision  ChangesPath
  1.3   +33 -89
jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/generator/util/EachElement.java
  
  Index: EachElement.java
  ===
  RCS file: 
/home/cvs/jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/generator/util/EachElement.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EachElement.java  17 Jul 2003 22:44:46 -  1.2
  +++ EachElement.java  19 Jul 2003 22:12:25 -  1.3
  @@ -62,8 +62,6 @@
   import java.util.Iterator;
   import java.util.Map;
   
  -import org.apache.commons.functor.UnaryProcedure;
  -import org.apache.commons.functor.generator.BaseGenerator;
   import org.apache.commons.functor.generator.Generator;
   import org.apache.commons.functor.generator.IteratorToGeneratorAdapter;
   
  @@ -75,90 +73,36 @@
* @author  Jason Horman ([EMAIL PROTECTED])
*/
   
  -public class EachElement extends BaseGenerator {
  -
  -/***
  - *  Instance variables
  - ***/
  -
  -private Generator generator = null;
  -
  -/***
  - *  Constructors
  - ***/
  -
  -/**
  - * Generator for collections.
  - */
  -public EachElement(Collection collection) {
  -generator = new IteratorToGeneratorAdapter(collection.iterator());
  -}
  -
  -/**
  - * Generator for maps. Generates [EMAIL PROTECTED] java.util.Map.Entry} objects.
  - */
  -public EachElement(Map map) {
  -generator = new IteratorToGeneratorAdapter(map.entrySet().iterator());
  -}
  -
  -/**
  - * Generator for arrays.
  - */
  -public EachElement(Object[] array) {
  -generator = new IteratorToGeneratorAdapter(Arrays.asList(array).iterator());
  -}
  -
  -/**
  - * EachElement over a generator.
  - */
  -public EachElement(Generator generator) {
  -this.generator = generator;
  -}
  -
  -/**
  - * EachElement over a iterator.
  - */
  -public EachElement(Iterator iter) {
  -this.generator = new IteratorToGeneratorAdapter(iter);
  -}
  -
  -/***
  - *  Instance methods
  - ***/
  -
  -public void run(UnaryProcedure proc) {
  -generator.run(proc);
  -}
  -
  -public void stop() {
  -generator.stop();
  -}
  -
  -public String toString() {
  -return EachElement + generator + ;
  -}
  -
  -/***
  - *  Class methods
  - ***/
  -
  -public static final EachElement from(Collection col) {
  -return new EachElement(col);
  -}
  -
  -public static final EachElement from(Map map) {
  -return new EachElement(map);
  -}
  -
  -public static final EachElement from(Object[] array) {
  -return new EachElement(array);
  -}
  -
  -public static final EachElement from(Iterator iter) {
  -return new EachElement(iter);
  -}
  -
  -public static final EachElement from(Generator gen) {
  -return new EachElement(gen);
  +public final class EachElement {
  +public static final Generator from(Collection collection) {
  +if(null == collection) {
  +return null;
  +} else {
  +return EachElement.from(collection.iterator());
  +}
  +}
  +
  +public static final Generator from(Map map) {
  +if(null == map) {
  +return null;
  +} else {
  +return EachElement.from(map.entrySet().iterator());
  +}
  +}
  +
  +public static final Generator from(Object[] array) {
  +if(null == array) {
  +return null;
  +} else {
  +return EachElement.from(Arrays.asList(array).iterator());
  +}
  +}
  +
  +public static final Generator from(Iterator iter) {
  +if(null == iter) {
  +return null;
  +} else {
  +return new IteratorToGeneratorAdapter(iter);
  +}
   }
   }
  
  
  
  1.4   +16 -16

[functor] changes to EachElement

2003-07-19 Thread Rodney Waldhoff
I've just checked in a somewhat significant change to the implementation,
but not the functionality, of EachElement.  Let me describe it for
comment:

Previously EachElement was an instantiable class implementing Generator,
but all the non-static methods simply delegating to some underlying
Generator instance (typically IteratorToGeneratorAdapter).  In other
words, EachElement was nothing more than a proxy/decorator for some other
Generator instance.

The other part of EachElement (that is, the static part) provided
factory methods for creating EachElement instances, e.g.,
EachElement.from(someCollection).

Since the instantiable EachElement instance didn't seem to be adding any
value, I've removed it.  Now EachElement is just a container for the
static factory methods (the from methods).

Also, I made those factory methods handle null values a bit more robustly,
so that EachElement.from(null) return null, and added tests for this
behavior.

What we've lost, relative to the previous revision of EachElement is:

1) the ability to write something like new EachElement(someCollection),
instead one must write EachElement.from(someCollection), or if you
really like new, then new
IteratorToGeneratorAdapater(someCollection.iterator()).

2) the ability to write something like new EachElement(generator), or
even EachElement.from(generator).  It's not clear to me why that was
provided in the first place.  new EachElement(generator) simply creates an
equivalent Generator, but with an extra level of indirection.

If someone is strongly opposed to these changes we can always roll back to
the previous revision.

- Rod http://radio.weblogs.com/0122027/

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



DO NOT REPLY [Bug 21633] - IndexOutOfBoundsException when encoding non-ASCII characters

2003-07-19 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21633.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21633

IndexOutOfBoundsException  when encoding non-ASCII characters





--- Additional Comments From [EMAIL PROTECTED]  2003-07-19 22:25 ---
Mike,
I apologize for having missed your point. I did not quite realize that you were
talking about a bug in the URLCodec that I contributed to Commons Codec. Somehow
I thought you were referring to the bug discovered by Odi. 

The bug is really ugly (my bad) and the fix is fairly straight-forward. It
should have no side-effects on the code outside the URLCodec lcass. I trust the
Codec folk will forgive us for committing the patch without their explicit
permission. 

My +1 for committing the patch.

Oleg

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



[lang] NumberUtils null handling

2003-07-19 Thread Phil Steitz
I have been going through NumberUtils code and tests to make sure that
handling of nulls is documented (and tested) correctly. I notice that
createNumber returns null for null (need to add a javadoc comment for
this); whereas createFloat, et al will throw NPEs on null.  Shouldn't
these behave the same?  In any case, the behavior should be documented.
Should I submit a patch to

1. Make createFloat et al return null for null as createNumber does

2. Make no changes to NumberUtils methods, just add javadoc and tests
documenting current behavior.
3. Go back to sleep...;-)

Phil



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


cvs commit: jakarta-commons/lang/src/test/org/apache/commons/lang StringUtilsTest.java

2003-07-19 Thread scolebourne
scolebourne2003/07/19 16:28:23

  Modified:lang/src/test/org/apache/commons/lang StringUtilsTest.java
  Log:
  Move IndexOf and Contains tests to StringUtilsEqualsIndexOfTest
  
  Revision  ChangesPath
  1.30  +1 -126
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java
  
  Index: StringUtilsTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- StringUtilsTest.java  19 Jul 2003 18:10:30 -  1.29
  +++ StringUtilsTest.java  19 Jul 2003 23:28:23 -  1.30
  @@ -685,131 +685,6 @@
1, StringUtils.getLevenshteinDistance(hello, hallo) );
   }
   
  -public void testContainsOnlyString() {
  -String str1 = a;
  -String str2 = b;
  -String str3 = ab;
  -String chars1= b;
  -String chars2= a;
  -String chars3= ab;
  -String emptyChars = ;
  -assertEquals(containsOnly(null, null) failed, false, 
StringUtils.containsOnly(null, (String) null));
  -assertEquals(containsOnly(empty-string, null) failed, false, 
StringUtils.containsOnly(, (String) null));
  -assertEquals(containsOnly(null, empty-string) failed, false, 
StringUtils.containsOnly(null, emptyChars));
  -assertEquals(containsOnly(str1, empty-char-array) failed, false, 
StringUtils.containsOnly(str1, emptyChars));
  -assertEquals(containsOnly(empty-string, empty-char-array) failed, true, 
StringUtils.containsOnly(, emptyChars));
  -assertEquals(containsOnly(empty-string, chars1) failed, true, 
StringUtils.containsOnly(, chars1));
  -assertEquals(containsOnly(str1, chars1) failed, false, 
StringUtils.containsOnly(str1, chars1));
  -assertEquals(containsOnly(str1, chars2) success, true, 
StringUtils.containsOnly(str1, chars2));
  -assertEquals(containsOnly(str1, chars3) success, true, 
StringUtils.containsOnly(str1, chars3));
  -assertEquals(containsOnly(str2, chars1) success, true, 
StringUtils.containsOnly(str2, chars1));
  -assertEquals(containsOnly(str2, chars2) failed, false, 
StringUtils.containsOnly(str2, chars2));
  -assertEquals(containsOnly(str2, chars3) success, true, 
StringUtils.containsOnly(str2, chars3));
  -assertEquals(containsOnly(String3, chars1) failed, false, 
StringUtils.containsOnly(str3, chars1));
  -assertEquals(containsOnly(String3, chars2) failed, false, 
StringUtils.containsOnly(str3, chars2));
  -assertEquals(containsOnly(String3, chars3) success, true, 
StringUtils.containsOnly(str3, chars3));
  -}
  -
  -public void testContainsOnlyCharArray() {
  -String str1 = a;
  -String str2 = b;
  -String str3 = ab;
  -char[] chars1= {'b'};
  -char[] chars2= {'a'};
  -char[] chars3= {'a', 'b'};
  -char[] emptyChars = new char[0];
  -assertEquals(containsOnly(null, null) failed, false, 
StringUtils.containsOnly(null, (char[]) null));
  -assertEquals(containsOnly(empty-string, null) failed, false, 
StringUtils.containsOnly(, (char[]) null));
  -assertEquals(containsOnly(null, empty-string) failed, false, 
StringUtils.containsOnly(null, emptyChars));
  -assertEquals(containsOnly(str1, empty-char-array) failed, false, 
StringUtils.containsOnly(str1, emptyChars));
  -assertEquals(containsOnly(empty-string, empty-char-array) failed, true, 
StringUtils.containsOnly(, emptyChars));
  -assertEquals(containsOnly(empty-string, chars1) failed, true, 
StringUtils.containsOnly(, chars1));
  -assertEquals(containsOnly(str1, chars1) failed, false, 
StringUtils.containsOnly(str1, chars1));
  -assertEquals(containsOnly(str1, chars2) success, true, 
StringUtils.containsOnly(str1, chars2));
  -assertEquals(containsOnly(str1, chars3) success, true, 
StringUtils.containsOnly(str1, chars3));
  -assertEquals(containsOnly(str2, chars1) success, true, 
StringUtils.containsOnly(str2, chars1));
  -assertEquals(containsOnly(str2, chars2) failed, false, 
StringUtils.containsOnly(str2, chars2));
  -assertEquals(containsOnly(str2, chars3) success, true, 
StringUtils.containsOnly(str2, chars3));
  -assertEquals(containsOnly(String3, chars1) failed, false, 
StringUtils.containsOnly(str3, chars1));
  -assertEquals(containsOnly(String3, chars2) failed, false, 
StringUtils.containsOnly(str3, chars2));
  -assertEquals(containsOnly(String3, chars3) success, true, 
StringUtils.containsOnly(str3, chars3));
  -}
  -
  -public void testContainsNoneString() {
  -String str1 = a;
  -String str2 = b;
  -String str3 = ab.;
  -String chars1= b;
  -String chars2= .;
  -String chars3= 

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-07-19 Thread scolebourne
scolebourne2003/07/19 16:29:07

  Modified:lang/src/test/org/apache/commons/lang
StringUtilsEqualsIndexOfTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Add new methods for null-safe indexOf/lastIndexOf
  Add new methods for contains
  
  Revision  ChangesPath
  1.3   +250 -1
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsEqualsIndexOfTest.java
  
  Index: StringUtilsEqualsIndexOfTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsEqualsIndexOfTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StringUtilsEqualsIndexOfTest.java 23 Mar 2003 21:50:58 -  1.2
  +++ StringUtilsEqualsIndexOfTest.java 19 Jul 2003 23:29:06 -  1.3
  @@ -115,6 +115,131 @@
   assertEquals(false, StringUtils.equalsIgnoreCase(null, FOO));
   }
   
  +//---
  +public void testIndexOf_char() {
  +assertEquals(-1, StringUtils.indexOf(null, ' '));
  +assertEquals(-1, StringUtils.indexOf(, ' '));
  +assertEquals(0, StringUtils.indexOf(aabaabaa, 'a'));
  +assertEquals(2, StringUtils.indexOf(aabaabaa, 'b'));
  +}
  +
  +public void testIndexOf_charInt() {
  +assertEquals(-1, StringUtils.indexOf(null, ' ', 0));
  +assertEquals(-1, StringUtils.indexOf(null, ' ', -1));
  +assertEquals(-1, StringUtils.indexOf(, ' ', 0));
  +assertEquals(-1, StringUtils.indexOf(, ' ', -1));
  +assertEquals(0, StringUtils.indexOf(aabaabaa, 'a', 0));
  +assertEquals(2, StringUtils.indexOf(aabaabaa, 'b', 0));
  +assertEquals(5, StringUtils.indexOf(aabaabaa, 'b', 3));
  +assertEquals(-1, StringUtils.indexOf(aabaabaa, 'b', 9));
  +assertEquals(2, StringUtils.indexOf(aabaabaa, 'b', -1));
  +}
  +
  +public void testIndexOf_String() {
  +assertEquals(-1, StringUtils.indexOf(null, null));
  +assertEquals(-1, StringUtils.indexOf(, null));
  +assertEquals(0, StringUtils.indexOf(, ));
  +assertEquals(0, StringUtils.indexOf(aabaabaa, a));
  +assertEquals(2, StringUtils.indexOf(aabaabaa, b));
  +assertEquals(1, StringUtils.indexOf(aabaabaa, ab));
  +}
  +
  +public void testIndexOf_StringInt() {
  +assertEquals(-1, StringUtils.indexOf(null, null, 0));
  +assertEquals(-1, StringUtils.indexOf(null, null, -1));
  +assertEquals(-1, StringUtils.indexOf(null, , 0));
  +assertEquals(-1, StringUtils.indexOf(null, , -1));
  +assertEquals(-1, StringUtils.indexOf(, null, 0));
  +assertEquals(-1, StringUtils.indexOf(, null, -1));
  +assertEquals(0, StringUtils.indexOf(, , 0));
  +assertEquals(0, StringUtils.indexOf(, , -1));
  +assertEquals(0, StringUtils.indexOf(, , 9));
  +assertEquals(0, StringUtils.indexOf(abc, , 0));
  +assertEquals(0, StringUtils.indexOf(abc, , -1));
  +assertEquals(3, StringUtils.indexOf(abc, , 9));
  +assertEquals(0, StringUtils.indexOf(aabaabaa, a, 0));
  +assertEquals(2, StringUtils.indexOf(aabaabaa, b, 0));
  +assertEquals(1, StringUtils.indexOf(aabaabaa, ab, 0));
  +assertEquals(5, StringUtils.indexOf(aabaabaa, b, 3));
  +assertEquals(-1, StringUtils.indexOf(aabaabaa, b, 9));
  +assertEquals(2, StringUtils.indexOf(aabaabaa, b, -1));
  +}
  +
  +//---
  +public void testLastIndexOf_char() {
  +assertEquals(-1, StringUtils.lastIndexOf(null, ' '));
  +assertEquals(-1, StringUtils.lastIndexOf(, ' '));
  +assertEquals(7, StringUtils.lastIndexOf(aabaabaa, 'a'));
  +assertEquals(5, StringUtils.lastIndexOf(aabaabaa, 'b'));
  +}
  +
  +public void testLastIndexOf_charInt() {
  +assertEquals(-1, StringUtils.lastIndexOf(null, ' ', 0));
  +assertEquals(-1, StringUtils.lastIndexOf(null, ' ', -1));
  +assertEquals(-1, StringUtils.lastIndexOf(, ' ', 0));
  +assertEquals(-1, StringUtils.lastIndexOf(, ' ', -1));
  +assertEquals(7, StringUtils.lastIndexOf(aabaabaa, 'a', 8));
  +assertEquals(5, StringUtils.lastIndexOf(aabaabaa, 'b', 8));
  +assertEquals(2, StringUtils.lastIndexOf(aabaabaa, 'b', 3));
  +assertEquals(5, StringUtils.lastIndexOf(aabaabaa, 'b', 9));
  +assertEquals(-1, StringUtils.lastIndexOf(aabaabaa, 'b', -1));
  +}
  +
  +public void testLastIndexOf_String() {
  +assertEquals(-1, StringUtils.lastIndexOf(null, null));
  +assertEquals(-1, StringUtils.lastIndexOf(, null));
  +assertEquals(0, StringUtils.lastIndexOf(, ));
  +assertEquals(7, 

Re: [lang] NumberUtils null handling

2003-07-19 Thread Stephen Colebourne
These should all be null in null out and documented as such (see
StringUtils).

PS. make sure you change the version in the math subpackage, not the one in
the main lang package!

Stephen

- Original Message -
From: Phil Steitz [EMAIL PROTECTED]
To: Jakarta Commons Developers List [EMAIL PROTECTED]
Sent: Sunday, July 20, 2003 12:26 AM
Subject: [lang] NumberUtils null handling


 I have been going through NumberUtils code and tests to make sure that
 handling of nulls is documented (and tested) correctly. I notice that
 createNumber returns null for null (need to add a javadoc comment for
 this); whereas createFloat, et al will throw NPEs on null.  Shouldn't
 these behave the same?  In any case, the behavior should be documented.

 Should I submit a patch to

 1. Make createFloat et al return null for null as createNumber does

 2. Make no changes to NumberUtils methods, just add javadoc and tests
 documenting current behavior.

 3. Go back to sleep...;-)


 Phil



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



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



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-07-19 Thread scolebourne
scolebourne2003/07/19 17:04:12

  Modified:lang/src/test/org/apache/commons/lang
StringUtilsTrimEmptyTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Add new methods stripToNull/stripToEmpty to provide alternative to trim versions
  
  Revision  ChangesPath
  1.13  +21 -1 
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTrimEmptyTest.java
  
  Index: StringUtilsTrimEmptyTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTrimEmptyTest.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- StringUtilsTrimEmptyTest.java 19 Jul 2003 21:55:05 -  1.12
  +++ StringUtilsTrimEmptyTest.java 20 Jul 2003 00:04:12 -  1.13
  @@ -199,6 +199,26 @@
   StringUtils.strip(StringUtilsTest.WHITESPACE + 
StringUtilsTest.NON_WHITESPACE + StringUtilsTest.WHITESPACE));
   }
   
  +public void testStripToNull_String() {
  +assertEquals(null, StringUtils.stripToNull(null));
  +assertEquals(null, StringUtils.stripToNull());
  +assertEquals(null, StringUtils.stripToNull());
  +assertEquals(null, StringUtils.stripToNull(StringUtilsTest.WHITESPACE));
  +assertEquals(ab c, StringUtils.stripToNull(  ab c  ));
  +assertEquals(StringUtilsTest.NON_WHITESPACE, 
  +StringUtils.stripToNull(StringUtilsTest.WHITESPACE + 
StringUtilsTest.NON_WHITESPACE + StringUtilsTest.WHITESPACE));
  +}
  +
  +public void testStripToEmpty_String() {
  +assertEquals(, StringUtils.stripToEmpty(null));
  +assertEquals(, StringUtils.stripToEmpty());
  +assertEquals(, StringUtils.stripToEmpty());
  +assertEquals(, StringUtils.stripToEmpty(StringUtilsTest.WHITESPACE));
  +assertEquals(ab c, StringUtils.stripToEmpty(  ab c  ));
  +assertEquals(StringUtilsTest.NON_WHITESPACE, 
  +StringUtils.stripToEmpty(StringUtilsTest.WHITESPACE + 
StringUtilsTest.NON_WHITESPACE + StringUtilsTest.WHITESPACE));
  +}
  +
   public void testStrip_StringString() {
   // null strip
   assertEquals(null, StringUtils.strip(null, null));
  
  
  
  1.68  +70 -9 
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.67
  retrieving revision 1.68
  diff -u -r1.67 -r1.68
  --- StringUtils.java  19 Jul 2003 23:29:06 -  1.67
  +++ StringUtils.java  20 Jul 2003 00:04:12 -  1.68
  @@ -179,7 +179,8 @@
* codenull/code./p
* 
* pThe String is trimmed using [EMAIL PROTECTED] String#trim()}.
  - * Trim removes start and end characters lt;= 32./p
  + * Trim removes start and end characters lt;= 32.
  + * To strip whitespace use [EMAIL PROTECTED] #strip(String)}./p
* 
* pTo trim your choice of characters, use the
* [EMAIL PROTECTED] #strip(String, String)} methods./p
  @@ -192,7 +193,6 @@
* StringUtils.trim()= 
* /pre
*
  - * @see java.lang.String#trim()
* @param str  the String to be trimmed, may be null
* @return the trimmed string, codenull/code if null String input
*/
  @@ -206,7 +206,8 @@
* empty () after the trim or if it is codenull/code.
* 
* pThe String is trimmed using [EMAIL PROTECTED] String#trim()}.
  - * Trim removes start and end characters lt;= 32./p
  + * Trim removes start and end characters lt;= 32.
  + * To strip whitespace use [EMAIL PROTECTED] #stripToNull(String)}./p
* 
* pre
* StringUtils.trimToNull(null)  = null
  @@ -216,7 +217,6 @@
* StringUtils.trimToNull()= null
* /pre
*  
  - * @see java.lang.String#trim()
* @param str  the String to be trimmed, may be null
* @return the trimmed String, 
*  codenull/code if only chars lt;= 32, empty or null String input
  @@ -232,7 +232,8 @@
* is empty () after the trim or if it is codenull/code.
* 
* pThe String is trimmed using [EMAIL PROTECTED] String#trim()}.
  - * Trim removes start and end characters lt;= 32./p
  + * Trim removes start and end characters lt;= 32.
  + * To strip whitespace use [EMAIL PROTECTED] #stripToEmpty(String)}./p
* 
* pre
* StringUtils.trimToEmpty(null)  = 
  @@ -242,7 +243,6 @@
* StringUtils.trimToEmpty()= 
* /pre
*  
  - * @see java.lang.String#trim()
* @param str  the String to be trimmed, may be null
* @return the 

RE: [lang] Proposal (2): isEmpty - commits

2003-07-19 Thread Gary Gregory
So, there are no isWhitespace methods, right?

Gray

-Original Message-
From: Stephen Colebourne [mailto:[EMAIL PROTECTED] 
Sent: Saturday, July 19, 2003 14:58
To: Jakarta Commons Developers List
Subject: Re: [lang] Proposal (2): isEmpty - commits

I have updated CVS HEAD as follows:

Removed:
isEmptyOrNull
isNotEmptyOrNull
isEmptyTrimmed
isNotEmptyTrimmed
isEmptyTrimmedOrNull
isNotEmptyTrimmedOrNull

Changed:
isEmpty - true for  or null
isNotEmpty - opposite (no change from 1.0)

Added:
isBlank - true for all whitespace,  or null
isNotBlank - opposite

I suggest that committers think if they want to -1 veto this change.

Stephen

- Original Message -
From: Henri Yandell [EMAIL PROTECTED]
To: Jakarta Commons Developers List [EMAIL PROTECTED]
Sent: Saturday, July 19, 2003 9:54 PM
Subject: Re: [lang] Proposal (2): isEmpty



 So what's our 2.0 state with regard to this? What needs to be changed?

 Do we want to release tight with the following removed from current HEAD:

 isEmptyOrNull
 isNotEmptyOrNull
 isEmptyTrimmed
 isNotEmptyTrimmed
 isEmptyTrimmedOrNull
 isNotEmptyTrimmedOrNull

 Hen

 On Sat, 19 Jul 2003, Stephen Colebourne wrote:

  From: Henri Yandell [EMAIL PROTECTED]
It isn't. My preference is now for
   
isEmpty() -  or null
isBlank() - whitespace only,  or null
  
   Could just tell people to do isWhitespace  isEmpty  ? :)
 
  I feel  isBlank() is more expressive than  isWhitespace(). It just feels
  more inclusive of null and empty.
 
  if (isNotBlank()) {
...process data
  }
  OR
  if (isNotWhitespace()) {
...process data
  }
 
  Then again isWhitespace follows our naming definitions.
 
  ---
isEmptyTrimmed() - trim() then  or null
  
   I'm not sure there's any need for this. I wonder how much of the chars
   less than 32 count as whitespace? But it seems that isWhitespace is
for
   most people's usage a superset of isEmptyTrimmed.
 
  Yeh, I'm happy to miss it out.
 
  ---
(plus isNotEmpty, isNotBlank, isEmptyNN, isBlankNN)
  
   Still hard to decide how far to go with all these. isEmptyNN is a
   single-atom method. isNotEmpty just replaces a ! sign etc etc.
 
  The Nots are very useful for these cases as they are so frequent.
 
  ---
   Does anyone actually want isEmptyNN, or is it just that people are
unhappy
   with the null-handling in StringUtils? In which case I think the NN is
the
   wrong solution, we need to be thinking about an ability to create a
   StringUtils with a strategy or having an underlying hidden class and 3
   facade's for the different strategies. All 3.0.
 
  +1. Leave out NN for now. Its a bit of a hack.
 
  Stephen
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 


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



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


RE: [lang] Proposal (2): isEmpty

2003-07-19 Thread Gary Gregory
I like the blank version as it is more expressive. 

Does this version isBlank trim? 

Gary

-Original Message-
From: Stephen Colebourne [mailto:[EMAIL PROTECTED] 
Sent: Saturday, July 19, 2003 13:13
To: Jakarta Commons Developers List
Subject: Re: [lang] Proposal (2): isEmpty

From: Henri Yandell [EMAIL PROTECTED]
  It isn't. My preference is now for
 
  isEmpty() -  or null
  isBlank() - whitespace only,  or null

 Could just tell people to do isWhitespace  isEmpty  ? :)

I feel  isBlank() is more expressive than  isWhitespace(). It just feels
more inclusive of null and empty.

if (isNotBlank()) {
  ...process data
}
OR
if (isNotWhitespace()) {
  ...process data
}

Then again isWhitespace follows our naming definitions.

---
  isEmptyTrimmed() - trim() then  or null

 I'm not sure there's any need for this. I wonder how much of the chars
 less than 32 count as whitespace? But it seems that isWhitespace is for
 most people's usage a superset of isEmptyTrimmed.

Yeh, I'm happy to miss it out.

---
  (plus isNotEmpty, isNotBlank, isEmptyNN, isBlankNN)

 Still hard to decide how far to go with all these. isEmptyNN is a
 single-atom method. isNotEmpty just replaces a ! sign etc etc.

The Nots are very useful for these cases as they are so frequent.

---
 Does anyone actually want isEmptyNN, or is it just that people are unhappy
 with the null-handling in StringUtils? In which case I think the NN is the
 wrong solution, we need to be thinking about an ability to create a
 StringUtils with a strategy or having an underlying hidden class and 3
 facade's for the different strategies. All 3.0.

+1. Leave out NN for now. Its a bit of a hack.

Stephen


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


cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-07-19 Thread scolebourne
scolebourne2003/07/19 17:17:30

  Modified:lang/src/test/org/apache/commons/lang
StringUtilsTrimEmptyTest.java StringUtilsTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Deprecate deleteSpaces()
  Move delete methods next to replace
  
  Revision  ChangesPath
  1.14  +1 -21 
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTrimEmptyTest.java
  
  Index: StringUtilsTrimEmptyTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTrimEmptyTest.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- StringUtilsTrimEmptyTest.java 20 Jul 2003 00:04:12 -  1.13
  +++ StringUtilsTrimEmptyTest.java 20 Jul 2003 00:17:29 -  1.14
  @@ -170,26 +170,6 @@
   assertEquals(true, StringUtils.isNotBlank(  foo  ));
   }
   
  -public void testDeleteSpace() {
  -assertEquals(null, StringUtils.deleteSpaces(null));
  -assertEquals(, StringUtils.deleteSpaces());
  -assertEquals(, StringUtils.deleteSpaces(\t\t\n\n   ));
  -assertEquals(test, StringUtils.deleteSpaces(t  \t\ne\rs\n\n   \tt));
  -}
  -
  -public void testDeleteWhitespace() {
  -assertEquals(null, StringUtils.deleteWhitespace(null));
  -assertEquals(, StringUtils.deleteWhitespace());
  -assertEquals(, StringUtils.deleteWhitespace(  \u000C  \t\t\u001F\n\n 
\u000B  ));
  -assertEquals(, StringUtils.deleteWhitespace(StringUtilsTest.WHITESPACE));
  -assertEquals(StringUtilsTest.NON_WHITESPACE, 
StringUtils.deleteWhitespace(StringUtilsTest.NON_WHITESPACE));
  -// Note: u-2007 and u-000A both cause problems in the source code
  -// it should ignore 2007 but delete 000A
  -assertEquals(\u00A0\u202F, StringUtils.deleteWhitespace(  \u00A0  
\t\t\n\n \u202F  ));
  -assertEquals(\u00A0\u202F, StringUtils.deleteWhitespace(\u00A0\u202F));
  -assertEquals(test, StringUtils.deleteWhitespace(\u000Bt  
\t\n\u0009e\rs\n\n   \tt));
  -}
  -
   public void testStrip_String() {
   assertEquals(null, StringUtils.strip(null));
   assertEquals(, StringUtils.strip());
  
  
  
  1.31  +73 -21
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java
  
  Index: StringUtilsTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- StringUtilsTest.java  19 Jul 2003 23:28:23 -  1.30
  +++ StringUtilsTest.java  20 Jul 2003 00:17:29 -  1.31
  @@ -341,26 +341,78 @@
   }
   }
   
  -public void testReplaceFunctions() {
  -assertEquals(replace(String, String, String, int) failed,
  - FOO, StringUtils.replace(oo + FOO, o, , 2));
  -assertEquals(replace(String, String, String) failed,
  - , StringUtils.replace(FOO + FOO + FOO, FOO, ));
  -assertEquals(replaceOnce(String, String, String) failed,
  - FOO, StringUtils.replaceOnce(FOO + FOO, FOO, ));
  -assertEquals(carriage-return replace(String,String,String) failed,
  - test123, StringUtils.replace(test\r1\r2\r3, \r, ));
  -
  -assertEquals(replace(String, String, String) failed,
  -FOO, StringUtils.replace(FOO, , any));
  -assertEquals(replace(String, String, String) failed,
  -FOO, StringUtils.replace(FOO, null, any));
  -assertEquals(replace(String, String, String) failed,
  -FOO, StringUtils.replace(FOO, F, null));
  -assertEquals(replace(String, String, String) failed,
  -FOO, StringUtils.replace(FOO, null, null));
  -assertEquals(replace(String, String, String) failed,
  -null, StringUtils.replace(null, , any));
  +public void testDeleteSpace_String() {
  +assertEquals(null, StringUtils.deleteSpaces(null));
  +assertEquals(, StringUtils.deleteSpaces());
  +assertEquals(, StringUtils.deleteSpaces(\t\t\n\n   ));
  +assertEquals(test, StringUtils.deleteSpaces(t  \t\ne\rs\n\n   \tt));
  +}
  +
  +public void testDeleteWhitespace_String() {
  +assertEquals(null, StringUtils.deleteWhitespace(null));
  +assertEquals(, StringUtils.deleteWhitespace());
  +assertEquals(, StringUtils.deleteWhitespace(  \u000C  \t\t\u001F\n\n 
\u000B  ));
  +assertEquals(, StringUtils.deleteWhitespace(StringUtilsTest.WHITESPACE));
  +assertEquals(StringUtilsTest.NON_WHITESPACE, 
StringUtils.deleteWhitespace(StringUtilsTest.NON_WHITESPACE));
  +// Note: u-2007 and u-000A 

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-07-19 Thread scolebourne
scolebourne2003/07/19 17:37:09

  Modified:lang/src/test/org/apache/commons/lang
StringUtilsTrimEmptyTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Group all the trim/strip methods together in source file
  
  Revision  ChangesPath
  1.15  +34 -33
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTrimEmptyTest.java
  
  Index: StringUtilsTrimEmptyTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTrimEmptyTest.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- StringUtilsTrimEmptyTest.java 20 Jul 2003 00:17:29 -  1.14
  +++ StringUtilsTrimEmptyTest.java 20 Jul 2003 00:37:09 -  1.15
  @@ -91,7 +91,39 @@
   }
   
   //---
  +public void testIsEmpty() {
  +assertEquals(true, StringUtils.isEmpty(null));
  +assertEquals(true, StringUtils.isEmpty());
  +assertEquals(false, StringUtils.isEmpty( ));
  +assertEquals(false, StringUtils.isEmpty(foo));
  +assertEquals(false, StringUtils.isEmpty(  foo  ));
  +}
  +
  +public void testIsNotEmpty() {
  +assertEquals(false, StringUtils.isNotEmpty(null));
  +assertEquals(false, StringUtils.isNotEmpty());
  +assertEquals(true, StringUtils.isNotEmpty( ));
  +assertEquals(true, StringUtils.isNotEmpty(foo));
  +assertEquals(true, StringUtils.isNotEmpty(  foo  ));
  +}
  +
  +public void testIsBlank() {
  +assertEquals(true, StringUtils.isBlank(null));
  +assertEquals(true, StringUtils.isBlank());
  +assertEquals(true, StringUtils.isBlank(StringUtilsTest.WHITESPACE));
  +assertEquals(false, StringUtils.isBlank(foo));
  +assertEquals(false, StringUtils.isBlank(  foo  ));
  +}
  +
  +public void testIsNotBlank() {
  +assertEquals(false, StringUtils.isNotBlank(null));
  +assertEquals(false, StringUtils.isNotBlank());
  +assertEquals(false, StringUtils.isNotBlank(StringUtilsTest.WHITESPACE));
  +assertEquals(true, StringUtils.isNotBlank(foo));
  +assertEquals(true, StringUtils.isNotBlank(  foo  ));
  +}
   
  +//---
   public void testClean() {
   assertEquals(FOO, StringUtils.clean(FOO +   ));
   assertEquals(FOO, StringUtils.clean(  + FOO +   ));
  @@ -138,38 +170,7 @@
   assertEquals(, StringUtils.trimToEmpty(null));
   }
   
  -public void testIsEmpty() {
  -assertEquals(true, StringUtils.isEmpty(null));
  -assertEquals(true, StringUtils.isEmpty());
  -assertEquals(false, StringUtils.isEmpty( ));
  -assertEquals(false, StringUtils.isEmpty(foo));
  -assertEquals(false, StringUtils.isEmpty(  foo  ));
  -}
  -
  -public void testIsNotEmpty() {
  -assertEquals(false, StringUtils.isNotEmpty(null));
  -assertEquals(false, StringUtils.isNotEmpty());
  -assertEquals(true, StringUtils.isNotEmpty( ));
  -assertEquals(true, StringUtils.isNotEmpty(foo));
  -assertEquals(true, StringUtils.isNotEmpty(  foo  ));
  -}
  -
  -public void testIsBlank() {
  -assertEquals(true, StringUtils.isBlank(null));
  -assertEquals(true, StringUtils.isBlank());
  -assertEquals(true, StringUtils.isBlank(StringUtilsTest.WHITESPACE));
  -assertEquals(false, StringUtils.isBlank(foo));
  -assertEquals(false, StringUtils.isBlank(  foo  ));
  -}
  -
  -public void testIsNotBlank() {
  -assertEquals(false, StringUtils.isNotBlank(null));
  -assertEquals(false, StringUtils.isNotBlank());
  -assertEquals(false, StringUtils.isNotBlank(StringUtilsTest.WHITESPACE));
  -assertEquals(true, StringUtils.isNotBlank(foo));
  -assertEquals(true, StringUtils.isNotBlank(  foo  ));
  -}
  -
  +//---
   public void testStrip_String() {
   assertEquals(null, StringUtils.strip(null));
   assertEquals(, StringUtils.strip());
  
  
  
  1.70  +321 -318  
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.69
  retrieving revision 1.70
  diff -u -r1.69 -r1.70
  --- StringUtils.java  20 Jul 2003 00:17:29 -  1.69
  +++ StringUtils.java  20 Jul 2003 00:37:09 -  1.70
  @@ -147,7 +147,106 @@
   public StringUtils() {
   }
   
  -// Empty
  +// Empty 

RE: [lang] Proposal (2): isEmpty

2003-07-19 Thread Henri Yandell

Ack. It would help if isWhitespace existed. I thought it did as a part of
our isAlpha etc methods. I need to check my assumptions more.

I still think isWhitespace is a bit better as it matches the
naming/functionality of Character.isWhitespace (as char's cannot be null)
and the StringUtils general functionality of trying to do the
obvious/quietest thing on null, but it's not that important.

Hen

On Sat, 19 Jul 2003, Gary Gregory wrote:

 I like the blank version as it is more expressive.

 Does this version isBlank trim?

 Gary

 -Original Message-
 From: Stephen Colebourne [mailto:[EMAIL PROTECTED]
 Sent: Saturday, July 19, 2003 13:13
 To: Jakarta Commons Developers List
 Subject: Re: [lang] Proposal (2): isEmpty

 From: Henri Yandell [EMAIL PROTECTED]
   It isn't. My preference is now for
  
   isEmpty() -  or null
   isBlank() - whitespace only,  or null
 
  Could just tell people to do isWhitespace  isEmpty  ? :)

 I feel  isBlank() is more expressive than  isWhitespace(). It just feels
 more inclusive of null and empty.

 if (isNotBlank()) {
   ...process data
 }
 OR
 if (isNotWhitespace()) {
   ...process data
 }

 Then again isWhitespace follows our naming definitions.

 ---
   isEmptyTrimmed() - trim() then  or null
 
  I'm not sure there's any need for this. I wonder how much of the chars
  less than 32 count as whitespace? But it seems that isWhitespace is for
  most people's usage a superset of isEmptyTrimmed.

 Yeh, I'm happy to miss it out.

 ---
   (plus isNotEmpty, isNotBlank, isEmptyNN, isBlankNN)
 
  Still hard to decide how far to go with all these. isEmptyNN is a
  single-atom method. isNotEmpty just replaces a ! sign etc etc.

 The Nots are very useful for these cases as they are so frequent.

 ---
  Does anyone actually want isEmptyNN, or is it just that people are unhappy
  with the null-handling in StringUtils? In which case I think the NN is the
  wrong solution, we need to be thinking about an ability to create a
  StringUtils with a strategy or having an underlying hidden class and 3
  facade's for the different strategies. All 3.0.

 +1. Leave out NN for now. Its a bit of a hack.

 Stephen


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



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



Re: [lang] NumberUtils null handling

2003-07-19 Thread Henri Yandell


On Sat, 19 Jul 2003, Phil Steitz wrote:

 I have been going through NumberUtils code and tests to make sure that
 handling of nulls is documented (and tested) correctly. I notice that
 createNumber returns null for null (need to add a javadoc comment for
 this); whereas createFloat, et al will throw NPEs on null.  Shouldn't
 these behave the same?  In any case, the behavior should be documented.

 Should I submit a patch to

 1. Make createFloat et al return null for null as createNumber does

+1 to the sub-package as Stephen said.

 2. Make no changes to NumberUtils methods, just add javadoc and tests
 documenting current behavior.

 3. Go back to sleep...;-)


 Phil



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



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



Re: [lang] Proposal (2): isEmpty

2003-07-19 Thread Stephen Colebourne
isWhitespace() still exists, but returns false for null. This is compliant
with the other character test methods such as isAlpha().

Empty checks:
 isEmpty() -  or null
 isBlank() - whitespace only,  or null

Character checks:
 isWhitespace() - whitespace or 
 isAlpha() - alpha or 
etc.

Thus, using isBlank avoids changing the functionality of the 1.0
isWhitespace.

Stephen

- Original Message -
From: Henri Yandell [EMAIL PROTECTED]
To: Jakarta Commons Developers List [EMAIL PROTECTED]
Sent: Sunday, July 20, 2003 1:37 AM
Subject: RE: [lang] Proposal (2): isEmpty



 Ack. It would help if isWhitespace existed. I thought it did as a part of
 our isAlpha etc methods. I need to check my assumptions more.

 I still think isWhitespace is a bit better as it matches the
 naming/functionality of Character.isWhitespace (as char's cannot be null)
 and the StringUtils general functionality of trying to do the
 obvious/quietest thing on null, but it's not that important.

 Hen

 On Sat, 19 Jul 2003, Gary Gregory wrote:

  I like the blank version as it is more expressive.
 
  Does this version isBlank trim?
 
  Gary
 
  -Original Message-
  From: Stephen Colebourne [mailto:[EMAIL PROTECTED]
  Sent: Saturday, July 19, 2003 13:13
  To: Jakarta Commons Developers List
  Subject: Re: [lang] Proposal (2): isEmpty
 
  From: Henri Yandell [EMAIL PROTECTED]
It isn't. My preference is now for
   
isEmpty() -  or null
isBlank() - whitespace only,  or null
  
   Could just tell people to do isWhitespace  isEmpty  ? :)
 
  I feel  isBlank() is more expressive than  isWhitespace(). It just feels
  more inclusive of null and empty.
 
  if (isNotBlank()) {
...process data
  }
  OR
  if (isNotWhitespace()) {
...process data
  }
 
  Then again isWhitespace follows our naming definitions.
 
  ---
isEmptyTrimmed() - trim() then  or null
  
   I'm not sure there's any need for this. I wonder how much of the chars
   less than 32 count as whitespace? But it seems that isWhitespace is
for
   most people's usage a superset of isEmptyTrimmed.
 
  Yeh, I'm happy to miss it out.
 
  ---
(plus isNotEmpty, isNotBlank, isEmptyNN, isBlankNN)
  
   Still hard to decide how far to go with all these. isEmptyNN is a
   single-atom method. isNotEmpty just replaces a ! sign etc etc.
 
  The Nots are very useful for these cases as they are so frequent.
 
  ---
   Does anyone actually want isEmptyNN, or is it just that people are
unhappy
   with the null-handling in StringUtils? In which case I think the NN is
the
   wrong solution, we need to be thinking about an ability to create a
   StringUtils with a strategy or having an underlying hidden class and 3
   facade's for the different strategies. All 3.0.
 
  +1. Leave out NN for now. Its a bit of a hack.
 
  Stephen
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 


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



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



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang/builder EqualsBuilder.java

2003-07-19 Thread ggregory
ggregory2003/07/19 18:11:06

  Modified:lang/src/java/org/apache/commons/lang/builder
EqualsBuilder.java
  Log:
  Severity  Description ResourceIn Folder   Location
Creation Time
The static method setAccessible(AccessibleObject[], boolean) from the type 
AccessibleObject should be accessed directly EqualsBuilder.java  Apache 
Jakarta Commons/lang/src/java/org/apache/commons/lang/builderline 268July 
19, 2003 6:10:35 PM
  
  Revision  ChangesPath
  1.15  +7 -6  
jakarta-commons/lang/src/java/org/apache/commons/lang/builder/EqualsBuilder.java
  
  Index: EqualsBuilder.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/builder/EqualsBuilder.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- EqualsBuilder.java14 Jul 2003 22:25:03 -  1.14
  +++ EqualsBuilder.java20 Jul 2003 01:11:05 -  1.15
  @@ -53,6 +53,7 @@
*/
   package org.apache.commons.lang.builder;
   
  +import java.lang.reflect.AccessibleObject;
   import java.lang.reflect.Field;
   import java.lang.reflect.Modifier;
   /**
  @@ -92,7 +93,7 @@
*
* p Alternatively, there is a method that uses reflection to determine
* the fields to test. Because these fields are usually private, the method,
  - * codereflectionEquals/code, uses codeField.setAccessible/code to
  + * codereflectionEquals/code, uses codeAccessibleObject.setAccessible/code 
to
* change the visibility of the fields. This will fail under a security
* manager, unless the appropriate permissions are set up correctly. It is
* also slower than testing explicitly./p
  @@ -133,7 +134,7 @@
* pThis method uses reflection to determine if the two codeObject/codes
* are equal./p
*
  - * pIt uses codeField.setAccessible/code to gain access to private
  + * pIt uses codeAccessibleObject.setAccessible/code to gain access to 
private
* fields. This means that it will throw a security exception if run under
* a security manger, if the permissions are not set up correctly. It is also
* not as efficient as testing explicitly./p
  @@ -155,7 +156,7 @@
* pThis method uses reflection to determine if the two codeObject/codes
* are equal./p
*
  - * pIt uses codeField.setAccessible/code to gain access to private
  + * pIt uses codeAccessibleObject.setAccessible/code to gain access to 
private
* fields. This means that it will throw a security exception if run under
* a security manger, if the permissions are not set up correctly. It is also
* not as efficient as testing explicitly./p
  @@ -179,7 +180,7 @@
* pThis method uses reflection to determine if the two codeObject/codes
* are equal./p
*
  - * pIt uses codeField.setAccessible/code to gain access to private
  + * pIt uses codeAccessibleObject.setAccessible/code to gain access to 
private
* fields. This means that it will throw a security exception if run under
* a security manger, if the permissions are not set up correctly. It is also
* not as efficient as testing explicitly./p
  @@ -264,7 +265,7 @@
   EqualsBuilder builder,
   boolean useTransients) {
   Field[] fields = clazz.getDeclaredFields();
  -Field.setAccessible(fields, true);
  +AccessibleObject.setAccessible(fields, true);
   for (int i = 0; i  fields.length  builder.isEquals; i++) {
   Field f = fields[i];
   if ((f.getName().indexOf('$') == -1)
  
  
  

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



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang/builder HashCodeBuilder.java

2003-07-19 Thread ggregory
ggregory2003/07/19 18:12:32

  Modified:lang/src/java/org/apache/commons/lang/builder
HashCodeBuilder.java
  Log:
  Severity  Description ResourceIn Folder   Location
Creation Time
The static method setAccessible(AccessibleObject[], boolean) from the type 
AccessibleObject should be accessed directly HashCodeBuilder.javaApache 
Jakarta Commons/lang/src/java/org/apache/commons/lang/builderline 341July 
18, 2003 8:21:31 PM
  
  Revision  ChangesPath
  1.14  +9 -8  
jakarta-commons/lang/src/java/org/apache/commons/lang/builder/HashCodeBuilder.java
  
  Index: HashCodeBuilder.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/builder/HashCodeBuilder.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- HashCodeBuilder.java  14 Jul 2003 22:25:03 -  1.13
  +++ HashCodeBuilder.java  20 Jul 2003 01:12:32 -  1.14
  @@ -53,6 +53,7 @@
*/
   package org.apache.commons.lang.builder;
   
  +import java.lang.reflect.AccessibleObject;
   import java.lang.reflect.Field;
   import java.lang.reflect.Modifier;
   /**
  @@ -93,7 +94,7 @@
*
* pAlternatively, there is a method that uses reflection to determine
* the fields to test. Because these fields are usually private, the method,
  - * codereflectionHashCode/code, uses codeField.setAccessible/code to
  + * codereflectionHashCode/code, uses 
codeAccessibleObject.setAccessible/code to
* change the visibility of the fields. This will fail under a security manager,
* unless the appropriate permissions are set up correctly. It is also slower
* than testing explicitly./p
  @@ -172,7 +173,7 @@
* pThis constructor uses two hard coded choices for the constants
* needed to build a hash code./p
*
  - * pIt uses codeField.setAccessible/code to gain access to private
  + * pIt uses codeAccessibleObject.setAccessible/code to gain access to 
private
* fields. This means that it will throw a security exception if run under
* a security manger, if the permissions are not set up correctly. It is
* also not as efficient as testing explicitly./p
  @@ -196,7 +197,7 @@
* pThis constructor uses two hard coded choices for the constants needed
* to build a hash code./p
*
  - * p It uses codeField.setAccessible/code to gain access to private
  + * p It uses codeAccessibleObject.setAccessible/code to gain access to 
private
* fields. This means that it will throw a security exception if run under
* a security manger, if the permissions are not set up correctly. It is
* also not as efficient as testing explicitly./p
  @@ -219,7 +220,7 @@
   /**
* pThis method uses reflection to build a valid hash code./p
*
  - * pIt uses codeField.setAccessible/code to gain access to private
  + * pIt uses codeAccessibleObject.setAccessible/code to gain access to 
private
* fields. This means that it will throw a security exception if run under
* a security manger, if the permissions are not set up correctly. It is
* also not as efficient as testing explicitly./p
  @@ -248,7 +249,7 @@
   /**
* pThis method uses reflection to build a valid hash code./p
*
  - * pIt uses codeField.setAccessible/code to gain access to private
  + * pIt uses codeAccessibleObject.setAccessible/code to gain access to 
private
* fields. This means that it will throw a security exception if run under
* a security manger, if the permissions are not set up correctly. It is also
* not as efficient as testing explicitly./p
  @@ -280,7 +281,7 @@
   /**
* pThis method uses reflection to build a valid hash code./p
*
  - * pIt uses codeField.setAccessible/code to gain access to private
  + * pIt uses codeAccessibleObject.setAccessible/code to gain access to 
private
* fields. This means that it will throw a security exception if run under
* a security manger, if the permissions are not set up correctly. It is also
* not as efficient as testing explicitly./p
  @@ -338,7 +339,7 @@
*/
   private static void reflectionAppend(Object object, Class clazz, 
HashCodeBuilder builder, boolean useTransients) {
   Field[] fields = clazz.getDeclaredFields();
  -Field.setAccessible(fields, true);
  +AccessibleObject.setAccessible(fields, true);
   for (int i = 0; i  fields.length; i++) {
   Field f = fields[i];
   if ((f.getName().indexOf('$') == -1)
  
  
  

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



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang/builder ReflectionToStringBuilder.java

2003-07-19 Thread ggregory
ggregory2003/07/19 18:13:14

  Modified:lang/src/java/org/apache/commons/lang/builder
ReflectionToStringBuilder.java
  Log:
  Severity  Description ResourceIn Folder   Location
Creation Time
The static method setAccessible(AccessibleObject[], boolean) from the type 
AccessibleObject should be accessed directly ReflectionToStringBuilder.java  
Apache Jakarta Commons/lang/src/java/org/apache/commons/lang/builderline 346   
 July 18, 2003 8:21:31 PM
  
  Revision  ChangesPath
  1.6   +8 -7  
jakarta-commons/lang/src/java/org/apache/commons/lang/builder/ReflectionToStringBuilder.java
  
  Index: ReflectionToStringBuilder.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/builder/ReflectionToStringBuilder.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ReflectionToStringBuilder.java15 Jul 2003 23:12:51 -  1.5
  +++ ReflectionToStringBuilder.java20 Jul 2003 01:13:14 -  1.6
  @@ -1,5 +1,6 @@
   package org.apache.commons.lang.builder;
   
  +import java.lang.reflect.AccessibleObject;
   import java.lang.reflect.Field;
   import java.lang.reflect.Modifier;
   import java.util.HashSet;
  @@ -12,7 +13,7 @@
*
* pThis class uses reflection to determine the fields to append. 
* Because these fields are usually private, the class 
  - * uses codeField.setAccessible/code to
  + * uses codeAccessibleObject.setAccessible/code to
* change the visibility of the fields. This will fail under a security manager,
* unless the appropriate permissions are set up correctly./p
*
  @@ -100,7 +101,7 @@
* pThis method uses reflection to build a suitable
* codetoString/code using the default codeToStringStyle/code.
*
  - * pIt uses codeField.setAccessible/code to gain access to private
  + * pIt uses codeAccessibleObject.setAccessible/code to gain access to 
private
* fields. This means that it will throw a security exception if run
* under a security manger, if the permissions are not set up correctly.
* It is also not as efficient as testing explicitly./p
  @@ -120,7 +121,7 @@
* pThis method uses reflection to build a suitable
* codetoString/code./p
*
  - * pIt uses codeField.setAccessible/code to gain access to private
  + * pIt uses codeAccessibleObject.setAccessible/code to gain access to 
private
* fields. This means that it will throw a security exception if run
* under a security manger, if the permissions are not set up correctly.
* It is also not as efficient as testing explicitly./p
  @@ -146,7 +147,7 @@
* pThis method uses reflection to build a suitable
* codetoString/code./p
*
  - * pIt uses codeField.setAccessible/code to gain access to private
  + * pIt uses codeAccessibleObject.setAccessible/code to gain access to 
private
* fields. This means that it will throw a security exception if run
* under a security manger, if the permissions are not set up correctly.
* It is also not as efficient as testing explicitly. /p
  @@ -176,7 +177,7 @@
* pThis method uses reflection to build a suitable
* codetoString/code./p
*
  - * pIt uses codeField.setAccessible/code to gain access to private
  + * pIt uses codeAccessibleObject.setAccessible/code to gain access to 
private
* fields. This means that it will throw a security exception if run
* under a security manger, if the permissions are not set up correctly.
* It is also not as efficient as testing explicitly. /p
  @@ -343,7 +344,7 @@
   return;
   }
   Field[] fields = clazz.getDeclaredFields();
  -Field.setAccessible(fields, true);
  +AccessibleObject.setAccessible(fields, true);
   for (int i = 0; i  fields.length; i++) {
   Field field = fields[i];
   String fieldName = field.getName();
  
  
  

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



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang/reflect MethodUtils.java

2003-07-19 Thread ggregory
ggregory2003/07/19 18:13:54

  Modified:lang/src/java/org/apache/commons/lang/reflect
MethodUtils.java
  Log:
  Severity  Description ResourceIn Folder   Location
Creation Time
Superfluous semicolon   MethodUtils.javaApache Jakarta 
Commons/lang/src/java/org/apache/commons/lang/reflectline 491July 18, 2003 
8:21:29 PM
  
  Revision  ChangesPath
  1.13  +2 -2  
jakarta-commons/lang/src/java/org/apache/commons/lang/reflect/MethodUtils.java
  
  Index: MethodUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/reflect/MethodUtils.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- MethodUtils.java  14 Jul 2003 22:29:04 -  1.12
  +++ MethodUtils.java  20 Jul 2003 01:13:54 -  1.13
  @@ -488,7 +488,7 @@
   method = interfaces[i].getDeclaredMethod(methodName,
   parameterTypes);
   } catch (NoSuchMethodException e) {
  -;
  +// empty
   }
   if (method != null)
   break;
  
  
  

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



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang/time FastDateFormat.java

2003-07-19 Thread ggregory
ggregory2003/07/19 18:21:29

  Modified:lang/src/java/org/apache/commons/lang/time
FastDateFormat.java
  Log:
  Severity  Description ResourceIn Folder   Location
Creation Time
The static field DateFormat.FULL should be accessed directly
FastDateFormat.java Apache Jakarta 
Commons/lang/src/java/org/apache/commons/lang/time   line 112July 19, 2003 
5:17:12 PM
The static field DateFormat.LONG should be accessed directly
FastDateFormat.java Apache Jakarta 
Commons/lang/src/java/org/apache/commons/lang/time   line 116July 19, 2003 
5:17:12 PM
The static field DateFormat.MEDIUM should be accessed directly  
FastDateFormat.java Apache Jakarta 
Commons/lang/src/java/org/apache/commons/lang/time   line 120July 19, 2003 
5:17:12 PM
The static field DateFormat.SHORT should be accessed directly   
FastDateFormat.java Apache Jakarta 
Commons/lang/src/java/org/apache/commons/lang/time   line 124July 19, 2003 
5:17:12 PM
  
  Revision  ChangesPath
  1.10  +5 -5  
jakarta-commons/lang/src/java/org/apache/commons/lang/time/FastDateFormat.java
  
  Index: FastDateFormat.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/time/FastDateFormat.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- FastDateFormat.java   19 Jul 2003 19:54:24 -  1.9
  +++ FastDateFormat.java   20 Jul 2003 01:21:29 -  1.10
  @@ -109,19 +109,19 @@
   /**
* FULL locale dependent date or time style.
*/
  -public static final int FULL = SimpleDateFormat.FULL;
  +public static final int FULL = DateFormat.FULL;
   /**
* LONG locale dependent date or time style
*/
  -public static final int LONG = SimpleDateFormat.LONG;
  +public static final int LONG = DateFormat.LONG;
   /**
* MEDIUM locale dependent date or time style
*/
  -public static final int MEDIUM = SimpleDateFormat.MEDIUM;
  +public static final int MEDIUM = DateFormat.MEDIUM;
   /**
* SHORT locale dependent date or time style
*/
  -public static final int SHORT = SimpleDateFormat.SHORT;
  +public static final int SHORT = DateFormat.SHORT;
   
   // package scoped as used by inner class
   static final double LOG_10 = Math.log(10);
  
  
  

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



cvs commit: jakarta-commons/codec/src/java/org/apache/commons/codec/language DoubleMetaphone.java

2003-07-19 Thread ggregory
ggregory2003/07/19 18:30:31

  Modified:codec/src/java/org/apache/commons/codec/language
DoubleMetaphone.java
  Log:
  The local variable result is never read   DoubleMetaphone.javaApache Jakarta 
Commons/codec/src/java/org/apache/commons/codec/language line 253July 18, 2003 
8:21:41 PM
  
  Revision  ChangesPath
  1.4   +0 -1  
jakarta-commons/codec/src/java/org/apache/commons/codec/language/DoubleMetaphone.java
  
  Index: DoubleMetaphone.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/codec/src/java/org/apache/commons/codec/language/DoubleMetaphone.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DoubleMetaphone.java  18 Jun 2003 18:43:56 -  1.3
  +++ DoubleMetaphone.java  20 Jul 2003 01:30:30 -  1.4
  @@ -250,7 +250,6 @@
* @return An encoded Object (will be of type String)
*/
   public Object encode(Object obj) throws EncoderException {
  -Object result;
   
   if (!(obj instanceof String)) {
   throw new EncoderException(Parameter supplied to Metaphone  
  
  
  

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



DO NOT REPLY [Bug 21734] New: - [lang] Make NumberUtils null handling consistent

2003-07-19 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21734.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21734

[lang] Make NumberUtils null handling consistent

   Summary: [lang] Make NumberUtils null handling consistent
   Product: Commons
   Version: Nightly Builds
  Platform: Other
OS/Version: Other
Status: NEW
  Severity: Enhancement
  Priority: Other
 Component: Lang
AssignedTo: [EMAIL PROTECTED]
ReportedBy: [EMAIL PROTECTED]


The attached patch makes all NumberUtils.createXXX(String) methods return null
for null input strings and adds javadoc comments to document this behavior.

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



DO NOT REPLY [Bug 21734] - [lang] Make NumberUtils null handling consistent

2003-07-19 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21734.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21734

[lang] Make NumberUtils null handling consistent





--- Additional Comments From [EMAIL PROTECTED]  2003-07-20 02:11 ---
Created an attachment (id=7402)
Patch to o.a.c.l.math.NumberUtils

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



[modeler] cleanup imports

2003-07-19 Thread Davanum Srinivas
Can someone please apply this patch to fix imports in modeler? See attached diff.txt

Thanks,
dims

=
Davanum Srinivas - http://webservices.apache.org/~dims/

__
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.comIndex: src/java/org/apache/commons/modeler/AttributeInfo.java
===
RCS file: 
/home/cvs/jakarta-commons/modeler/src/java/org/apache/commons/modeler/AttributeInfo.java,v
retrieving revision 1.6
diff -d -u -b -B -w -u -r1.6 AttributeInfo.java
--- src/java/org/apache/commons/modeler/AttributeInfo.java  17 Feb 2003 00:52:45 
-  1.6
+++ src/java/org/apache/commons/modeler/AttributeInfo.java  20 Jul 2003 02:06:37 
-
@@ -67,8 +67,8 @@
 
 import javax.management.Descriptor;
 import javax.management.modelmbean.ModelMBeanAttributeInfo;
-import java.lang.reflect.Method;
 import java.io.Serializable;
+import java.lang.reflect.Method;
 
 
 /**
Index: src/java/org/apache/commons/modeler/BaseAttributeFilter.java
===
RCS file: 
/home/cvs/jakarta-commons/modeler/src/java/org/apache/commons/modeler/BaseAttributeFilter.java,v
retrieving revision 1.2
diff -d -u -b -B -w -u -r1.2 BaseAttributeFilter.java
--- src/java/org/apache/commons/modeler/BaseAttributeFilter.java15 Jun 2002 
18:17:02 -  1.2
+++ src/java/org/apache/commons/modeler/BaseAttributeFilter.java20 Jul 2003 
02:06:37 -
@@ -65,10 +65,10 @@
 package org.apache.commons.modeler;
 
 
-import java.util.HashSet;
 import javax.management.AttributeChangeNotification;
 import javax.management.Notification;
 import javax.management.NotificationFilter;
+import java.util.HashSet;
 
 
 /**
Index: src/java/org/apache/commons/modeler/BaseModelMBean.java
===
RCS file: 
/home/cvs/jakarta-commons/modeler/src/java/org/apache/commons/modeler/BaseModelMBean.java,v
retrieving revision 1.22
diff -d -u -b -B -w -u -r1.22 BaseModelMBean.java
--- src/java/org/apache/commons/modeler/BaseModelMBean.java 17 Apr 2003 04:31:36 
-  1.22
+++ src/java/org/apache/commons/modeler/BaseModelMBean.java 20 Jul 2003 02:06:39 
-
@@ -69,12 +69,28 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.commons.modeler.modules.ModelerSource;
 
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Iterator;
-import java.util.Hashtable;
-import java.util.HashMap;
-
+import javax.management.Attribute;
+import javax.management.AttributeChangeNotification;
+import javax.management.AttributeList;
+import javax.management.AttributeNotFoundException;
+import javax.management.Descriptor;
+import javax.management.DynamicMBean;
+import javax.management.InstanceNotFoundException;
+import javax.management.InvalidAttributeValueException;
+import javax.management.ListenerNotFoundException;
+import javax.management.MBeanException;
+import javax.management.MBeanInfo;
+import javax.management.MBeanNotificationInfo;
+import javax.management.MBeanRegistration;
+import javax.management.MBeanServer;
+import javax.management.Notification;
+import javax.management.NotificationFilter;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
+import javax.management.RuntimeErrorException;
+import javax.management.RuntimeOperationsException;
+import javax.management.ServiceNotFoundException;
 import javax.management.modelmbean.DescriptorSupport;
 import javax.management.modelmbean.InvalidTargetObjectTypeException;
 import javax.management.modelmbean.ModelMBean;
@@ -83,8 +99,11 @@
 import javax.management.modelmbean.ModelMBeanInfoSupport;
 import javax.management.modelmbean.ModelMBeanNotificationInfo;
 import javax.management.modelmbean.ModelMBeanOperationInfo;
-import javax.management.*;
-import javax.management.DynamicMBean;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
 
 // TODO: enable ant-like substitutions ? ( or at least discuss it )
 
Index: src/java/org/apache/commons/modeler/BaseNotificationBroadcaster.java
===
RCS file: 
/home/cvs/jakarta-commons/modeler/src/java/org/apache/commons/modeler/BaseNotificationBroadcaster.java,v
retrieving revision 1.4
diff -d -u -b -B -w -u -r1.4 BaseNotificationBroadcaster.java
--- src/java/org/apache/commons/modeler/BaseNotificationBroadcaster.java14 Apr 
2003 02:08:16 -  1.4
+++ src/java/org/apache/commons/modeler/BaseNotificationBroadcaster.java20 Jul 
2003 02:06:39 -
@@ -65,14 +65,14 @@
 package org.apache.commons.modeler;
 
 
-import java.util.ArrayList;
-import java.util.Iterator;
 import 

DO NOT REPLY [Bug 21734] - [lang] Make NumberUtils null handling consistent

2003-07-19 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21734.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21734

[lang] Make NumberUtils null handling consistent





--- Additional Comments From [EMAIL PROTECTED]  2003-07-20 02:12 ---
Created an attachment (id=7403)
Path to o.a.c.l.NumberUtilsTest

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



RE: [lang] StringUtils isEmpty summary(2)

2003-07-19 Thread maillist
 d) The isXxxOrNull() naming is disliked as too long even 
 though its clear.

I don't agree with this.  I'm very much in favor of precise,
intention-revealing names.  IMHO, isEmpty is unambiguous and should
only mean that there's no content in the referenced String (that is,
string.length() == 0).  Empty means that there's some container that
_could_ hold something, but null means that there's no container there
at all (in a sense, string.length() == N/A).  So, isEmptyOrNull() seems
very straightforward and would remove all doubt that it's checking for
null.

 e) Similarly isEmptyTrimmed() naming is too long.

I don't mind the length, but then I'm not sure here if it's checking for
nulls.

 f) More people want isEmpty() to be true for null than false.

I can't disagree with that.  While I for sure don't want isEmpty() to
return true for a null (it's not empty, there's no 'it' there to
check!), I'm not sure I like isEmpty() returning false for a null
either, so a NPE would be appropriate.

I would say that my most common usage is a replacement for:

if ( ( string == null ) || ( string.length() == 0 ) )

So I'd be using isEmptyOrNull( string ).

However, there certainly are times that I don't want a null to silently
return false (such as when there's a contract with the rest of the code
that nulls should not exist for this variable) and I'd use isEmpty(
string ) in that case, fully expecting that if string == null, then a
NPE would be thrown and I'd have the underlying bug fixed.

;ted


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



RE: [lang] Proposal (2): isEmpty

2003-07-19 Thread Jitterpig Default
sigh

 Any views on NN for 'not null' ?

What's the problem with spelling this stuff out?  -1 on using NN instead
of NotNull.  Are we really concerned with saving space (a whole 4
characters) or reducing typing over making code more readable?  Keep in
mind that more and more people are using IDEs that automatically display
the available methods on an object once you hit the ., e.g.:

  if ( StringUtils.

as soon as I type this, all of the methods are displayed...if I see:

isBlank
isBlankNN
isEmpty
isEmptyNN

then I will have to go to the JavaDoc to see what NN is.

if I instead see:

isBlank
isBlankNotNull
isEmpty
isEmptyNotNull

then not only do I know what isEmptyNotNull does, it also solidifies the
meaning of isEmpty.

;ted

 
 Stephen
 
 - Original Message -
 From: Henri Yandell [EMAIL PROTECTED]
  On Fri, 18 Jul 2003, Gary Gregory wrote:
 
   I like #2.
 
  Boo! ;)
 
  Seriously for a moment. I think the usage of commons-lang 
 is beginning to
  hit the up-curve. It's creeping into projects and people 
 are starting to
  talk about it [along with other Commons things] outside of the usual
  circles. A 2.0 soon will really take off I believe.
 
   A clarification please: I do not see why any isWhitespace 
 methods are
 needed
   since the isBlank methods trim()'s their arguments.
  
   isBlank(null) returns true
   isWS(null) returns true
  
   isBlank() returns true
   isWS() returns true
  
   isBlank( ) returns true
   isWS( ) returns true
  
   isBlank(\t\n) returns true
   isWS(\t\n) returns true
  
   isBlank( Hello ) returns false
   isWS( Hello ) returns false
  
   Am I missing something?
 
  Re-reading Stephen's suggestion, only thing I can see is that he
  suggests that isBlank(\t\n) would not be true. However a 
 quick test
  shows that trim() removes all whitespace, so I'm a believer 
 in Gary's
  point.
 
  Hen
 
 
 
  
 -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 


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



DO NOT REPLY [Bug 11240] - Cookies with ',' in the value string is not parsed correctly in some cases

2003-07-19 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11240.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11240

Cookies with ',' in the value string is not parsed correctly in some cases

[EMAIL PROTECTED] changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED



--- Additional Comments From [EMAIL PROTECTED]  2003-07-19 08:50 ---
Patch committed.

Oleg

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



DO NOT REPLY [Bug 19618] - URI class constructors need revision, optimization

2003-07-19 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19618.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19618

URI class constructors need revision, optimization





--- Additional Comments From [EMAIL PROTECTED]  2003-07-19 09:42 ---
I agree. I'll commit the patch for now. 

Anyways, we all know that URI class will require quite a bit of attention in the
future. So, plain string constructor can always be reinstated, should we change
our mind

Oleg

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



DO NOT REPLY [Bug 19618] - URI class constructors need revision, optimization

2003-07-19 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19618.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19618

URI class constructors need revision, optimization

[EMAIL PROTECTED] changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED



--- Additional Comments From [EMAIL PROTECTED]  2003-07-19 09:45 ---
Patch committed.

Oleg

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



DO NOT REPLY [Bug 10805] - UnderscoreIsDash http workaround

2003-07-19 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10805.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10805

UnderscoreIsDash http workaround

[EMAIL PROTECTED] changed:

   What|Removed |Added

   Target Milestone|2.1 Final   |3.0 Final

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



DO NOT REPLY [Bug 17947] - Need setURI() methods in HttpMethod interface

2003-07-19 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17947.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17947

Need setURI() methods in HttpMethod interface





--- Additional Comments From [EMAIL PROTECTED]  2003-07-19 19:40 ---
Created an attachment (id=7397)
Patch (take 2)

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



DO NOT REPLY [Bug 10815] - Instrumentation for Timings

2003-07-19 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10815.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10815

Instrumentation for Timings

[EMAIL PROTECTED] changed:

   What|Removed |Added

   Target Milestone|2.1 Final   |3.0 Final

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