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

Type Parameters:
S - type for all setter operations
R - type for all remove operations
All Known Subinterfaces:
FileIndexer<G,S,R>, PacketIndexer<I>, RawIndexer, RecordIndexer<T>

public interface IndexedFileModifier<S,R>

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(long index, S... elements)
          Adds an array of list at the index location in the order they appear in the array.
 void add(S element)
          Appends the content of the buffer to the end of the storage medium.
 void addAll(long index, java.util.List<S> elements)
          Add new content from supplied buffer at the index position.
 void remove(long index)
          Removes an element at the index 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 index, long count)
          Removes a consecutive sequence of elements starting with the element at the index position.
 void removeAll(R... elements)
          Bulk remove of all the elements found in the array.
 void replace(long index, S element)
          Replaces the index 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 set(long index, S element)
          Sets the element at index position to the specified element.
 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.

Parameters:
element - add new element at the end
Throws:
java.io.IOException - any IO errors

addAll

void addAll(long index,
            java.util.List<S> elements)
            throws java.io.IOException
Add new content from supplied buffer at the index 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

add

void add(long index,
         S... elements)
         throws java.io.IOException
Adds an array of list at the index 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(long index)
            throws java.io.IOException
Removes an element at the index location.

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 index,
               long count)
               throws java.io.IOException
Removes a consecutive sequence of elements starting with the element at the index 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(long index,
             S element)
             throws java.io.IOException
Replaces the index 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

set

void set(long index,
         S element)
         throws java.io.IOException
Sets the element at index position to the specified element. The index must address a valid position and not the end of the file or collection.

Parameters:
index - index of the element to affect
element - element that will replace the element at the index position
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