You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Phil Steitz <st...@yahoo.com> on 2003/08/01 20:47:48 UTC

Re: [lang] ReplaceChars committed (was Translate)

I agree with this move.

One thing that we might want to think about (post 2.0), however, is
actually adding back a better version to CharSetUtils with set support.

I have never understood, btw, why the CharSetUtils methods do not also
accept CharSets as arguments.  Why is this?   

Phil

--- Stephen Colebourne <sc...@btopenworld.com> wrote:
> I have committed this change to CVS as follows:
> 
> - original translate function in CharSetUtils is unchanged, but
> DEPRECATED
> 
> - NEW method 'replaceChars' added to StringUtils. (translate didn't use
> set
> notation, so was completely out of place on CharSetUtils. replaceChars
> follows our style of using Java-like method names)
> 
> - replaceChars performs as per below:
> replaceChars(*str, null, *)  = *str
> replaceChars(*str, "", *)  = *str
> replaceChars(*, "abc", null)  = delete chars 'abc' from string
> replaceChars(*, "abc", "")  = delete chars 'abc' from string
> replaceChars(*, "abc", "z")  = replace chars 'a' with 'z', DELETE 'b','c'
> replaceChars(*, "abc", "zyxwv")  = replace chars 'a' with 'z', 'b' with
> 'y',
> 'c' with 'x', IGNORE 'w','v'
> Note the change to delete if replaceChars is shorter, as Eric suggested.
> It
> makes much more sense that way.
> 
> Stephen
> 
> From: "Eric Galluzzo" <eg...@einnovation.com>
> > Stephen Colebourne wrote:
> > > I propose the clearest is:
> > >
> > >translate(*str, null, *)  = *str
> > >translate(*str, "", *)  = *str
> > >translate(*, "abc", null)  = delete chars 'abc' from string
> > >translate(*, "abc", "")  = delete chars 'abc' from string
> > >translate(*, "abc", "z")  = replace chars 'abc' with 'z'
> > >translate(*, "abc", "zyxwv")  = replace chars 'a' with 'z', 'b' with
> 'y',
> > >'c' with 'x', ignore 'wv'
> > >
> > >--> no errors
> > >
> > >
> > Would it make sense for the translate() function to mimic the XPath
> > translate() function's behavior?  (See
> > http://www.w3.org/TR/xpath#function-translate.)  That seems to be what
> > StringUtils.translate() is modeled upon -- either that or the old Unix
> > 'tr' utility.  Following XPath's translate() function definition, all
> > your examples above would remain intact except that:
> >
> > translate(*, "abc", "z")
> >
> > would cause 'a' to be replaced with 'z', and would delete all
> > occurrences of 'b' and 'c'.
> >
> > If I have no idea what I'm talking about, feel free to brush these
> > comments aside with a Dogbert-style "Bah." :)
> >
> >     - Eric
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

Re: [lang] ReplaceChars committed (was Translate)

Posted by Phil Steitz <st...@yahoo.com>.
--- Stephen Colebourne <sc...@btopenworld.com> wrote:
> CharSetUtils/CharSet needs refactoring really.
> 
> CharSet should have the methods squeeze/count/keep/delete as instance
> methods.
> CharSetUtils is then just a simple access mechanism that creates a
> CharSet
> and calls the method.
> 
> None of this breaks backwards compatability, so we don't need to do it
> until
> after 2.0.

OK.  Now I get it.  Sorry for the noise.  

