akka.util
Class ByteString
java.lang.Object
akka.util.ByteString
- All Implemented Interfaces:
- scala.collection.generic.FilterMonadic<java.lang.Object,ByteString>, scala.collection.generic.GenericTraversableTemplate<java.lang.Object,scala.collection.immutable.IndexedSeq>, scala.collection.generic.HasNewBuilder<java.lang.Object,ByteString>, scala.collection.GenIterable<java.lang.Object>, scala.collection.GenIterableLike<java.lang.Object,ByteString>, scala.collection.GenSeq<java.lang.Object>, scala.collection.GenSeqLike<java.lang.Object,ByteString>, scala.collection.GenTraversable<java.lang.Object>, scala.collection.GenTraversableLike<java.lang.Object,ByteString>, scala.collection.GenTraversableOnce<java.lang.Object>, scala.collection.IndexedSeq<java.lang.Object>, scala.collection.IndexedSeqLike<java.lang.Object,ByteString>, scala.collection.IndexedSeqOptimized<java.lang.Object,ByteString>, scala.collection.Iterable<java.lang.Object>, scala.collection.IterableLike<java.lang.Object,ByteString>, scala.collection.Parallelizable<java.lang.Object,scala.collection.parallel.ParSeq<java.lang.Object>>, scala.collection.Seq<java.lang.Object>, scala.collection.SeqLike<java.lang.Object,ByteString>, scala.collection.Traversable<java.lang.Object>, scala.collection.TraversableLike<java.lang.Object,ByteString>, scala.collection.TraversableOnce<java.lang.Object>, scala.Equals, scala.Function1<java.lang.Object,java.lang.Object>, scala.Immutable, scala.PartialFunction<java.lang.Object,java.lang.Object>
- Direct Known Subclasses:
- ByteString.ByteString1, ByteString.ByteStrings, CompactByteString
public abstract class ByteString
- extends java.lang.Object
- implements scala.collection.immutable.IndexedSeq<java.lang.Object>, scala.collection.IndexedSeqOptimized<java.lang.Object,ByteString>
A rope-like immutable data structure containing bytes.
The goal of this structure is to reduce copying of arrays
when concatenating and slicing sequences of bytes,
and also providing a thread safe way of working with bytes.
TODO: Add performance characteristics
| Nested classes/interfaces inherited from interface scala.collection.immutable.IndexedSeq |
scala.collection.immutable.IndexedSeq.Impl<A> |
| Nested classes/interfaces inherited from interface scala.PartialFunction |
scala.PartialFunction.AndThen<A,B,C>, scala.PartialFunction.Lifted<A,B>, scala.PartialFunction.OrElse<A,B>, scala.PartialFunction.Unlifted<A,B> |
| Nested classes/interfaces inherited from interface scala.collection.IndexedSeqLike |
scala.collection.IndexedSeqLike.Elements |
| Nested classes/interfaces inherited from interface scala.collection.SeqLike |
scala.collection.SeqLike.CombinationsItr, scala.collection.SeqLike.PermutationsItr |
| Nested classes/interfaces inherited from interface scala.collection.TraversableLike |
scala.collection.TraversableLike.WithFilter |
| Nested classes/interfaces inherited from interface scala.collection.TraversableOnce |
scala.collection.TraversableOnce.BufferedCanBuildFrom<A,Coll extends scala.collection.TraversableOnce<java.lang.Object>>, scala.collection.TraversableOnce.FlattenOps<A>, scala.collection.TraversableOnce.ForceImplicitAmbiguity, scala.collection.TraversableOnce.MonadOps<A>, scala.collection.TraversableOnce.OnceCanBuildFrom<A> |
|
Method Summary |
abstract byte |
apply(int idx)
|
abstract java.nio.ByteBuffer |
asByteBuffer()
Returns a read-only ByteBuffer that directly wraps this ByteString
if it is not fragmented. |
static scala.collection.generic.CanBuildFrom<scala.collection.TraversableOnce<java.lang.Object>,java.lang.Object,ByteString> |
canBuildFrom()
|
abstract CompactByteString |
compact()
Create a new ByteString with all contents compacted into a single,
full byte array. |
|
copyToArray(java.lang.Object xs,
int start,
int len)
|
int |
copyToBuffer(java.nio.ByteBuffer buffer)
Copy as many bytes as possible to a ByteBuffer, starting from it's
current position. |
abstract java.lang.String |
decodeString(java.lang.String charset)
Decodes this ByteString using a charset to produce a String. |
ByteString |
drop(int n)
|
ByteString |
dropRight(int n)
|
ByteString |
dropWhile(scala.Function1<java.lang.Object,java.lang.Object> p)
|
static ByteString |
empty()
|
|
foreach(scala.Function1<java.lang.Object,U> f)
|
static ByteString |
fromArray(byte[] array,
int offset,
int length)
Creates a new ByteString by copying length bytes starting at offset from
an Array. |
byte |
head()
|
|
indexOf(B elem)
|
int |
indexWhere(scala.Function1<java.lang.Object,java.lang.Object> p)
|
ByteString |
init()
|
abstract boolean |
isCompact()
Check whether this ByteString is compact in memory. |
ByteIterator |
iterator()
|
byte |
last()
|
ByteString |
mapI(scala.Function1<java.lang.Object,java.lang.Object> f)
map method that will automatically cast Int back into Byte. |
protected ByteStringBuilder |
newBuilder()
|
ByteString |
slice(int from,
int until)
|
scala.Tuple2<ByteString,ByteString> |
span(scala.Function1<java.lang.Object,java.lang.Object> p)
|
scala.Tuple2<ByteString,ByteString> |
splitAt(int n)
|
ByteString |
tail()
|
ByteString |
take(int n)
|
ByteString |
takeRight(int n)
|
ByteString |
takeWhile(scala.Function1<java.lang.Object,java.lang.Object> p)
|
|
toArray(scala.reflect.ClassTag<B> arg0)
|
java.nio.ByteBuffer |
toByteBuffer()
Creates a new ByteBuffer with a copy of all bytes contained in this
ByteString. |
java.lang.String |
utf8String()
Decodes this ByteString as a UTF-8 encoded String. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface scala.collection.immutable.IndexedSeq |
companion, seq, toIndexedSeq |
| Methods inherited from interface scala.collection.immutable.Seq |
parCombiner, toSeq |
| Methods inherited from interface scala.PartialFunction |
andThen, applyOrElse, isDefinedAt, lift, orElse, runWith |
| Methods inherited from interface scala.Function1 |
andThen$mcDD$sp, andThen$mcDF$sp, andThen$mcDI$sp, andThen$mcDJ$sp, andThen$mcFD$sp, andThen$mcFF$sp, andThen$mcFI$sp, andThen$mcFJ$sp, andThen$mcID$sp, andThen$mcIF$sp, andThen$mcII$sp, andThen$mcIJ$sp, andThen$mcJD$sp, andThen$mcJF$sp, andThen$mcJI$sp, andThen$mcJJ$sp, andThen$mcVD$sp, andThen$mcVF$sp, andThen$mcVI$sp, andThen$mcVJ$sp, andThen$mcZD$sp, andThen$mcZF$sp, andThen$mcZI$sp, andThen$mcZJ$sp, apply, apply$mcDD$sp, apply$mcDF$sp, apply$mcDI$sp, apply$mcDJ$sp, apply$mcFD$sp, apply$mcFF$sp, apply$mcFI$sp, apply$mcFJ$sp, apply$mcID$sp, apply$mcIF$sp, apply$mcII$sp, apply$mcIJ$sp, apply$mcJD$sp, apply$mcJF$sp, apply$mcJI$sp, apply$mcJJ$sp, apply$mcVD$sp, apply$mcVF$sp, apply$mcVI$sp, apply$mcVJ$sp, apply$mcZD$sp, apply$mcZF$sp, apply$mcZI$sp, apply$mcZJ$sp, compose, compose$mcDD$sp, compose$mcDF$sp, compose$mcDI$sp, compose$mcDJ$sp, compose$mcFD$sp, compose$mcFF$sp, compose$mcFI$sp, compose$mcFJ$sp, compose$mcID$sp, compose$mcIF$sp, compose$mcII$sp, compose$mcIJ$sp, compose$mcJD$sp, compose$mcJF$sp, compose$mcJI$sp, compose$mcJJ$sp, compose$mcVD$sp, compose$mcVF$sp, compose$mcVI$sp, compose$mcVJ$sp, compose$mcZD$sp, compose$mcZF$sp, compose$mcZI$sp, compose$mcZJ$sp, toString |
| Methods inherited from interface scala.collection.IndexedSeqLike |
hashCode, thisCollection, toBuffer, toCollection |
| Methods inherited from interface scala.collection.SeqLike |
$colon$plus, $plus$colon, combinations, contains, containsSlice, corresponds, diff, distinct, endsWith, indexOfSlice, indexOfSlice, indexWhere, indices, intersect, isEmpty, lastIndexOfSlice, lastIndexOfSlice, lastIndexWhere, length, lengthCompare, padTo, patch, permutations, reverse, reverseIterator, reverseMap, segmentLength, size, sortBy, sorted, sortWith, startsWith, toString, union, updated, view, view |
| Methods inherited from interface scala.collection.IterableLike |
canEqual, exists, find, foldRight, forall, grouped, reduceRight, sameElements, sliding, sliding, toIterable, toIterator, toStream, zip, zipAll, zipWithIndex |
| Methods inherited from interface scala.collection.TraversableLike |
$plus$plus, $plus$plus$colon, $plus$plus$colon, collect, filter, filterNot, flatMap, groupBy, hasDefiniteSize, headOption, inits, isTraversableAgain, lastOption, map, partition, repr, scan, scanLeft, scanRight, sliceWithKnownBound, sliceWithKnownDelta, stringPrefix, tails, to, toTraversable, withFilter |
| Methods inherited from interface scala.collection.TraversableOnce |
$colon$bslash, $div$colon, addString, addString, addString, aggregate, collectFirst, copyToArray, copyToArray, copyToBuffer, count, fold, foldLeft, max, maxBy, min, minBy, mkString, mkString, mkString, nonEmpty, product, reduce, reduceLeft, reduceLeftOption, reduceOption, reduceRightOption, reversed, sum, toList, toMap, toSet, toVector |
| Methods inherited from interface scala.collection.GenSeqLike |
equals, indexOf, isDefinedAt, lastIndexOf, lastIndexOf, lastIndexWhere, prefixLength, startsWith |
| Methods inherited from interface scala.collection.GenTraversableOnce |
$div$colon$bslash |
| Methods inherited from interface scala.collection.Parallelizable |
par |
| Methods inherited from interface scala.collection.IndexedSeqOptimized |
endsWith, exists, find, foldLeft, foldRight, forall, indexWhere, isEmpty, lastIndexWhere, lengthCompare, reduceLeft, reduceRight, reverse, reverseIterator, sameElements, scala$collection$IndexedSeqOptimized$$super$endsWith, scala$collection$IndexedSeqOptimized$$super$head, scala$collection$IndexedSeqOptimized$$super$init, scala$collection$IndexedSeqOptimized$$super$last, scala$collection$IndexedSeqOptimized$$super$reduceLeft, scala$collection$IndexedSeqOptimized$$super$reduceRight, scala$collection$IndexedSeqOptimized$$super$sameElements, scala$collection$IndexedSeqOptimized$$super$tail, scala$collection$IndexedSeqOptimized$$super$zip, segmentLength, startsWith, zip, zipWithIndex |
ByteString
public ByteString()
fromArray
public static ByteString fromArray(byte[] array,
int offset,
int length)
- Creates a new ByteString by copying length bytes starting at offset from
an Array.
empty
public static ByteString empty()
canBuildFrom
public static scala.collection.generic.CanBuildFrom<scala.collection.TraversableOnce<java.lang.Object>,java.lang.Object,ByteString> canBuildFrom()
apply
public abstract byte apply(int idx)
- Specified by:
apply in interface scala.collection.GenSeqLike<java.lang.Object,ByteString>- Specified by:
apply in interface scala.collection.SeqLike<java.lang.Object,ByteString>
newBuilder
protected ByteStringBuilder newBuilder()
- Specified by:
newBuilder in interface scala.collection.generic.GenericTraversableTemplate<java.lang.Object,scala.collection.immutable.IndexedSeq>- Specified by:
newBuilder in interface scala.collection.generic.HasNewBuilder<java.lang.Object,ByteString>- Specified by:
newBuilder in interface scala.collection.TraversableLike<java.lang.Object,ByteString>
iterator
public ByteIterator iterator()
- Specified by:
iterator in interface scala.collection.GenIterableLike<java.lang.Object,ByteString>- Specified by:
iterator in interface scala.collection.IndexedSeqLike<java.lang.Object,ByteString>- Specified by:
iterator in interface scala.collection.IterableLike<java.lang.Object,ByteString>
head
public byte head()
- Specified by:
head in interface scala.collection.generic.GenericTraversableTemplate<java.lang.Object,scala.collection.immutable.IndexedSeq>- Specified by:
head in interface scala.collection.GenTraversableLike<java.lang.Object,ByteString>- Specified by:
head in interface scala.collection.IndexedSeqOptimized<java.lang.Object,ByteString>- Specified by:
head in interface scala.collection.IterableLike<java.lang.Object,ByteString>- Specified by:
head in interface scala.collection.TraversableLike<java.lang.Object,ByteString>
tail
public ByteString tail()
- Specified by:
tail in interface scala.collection.GenTraversableLike<java.lang.Object,ByteString>- Specified by:
tail in interface scala.collection.IndexedSeqOptimized<java.lang.Object,ByteString>- Specified by:
tail in interface scala.collection.TraversableLike<java.lang.Object,ByteString>
last
public byte last()
- Specified by:
last in interface scala.collection.GenTraversableLike<java.lang.Object,ByteString>- Specified by:
last in interface scala.collection.IndexedSeqOptimized<java.lang.Object,ByteString>- Specified by:
last in interface scala.collection.TraversableLike<java.lang.Object,ByteString>
init
public ByteString init()
- Specified by:
init in interface scala.collection.GenTraversableLike<java.lang.Object,ByteString>- Specified by:
init in interface scala.collection.IndexedSeqOptimized<java.lang.Object,ByteString>- Specified by:
init in interface scala.collection.TraversableLike<java.lang.Object,ByteString>
slice
public ByteString slice(int from,
int until)
- Specified by:
slice in interface scala.collection.GenTraversableLike<java.lang.Object,ByteString>- Specified by:
slice in interface scala.collection.IndexedSeqOptimized<java.lang.Object,ByteString>- Specified by:
slice in interface scala.collection.IterableLike<java.lang.Object,ByteString>- Specified by:
slice in interface scala.collection.TraversableLike<java.lang.Object,ByteString>
take
public ByteString take(int n)
- Specified by:
take in interface scala.collection.GenTraversableLike<java.lang.Object,ByteString>- Specified by:
take in interface scala.collection.IndexedSeqOptimized<java.lang.Object,ByteString>- Specified by:
take in interface scala.collection.IterableLike<java.lang.Object,ByteString>- Specified by:
take in interface scala.collection.TraversableLike<java.lang.Object,ByteString>
takeRight
public ByteString takeRight(int n)
- Specified by:
takeRight in interface scala.collection.IndexedSeqOptimized<java.lang.Object,ByteString>- Specified by:
takeRight in interface scala.collection.IterableLike<java.lang.Object,ByteString>
drop
public ByteString drop(int n)
- Specified by:
drop in interface scala.collection.GenTraversableLike<java.lang.Object,ByteString>- Specified by:
drop in interface scala.collection.IndexedSeqOptimized<java.lang.Object,ByteString>- Specified by:
drop in interface scala.collection.IterableLike<java.lang.Object,ByteString>- Specified by:
drop in interface scala.collection.TraversableLike<java.lang.Object,ByteString>
dropRight
public ByteString dropRight(int n)
- Specified by:
dropRight in interface scala.collection.IndexedSeqOptimized<java.lang.Object,ByteString>- Specified by:
dropRight in interface scala.collection.IterableLike<java.lang.Object,ByteString>
takeWhile
public ByteString takeWhile(scala.Function1<java.lang.Object,java.lang.Object> p)
- Specified by:
takeWhile in interface scala.collection.GenTraversableLike<java.lang.Object,ByteString>- Specified by:
takeWhile in interface scala.collection.IndexedSeqOptimized<java.lang.Object,ByteString>- Specified by:
takeWhile in interface scala.collection.IterableLike<java.lang.Object,ByteString>- Specified by:
takeWhile in interface scala.collection.TraversableLike<java.lang.Object,ByteString>
dropWhile
public ByteString dropWhile(scala.Function1<java.lang.Object,java.lang.Object> p)
- Specified by:
dropWhile in interface scala.collection.GenTraversableLike<java.lang.Object,ByteString>- Specified by:
dropWhile in interface scala.collection.IndexedSeqOptimized<java.lang.Object,ByteString>- Specified by:
dropWhile in interface scala.collection.TraversableLike<java.lang.Object,ByteString>
span
public scala.Tuple2<ByteString,ByteString> span(scala.Function1<java.lang.Object,java.lang.Object> p)
- Specified by:
span in interface scala.collection.GenTraversableLike<java.lang.Object,ByteString>- Specified by:
span in interface scala.collection.IndexedSeqOptimized<java.lang.Object,ByteString>- Specified by:
span in interface scala.collection.TraversableLike<java.lang.Object,ByteString>
splitAt
public scala.Tuple2<ByteString,ByteString> splitAt(int n)
- Specified by:
splitAt in interface scala.collection.GenTraversableLike<java.lang.Object,ByteString>- Specified by:
splitAt in interface scala.collection.IndexedSeqOptimized<java.lang.Object,ByteString>- Specified by:
splitAt in interface scala.collection.TraversableLike<java.lang.Object,ByteString>
indexWhere
public int indexWhere(scala.Function1<java.lang.Object,java.lang.Object> p)
- Specified by:
indexWhere in interface scala.collection.GenSeqLike<java.lang.Object,ByteString>
indexOf
public <B> int indexOf(B elem)
- Specified by:
indexOf in interface scala.collection.GenSeqLike<java.lang.Object,ByteString>
toArray
public <B> java.lang.Object toArray(scala.reflect.ClassTag<B> arg0)
- Specified by:
toArray in interface scala.collection.GenTraversableOnce<java.lang.Object>- Specified by:
toArray in interface scala.collection.TraversableOnce<java.lang.Object>
copyToArray
public <B> void copyToArray(java.lang.Object xs,
int start,
int len)
- Specified by:
copyToArray in interface scala.collection.GenTraversableOnce<java.lang.Object>- Specified by:
copyToArray in interface scala.collection.IndexedSeqOptimized<java.lang.Object,ByteString>- Specified by:
copyToArray in interface scala.collection.IterableLike<java.lang.Object,ByteString>- Specified by:
copyToArray in interface scala.collection.TraversableLike<java.lang.Object,ByteString>- Specified by:
copyToArray in interface scala.collection.TraversableOnce<java.lang.Object>
foreach
public <U> void foreach(scala.Function1<java.lang.Object,U> f)
- Specified by:
foreach in interface scala.collection.generic.FilterMonadic<java.lang.Object,ByteString>- Specified by:
foreach in interface scala.collection.generic.GenericTraversableTemplate<java.lang.Object,scala.collection.immutable.IndexedSeq>- Specified by:
foreach in interface scala.collection.GenTraversableLike<java.lang.Object,ByteString>- Specified by:
foreach in interface scala.collection.GenTraversableOnce<java.lang.Object>- Specified by:
foreach in interface scala.collection.IndexedSeqOptimized<java.lang.Object,ByteString>- Specified by:
foreach in interface scala.collection.IterableLike<java.lang.Object,ByteString>- Specified by:
foreach in interface scala.collection.TraversableLike<java.lang.Object,ByteString>- Specified by:
foreach in interface scala.collection.TraversableOnce<java.lang.Object>
copyToBuffer
public int copyToBuffer(java.nio.ByteBuffer buffer)
- Copy as many bytes as possible to a ByteBuffer, starting from it's
current position. This method will not overflow the buffer.
- Parameters:
buffer - a ByteBuffer to copy bytes to
- Returns:
- the number of bytes actually copied
compact
public abstract CompactByteString compact()
- Create a new ByteString with all contents compacted into a single,
full byte array.
If isCompact returns true, compact is an O(1) operation, but
might return a different object with an optimized implementation.
isCompact
public abstract boolean isCompact()
- Check whether this ByteString is compact in memory.
If the ByteString is compact, it might, however, not be represented
by an object that takes full advantage of that fact. Use compact to
get such an object.
asByteBuffer
public abstract java.nio.ByteBuffer asByteBuffer()
- Returns a read-only ByteBuffer that directly wraps this ByteString
if it is not fragmented.
toByteBuffer
public java.nio.ByteBuffer toByteBuffer()
- Creates a new ByteBuffer with a copy of all bytes contained in this
ByteString.
utf8String
public final java.lang.String utf8String()
- Decodes this ByteString as a UTF-8 encoded String.
decodeString
public abstract java.lang.String decodeString(java.lang.String charset)
- Decodes this ByteString using a charset to produce a String.
mapI
public final ByteString mapI(scala.Function1<java.lang.Object,java.lang.Object> f)
- map method that will automatically cast Int back into Byte.