org.xBaseJ.fields
Class Field

java.lang.Object
  extended by org.xBaseJ.fields.Field
All Implemented Interfaces:
Externalizable, Serializable, Cloneable
Direct Known Subclasses:
CharField, DateField, LogicalField, MemoField, NumField, PictureField

public abstract class Field
extends Object
implements Cloneable, Externalizable

This class is courtesy of the xBaseJ project: http://xbasej.sourceforge.net/ Copyright 1997-2007 - American Coders, LTD - Raleigh NC USA

 American Coders, Ltd
 P. O. Box 97462
 Raleigh, NC  27615  USA
 1-919-846-2014
 http://www.americancoders.com
 

Author:
Joe McVerry, American Coders Ltd.
See Also:
Serialized Form

Field Summary
protected  byte[] buffer
           
protected  ByteBuffer bytebuffer
           
protected  boolean deleted
           
protected  long myoffset
           
protected  String name
           
protected  int nength
           
static String otherValidCharacters
           
 
Constructor Summary
Field()
          creates a Field object. not useful for the abstract Field class
 
Method Summary
 Object clone()
           
 String get()
           
 byte[] getBytes()
          returns the original byte array as stored in the file.
 int getDecimalPositionCount()
           
 int getLength()
           
 String getName()
           
abstract  char getType()
           
 void put(byte[] inValue)
          set field contents with binary data, no database updates until a DBF update or write is issued if inValue is too short buffer is filled with binary zeros.
 void put(String inValue)
          set field contents, no database updates until a DBF update or write is issued
 void read()
           
 void readExternal(ObjectInput in)
          used by externalize methods
 void setBuffer(ByteBuffer inBuffer)
           
 void setBufferSpace()
           
 void setField(String iName, int iLength, ByteBuffer inbuffer)
           
 void update()
           
 void write()
           
 void writeExternal(ObjectOutput out)
          used by externalize methods
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected String name

nength

protected int nength

buffer

protected byte[] buffer

deleted

protected boolean deleted

bytebuffer

protected ByteBuffer bytebuffer

myoffset

protected long myoffset

otherValidCharacters

public static String otherValidCharacters
Constructor Detail

Field

public Field()
creates a Field object. not useful for the abstract Field class

See Also:
CharField, DateField, LogicalField, MemoField, NumField
Method Detail

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
used by externalize methods

Specified by:
readExternal in interface Externalizable
Parameters:
in - ObjectInput stream
Throws:
IOException - - most likely class changed since written
ClassNotFoundException - - only when dummy constructro not found

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
used by externalize methods

Specified by:
writeExternal in interface Externalizable
Parameters:
out - ObjectOutput stream
Throws:
IOException - Java.io error

clone

public Object clone()
             throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException

setField

public void setField(String iName,
                     int iLength,
                     ByteBuffer inbuffer)
              throws xBaseJException
Throws:
xBaseJException

setBuffer

public void setBuffer(ByteBuffer inBuffer)

setBufferSpace

public void setBufferSpace()

getName

public String getName()
Returns:
String contianing the field name

getLength

public int getLength()
Returns:
int - the field length

getType

public abstract char getType()
Returns:
char field type

getDecimalPositionCount

public int getDecimalPositionCount()
Returns:
int - the number of decimal positions for numeric fields, zero returned otherwise

read

public void read()
          throws IOException,
                 xBaseJException
Throws:
IOException
xBaseJException

get

public String get()
Returns:
String field contents after any type of read.

getBytes

public byte[] getBytes()
returns the original byte array as stored in the file.

Returns:
byte[] - may return a null if not set

write

public void write()
           throws IOException,
                  xBaseJException
Throws:
IOException
xBaseJException

update

public void update()
            throws IOException,
                   xBaseJException
Throws:
IOException
xBaseJException

put

public void put(String inValue)
         throws xBaseJException
set field contents, no database updates until a DBF update or write is issued

Parameters:
inValue - value to set
Throws:
xBaseJException - value length too long

put

public void put(byte[] inValue)
         throws xBaseJException
set field contents with binary data, no database updates until a DBF update or write is issued if inValue is too short buffer is filled with binary zeros.

Parameters:
inValue - byte array
Throws:
xBaseJException - value length too long


Copyright © 2007-2011. All Rights Reserved.