Phil
> 
> Stephen
> 
> ----- Original Message -----
> From: "Phil Steitz" <st...@yahoo.com>
> > I agree with this move.
> >
> > One thing that we might want to think about (post 2.0), however, is
> > actually adding back a better version to CharSetUtils with set support.
> >
> > I have never understood, btw, why the CharSetUtils methods do not also
> > accept CharSets as arguments.  Why is this?
> >
> > Phil
> >
> > --- Stephen Colebourne <sc...@btopenworld.com> wrote:
> > > I have committed this change to CVS as follows:
> > >
> > > - original translate function in CharSetUtils is unchanged, but
> > > DEPRECATED
> > >
> > > - NEW method 'replaceChars' added to StringUtils. (translate didn't
> use
> > > set
> > > notation, so was completely out of place on CharSetUtils.
> replaceChars
> > > follows our style of using Java-like method names)
> > >
> > > - replaceChars performs as per below:
> > > replaceChars(*str, null, *)  = *str
> > > replaceChars(*str, "", *)  = *str
> > > replaceChars(*, "abc", null)  = delete chars 'abc' from string
> > > replaceChars(*, "abc", "")  = delete chars 'abc' from string
> > > replaceChars(*, "abc", "z")  = replace chars 'a' with 'z', DELETE
> 'b','c'
> > > replaceChars(*, "abc", "zyxwv")  = replace chars 'a' with 'z', 'b'
> with
> > > 'y',
> > > 'c' with 'x', IGNORE 'w','v'
> > > Note the change to delete if replaceChars is shorter, as Eric
> suggested.
> > > It
> > > makes much more sense that way.
> > >
> > > Stephen
> > >
> > > From: "Eric Galluzzo" <eg...@einnovation.com>
> > > > Stephen Colebourne wrote:
> > > > > I propose the clearest is:
> > > > >
> > > > >translate(*str, null, *)  = *str
> > > > >translate(*str, "", *)  = *str
> > > > >translate(*, "abc", null)  = delete chars 'abc' from string
> > > > >translate(*, "abc", "")  = delete chars 'abc' from string
> > > > >translate(*, "abc", "z")  = replace chars 'abc' with 'z'
> > > > >translate(*, "abc", "zyxwv")  = replace chars 'a' with 'z', 'b'
> with
> > > 'y',
> > > > >'c' with 'x', ignore 'wv'
> > > > >
> > > > >--> no errors
> > > > >
> > > > >
> > > > Would it make sense for the translate() function to mimic the XPath
> > > > translate() function's behavior?  (See
> > > > http://www.w3.org/TR/xpath#function-translate.)  That seems to be
> what
> > > > StringUtils.translate() is modeled upon -- either that or the old
> Unix
> > > > 'tr' utility.  Following XPath's translate() function definition,
> all
> > > > your examples above would remain intact except that:
> > > >
> > > > translate(*, "abc", "z")
> > > >
> > > > would cause 'a' to be replaced with 'z', and would delete all
> > > > occurrences of 'b' and 'c'.
> > > >
> > > > If I have no idea what I'm talking about, feel free to brush these
> > > > comments aside with a Dogbert-style "Bah." :)
> > > >
> > > >     - Eric
> > > >
> > > >
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > > > For additional commands, e-mail:
> commons-dev-help@jakarta.apache.org
> > > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> > >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! SiteBuilder - Free, easy-to-use web site design software
> > http://sitebuilder.yahoo.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [lang] ReplaceChars committed (was Translate)

Posted by Phil Steitz <st...@yahoo.com>.
--- Stephen Colebourne <sc...@btopenworld.com> wrote:
> CharSetUtils/CharSet needs refactoring really.
> 
> CharSet should have the methods squeeze/count/keep/delete as instance
> methods.
> CharSetUtils is then just a simple access mechanism that creates a
> CharSet
> and calls the method.
> 
> None of this breaks backwards compatability, so we don't need to do it
> until
> after 2.0.

OK.  Now I get it.  Sorry for the noise.  

