[jruby-joni] 63/223: Add some convenience constructors for byte[], CharSequence, and String

Hideki Yamane henrich at moszumanska.debian.org
Mon Nov 16 11:21:48 UTC 2015


This is an automated email from the git hooks/post-receive script.

henrich pushed a commit to branch debian/sid
in repository jruby-joni.

commit 1545022137af237d7ad27e5d99fb40fd1187b93d
Author: Charles Oliver Nutter <headius at headius.com>
Date:   Fri Jul 22 15:28:00 2011 -0500

    Add some convenience constructors for byte[], CharSequence, and String
---
 src/org/joni/Regex.java | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/src/org/joni/Regex.java b/src/org/joni/Regex.java
index d6308de..258920a 100644
--- a/src/org/joni/Regex.java
+++ b/src/org/joni/Regex.java
@@ -27,6 +27,9 @@ import java.util.IllegalFormatConversionException;
 import java.util.Iterator;
 
 import org.jcodings.Encoding;
+import org.jcodings.EncodingDB;
+import org.jcodings.specific.ASCIIEncoding;
+import org.jcodings.specific.UTF8Encoding;
 import org.jcodings.util.BytesHash;
 import org.joni.constants.AnchorType;
 import org.joni.constants.RegexState;
@@ -86,6 +89,34 @@ public final class Regex implements RegexState {
     int[]intMapBackward;                    /* BM skip for backward search */
     int dMin;                               /* min-distance of exact or map */
     int dMax;                               /* max-distance of exact or map */
+    
+    public Regex(CharSequence cs) {
+        this(cs.toString());
+    }
+    
+    public Regex(CharSequence cs, Encoding enc) {
+        this(cs.toString(), enc);
+    }
+    
+    public Regex(String str) {
+        this(str.getBytes(), 0, str.length(), 0, UTF8Encoding.INSTANCE);
+    }
+    
+    public Regex(String str, Encoding enc) {
+        this(str.getBytes(), 0, str.length(), 0, enc);
+    }
+    
+    public Regex(byte[] bytes) {
+        this(bytes, 0, bytes.length, 0, ASCIIEncoding.INSTANCE);
+    }
+    
+    public Regex(byte[] bytes, int p, int end) {
+        this(bytes, p, end, 0, ASCIIEncoding.INSTANCE);
+    }
+    
+    public Regex(byte[] bytes, int p, int end, int option) {
+        this(bytes, p, end, 0, ASCIIEncoding.INSTANCE);
+    }
 
     public Regex(byte[]bytes, int p, int end, int option, Encoding enc) {
         this(bytes, p, end, option, enc, Syntax.RUBY, WarnCallback.DEFAULT);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jruby-joni.git



More information about the pkg-java-commits mailing list