Bug 32080

Summary: CharSequence
Product: ORO Reporter: ArtemGr <artem>
Component: MainAssignee: Jakarta Notifications Mailing List <notifications>
Status: CLOSED LATER    
Severity: enhancement    
Priority: P3    
Version: Unknown   
Target Milestone: ---   
Hardware: All   
OS: All   
URL: http://java.sun.com/j2se/1.4.2/docs/api/java/lang/CharSequence.html

Description ArtemGr 2004-11-05 12:08:17 UTC
It would be great to have an effective
#public synchronized boolean match(CharSequence pattern, CharSequence input)
and
#public synchronized String substitute(CharSequence expression, CharSequence 
input)
methods.
Otherwise we need to copy the CharSequence into the String,
which is cumbersome both in notation and in performance.

I hope there would be a way for you to achieve it
without breaking compatibility with earlier JDKs (if you care).
Comment 1 Daniel F. Savarese 2004-11-07 15:59:02 UTC
We have avoided making use of J2SE 1.4 features to maintain backward
compatibility.  We intend to use conditional compilation to provide
different versions for J2ME, J2SE < 1.4 and J2SE >= 1.4.  At that time,
we will make use of 1.4isms like CharSequence.
Comment 2 ArtemGr 2004-12-25 14:58:26 UTC
Ability to use char[] is even better.

It is usually possible to effectively wrap/unwrap char[] arrays into whatever
CharSequence objects we have. And no J2SE 1.4 dependency required.

org.apache.oro.text.perl.Perl5Util.match seems to have char[] argument already.
May I ask for other methods to have fast char[] variants also?
In particular, for:
org.apache.oro.text.perl.Perl5Util.split( Collection, String, String, int )
org.apache.oro.text.perl.Perl5Util.substitute( StringBuffer, String, String )
and
org.apache.oro.text.regex.MatchResult.group( int )
Comment 3 ArtemGr 2004-12-25 15:15:30 UTC
Afterthought, it is less important to have a char[] alternative to

org.apache.oro.text.regex.MatchResult.group( int )

since in most cases we will append the result to something else using
String.getChars. But

org.apache.oro.text.perl.Perl5Util.split( Collection, String, String, int )
org.apache.oro.text.perl.Perl5Util.substitute( StringBuffer, String, String )

are still important, becouse their arguments might be quite big and there is no
way to wrap existing char[] array into String without needless copying.
Comment 4 ArtemGr 2004-12-25 15:43:08 UTC
For org.apache.oro.text.perl.Perl5Util.split it is even better to use the
org.apache.oro.text.regex.PatternMatcherInput as parameter. split already uses
PatternMatcherInput! And PatternMatcherInput allows to specify a part of char[]
array - perfect. It seems quite reasonable to include a method which accepts
PatternMatcherInput directly, instead of creating it every time from String. Am
I missing something?  : )
Comment 5 ArtemGr 2005-07-06 08:08:13 UTC
The org.apache.oro.text.regex package contains already everything i need to work
with char[] arrays. Sorry for the buzz.