Package org.xBaseJ.micro

Examples of org.xBaseJ.micro.xBaseJException


public void put(byte inValue[]) throws xBaseJException
  {
    int i;

    if (inValue.length > Length)
      throw new xBaseJException("Field length too long");

    for (i = 0; i < inValue.length; i++)
       buffer[i] = inValue[i];

    for (; i < Length; i++)
View Full Code Here


    int j;

  unique_key = (byte) (unique ? 64 : 0);

  if ((i < 1) || (i > 10))
       throw new xBaseJException("Invalid tag name " + iname + " name length incorrect");

  if (!Character.isLetter(iname.charAt(0)))
       throw new xBaseJException("Invalid tag name " + iname + " first character not alphabetic");

  iname = iname.toUpperCase();

  for (j = 1; j < i; j++)
  {
    if (Character.isLetter(iname.charAt(j))
  || (Character.isDigit(iname.charAt(j))
  || (iname.charAt(j) == '_') ) )
      ;
    else
       throw new xBaseJException("Invalid tag name " + iname + " invalid character at position " + (j+1));
   }

  stringKey = new String(NDXString);
  StringTokenizer strtok = new StringTokenizer(NDXString, "+");

  String fname;
  Field ffld;
  char type;

  int keylen = 0;
  keyType = ' ';

  do
  {
    fname = (String) strtok.nextElement();
    ffld = iDBF.getField(fname);
    type = ffld.getType();
    if (type == 'M')
  throw new xBaseJException("Can't make memo field part of a key");
    if (type == 'L')
  throw new xBaseJException("Can't make logical field part of a key");
    if (type == 'F')
  throw new xBaseJException("Can't make float field part of a key");
    if (keyType == ' ')
    {
      keyType = type;
    }
    else
    {
      if (keyType != type)
      {
  keyType = 'C';
      }        /* endif */
    }        /* endif */
    keylen += ffld.getLength();
    keyControl.addElement(ffld);
  } while (strtok.hasMoreElements())/* endwhile */

  if (keyType == 'D')
    keylen = 8;
  if (keyType == 'N')
    keylen = 12;

  int len = (((keylen - 1) / 4) + 1) * 4;
  if (len < 1)
    throw new xBaseJException("Key length too short");

  if (len > 100)
    throw new xBaseJException("Key length too long");

  tagDesc = inTagDesc;
  tagDesc.setKeyType(keyType);
  tagHead = new TagHeader(mfile, (short) tagDesc.indheaderpage, (short) len, keyType, unique);

View Full Code Here

public int  find_entry(NodeKey findKey, int rec) throws   xBaseJException, IOException
{
  if (topNode == null)
  {        /* no keys yet */
    throw new xBaseJException("No keys built");
  }        /* endif */
  topNode.set_pos(0);
  record = find_entry(findKey, (MNode) topNode, rec);
  return record;
}
View Full Code Here

  MNode Node_2;
  foundExact = false;
  workNode = aNode;
  if (aNode == null)
  {        /* no keys yet */
    throw new xBaseJException("No keys built");
  }        /* endif */

  leaf = aNode.get_lower_level();
  if (leaf != 0)      /* leaf pointers usually have one more pointer than shown */
    until = aNode.get_keys_in_this_Node() + 1;
View Full Code Here

}

public void set_record_number(int r) throws xBaseJException
{
if (r == 0)
   throw new xBaseJException("Invalid record number in set");
  record_number = r;
}
View Full Code Here

public void write() throws IOException,  xBaseJException
{

int i, j, k, ll = 512;
if (record_number == 0)
   throw new xBaseJException("Invalid record number in write");

long longrecn = record_number;

nfile.seek(longrecn * 512);

nfile.writeInt(Util.x86(keys_in_this_Node));
ll -= 4; // sizeof(int)
for (i=0; i < keys_in_this_Node && i < keys_in_a_Node && key_expression[i] != null; i++)
   {
   if (key_expression[i] == null)
     throw new xBaseJException("Missing node key expression at " + i);
    if ((lower_level[0]==0) &&  (key_record_number[i]==0))
         throw new xBaseJException("Logic mismatch, both pointers are zero");
    nfile.writeInt(Util.x86(lower_level[i]));
    ll-=4;
    nfile.writeInt(Util.x86(key_record_number[i]));
    ll-=4;
     if (key_expression[i].getType() == 'N')
       { double d = key_expression[i].toDouble();
         nfile.writeLong(Double.doubleToLongBits(d));
       }
     if (key_expression[i].getType() == 'C')
         {
           int x;
           byte bytebuffer[];
           try {bytebuffer = key_expression[i].toString().getBytes(DBF.encodedType);}
           catch (UnsupportedEncodingException UEE){ bytebuffer = key_expression[i].toString().getBytes();}
           for (x = 0; x < bytebuffer.length; x++)
               key_buffer[x] = bytebuffer[x];
           for (; x < key_expression_size; x++)
               key_buffer[x] = 0;
            nfile.write(key_buffer, 0, key_expression_size);
         }
    ll -= key_expression_size; // sizeof(2 ints) and full key length to its 4 byte alignment
    j = key_expression_size % 4;
    if (j>0) j = 4 - j;  // 4 byte alignment
    key_buffer[0] = 0;
    for (k=0; k < j; k++) {
         nfile.write(key_buffer[0]);
         ll--;
         }
   } // for i
   if ((branch==true) && (lower_level[i] == 0))
         throw new xBaseJException("Logic mismatch, lower level pointer is zero");
  nfile.writeInt(Util.x86(lower_level[i]));
  ll -= 4; // sizeof(int)
  if (ll > 0) {
    // a Node is 512 bytes long;
    byte temp[] = new byte[ll];
View Full Code Here

return  prev;
}


public void set_prev_page(int t) throws xBaseJException
{ throw new xBaseJException("method not available"); }
View Full Code Here

TOP

Related Classes of org.xBaseJ.micro.xBaseJException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.