summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2006-09-21 15:57:49 +0000
committermichelou <michelou@epfl.ch>2006-09-21 15:57:49 +0000
commitbfe77062209d59fd45186d54edb18b4ceec55b54 (patch)
tree7ef9052c2045af4288c391bcca606c2a052170ac
parent5fab489bd534909f78d514d57fe81298a56a2d27 (diff)
downloadscala-bfe77062209d59fd45186d54edb18b4ceec55b54.tar.gz
scala-bfe77062209d59fd45186d54edb18b4ceec55b54.tar.bz2
scala-bfe77062209d59fd45186d54edb18b4ceec55b54.zip
fixed typo in generated scaladoc tags
-rw-r--r--src/compiler/scala/tools/nsc/doc/DocGenerator.scala3
-rw-r--r--src/library/scala/Iterable.scala4
-rw-r--r--src/library/scala/io/BytePickle.scala89
-rw-r--r--src/library/scala/io/Position.scala58
-rw-r--r--src/library/scala/io/Source.scala170
-rw-r--r--src/library/scala/io/UTF8Codec.scala79
6 files changed, 212 insertions, 191 deletions
diff --git a/src/compiler/scala/tools/nsc/doc/DocGenerator.scala b/src/compiler/scala/tools/nsc/doc/DocGenerator.scala
index ca153a5bee..0558dc7ea7 100644
--- a/src/compiler/scala/tools/nsc/doc/DocGenerator.scala
+++ b/src/compiler/scala/tools/nsc/doc/DocGenerator.scala
@@ -612,6 +612,7 @@ abstract class DocGenerator extends Models {
private def tag(name: String): NodeSeq =
<b> {
Text((name match {
+ case "author" => "Author"
case "param" => "Parameters"
case "return" => "Returns"
case "see" => "See"
@@ -654,7 +655,7 @@ abstract class DocGenerator extends Models {
{ {
for (val attr <- attributes) yield
<dt style="margin:10px 0 0 10px;">
- tag(attr._1) //<b>{Text(attr._1 + ":")}</b>
+ {tag(attr._1)}
</dt>
<dd>{(parse(attr._2))}</dd>;
} } </dl></span>;
diff --git a/src/library/scala/Iterable.scala b/src/library/scala/Iterable.scala
index 175a584d0e..1c1a3915de 100644
--- a/src/library/scala/Iterable.scala
+++ b/src/library/scala/Iterable.scala
@@ -99,7 +99,7 @@ trait Iterable[+A] {
* true for all elements.
*
* @param p the predicate
- * @returns true, iff the predicate yields true for all elements.
+ * @return true, iff the predicate yields true for all elements.
*/
def forall(p: A => Boolean): Boolean = elements.forall(p)
@@ -108,7 +108,7 @@ trait Iterable[+A] {
* element for which <code>p</code> yields true.
*
* @param p the predicate
- * @returns true, iff the predicate yields true for at least one element.
+ * @return true, iff the predicate yields true for at least one element.
*/
def exists(p: A => Boolean): Boolean = elements.exists(p)
diff --git a/src/library/scala/io/BytePickle.scala b/src/library/scala/io/BytePickle.scala
index 55b7db15b5..aa4f810f40 100644
--- a/src/library/scala/io/BytePickle.scala
+++ b/src/library/scala/io/BytePickle.scala
@@ -1,53 +1,65 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+// $Id$
+
+
package scala.io
import scala.collection.mutable.{HashMap,ArrayBuffer}
/**
- Pickler combinators.
- Based on a Haskell library by Andrew Kennedy, see http://research.microsoft.com/~akenn/fun/index.html.
-
- Author: Philipp Haller <philipp.haller@epfl.ch>
- */
-
+ * Pickler combinators.
+ * Based on a Haskell library by Andrew Kennedy,
+ * see http://research.microsoft.com/~akenn/fun/index.html.
+ *
+ * @author Philipp Haller &lt;philipp.haller@epfl.ch&gt;
+ * @version 1.0
+ */
object BytePickle {
abstract class SPU[t] {
- def appP(a: t, state: PicklerState): PicklerState;
- def appU(state: UnPicklerState): Pair[t, UnPicklerState];
+ def appP(a: t, state: PicklerState): PicklerState
+ def appU(state: UnPicklerState): Pair[t, UnPicklerState]
}
def pickle[t](p: SPU[t], a: t): Array[byte] =
- p.appP(a, new PicklerState(new Array[byte](0), new PicklerEnv)).stream;
+ p.appP(a, new PicklerState(new Array[byte](0), new PicklerEnv)).stream
def unpickle[t](p: SPU[t], stream: Array[byte]): t =
- p.appU(new UnPicklerState(stream, new UnPicklerEnv))._1;
+ p.appU(new UnPicklerState(stream, new UnPicklerEnv))._1
abstract class PU[t] {
- def appP(a: t, state: Array[byte]): Array[byte];
- def appU(state: Array[byte]): Pair[t, Array[byte]];
+ def appP(a: t, state: Array[byte]): Array[byte]
+ def appU(state: Array[byte]): Pair[t, Array[byte]]
}
def upickle[t](p: PU[t], a: t): Array[byte] =
- p.appP(a, new Array[byte](0));
+ p.appP(a, new Array[byte](0))
def uunpickle[t](p: PU[t], stream: Array[byte]): t =
- p.appU(stream)._1;
+ p.appU(stream)._1
class PicklerEnv extends HashMap[Any, int] {
- private var cnt: int = 64;
- def nextLoc() = { cnt = cnt + 1; cnt };
+ private var cnt: int = 64
+ def nextLoc() = { cnt = cnt + 1; cnt }
}
class UnPicklerEnv extends HashMap[int, Any] {
- private var cnt: int = 64;
- def nextLoc() = { cnt = cnt + 1; cnt };
+ private var cnt: int = 64
+ def nextLoc() = { cnt = cnt + 1; cnt }
}
- class PicklerState(val stream: Array[byte], val dict: PicklerEnv) {}
- class UnPicklerState(val stream: Array[byte], val dict: UnPicklerEnv) {}
+ class PicklerState(val stream: Array[byte], val dict: PicklerEnv)
+ class UnPicklerState(val stream: Array[byte], val dict: UnPicklerEnv)
- abstract class RefDef;
- case class Ref() extends RefDef;
- case class Def() extends RefDef;
+ abstract class RefDef
+ case class Ref() extends RefDef
+ case class Def() extends RefDef
def refDef: PU[RefDef] = new PU[RefDef] {
def appP(b: RefDef, s: Array[byte]): Array[byte] =
@@ -97,7 +109,7 @@ object BytePickle {
pe.get(v) match {
case None =>
//Console.println("" + v + " is new")
- //Console.println("writing DEF...")
+ //Console.println("writing DEF...")
val sPrime = refDef.appP(Def(), state.stream)
val l = pe.nextLoc()
@@ -195,21 +207,21 @@ object BytePickle {
}
def upair[a,b](pa: PU[a], pb: PU[b]): PU[Pair[a,b]] = {
- def fst(p: Pair[a,b]): a = p._1;
- def snd(p: Pair[a,b]): b = p._2;
+ def fst(p: Pair[a,b]): a = p._1
+ def snd(p: Pair[a,b]): b = p._2
usequ(fst, pa, (x: a) => usequ(snd, pb, (y: b) => ulift(Pair(x, y))))
}
def pair[a,b](pa: SPU[a], pb: SPU[b]): SPU[Pair[a,b]] = {
- def fst(p: Pair[a,b]): a = p._1;
- def snd(p: Pair[a,b]): b = p._2;
+ def fst(p: Pair[a,b]): a = p._1
+ def snd(p: Pair[a,b]): b = p._2
sequ(fst, pa, (x: a) => sequ(snd, pb, (y: b) => lift(Pair(x, y))))
}
def triple[a,b,c](pa: SPU[a], pb: SPU[b], pc: SPU[c]): SPU[Triple[a,b,c]] = {
- def fst(p: Triple[a,b,c]): a = p._1;
- def snd(p: Triple[a,b,c]): b = p._2;
- def trd(p: Triple[a,b,c]): c = p._3;
+ def fst(p: Triple[a,b,c]): a = p._1
+ def snd(p: Triple[a,b,c]): b = p._2
+ def trd(p: Triple[a,b,c]): c = p._3
sequ(fst, pa,
(x: a) => sequ(snd, pb,
@@ -218,14 +230,13 @@ object BytePickle {
}
def uwrap[a,b](i: a => b, j: b => a, pa: PU[a]): PU[b] =
- usequ(j, pa, (x: a) => ulift(i(x)));
+ usequ(j, pa, (x: a) => ulift(i(x)))
def wrap[a,b](i: a => b, j: b => a, pa: SPU[a]): SPU[b] =
- sequ(j, pa, (x: a) => lift(i(x)));
+ sequ(j, pa, (x: a) => lift(i(x)))
- def appendByte(a: Array[byte], b: int): Array[byte] = {
+ def appendByte(a: Array[byte], b: int): Array[byte] =
Array.concat(a, (List[byte](b.asInstanceOf[byte])).toArray)
- }
def nat2Bytes(x: int): Array[byte] = {
val buf = new ArrayBuffer[byte]
@@ -247,8 +258,8 @@ object BytePickle {
def appU(s: UnPicklerState): Pair[int,UnPicklerState] = {
var num = 0
def readNat: int = {
- var b = 0;
- var x = 0;
+ var b = 0
+ var x = 0
do {
b = s.stream(num)
num = num + 1
@@ -275,8 +286,8 @@ object BytePickle {
}
def bool: SPU[boolean] = {
- def toEnum(b: boolean) = if (b) 1 else 0;
- def fromEnum(n: int) = if (n == 0) false else true;
+ def toEnum(b: boolean) = if (b) 1 else 0
+ def fromEnum(n: int) = if (n == 0) false else true
wrap(fromEnum, toEnum, nat)
}
diff --git a/src/library/scala/io/Position.scala b/src/library/scala/io/Position.scala
index 6cb952d378..6c7d6bbb83 100644
--- a/src/library/scala/io/Position.scala
+++ b/src/library/scala/io/Position.scala
@@ -9,9 +9,9 @@
// $Id$
-package scala.io;
+package scala.io
-import scala.runtime.compat.StringBuilder;
+import scala.runtime.compat.StringBuilder
/** convenience methods to encode line and column number in one
* single integer. The encode line (column)
@@ -34,41 +34,41 @@ import scala.runtime.compat.StringBuilder;
object Position {
/** Number of bits used to encode the line number */
- final val LINE_BITS = 20;
+ final val LINE_BITS = 20
/** Number of bits used to encode the column number */
- final val COLUMN_BITS = 31 - LINE_BITS; // no negatives => 31
+ final val COLUMN_BITS = 31 - LINE_BITS // no negatives => 31
/** Mask to decode the line number */
- final val LINE_MASK = (1 << LINE_BITS) - 1;
+ final val LINE_MASK = (1 << LINE_BITS) - 1
/** Mask to decode the column number */
- final val COLUMN_MASK = (1 << COLUMN_BITS) - 1;
+ final val COLUMN_MASK = (1 << COLUMN_BITS) - 1
/** The undefined position */
- final val NOPOS = 0;
+ final val NOPOS = 0
/** The first position in a source file */
- final val FIRSTPOS = encode(1, 1);
+ final val FIRSTPOS = encode(1, 1)
//########################################################################
// Public Functions
/** Encodes a position into a single integer. */
final def encode(line: Int, column: Int): Int = {
- var line1, column1 = 0;
- if( line < 0 )
- error(line+" < 0");
- if(( line == 0 )&&(column != 0))
- error(line+","+column+" not allowed");
- if( column < 0 )
- error(line+","+column+" not allowed");
+ var line1, column1 = 0
+ if (line < 0)
+ error(line + " < 0")
+ if ((line == 0) && (column != 0))
+ error(line + "," + column + " not allowed")
+ if (column < 0)
+ error(line + "," + column + " not allowed")
{if (line >= LINE_MASK) {
- line1 = LINE_MASK;
- column1 = 0;
+ line1 = LINE_MASK
+ column1 = 0
} else {
- line1 = line;
+ line1 = line
if (column > COLUMN_MASK)
- column1 = COLUMN_MASK;
+ column1 = COLUMN_MASK
else
column1 = column
}}
@@ -76,21 +76,19 @@ object Position {
}
/** Returns the line number of the encoded position. */
- final def line(pos: Int): Int = {
- (pos >> COLUMN_BITS) & LINE_MASK;
- }
+ final def line(pos: Int): Int =
+ (pos >> COLUMN_BITS) & LINE_MASK
/** Returns the column number of the encoded position. */
- final def column(pos: Int): Int = {
- pos & COLUMN_MASK;
- }
+ final def column(pos: Int): Int =
+ pos & COLUMN_MASK
/** Returns a string representation of the encoded position. */
def toString(pos: Int): String = {
- val sb = new StringBuilder();
- sb.append(line(pos));
- sb.append(':');
- sb.append(column(pos));
- sb.toString();
+ val sb = new StringBuilder()
+ sb.append(line(pos))
+ sb.append(':')
+ sb.append(column(pos))
+ sb.toString()
}
}
diff --git a/src/library/scala/io/Source.scala b/src/library/scala/io/Source.scala
index f9d1975bc2..d0e7faf2bd 100644
--- a/src/library/scala/io/Source.scala
+++ b/src/library/scala/io/Source.scala
@@ -9,51 +9,58 @@
// $Id$
-package scala.io;
+package scala.io
import scala.runtime.compat.StringBuilder;
import java.io.{ File, FileInputStream, PrintStream };
/** convenience methods to create an iterable representation of a source
- * file
- * @author buraq
+ * file.
+ *
+ * @author Burak Emir
+ * @version 1.0, 19/08/2004
*/
object Source {
/** creates Source from array of bytes, with empty description
*/
def fromBytes(bytes: Array[Byte]): Source =
- fromString(new String(bytes));
-
- /** creates Source from array of bytes with given encoding, with empty description
+ fromString(new String(bytes))
+
+ /** creates Source from array of bytes with given encoding, with
+ * empty description.
+ *
+ * @param bytes ...
+ * @param enc ...
+ * @return ...
*/
def fromBytes(bytes: Array[Byte], enc: String): Source =
- fromString(new String(bytes, enc));
+ fromString(new String(bytes, enc))
/** creates Source from a single char */
def fromChar(c: Char): Source = {
- val it = Iterator.single(c);
+ val it = Iterator.single(c)
new Source {
- def reset = fromChar(c);
- val iter = it;
+ def reset = fromChar(c)
+ val iter = it
}
}
/** creates Source from array of characters, with empty description
*/
def fromChars(chars: Array[Char]): Source = {
- val it = Iterator.fromArray(chars);
+ val it = Iterator.fromArray(chars)
new Source {
- def reset = fromChars(chars);
- val iter = it;
+ def reset = fromChars(chars)
+ val iter = it
}
}
/** creates Source from string, with empty description
*/
def fromString(s: String): Source = {
- val it = Iterator.fromString(s);
+ val it = Iterator.fromString(s)
new Source {
- def reset = fromString(s);
- val iter = it;
+ def reset = fromString(s)
+ val iter = it
}
}
@@ -61,40 +68,40 @@ object Source {
* filename.
*/
def fromFile(name: String): Source =
- fromFile( new File( name ));
+ fromFile(new File(name))
/** creates Source from file with given name, using given encoding, setting
* its description to filename.
*/
def fromFile(name: String, enc: String): Source =
- fromFile( new File( name ), enc);
+ fromFile(new File(name), enc)
/** creates Source from file with given file: URI
*/
def fromFile(uri: java.net.URI): Source =
- fromFile(new File(uri));
+ fromFile(new File(uri))
/** creates Source from file, using default character encoding, setting its
* description to filename.
*/
def fromFile(file: java.io.File): Source = {
- val arr: Array[Byte] = new Array[Byte]( file.length().asInstanceOf[Int] );
- val is = new FileInputStream( file );
- is.read( arr );
- val s = fromBytes(arr);
- return setFileDescriptor(file,s);
+ val arr: Array[Byte] = new Array[Byte](file.length().asInstanceOf[Int])
+ val is = new FileInputStream(file)
+ is.read(arr)
+ val s = fromBytes(arr)
+ return setFileDescriptor(file, s)
}
/** creates Source from file, using given character encoding, setting its
* description to filename.
*/
def fromFile(file: java.io.File, enc: String): Source = {
- val arr: Array[Byte] = new Array[Byte]( file.length().asInstanceOf[Int] );
- val is = new FileInputStream( file );
- is.read( arr );
- val s = fromBytes(arr, enc);
- s.descr = file.getName();
- return setFileDescriptor(file,s);
+ val arr: Array[Byte] = new Array[Byte](file.length().asInstanceOf[Int])
+ val is = new FileInputStream(file)
+ is.read(arr)
+ val s = fromBytes(arr, enc)
+ s.descr = file.getName()
+ return setFileDescriptor(file, s)
}
def setFileDescriptor(file: File, s: Source): Source = {
@@ -103,22 +110,22 @@ object Source {
}
def fromURL(s:String): Source =
- fromURL(new java.net.URL(s));
+ fromURL(new java.net.URL(s))
def fromURL(url: java.net.URL): Source = {
val it = new Iterator[Char] {
- var data: Int = _;
- def hasNext = {data != -1};
+ var data: Int = _
+ def hasNext = {data != -1}
def next = {val x = data.asInstanceOf[char]; data = bufIn.read(); x}
- val in = url.openStream();
- val bufIn = new java.io.BufferedInputStream(in);
+ val in = url.openStream()
+ val bufIn = new java.io.BufferedInputStream(in)
data = bufIn.read()
}
val s = new Source {
- def reset = fromURL(url);
- val iter = it;
- };
- s.descr = url.toString();
+ def reset = fromURL(url)
+ val iter = it
+ }
+ s.descr = url.toString()
s
}
@@ -135,30 +142,30 @@ abstract class Source extends Iterator[Char] {
// ------ protected values
/** the actual iterator */
- protected val iter: Iterator[Char];
+ protected val iter: Iterator[Char]
- protected var cline = 1;
- protected var ccol = 1;
+ protected var cline = 1
+ protected var ccol = 1
// ------ public values
/** position of last character returned by next*/
- var pos = 0;
+ var pos = 0
/** the last character returned by next.
* the value before the first call to next is undefined.
*/
- var ch: Char = _;
+ var ch: Char = _
/** description of this source, default empty */
- var descr: String = "";
+ var descr: String = ""
- var nerrors = 0;
- var nwarnings = 0;
+ var nerrors = 0
+ var nwarnings = 0
/** default col increment for tabs '\t', set to 4 initially
*/
- var tabinc = 4;
+ var tabinc = 4
//
// -- methods
@@ -168,83 +175,82 @@ abstract class Source extends Iterator[Char] {
* from Source
*/
def getLine(line: Int): String = {
- val buf = new StringBuffer();
- val it = reset;
- var i = 0;
+ val buf = new StringBuffer()
+ val it = reset
+ var i = 0
while( it.hasNext && i < (line-1))
if('\n' == it.next)
- i = i + 1;
+ i = i + 1;
if(!it.hasNext) // this should not happen
throw new java.lang.IllegalArgumentException(
"line "+line+" does not exist?!"
);
- var ch = it.next;
+ var ch = it.next
while(it.hasNext && '\n' != ch) {
- buf.append( ch );
- ch = it.next;
+ buf.append(ch)
+ ch = it.next
}
- val res = buf.toString();
- buf.setLength( 0 );
+ val res = buf.toString()
+ buf.setLength(0)
res
}
/** returns true if this source has more characters
*/
- def hasNext = iter.hasNext;
+ def hasNext = iter.hasNext
/** returns next character and has the following side-effects: updates
* position (ccol and cline) and assigns the character to ch
*/
def next = {
- ch = iter.next;
- pos = Position.encode(cline,ccol);
+ ch = iter.next
+ pos = Position.encode(cline,ccol)
ch match {
case '\n' =>
- ccol = 1;
- cline = cline + 1;
+ ccol = 1
+ cline = cline + 1
case '\t' =>
- ccol = ccol + tabinc;
+ ccol = ccol + tabinc
case _ =>
- ccol = ccol + 1;
+ ccol = ccol + 1
}
ch
- };
-
+ }
/** reports an error message to console */
def reportError(pos: Int, msg: String): Unit =
- report(pos, msg, java.lang.System.out);
+ report(pos, msg, java.lang.System.out)
def reportError(pos: Int, msg: String, out: PrintStream): Unit = {
- nerrors = nerrors + 1;
- report(pos, msg, java.lang.System.out);
+ nerrors = nerrors + 1
+ report(pos, msg, java.lang.System.out)
}
def report(pos: Int, msg: String, out: PrintStream): Unit = {
- val line = Position.line(pos);
- val col = Position.column(pos);
- Console.println(descr+":"+line+":"+col+": "+msg);
- Console.println(getLine(line));
- var i = 1;
- while( i < col ) {
- Console.print(' ');
- i = i + 1;
+ val line = Position.line(pos)
+ val col = Position.column(pos)
+ Console.println(descr+":"+line+":"+col+": "+msg)
+ Console.println(getLine(line))
+ var i = 1
+ while (i < col) {
+ Console.print(' ')
+ i = i + 1
}
- Console.println('^');
+ Console.println('^')
}
/** reports a warning message to java.lang.System.out */
def reportWarning(pos: Int, msg: String): Unit =
- reportWarning(pos, msg, java.lang.System.out);
+ reportWarning(pos, msg, java.lang.System.out)
def reportWarning(pos: Int, msg: String, out: PrintStream): Unit = {
- nwarnings = nwarnings + 1;
- report(pos, "warning! "+msg, out);
+ nwarnings = nwarnings + 1
+ report(pos, "warning! "+msg, out)
}
/** the actual reset method */
- def reset: Source;
+ def reset: Source
}
diff --git a/src/library/scala/io/UTF8Codec.scala b/src/library/scala/io/UTF8Codec.scala
index 3ff0fefe8e..729e79586e 100644
--- a/src/library/scala/io/UTF8Codec.scala
+++ b/src/library/scala/io/UTF8Codec.scala
@@ -1,78 +1,83 @@
-/* ____ ____ ____ ____ ______ *\
-** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
-** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002-2006, LAMP/EPFL **
-** /_____/\____/\___/\____/____/ **
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
\* */
// $Id$
-package scala.io;
-
+package scala.io
+/**
+ * @author Martin Odersky
+ * @version 1.0, 04/10/2004
+ */
object UTF8Codec {
def encode(src: Array[Char], from: Int, dst: Array[Byte], to: Int, len: Int): Int = {
- var i = from;
- var j = to;
- val end = from + len;
+ var i = from
+ var j = to
+ val end = from + len
while (i < end) {
- val ch = src(i);
- i = i + 1;
+ val ch = src(i)
+ i = i + 1
if (ch < 128) {
- dst(j) = ch.toByte;
- j = j + 1;
+ dst(j) = ch.toByte
+ j = j + 1
}
else if (ch <= 0x3FF) {
- dst(j) = (0xC0 | (ch >> 6)).toByte;
- dst(j+1) = (0x80 | (ch & 0x3F)).toByte;
- j = j + 2;
+ dst(j) = (0xC0 | (ch >> 6)).toByte
+ dst(j+1) = (0x80 | (ch & 0x3F)).toByte
+ j = j + 2
} else {
- dst(j) = (0xE0 | (ch >> 12)).toByte;
- dst(j+1) = (0x80 | ((ch >> 6) & 0x3F)).toByte;
- dst(j+2) = (0x80 | (ch & 0x3F)).toByte;
- j = j + 3;
+ dst(j) = (0xE0 | (ch >> 12)).toByte
+ dst(j+1) = (0x80 | ((ch >> 6) & 0x3F)).toByte
+ dst(j+2) = (0x80 | (ch & 0x3F)).toByte
+ j = j + 3
}
}
j
}
def encode(s: String, dst: Array[Byte], to: Int): Int =
- encode(s.toCharArray(), 0, dst, to, s.length());
+ encode(s.toCharArray(), 0, dst, to, s.length())
def encode(s: String): Array[Byte] = {
- val dst = new Array[Byte](s.length() * 3);
- val len = encode(s, dst, 0);
+ val dst = new Array[Byte](s.length() * 3)
+ val len = encode(s, dst, 0)
dst.subArray(0, len)
}
def decode(src: Array[Byte], from: Int,
dst: Array[Char], to: Int, len: Int): Int =
{
- var i = from;
- var j = to;
- val end = from + len;
+ var i = from
+ var j = to
+ val end = from + len
while (i < end) {
- var b = src(i) & 0xFF;
- i = i + 1;
+ var b = src(i) & 0xFF
+ i = i + 1
if (b >= 0xE0) {
- b = ((b & 0x0F) << 12) | (src(i) & 0x3F) << 6;
- b = b | (src(i+1) & 0x3F);
- i = i + 2;
+ b = ((b & 0x0F) << 12) | (src(i) & 0x3F) << 6
+ b = b | (src(i+1) & 0x3F)
+ i = i + 2
} else if (b >= 0xC0) {
- b = ((b & 0x1F) << 6) | (src(i) & 0x3F);
- i = i + 1;
+ b = ((b & 0x1F) << 6) | (src(i) & 0x3F)
+ i = i + 1
}
- dst(j) = b.toChar;
- j = j + 1;
+ dst(j) = b.toChar
+ j = j + 1
}
j
}
def decode(src: Array[Byte], from: Int, len: Int): String = {
- val cs = new Array[Char](len);
- String.copyValueOf(cs, 0, decode(src, 0, cs, 0, len));
+ val cs = new Array[Char](len)
+ String.copyValueOf(cs, 0, decode(src, 0, cs, 0, len))
}
}