|
WebObjects 5.2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.webobjects.foundation.NSData | +--com.webobjects.foundation.NSMutableData
The NSMutableData class declares the programmatic interface to an object that contains modifiable data in the form of bytes. The data grows automatically if necessary.
The following table describes the NSMutableData methods that provide the basis for all NSMutableData's other methods; that is, all other methods are implemented in terms of these nine. If you create a subclass of NSMutableData, you need only ensure that these base methods work properly. Having done so, you can be sure that all your subclass's inherited methods operate properly.
Method | Description |
appendByte |
Appends a byte to the receiver. |
appendBytes |
Appends the contents of a byte array to the receiver. The two-argument version is part of the base API. |
bytesNoCopy |
Returns the internal byte array that contains the receiver's data. Inherited from NSData. |
immutableBytes |
Returns an immutable byte array that contains a copy of the receiver's data. |
immutableRange |
Returns an immutable copy of the NSRange object that specifies the receiver's length. |
rangeNoCopy |
Returns the internal NSRange object that specifies the receiver's length. Inherited from NSData. |
resetBytesInRange |
Resets to zero the receiver's bytes that fall within the specified range. |
setData |
Replaces the receiver's contents with the specified NSData object. |
setLength |
Extends or truncates a mutable data object to the specified length. |
To modify the data, use the setData
, appendByte
,
appendBytes
, and appendData
methods. If you want to set a
range of bytes to zero, use the resetBytesInRange
method. To change
the length of the data, use the setLength
and increaseLengthBy
methods.
NSData
,
appendByte(byte byte)
,
appendBytes(byte[] bytes[])
,
appendBytes( byte[] bytes, NSRange range)
,
NSData.bytesNoCopy()
,
immutableBytes()
,
immutableRange()
,
NSData.rangeNoCopy()
,
resetBytesInRange(NSRange range)
,
setData(NSData data)
,
setLength(int length)
,
appendData(NSData otherData)
,
increaseLengthBy(int additionalLength)
, Serialized FormInner classes inherited from class com.webobjects.foundation.NSCoding |
NSCoding.Support |
Fields inherited from class com.webobjects.foundation.NSData |
EmptyData |
Constructor Summary | |
NSMutableData()
Creates an empty NSMutableData object. |
|
NSMutableData(byte[] bytes)
Creates an NSMutableData object with all the data in the byte array bytes . |
|
NSMutableData(byte[] bytes,
NSRange range)
Creates an NSMutableData object with the bytes from the byte array bytes that fall in the range specified by
range . |
|
NSMutableData(byte[] bytes,
NSRange range,
boolean noCopy)
Creates an NSMutableData object with the bytes from the byte array bytes that fall in the range specified by
range . |
|
NSMutableData(File file)
Deprecated. |
|
NSMutableData(InputStream inputStream,
int chunkSize)
Creates a data object with the data from the stream specified by inputStream . |
|
NSMutableData(int capacity)
Creates an NSMutableData object prepared to store at least capacity
bytes. |
|
NSMutableData(NSData otherData)
Creates an NSMutableData object containing the contents of another data object otherData . |
|
NSMutableData(String value)
Deprecated. |
|
NSMutableData(String value,
String encoding)
This constructor creates a new NSMutableData object from a String |
|
NSMutableData(URL url)
Deprecated. |
Method Summary | |
void |
appendByte(byte singleByte)
Appends the specified byte to the receiver. |
void |
appendBytes(byte[] bytes)
Appends the specified byte array to the receiver. |
void |
appendBytes(byte[] bytes,
NSRange range)
Appends the contents of byte array bytes to the receiver. |
void |
appendData(NSData otherData)
Appends the contents of a data object otherData
to the receiver. |
Object |
clone()
Returns an identical copy of the receiver. |
protected byte[] |
immutableBytes()
Privitive method that returns the receiver's data. |
protected NSRange |
immutableRange()
Privitive method that returns the receiver's range. |
void |
increaseLengthBy(int additionalLength)
Increases the length of the receiver by additionalLength . |
void |
resetBytesInRange(NSRange range)
Resets to zero the receiver's bytes that fall within the specified range. |
void |
setData(NSData otherData)
Replaces the entire contents of the receiver with the contents of otherdata . |
void |
setLength(int length)
Extends or truncates a mutable data object to the specified length. |
Methods inherited from class com.webobjects.foundation.NSData |
bytes, bytes, bytes, bytesNoCopy, bytesNoCopy, classForCoder, dataWithContentsOfFile, dataWithContentsOfFile, dataWithContentsOfMappedFile, decodeObject, encodeWithCoder, equals, hashCode, isEqualToData, length, rangeNoCopy, stream, subdataWithRange, toString, writeToFile, writeToStream, writeToURL |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public NSMutableData()
public NSMutableData(int capacity)
capacity
bytes.
If you know the upper bound on the size of his data, you can use this
constructor to improve performance. As long as the data size
does not exceed capacity
bytes, the internal byte array will not
be reallocated.
capacity
- the upper bound on the size of the datapublic NSMutableData(byte[] bytes)
bytes
.bytes
- input byte arraypublic NSMutableData(byte[] bytes, NSRange range)
bytes
that fall in the range specified by
range
.bytes
- input byte arrayrange
- specifies the range that the bytes fall inpublic NSMutableData(byte[] bytes, NSRange range, boolean noCopy)
bytes
that fall in the range specified by
range
. The noCopy
parameter specifies
whether or not a copy of bytes
is made.bytes
- input byte arrayrange
- specifies the range that the bytes fall innoCopy
- specifies whether or not a copy of bytes is madepublic NSMutableData(NSData otherData)
otherData
.otherData
- contents of another data objectpublic NSMutableData(InputStream inputStream, int chunkSize) throws IOException
inputStream
.
The chunkSize
parameter specifies the size, in bytes, of the block
that the input stream returns when it reads. For maximum performance,
you should set the chunk size to the approximate size of the data.
This constructor does not close the stream.
inputStream
- data object is created with the data from thischunkSize
- specifies the size of the block that the input stream
returns when it readsjava.lang.IOException
- public NSMutableData(File file) throws IOException
NSMutableData(new FileInputStream(file),myChunkSize)
instead.NSMutableData(InputStream, int)
public NSMutableData(URL url) throws IOException
URLConnection connection = url.openConnection(); connection.connect(); NSMutableData myData = new NSMutableData(connection.getInputStream(),myChunkSize);
NSMutableData(InputStream, int)
public NSMutableData(String value)
NSMutableData(string.getBytes())
instead.NSMutableData(byte[])
public NSMutableData(String value, String encoding)
value
- The textual data to useencoding
- The encoding type used to create the bytes.Method Detail |
public void appendByte(byte singleByte)
singleByte
- the specified byteappendBytes(byte[] bytes)
,
appendBytes(byte[] bytes, NSRange range)
,
appendData(NSData otherData)
public void appendBytes(byte[] bytes, NSRange range)
bytes
to the receiver.
The two-argument method appends the bytes in bytes
that
fall within the range specified by range
.bytes
- the contents of byte arrayrange
- the range specified for the bytesappendByte(byte singleByte)
,
appendData(NSData otherData)
public void appendBytes(byte[] bytes)
bytes
- the specified byte array that is appended to the receiverappendByte(byte singleByte)
,
appendData(NSData otherData)
public void appendData(NSData otherData)
otherData
to the receiver.otherData
- a data object whose contents are appended
to the receiverappendByte(byte byte)
,
appendBytes(byte[] bytes)
public Object clone()
clone
in class NSData
protected byte[] immutableBytes()
immutableBytes
in class NSData
protected NSRange immutableRange()
immutableRange
in class NSData
public void increaseLengthBy(int additionalLength)
additionalLength
.
The additional bytes are all set to zero.additionalLength
- the length of the receiver is
increased by this muchsetLength(int length)
public void resetBytesInRange(NSRange range)
The receiver is resized to accommodate the new bytes, if necessary.
range
- specifies the range that the bytes should fall inIllegalArgumentException
- if the location of
range
isn't within the receiver's range of bytes.public void setData(NSData otherData)
otherdata
.otherData
- the entire contents of the receiver is replaced
by thissetLength(int length)
public void setLength(int length)
length
- mutable data object is extended or truncated to this valueincreaseLengthBy(int additionalLength)
,
setData(NSData otherData)
|
Last updated Fri Feb 21 13:15:00 PST 2003. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |