TrueZIP Kernel 7.0-rc2

de.schlichtherle.truezip.socket
Class ByteArrayIOEntry

java.lang.Object
  extended by de.schlichtherle.truezip.socket.ByteArrayIOEntry
All Implemented Interfaces:
Entry, InputEntry<ByteArrayIOEntry>, IOEntry<ByteArrayIOEntry>, OutputEntry<ByteArrayIOEntry>
Direct Known Subclasses:
ByteArrayIOPool.Entry

@DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class)
@NotThreadSafe
public class ByteArrayIOEntry
extends Object
implements IOEntry<ByteArrayIOEntry>

An I/O entry which uses a byte array.

Author:
Christian Schlichtherle

Nested Class Summary
private  class ByteArrayIOEntry.ByteArrayInputSocket
           
private  class ByteArrayIOEntry.ByteArrayOutputSocket
           
private  class ByteArrayIOEntry.DataOutputStream
           
 
Nested classes/interfaces inherited from interface de.schlichtherle.truezip.entry.Entry
Entry.Access, Entry.Size, Entry.Type
 
Field Summary
private  byte[] data
           
(package private)  int initialCapacity
           
private  String name
           
private  int reads
           
private  int writes
           
 
Fields inherited from interface de.schlichtherle.truezip.entry.Entry
NULL, UNKNOWN
 
Constructor Summary
ByteArrayIOEntry(String name)
          Equivalent to new ByteArrayIOPool(name, 32).
ByteArrayIOEntry(String name, int initialCapacity)
          Constructs a new byte array I/O entry with the given name and initial capacity of the byte array for the next output to this I/O entry.
 
Method Summary
 byte[] getData()
          Returns the byte array for input from this I/O entry.
 InputSocket<ByteArrayIOEntry> getInputSocket()
          Returns an input socket for reading this entry.
 String getName()
          Returns the entry name.
 OutputSocket<ByteArrayIOEntry> getOutputSocket()
          Returns an output socket for writing this entry.
 int getReads()
           
 long getSize(Entry.Size type)
          Returns the size of this entry.
 long getTime(Entry.Access type)
          Returns the last access time of this entry.
 Entry.Type getType()
          Returns the type of this entry or null if and only if this entry does not exist.
 int getWrites()
           
 void setData(byte[] data)
          Sets the byte array for input from this I/O entry.
 void setInitialCapacity(int initialCapacity)
          Sets the initial capacity of the byte array for the next output to this I/O entry.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

private final String name

data

@CheckForNull
private byte[] data

reads

private int reads

writes

private int writes

initialCapacity

int initialCapacity
Constructor Detail

ByteArrayIOEntry

public ByteArrayIOEntry(String name)
Equivalent to new ByteArrayIOPool(name, 32).


ByteArrayIOEntry

public ByteArrayIOEntry(String name,
                        int initialCapacity)
Constructs a new byte array I/O entry with the given name and initial capacity of the byte array for the next output to this I/O entry.

Parameters:
name - the name of this entry.
initialCapacity - the initial capacity of the array to use for the next output to this I/O entry.
Method Detail

setInitialCapacity

public final void setInitialCapacity(int initialCapacity)
Sets the initial capacity of the byte array for the next output to this I/O entry.

Parameters:
initialCapacity - the initial capacity of the array to use for the next output to this I/O entry.

getData

@CheckForNull
public byte[] getData()
Returns the byte array for input from this I/O entry. This usually results from the last output and is initially null. Note that the returned array is not copied, so beware of concurrent modifications!

Returns:
The byte array for input from this I/O entry.

setData

public void setData(@Nullable
                    byte[] data)
Sets the byte array for input from this I/O entry. Note that the given array is not copied, so beware of concurrent modifications!

Parameters:
data - the byte array for input from this I/O entry.

getReads

public int getReads()
Returns:
The number of times a read only file or an input stream for this I/O entry has been opened.

getWrites

public int getWrites()
Returns:
The number of times an output stream for this I/O entry has been opened.

getName

public final String getName()
Description copied from interface: Entry
Returns the entry name. When parsed, an entry name is interpreted as follows:
  1. An entry name is a sequence of segments which are separated by one or more separator characters (EntryName.SEPARATOR_CHAR). This implies that a segment cannot contain separator characters.
  2. An entry name may contain one or more dot (".") or dot-dot ("..") segments which represent the current or parent segment respectively.
  3. An entry name may start with one or more separator characters. In this case, its said to be absolute. Otherwise, its said to be relative.
  4. An entry name may end with one or more separator characters (e.g. to identify a directory entry).
For example, the entry names "foo/bar/" and "./abc/../foo/./def/./../bar/." both refer to the same entry when being parsed.

Specified by:
getName in interface Entry
Returns:
The entry name.
See Also:
EntryName.create(String)

getType

public Entry.Type getType()
Description copied from interface: Entry
Returns the type of this entry or null if and only if this entry does not exist.

Specified by:
getType in interface Entry
Returns:
The type of this entry or null if and only if this entry does not exist.

getSize

public long getSize(Entry.Size type)
Description copied from interface: Entry
Returns the size of this entry.

Specified by:
getSize in interface Entry
Returns:
The size of the given size type for this entry in bytes, or Entry.UNKNOWN if not specified or the type is unsupported. This method may not be meaningful for non-file entries.

getTime

public long getTime(Entry.Access type)
Description copied from interface: Entry
Returns the last access time of this entry.

Specified by:
getTime in interface Entry
Returns:
The last time of the given access type for this entry in milliseconds since the epoch or -1 if not specified or the type is unsupported.

getInputSocket

public InputSocket<ByteArrayIOEntry> getInputSocket()
Description copied from interface: InputEntry
Returns an input socket for reading this entry. The method IOSocket.getLocalTarget() of the returned socket must return this entry.

Specified by:
getInputSocket in interface InputEntry<ByteArrayIOEntry>
Returns:
An input socket for reading this entry.

getOutputSocket

public OutputSocket<ByteArrayIOEntry> getOutputSocket()
Description copied from interface: OutputEntry
Returns an output socket for writing this entry. The method IOSocket.getLocalTarget() of the returned socket must return this entry.

Specified by:
getOutputSocket in interface OutputEntry<ByteArrayIOEntry>
Returns:
An output socket for writing this entry.

toString

public String toString()
Overrides:
toString in class Object

TrueZIP Kernel 7.0-rc2

Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.