Phil
> 
> Stephen
> 
> ----- Original Message -----
> From: "Phil Steitz" <st...@yahoo.com>
> > I agree with this move.
> >
> > One thing that we might want to think about (post 2.0), however, is
> > actually adding back a better version to CharSetUtils with set support.
> >
> > I have never understood, btw, why the CharSetUtils methods do not also
> > accept CharSets as arguments.  Why is this?
> >
> > Phil
> >
> > --- Stephen Colebourne <sc...@btopenworld.com> wrote:
> > > I have committed this change to CVS as follows:
> > >
> > > - original translate function in CharSetUtils is unchanged, but
> > > DEPRECATED
> > >
> > > - NEW method 'replaceChars' added to StringUtils. (translate didn't
> use
> > > set
> > > notation, so was completely out of place on CharSetUtils.
> replaceChars
> > > follows our style of using Java-like method names)
> > >
> > > - replaceChars performs as per below:
> > > replaceChars(*str, null, *)  = *str
> > > replaceChars(*str, "", *)  = *str
> > > replaceChars(*, "abc", null)  = delete chars 'abc' from string
> > > replaceChars(*, "abc", "")  = delete chars 'abc' from string
> > > replaceChars(*, "abc", "z")  = replace chars 'a' with 'z', DELETE
> 'b','c'
> > > replaceChars(*, "abc", "zyxwv")  = replace chars 'a' with 'z', 'b'
> with
> > > 'y',
> > > 'c' with 'x', IGNORE 'w','v'
> > > Note the change to delete if replaceChars is shorter, as Eric
> suggested.
> > > It
> > > makes much more sense that way.
> > >
> > > Stephen
> > >
> > > From: "Eric Galluzzo" <eg...@einnovation.com>
> > > > Stephen Colebourne wrote:
> > > > > I propose the clearest is:
> > > > >
> > > > >translate(*str, null, *)  = *str
> > > > >translate(*str, "", *)  = *str
> > > > >translate(*, "abc", null)  = delete chars 'abc' from string
> > > > >translate(*, "abc", "")  = delete chars 'abc' from string
> > > > >translate(*, "abc", "z")  = replace chars 'abc' with 'z'
> > > > >translate(*, "abc", "zyxwv")  = replace chars 'a' with 'z', 'b'
> with
> > > 'y',
> > > > >'c' with 'x', ignore 'wv'
> > > > >
> > > > >--> no errors
> > > > >
> > > > >
> > > > Would it make sense for the translate() function to mimic the XPath
> > > > translate() function's behavior?  (See
> > > > http://www.w3.org/TR/xpath#function-translate.)  That seems to be
> what
> > > > StringUtils.translate() is modeled upon -- either that or the old
> Unix
> > > > 'tr' utility.  Following XPath's translate() function definition,
> all
> > > > your examples above would remain intact except that:
> > > >
> > > > translate(*, "abc", "z")
> > > >
> > > > would cause 'a' to be replaced with 'z', and would delete all
> > > > occurrences of 'b' and 'c'.
> > > >
> > > > If I have no idea what I'm talking about, feel free to brush these
> > > > comments aside with a Dogbert-style "Bah." :)
> > > >
> > > >     - Eric
> > > >
> > > >
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > > > For additional commands, e-mail:
> commons-dev-help@jakarta.apache.org
> > > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> > >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! SiteBuilder - Free, easy-to-use web site design software
> > http://sitebuilder.yahoo.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

Re: [lang] ReplaceChars committed (was Translate)

Posted by Stephen Colebourne <sc...@btopenworld.com>.
CharSetUtils/CharSet needs refactoring really.

CharSet should have the methods squeeze/count/keep/delete as instance
methods.
CharSetUtils is then just a simple access mechanism that creates a CharSet
and calls the method.

None of this breaks backwards compatability, so we don't need to do it until
after 2.0.

Stephen

----- Original Message -----
From: "Phil Steitz" <st...@yahoo.com>
> I agree with this move.
>
> One thing that we might want to think about (post 2.0), however, is
> actually adding back a better version to CharSetUtils with set support.
>
> I have never understood, btw, why the CharSetUtils methods do not also
> accept CharSets as arguments.  Why is this?
>
> Phil
>
> --- Stephen Colebourne <sc...@btopenworld.com> wrote:
> > I have committed this change to CVS as follows:
> >
> > - original translate function in CharSetUtils is unchanged, but
> > DEPRECATED
> >
> > - NEW method 'replaceChars' added to StringUtils. (translate didn't use
> > set
> > notation, so was completely out of place on CharSetUtils. replaceChars
> > follows our style of using Java-like method names)
> >
> > - replaceChars performs as per below:
> > replaceChars(*str, null, *)  = *str
> > replaceChars(*str, "", *)  = *str
> > replaceChars(*, "abc", null)  = delete chars 'abc' from string
> > replaceChars(*, "abc", "")  = delete chars 'abc' from string
> > replaceChars(*, "abc", "z")  = replace chars 'a' with 'z', DELETE
'b','c'
> > replaceChars(*, "abc", "zyxwv")  = replace chars 'a' with 'z', 'b' with
> > 'y',
> > 'c' with 'x', IGNORE 'w','v'
> > Note the change to delete if replaceChars is shorter, as Eric suggested.
> > It
> > makes much more sense that way.
> >
> > Stephen
> >
> > From: "Eric Galluzzo" <eg...@einnovation.com>
> > > Stephen Colebourne wrote:
> > > > I propose the clearest is:
> > > >
> > > >translate(*str, null, *)  = *str
> > > >translate(*str, "", *)  = *str
> > > >translate(*, "abc", null)  = delete chars 'abc' from string
> > > >translate(*, "abc", "")  = delete chars 'abc' from string
> > > >translate(*, "abc", "z")  = replace chars 'abc' with 'z'
> > > >translate(*, "abc", "zyxwv")  = replace chars 'a' with 'z', 'b' with
> > 'y',
> > > >'c' with 'x', ignore 'wv'
> > > >
> > > >--> no errors
> > > >
> > > >
> > > Would it make sense for the translate() function to mimic the XPath
> > > translate() function's behavior?  (See
> > > http://www.w3.org/TR/xpath#function-translate.)  That seems to be what
> > > StringUtils.translate() is modeled upon -- either that or the old Unix
> > > 'tr' utility.  Following XPath's translate() function definition, all
> > > your examples above would remain intact except that:
> > >
> > > translate(*, "abc", "z")
> > >
> > > would cause 'a' to be replaced with 'z', and would delete all
> > > occurrences of 'b' and 'c'.
> > >
> > > If I have no idea what I'm talking about, feel free to brush these
> > > comments aside with a Dogbert-style "Bah." :)
> > >
> > >     - Eric
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> >
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>


