PATH |
NSMutableData
- Inherits from:
- NSData : Object
- Implements:
- Cloneable
- java.io.Serializable
- NSCoding
- Package:
- com.webobjects.foundation
Class Description
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.
Table 0-8 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.
Interfaces Implemented
- Cloneable
- clone
- java.io.Serializable
- NSCoding
- classForCoder
- decodeObject
- encodeWithCoder
Method Types
- Constructors
- NSMutableData
- Modifying the data
- appendByte
- appendBytes
- appendData
- resetBytesInRange
- setData
- Modifying the range
- increaseLengthBy
- setLength
- Accessing internal data directly
- immutableBytes
- immutableRange
Constructors
NSMutableData
public NSMutableData()
public NSMutableData(NSData data)
public NSMutableData(String string)
NSMutableData(string.getBytes())
instead.
public NSMutableData(byte[] bytes)
public NSMutableData( byte[] bytes, NSRange range)
public NSMutableData( byte[] bytes, NSRange range, boolean nocopy)
public NSMutableData(int capacity)
public NSMutableData(java.io.File file) throws java.io.IOException
NSMutableData(new FileInputStream(file),myChunkSize)
instead.
public NSMutableData( java.io.InputStream inputStream, int chunkSize) throws java.io.IOException
public NSMutableData(java.net.URL url) throws java.io.IOException
URLConnection connection = url.openConnection(); connection.connect(); NSMutableData myData = new NSMutableData(connection.getInputStream(),myChunkSize);
Instance Methods
appendByte
public void appendByte(byte byte)
See Also: appendBytes, appendData
appendBytes
public void appendBytes(byte[] bytes[])
public void appendBytes( byte[] bytes, NSRange range)
See Also: appendByte, appendData
appendData
public void appendData(NSData otherData)
See Also: appendByte, appendBytes
clone
public Object clone()
immutableBytes
protected byte[] immutableBytes()
immutableRange
protected NSRange immutableRange()
increaseLengthBy
public void increaseLengthBy(int additionalLength)
See Also: setLength
resetBytesInRange
public void resetBytesInRange(NSRange range)
setData
public void setData(NSData data)
See Also: setLength
setLength
public void setLength(int length)
See Also: increaseLengthBy, setData
© 2001 Apple Computer, Inc. (Last Published April 17, 2001)