org.jnetstream.capture.file
Interface FileModifier<S,R>

Type Parameters:
S - type for all setter operations
R - type for all remove operations
All Superinterfaces:
com.slytechs.utils.collection.IOAddable<S>, com.slytechs.utils.collection.IORemovable
All Known Subinterfaces:
FileIterator<G,S,R>, NAPBlockRecordIterator, NAPDataRecordIterator, NAPDataRecordModifier, PacketIterator<I>, PcapModifier, RawIterator, RecordIterator<T>

public interface FileModifier<S,R>
extends com.slytechs.utils.collection.IOAddable<S>, com.slytechs.utils.collection.IORemovable

Interface which allows modifications on the underlying storage using a generic interface. You can manipulate storage contents using elements with the following mutable actions.

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Method Summary
 void abortChanges()
          Aborts any in-memory changes that currently exist.
 void add(S element)
          Appends the content of the buffer to the end of the storage medium.
 void addAll(java.util.List<S> elements)
          Add new content from supplied buffer at the current position.
 void addAll(S... elements)
          Adds an array of list at the current location in the order they appear in the array.
 void remove()
          Removes an element at the current location.
 void removeAll()
          All elements are removed.
 void removeAll(java.util.Collection<R> elements)
           Bulk remove, that removes several elements from the collection.
 void removeAll(long count)
          Removes a consecutive sequence of elements starting with the element at the current position.
 void removeAll(R... elements)
          Bulk remove of all the elements found in the array.
 void replace(S element)
          Replaces the current element with the new element specified.
 void retainAll(java.util.List<R> elements)
           Bulk remove, that removes all records other then the ones found in the list.
 void retainAll(R... elements)
           Bulk remove, that removes all records other then the ones found in the array.
 void swap(R dst, R src)
          Swaps the two elements around, physically, within the storage.
 

Method Detail

abortChanges

void abortChanges()
                  throws java.io.IOException
Aborts any in-memory changes that currently exist. Any changes that have already been flushed, can not be aborted as they have already been physically written out to storage. But changes that still remaining in memory can be safely aborted and discarded.

Throws:
java.io.IOException

add

void add(S element)
         throws java.io.IOException
Appends the content of the buffer to the end of the storage medium.

Specified by:
add in interface com.slytechs.utils.collection.IOAddable<S>
Parameters:
element - add new element at current position
Throws:
java.io.IOException - any IO errors

addAll

void addAll(java.util.List<S> elements)
            throws java.io.IOException
Add new content from supplied buffer at the current position.

Parameters:
elements - adds a list of elements at the current location in order they appear in the list
Throws:
java.io.IOException - any IO errors

addAll

void addAll(S... elements)
            throws java.io.IOException
Adds an array of list at the current location in the order they appear in the array.

Parameters:
elements - array of elements to add
Throws:
java.io.IOException - any IO errors

remove

void remove()
            throws java.io.IOException
Removes an element at the current location.

Specified by:
remove in interface com.slytechs.utils.collection.IORemovable
Throws:
java.io.IOException - any IO errors

removeAll

void removeAll()
               throws java.io.IOException
All elements are removed. Care must be taken when using this method as this has the potential to remove all record or packets from a given file. The remove is done in memory only until a flush is invoked.

Throws:
java.io.IOException

removeAll

void removeAll(java.util.Collection<R> elements)
               throws java.io.IOException

Bulk remove, that removes several elements from the collection. The elements that are part of the collection, must have been created by the underlying capture session associated with this interface. For example FilePackets retain certain information about the position within the file, the packet came from and this information is needed to efficiently perform the operation.

Note that it is typically a lot more efficient to use bulk methods instead of doing the same work one iteration at a time. The implementation can use certain optimazations to perform the task at hand as efficiently as possible.

Parameters:
elements - collection of segments to be removed from the underlying storage
Throws:
java.io.IOException - any IO errors

removeAll

void removeAll(long count)
               throws java.io.IOException
Removes a consecutive sequence of elements starting with the element at the current position.

Parameters:
count - number of elements to remove from the current position on
Throws:
java.io.IOException - any IO errors

removeAll

void removeAll(R... elements)
               throws java.io.IOException
Bulk remove of all the elements found in the array. All elements must be associated with this file capture session. All elements will be removed as efficiently as possible.

Parameters:
elements - offset of the region to be removed
Throws:
java.io.IOException - any IO errors

replace

void replace(S element)
             throws java.io.IOException
Replaces the current element with the new element specified. If the element being replaced is a Packet or a Record, that original record will no longer be valid and accessible.

Parameters:
element - element containing new data
Throws:
java.io.IOException - any IO errors

retainAll

void retainAll(java.util.List<R> elements)
               throws java.io.IOException

Bulk remove, that removes all records other then the ones found in the list. The records that are part of the list, must have been created by the underlying capture session associated with this interface. For example FilePackets retain certain information about the position within the file, the packet came from and this information is needed to efficiently perform the operation.

The retained elements are reorder to match the order of as specified by the list's order. Therefore it is important order the records to be retained in a specificaly user defined order. Note you can always use Collections.sort method to sort the list easily if needed.

Parameters:
elements - collection of elements to be retained in the underlying storage
Throws:
java.io.IOException - any IO errors

retainAll

void retainAll(R... elements)
               throws java.io.IOException

Bulk remove, that removes all records other then the ones found in the array. The records that are part of the collection, must have been created by the underlying capture session associated with this interface. For example FilePackets retain certain information about the position within the file, the packet came from and this information is needed to efficiently perform the operation.

The retained elements are reorder to match the order of as specified in the array.

Parameters:
elements - array of elements to be retained in the underlying storage
Throws:
java.io.IOException - any IO errors

swap

void swap(R dst,
          R src)
          throws java.io.IOException
Swaps the two elements around, physically, within the storage.

Parameters:
dst - source record will be copied into this destination record's space
src - destination record will be copied into this source record's space
Throws:
java.io.IOException