Re: [lang] ReplaceChars committed (was Translate)

Posted by Stephen Colebourne <sc...@btopenworld.com>.
CharSetUtils/CharSet needs refactoring really.

CharSet should have the methods squeeze/count/keep/delete as instance
methods.
CharSetUtils is then just a simple access mechanism that creates a CharSet
and calls the method.

None of this breaks backwards compatability, so we don't need to do it until
after 2.0.

Stephen

----- Original Message -----
From: "Phil Steitz" <st...@yahoo.com>
> I agree with this move.
>
> One thing that we might want to think about (post 2.0), however, is
> actually adding back a better version to CharSetUtils with set support.
>
> I have never understood, btw, why the CharSetUtils methods do not also
> accept CharSets as arguments.  Why is this?
>
> Phil
>
> --- Stephen Colebourne <sc...@btopenworld.com> wrote:
> > I have committed this change to CVS as follows:
> >
> > - original translate function in CharSetUtils is unchanged, but
> > DEPRECATED
> >
> > - NEW method 'replaceChars' added to StringUtils. (translate didn't use
> > set
> > notation, so was completely out of place on CharSetUtils. replaceChars
> > follows our style of using Java-like method names)
> >
> > - replaceChars performs as per below:
> > replaceChars(*str, null, *)  = *str
> > replaceChars(*str, "", *)  = *str
> > replaceChars(*, "abc", null)  = delete chars 'abc' from string
> > replaceChars(*, "abc", "")  = delete chars 'abc' from string
> > replaceChars(*, "abc", "z")  = replace chars 'a' with 'z', DELETE
'b','c'
> > replaceChars(*, "abc", "zyxwv")  = replace chars 'a' with 'z', 'b' with
> > 'y',
> > 'c' with 'x', IGNORE 'w','v'
> > Note the change to delete if replaceChars is shorter, as Eric suggested.
> > It
> > makes much more sense that way.
> >
> > Stephen
> >
> > From: "Eric Galluzzo" <eg...@einnovation.com>
> > > Stephen Colebourne wrote:
> > > > I propose the clearest is:
> > > >
> > > >translate(*str, null, *)  = *str
> > > >translate(*str, "", *)  = *str
> > > >translate(*, "abc", null)  = delete chars 'abc' from string
> > > >translate(*, "abc", "")  = delete chars 'abc' from string
> > > >translate(*, "abc", "z")  = replace chars 'abc' with 'z'
> > > >translate(*, "abc", "zyxwv")  = replace chars 'a' with 'z', 'b' with
> > 'y',
> > > >'c' with 'x', ignore 'wv'
> > > >
> > > >--> no errors
> > > >
> > > >
> > > Would it make sense for the translate() function to mimic the XPath
> > > translate() function's behavior?  (See
> > > http://www.w3.org/TR/xpath#function-translate.)  That seems to be what
> > > StringUtils.translate() is modeled upon -- either that or the old Unix
> > > 'tr' utility.  Following XPath's translate() function definition, all
> > > your examples above would remain intact except that:
> > >
> > > translate(*, "abc", "z")
> > >
> > > would cause 'a' to be replaced with 'z', and would delete all
> > > occurrences of 'b' and 'c'.
> > >
> > > If I have no idea what I'm talking about, feel free to brush these
> > > comments aside with a Dogbert-style "Bah." :)
> > >
> > >     - Eric
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> >
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [lang] ReplaceChars committed (was Translate)

