forked from jruby/jruby
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added Ustr code and Java 5 support to mutable-string branch
git-svn-id: http://svn.codehaus.org/jruby/branches/mutable-string@2238 961051c9-f516-0410-bf72-c9f7e237a7b7
- Loading branch information
Showing
5 changed files
with
1,535 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
#Mon Jan 02 00:48:54 CST 2006 | ||
#Mon Sep 25 23:02:20 CDT 2006 | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=1.4 | ||
org.eclipse.jdt.core.compiler.compliance=1.5 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning | ||
org.eclipse.jdt.core.compiler.source=1.4 | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.source=1.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#Thu Sep 29 15:25:20 CDT 2005 | ||
#Mon Sep 25 23:02:20 CDT 2006 | ||
eclipse.preferences.version=1 | ||
internal.default.compliance=user | ||
internal.default.compliance=default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package org.jruby.util.string; | ||
|
||
/** | ||
* UcharIterator - an Iterator on Unicode characters in a UTF-8 byte array. | ||
* | ||
* <p>A conventional Iterator, remove() is not supported, and there's an extra | ||
* nextChar() method that returns a naked int as opposed to a wrapped Integer. | ||
* </p> | ||
* | ||
* @author Tim Bray | ||
* @see org.jruby.util.string.Ustr | ||
*/ | ||
|
||
public class UcharIterator implements java.util.Iterator, java.io.Serializable { | ||
private Ustr u; | ||
private int next; | ||
|
||
/** | ||
* Creates a new UcharIterator starting at an offset in a buffer. | ||
* | ||
* @param s the byte array containing UTF-8-encoded Unicode characters. | ||
* @param offset how far into the array to start iterating. | ||
*/ | ||
public UcharIterator(byte[] s, int offset) { | ||
u = new Ustr(s, offset); | ||
u.prepareNext(); | ||
next = u.nextChar(); | ||
} | ||
|
||
/** | ||
* Tests whether there are any more characters in the buffer. | ||
* | ||
* @return true or false depending on whether there are more characters. | ||
*/ | ||
public boolean hasNext() { | ||
return (next != 0); | ||
} | ||
|
||
/** | ||
* Retrieve the next Unicode character from a UTF-8 byte buffer, wrapped | ||
* in an Integer object. Throws NoSuchElementException if hasNext | ||
* would return false. | ||
* | ||
* @return the next Unicode character as a java.lang.Integer | ||
* @throws NoSuchElementException | ||
*/ | ||
public Object next() { | ||
if (next == 0) | ||
throw new java.util.NoSuchElementException("Ran off end of array"); | ||
Integer i = new Integer(next); | ||
next = u.nextChar(); | ||
return i; | ||
} | ||
|
||
/** | ||
* Retrieve the next Unicode character from a UTF-8 byte buffer and return | ||
* it as an int. Once the null-termination is hit, returns 0 as many times | ||
* as you want to call it. | ||
* | ||
* @return the next Unicode character as an int, 0 on end-of-string. | ||
*/ | ||
public int nextChar() { | ||
int i = next; | ||
if (i != 0) | ||
next = u.nextChar(); | ||
return i; | ||
} | ||
|
||
/** | ||
* Throws an UnsupportedOperationException. | ||
* | ||
* @throws UnsupportedOperationException | ||
*/ | ||
public void remove() { | ||
throw new UnsupportedOperationException("UcharIterator doesn't remove"); | ||
} | ||
|
||
} |
Oops, something went wrong.