150 if (this == Bytes(s)) (false, s) else (true, base64) |
150 if (this == Bytes(s)) (false, s) else (true, base64) |
151 } |
151 } |
152 |
152 |
153 override def toString: String = "Bytes(" + length + ")" |
153 override def toString: String = "Bytes(" + length + ")" |
154 |
154 |
155 def isEmpty: Boolean = length == 0 |
155 def proper: Option[Bytes] = if (is_empty) None else Some(this) |
156 |
156 def proper_text: Option[String] = if (is_empty) None else Some(text) |
157 def proper: Option[Bytes] = if (isEmpty) None else Some(this) |
|
158 def proper_text: Option[String] = if (isEmpty) None else Some(text) |
|
159 |
157 |
160 def +(other: Bytes): Bytes = |
158 def +(other: Bytes): Bytes = |
161 if (other.isEmpty) this |
159 if (other.is_empty) this |
162 else if (isEmpty) other |
160 else if (is_empty) other |
163 else { |
161 else { |
164 val new_bytes = new Array[Byte](length + other.length) |
162 val new_bytes = new Array[Byte](length + other.length) |
165 System.arraycopy(bytes, offset, new_bytes, 0, length) |
163 System.arraycopy(bytes, offset, new_bytes, 0, length) |
166 System.arraycopy(other.bytes, other.offset, new_bytes, length, other.length) |
164 System.arraycopy(other.bytes, other.offset, new_bytes, length, other.length) |
167 new Bytes(new_bytes, 0, new_bytes.length) |
165 new Bytes(new_bytes, 0, new_bytes.length) |