Posted by Henri Yandell <ba...@generationjava.com>.

On Fri, 1 Aug 2003, Phil Steitz wrote:

> Sorry if I am being dense here, but isn't CharSet already exposed? Its

Teach me to look at the code before answering :)

> I think that I am missing something basic.  Sorry if these are stupid
> questions.

No such thing as stupid questions. Only stupid answers. Mine might have
been such.

Hen


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [lang] ReplaceChars committed (was Translate)

Posted by Henri Yandell <ba...@generationjava.com>.

On Fri, 1 Aug 2003, Phil Steitz wrote:

> Sorry if I am being dense here, but isn't CharSet already exposed? Its

Teach me to look at the code before answering :)

> I think that I am missing something basic.  Sorry if these are stupid
> questions.

No such thing as stupid questions. Only stupid answers. Mine might have
been such.

Hen


Re: [lang] ReplaceChars committed (was Translate)

Posted by Phil Steitz <st...@yahoo.com>.
--- Henri Yandell <ba...@generationjava.com> wrote:
> 
> Religion.
> 
> While in my own code I used to be quite open in terms of allowing lots of
> things, Lang is helping to make me think more defensively when code will
> be used by other people. For example I no longer make methods public if I
> don't think they should be private/protected, I actually use the
> anonymous/package scope.
> 
> Anyways. Offering the CharSet seemed to be too much like showing the
> implementation to the user and a particular religion to be obeyed, so I
> was quite happy for it to be hidden.

Sorry if I am being dense here, but isn't CharSet already exposed? Its
constructor is protected, but the public factory method
CharSetUtils.evaluate can be used to create instances.  Am I missing
something?  I must be really missing the point, since to me it seems that
having the CharSetUtils methods take strings or string[]s in the internal
"set notation" is actually showing/depending on more internal
implementation detail than just having them take the encapsulated objects
(CharSets).  

I think that I am missing something basic.  Sorry if these are stupid
questions.

Phil


> 
> It's better to hide it before release then offer it later than try to
> hide
> it later :)
> 
> Hen
> 
> On Fri, 1 Aug 2003, Phil Steitz wrote:
> 
> > I agree with this move.
> >
> > One thing that we might want to think about (post 2.0), however, is
> > actually adding back a better version to CharSetUtils with set support.
> >
> > I have never understood, btw, why the CharSetUtils methods do not also
> > accept CharSets as arguments.  Why is this?
> >
> > Phil
> >
> > --- Stephen Colebourne <sc...@btopenworld.com> wrote:
> > > I have committed this change to CVS as follows:
> > >
> > > - original translate function in CharSetUtils is unchanged, but
> > > DEPRECATED
> > >
> > > - NEW method 'replaceChars' added to StringUtils. (translate didn't
> use
> > > set
> > > notation, so was completely out of place on CharSetUtils.
> replaceChars
> > > follows our style of using Java-like method names)
> > >
> > > - replaceChars performs as per below:
> > > replaceChars(*str, null, *)  = *str
> > > replaceChars(*str, "", *)  = *str
> > > replaceChars(*, "abc", null)  = delete chars 'abc' from string
> > > replaceChars(*, "abc", "")  = delete chars 'abc' from string
> > > replaceChars(*, "abc", "z")  = replace chars 'a' with 'z', DELETE
> 'b','c'
> > > replaceChars(*, "abc", "zyxwv")  = replace chars 'a' with 'z', 'b'
> with
> > > 'y',
> > > 'c' with 'x', IGNORE 'w','v'
> > > Note the change to delete if replaceChars is shorter, as Eric
> suggested.
> > > It
> > > makes much more sense that way.
> > >
> > > Stephen
> > >
> > > From: "Eric Galluzzo" <eg...@einnovation.com>
> > > > Stephen Colebourne wrote:
> > > > > I propose the clearest is:
> > > > >
> > > > >translate(*str, null, *)  = *str
> > > > >translate(*str, "", *)  = *str
> > > > >translate(*, "abc", null)  = delete chars 'abc' from string
> > > > >translate(*, "abc", "")  = delete chars 'abc' from string
> > > > >translate(*, "abc", "z")  = replace chars 'abc' with 'z'
> > > > >translate(*, "abc", "zyxwv")  = replace chars 'a' with 'z', 'b'
> with
> > > 'y',
> > > > >'c' with 'x', ignore 'wv'
> > > > >
> > > > >--> no errors
> > > > >
> > > > >
> > > > Would it make sense for the translate() function to mimic the XPath
> > > > translate() function's behavior?  (See
> > > > http://www.w3.org/TR/xpath#function-translate.)  That seems to be
> what
> > > > StringUtils.translate() is modeled upon -- either that or the old
> Unix
> > > > 'tr' utility.  Following XPath's translate() function definition,
> all
> > > > your examples above would remain intact except that:
> > > >
> > > > translate(*, "abc", "z")
> > > >
> > > > would cause 'a' to be replaced with 'z', and would delete all
> > > > occurrences of 'b' and 'c'.
> > > >
> > > > If I have no idea what I'm talking about, feel free to brush these
> > > > comments aside with a Dogbert-style "Bah." :)
> > > >
> > > >     - Eric
> > > >
> > > >
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > > > For additional commands, e-mail:
> commons-dev-help@jakarta.apache.org
> > > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> > >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! SiteBuilder - Free, easy-to-use web site design software
> > http://sitebuilder.yahoo.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

