org.javaseis.properties
Class SeisTraceProperties

java.lang.Object
  extended by org.javaseis.properties.SeisTraceProperties

public class SeisTraceProperties
extends java.lang.Object

Title: JavaSeis Trace Property Handler

Description: An initial design for trace property handling for JavaSeis datasets. This design uses Java Properties files for persistence, and a HashMap from the Collections interface to hold property descriptions in memory at run time. The descriptions provide the header name and location in the binary trace header records. A Java NIO ByteBuffer holds the binary trace header records in memory. Typed views (int, float, etc) of the ByteBuffer are then used to return typed values for a particular header element back to the user.

Copyright: Copyright (c) 2005

Company: JavaSeis.org

Version:
1.0
Author:
Chuck Mosher

Field Summary
(package private)  java.nio.DoubleBuffer _doubleView
           
(package private)  java.nio.FloatBuffer _floatView
           
(package private)  java.util.Properties _fp
           
(package private)  java.nio.ByteBuffer _headers
           
(package private)  int _index
           
(package private)  java.nio.IntBuffer _intView
           
(package private)  java.nio.LongBuffer _longView
           
(package private)  java.util.Map _map
           
(package private)  SeisTraceProperty _prop
           
(package private)  int _reclen
           
(package private)  java.nio.ShortBuffer _shortView
           
(package private)  Seisio _sio
           
 
Constructor Summary
SeisTraceProperties()
          Construct a new trace property handler.
SeisTraceProperties(java.nio.ByteBuffer headers)
          Construct a new trace property handler.
 
Method Summary
 void add(SeisTraceProperty prop)
          Add a property description to this trace property handler
 SeisTraceProperty get(java.lang.String name)
          Return a trace property descriptor for a particular header entry
 double getDouble(java.lang.String name)
           
 float getFloat(java.lang.String name)
           
 int getInt(java.lang.String name)
           
<T> T
getValue(java.lang.String name)
          Generic method for returning values of trace properties as "wrapped" primitives, i.e.
 void load(java.io.InputStream is)
          Load a set of trace property descriptions from a Java Properties file
static void main(java.lang.String[] args)
           
 double putDouble(java.lang.String name, double d)
           
 float putFloat(java.lang.String name, float f)
           
 int putInt(java.lang.String name, int i)
           
 int recordLength()
          Return the current record length for the property catalog
 void setBuffer(java.nio.ByteBuffer headers)
          Set the header buffer for this handler.
 void setIndex(int index)
          Set the index of the trace property record for subsequent operations
<T> T
setValue(java.lang.String name, T value)
          Generic method for setting "typed" values of trace properties.
 int size()
          Return the number of properties in the catalog
 void store(java.io.OutputStream os)
          Store the contents of the TraceProperty catalog to an output stream in Java Properties format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_doubleView

java.nio.DoubleBuffer _doubleView

_floatView

java.nio.FloatBuffer _floatView

_fp

java.util.Properties _fp

_headers

java.nio.ByteBuffer _headers

_index

int _index

_intView

java.nio.IntBuffer _intView

_longView

java.nio.LongBuffer _longView

_map

java.util.Map _map

_prop

SeisTraceProperty _prop

_reclen

int _reclen

_shortView

java.nio.ShortBuffer _shortView

_sio

Seisio _sio
Constructor Detail

SeisTraceProperties

public SeisTraceProperties()
Construct a new trace property handler. An empty property map is created by this constructor.


SeisTraceProperties

public SeisTraceProperties(java.nio.ByteBuffer headers)
Construct a new trace property handler. The ByteBuffer specified will be used to read trace headers as requested by the methods in this class. An empty property map is created by this constructor.

Parameters:
headers - buffer containing trace header records
Method Detail

add

public void add(SeisTraceProperty prop)
Add a property description to this trace property handler

Parameters:
prop - SeisTraceProperty that will be added to the property map for this handler.

get

public SeisTraceProperty get(java.lang.String name)
Return a trace property descriptor for a particular header entry

Parameters:
name - String containing the name of the trace property for which a descriptor should be returned. Note that this method returns the descriptor for the trace property, not the value.
Returns:
SeisTraceProperty descriptor for the desired trace property

getDouble

public double getDouble(java.lang.String name)

getFloat

public float getFloat(java.lang.String name)

getInt

public int getInt(java.lang.String name)

getValue

public <T> T getValue(java.lang.String name)
Generic method for returning values of trace properties as "wrapped" primitives, i.e. Integer, Float, Double, etc.

Parameters:
name - String containing the name of the trace property for which a value should be returned.
Returns:
typed value for the trace property

load

public void load(java.io.InputStream is)
          throws java.io.IOException
Load a set of trace property descriptions from a Java Properties file

Parameters:
is - InputStream for the input properties
Throws:
java.io.IOException - on I/O errors

main

public static void main(java.lang.String[] args)
                 throws SeisException
Throws:
SeisException

putDouble

public double putDouble(java.lang.String name,
                        double d)

putFloat

public float putFloat(java.lang.String name,
                      float f)

putInt

public int putInt(java.lang.String name,
                  int i)

recordLength

public int recordLength()
Return the current record length for the property catalog

Returns:
int length in bytes of the property catalog record length

setBuffer

public void setBuffer(java.nio.ByteBuffer headers)
Set the header buffer for this handler. The ByteBuffer specified will be used to read trace headers as requested by the methods in this class.

Parameters:
headers - buffer containing trace header records

setIndex

public void setIndex(int index)
Set the index of the trace property record for subsequent operations

Parameters:
index - int trace index to be used for subsequent operations

setValue

public <T> T setValue(java.lang.String name,
                      T value)
Generic method for setting "typed" values of trace properties.

Parameters:
name - String containing the name of the trace property for which a value should be set.
value - "wrapped" primitive type, i.e. Integer, Float, Double ...
Returns:
typed value that was set, null on errors

size

public int size()
Return the number of properties in the catalog

Returns:
int number of name-description entries in the catalog

store

public void store(java.io.OutputStream os)
           throws java.io.IOException
Store the contents of the TraceProperty catalog to an output stream in Java Properties format.

Parameters:
os - OutputStream that will receive the property catalog
Throws:
java.io.IOException - on I/O errors