Re: [lang] ReplaceChars committed (was Translate)

Posted by Phil Steitz <st...@yahoo.com>.
--- Henri Yandell <ba...@generationjava.com> wrote:
> 
> Religion.
> 
> While in my own code I used to be quite open in terms of allowing lots of
> things, Lang is helping to make me think more defensively when code will
> be used by other people. For example I no longer make methods public if I
> don't think they should be private/protected, I actually use the
> anonymous/package scope.
> 
> Anyways. Offering the CharSet seemed to be too much like showing the
> implementation to the user and a particular religion to be obeyed, so I
> was quite happy for it to be hidden.

Sorry if I am being dense here, but isn't CharSet already exposed? Its
constructor is protected, but the public factory method
CharSetUtils.evaluate can be used to create instances.  Am I missing
something?  I must be really missing the point, since to me it seems that
having the CharSetUtils methods take strings or string[]s in the internal
"set notation" is actually showing/depending on more internal
implementation detail than just having them take the encapsulated objects
(CharSets).  

I think that I am missing something basic.  Sorry if these are stupid
questions.

Phil


> 
> It's better to hide it before release then offer it later than try to
> hide
> it later :)
> 
> Hen
> 
> On Fri, 1 Aug 2003, Phil Steitz wrote:
> 
> > I agree with this move.
> >
> > One thing that we might want to think about (post 2.0), however, is
> > actually adding back a better version to CharSetUtils with set support.
> >
> > I have never understood, btw, why the CharSetUtils methods do not also
> > accept CharSets as arguments.  Why is this?
> >
> > Phil
> >
> > --- Stephen Colebourne <sc...@btopenworld.com> wrote:
> > > I have committed this change to CVS as follows:
> > >
> > > - original translate function in CharSetUtils is unchanged, but
> > > DEPRECATED
> > >
> > > - NEW method 'replaceChars' added to StringUtils. (translate didn't
> use
> > > set
> > > notation, so was completely out of place on CharSetUtils.
> replaceChars
> > > follows our style of using Java-like method names)
> > >
> > > - replaceChars performs as per below:
> > > replaceChars(*str, null, *)  = *str
> > > replaceChars(*str, "", *)  = *str
> > > replaceChars(*, "abc", null)  = delete chars 'abc' from string
> > > replaceChars(*, "abc", "")  = delete chars 'abc' from string
> > > replaceChars(*, "abc", "z")  = replace chars 'a' with 'z', DELETE
> 'b','c'
> > > replaceChars(*, "abc", "zyxwv")  = replace chars 'a' with 'z', 'b'
> with
> > > 'y',
> > > 'c' with 'x', IGNORE 'w','v'
> > > Note the change to delete if replaceChars is shorter, as Eric
> suggested.
> > > It
> > > makes much more sense that way.
> > >
> > > Stephen
> > >
> > > From: "Eric Galluzzo" <eg...@einnovation.com>
> > > > Stephen Colebourne wrote:
> > > > > I propose the clearest is:
> > > > >
> > > > >translate(*str, null, *)  = *str
> > > > >translate(*str, "", *)  = *str
> > > > >translate(*, "abc", null)  = delete chars 'abc' from string
> > > > >translate(*, "abc", "")  = delete chars 'abc' from string
> > > > >translate(*, "abc", "z")  = replace chars 'abc' with 'z'
> > > > >translate(*, "abc", "zyxwv")  = replace chars 'a' with 'z', 'b'
> with
> > > 'y',
> > > > >'c' with 'x', ignore 'wv'
> > > > >
> > > > >--> no errors
> > > > >
> > > > >
> > > > Would it make sense for the translate() function to mimic the XPath
> > > > translate() function's behavior?  (See
> > > > http://www.w3.org/TR/xpath#function-translate.)  That seems to be
> what
> > > > StringUtils.translate() is modeled upon -- either that or the old
> Unix
> > > > 'tr' utility.  Following XPath's translate() function definition,
> all
> > > > your examples above would remain intact except that:
> > > >
> > > > translate(*, "abc", "z")
> > > >
> > > > would cause 'a' to be replaced with 'z', and would delete all
> > > > occurrences of 'b' and 'c'.
> > > >
> > > > If I have no idea what I'm talking about, feel free to brush these
> > > > comments aside with a Dogbert-style "Bah." :)
> > > >
> > > >     - Eric
> > > >
> > > >
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > > > For additional commands, e-mail:
> commons-dev-help@jakarta.apache.org
> > > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> > >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! SiteBuilder - Free, easy-to-use web site design software
> > http://sitebuilder.yahoo.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [lang] ReplaceChars committed (was Translate)

Posted by Henri Yandell <ba...@generationjava.com>.
Religion.

While in my own code I used to be quite open in terms of allowing lots of
things, Lang is helping to make me think more defensively when code will
be used by other people. For example I no longer make methods public if I
don't think they should be private/protected, I actually use the
anonymous/package scope.

Anyways. Offering the CharSet seemed to be too much like showing the
implementation to the user and a particular religion to be obeyed, so I
was quite happy for it to be hidden.

It's better to hide it before release then offer it later than try to hide
it later :)

Hen

On Fri, 1 Aug 2003, Phil Steitz wrote:

> I agree with this move.
>
> One thing that we might want to think about (post 2.0), however, is
> actually adding back a better version to CharSetUtils with set support.
>
> I have never understood, btw, why the CharSetUtils methods do not also
> accept CharSets as arguments.  Why is this?
>
> Phil
>
> --- Stephen Colebourne <sc...@btopenworld.com> wrote:
> > I have committed this change to CVS as follows:
> >
> > - original translate function in CharSetUtils is unchanged, but
> > DEPRECATED
> >
> > - NEW method 'replaceChars' added to StringUtils. (translate didn't use
> > set
> > notation, so was completely out of place on CharSetUtils. replaceChars
> > follows our style of using Java-like method names)
> >
> > - replaceChars performs as per below:
> > replaceChars(*str, null, *)  = *str
> > replaceChars(*str, "", *)  = *str
> > replaceChars(*, "abc", null)  = delete chars 'abc' from string
> > replaceChars(*, "abc", "")  = delete chars 'abc' from string
> > replaceChars(*, "abc", "z")  = replace chars 'a' with 'z', DELETE 'b','c'
> > replaceChars(*, "abc", "zyxwv")  = replace chars 'a' with 'z', 'b' with
> > 'y',
> > 'c' with 'x', IGNORE 'w','v'
> > Note the change to delete if replaceChars is shorter, as Eric suggested.
> > It
> > makes much more sense that way.
> >
> > Stephen
> >
> > From: "Eric Galluzzo" <eg...@einnovation.com>
> > > Stephen Colebourne wrote:
> > > > I propose the clearest is:
> > > >
> > > >translate(*str, null, *)  = *str
> > > >translate(*str, "", *)  = *str
> > > >translate(*, "abc", null)  = delete chars 'abc' from string
> > > >translate(*, "abc", "")  = delete chars 'abc' from string
> > > >translate(*, "abc", "z")  = replace chars 'abc' with 'z'
> > > >translate(*, "abc", "zyxwv")  = replace chars 'a' with 'z', 'b' with
> > 'y',
> > > >'c' with 'x', ignore 'wv'
> > > >
> > > >--> no errors
> > > >
> > > >
> > > Would it make sense for the translate() function to mimic the XPath
> > > translate() function's behavior?  (See
> > > http://www.w3.org/TR/xpath#function-translate.)  That seems to be what
> > > StringUtils.translate() is modeled upon -- either that or the old Unix
> > > 'tr' utility.  Following XPath's translate() function definition, all
> > > your examples above would remain intact except that:
> > >
> > > translate(*, "abc", "z")
> > >
> > > would cause 'a' to be replaced with 'z', and would delete all
> > > occurrences of 'b' and 'c'.
> > >
> > > If I have no idea what I'm talking about, feel free to brush these
> > > comments aside with a Dogbert-style "Bah." :)
> > >
> > >     - Eric
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> >
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [lang] ReplaceChars committed (was Translate)

Posted by Henri Yandell <ba...@generationjava.com>.
Religion.

While in my own code I used to be quite open in terms of allowing lots of
things, Lang is helping to make me think more defensively when code will
be used by other people. For example I no longer make methods public if I
don't think they should be private/protected, I actually use the
anonymous/package scope.

Anyways. Offering the CharSet seemed to be too much like showing the
implementation to the user and a particular religion to be obeyed, so I
was quite happy for it to be hidden.

It's better to hide it before release then offer it later than try to hide
it later :)

Hen

On Fri, 1 Aug 2003, Phil Steitz wrote:

> I agree with this move.
>
> One thing that we might want to think about (post 2.0), however, is
> actually adding back a better version to CharSetUtils with set support.
>
> I have never understood, btw, why the CharSetUtils methods do not also
> accept CharSets as arguments.  Why is this?
>
> Phil
>
> --- Stephen Colebourne <sc...@btopenworld.com> wrote:
> > I have committed this change to CVS as follows:
> >
> > - original translate function in CharSetUtils is unchanged, but
> > DEPRECATED
> >
> > - NEW method 'replaceChars' added to StringUtils. (translate didn't use
> > set
> > notation, so was completely out of place on CharSetUtils. replaceChars
> > follows our style of using Java-like method names)
> >
> > - replaceChars performs as per below:
> > replaceChars(*str, null, *)  = *str
> > replaceChars(*str, "", *)  = *str
> > replaceChars(*, "abc", null)  = delete chars 'abc' from string
> > replaceChars(*, "abc", "")  = delete chars 'abc' from string
> > replaceChars(*, "abc", "z")  = replace chars 'a' with 'z', DELETE 'b','c'
> > replaceChars(*, "abc", "zyxwv")  = replace chars 'a' with 'z', 'b' with
> > 'y',
> > 'c' with 'x', IGNORE 'w','v'
> > Note the change to delete if replaceChars is shorter, as Eric suggested.
> > It
> > makes much more sense that way.
> >
> > Stephen
> >
> > From: "Eric Galluzzo" <eg...@einnovation.com>
> > > Stephen Colebourne wrote:
> > > > I propose the clearest is:
> > > >
> > > >translate(*str, null, *)  = *str
> > > >translate(*str, "", *)  = *str
> > > >translate(*, "abc", null)  = delete chars 'abc' from string
> > > >translate(*, "abc", "")  = delete chars 'abc' from string
> > > >translate(*, "abc", "z")  = replace chars 'abc' with 'z'
> > > >translate(*, "abc", "zyxwv")  = replace chars 'a' with 'z', 'b' with
> > 'y',
> > > >'c' with 'x', ignore 'wv'
> > > >
> > > >--> no errors
> > > >
> > > >
> > > Would it make sense for the translate() function to mimic the XPath
> > > translate() function's behavior?  (See
> > > http://www.w3.org/TR/xpath#function-translate.)  That seems to be what
> > > StringUtils.translate() is modeled upon -- either that or the old Unix
> > > 'tr' utility.  Following XPath's translate() function definition, all
> > > your examples above would remain intact except that:
> > >
> > > translate(*, "abc", "z")
> > >
> > > would cause 'a' to be replaced with 'z', and would delete all
> > > occurrences of 'b' and 'c'.
> > >
> > > If I have no idea what I'm talking about, feel free to brush these
> > > comments aside with a Dogbert-style "Bah." :)
> > >
> > >     - Eric
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> >
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>