Package org.xBaseJ.micro.fields

Examples of org.xBaseJ.micro.fields.Field


  public  void  write()  throws xBaseJException, IOException
  {
    /** writes a new record in the database */
    int i;
    byte wb;
    Field tField;

    Index NDXes;
    for (i=1; i<= jNDXes.size(); i++)
      {
        NDXes =  (Index) jNDXes.elementAt(i-1);
        NDXes.check_for_duplicates(Index.findFirstMatchingKey);
      }


    seek(count);
    delete_ind = NOTDELETED;
    file.writeByte(delete_ind);


    for (i=0; i < fldcount; i++)
    {
      tField = (Field) fld_root.elementAt(i);
      tField.write();
    }


    wb = 0x1a;
    file.writeByte(wb);
View Full Code Here


  public  void update()  throws xBaseJException, IOException
  {

    /** updates the last record read */
    int i;
    Field tField;

    if ((current_record < 1) ||
      (current_record > count) )
    {
      throw new xBaseJException("Invalid current record pointer");
    }

    seek(current_record-1);
    file.readByte(); // don't change delete indicator let delete/undelete do that.

    Index NDXes;

    for (i=1; i<= jNDXes.size(); i++)
    {
      NDXes =  (Index) jNDXes.elementAt(i-1);
      NDXes.check_for_duplicates(current_record);
    }

    for (i=1; i<= jNDXes.size(); i++//  reposition record pointer and current key for index update
    {
      NDXes =  (Index) jNDXes.elementAt(i-1);
      NDXes.find_entry(NDXes.get_active_key(), current_record);
    }


    for (i=0; i < fldcount; i++)
    {
      tField = (Field) fld_root.elementAt(i);
      if (tField instanceof MemoField) tField.update();
      else tField.write();
    }

    for (i=1; i<= jNDXes.size(); i++)
    {
      NDXes =  (Index) jNDXes.elementAt(i-1);
View Full Code Here

  public  Field  getField(String name) throws xBaseJException, ArrayIndexOutOfBoundsException
  {
    /** returns a Field object referred to by its name, not case sensitive */
    short i;
    Field tField;

    for (i = 0; i < fldcount; i++)
    {
      tField = (Field)fld_root.elementAt(i);
      if (name.toUpperCase().compareTo(tField.getName().toUpperCase()) == 0)
      {
        return tField;
      }                                /* endif */
    }                                /* endfor */

 
View Full Code Here


  public Field read_Field_header() throws IOException, xBaseJException
  {

    Field tField;
    int i;
    byte[] byter = new byte[15];
    String name;
    char type;
    byte length;
View Full Code Here

   */

  public void pack()
    throws xBaseJException, IOException, SecurityException, CloneNotSupportedException
  {
    Field Fields[] = new Field[fldcount];

    int i, j;
    for (i=1; i<=fldcount; i++)
    {
      Fields[i-1] = (Field) getField(i).clone();
    }


    String parent = ffile.getParent();
    if (parent == null)
      parent = ".";

    String tempname = new String(parent + File.separator + "temp.tmp");


    DBF tempDBF = new DBF(tempname, version, true);





    tempDBF.MDX_exist = MDX_exist;
    tempDBF.addField(Fields);

    Field t, p;
    for (i=1; i <= count; i++)
    {
      gotoRecord(i);
      if (deleted()) {
        continue;
      }

      for (j=1; j<=fldcount; j++)
      {
        t = tempDBF.getField(j);
        p = getField(j);
        t.put(p.get());
      }
      tempDBF.write();
    }


    file.close();
    ffile.delete();
    tempDBF.renameTo(dosname);

    //if (dbtobj != null && tempDBF.dbtobj == null) {
    if (dbtobj != null) {
      dbtobj.file.close();
      dbtobj.thefile.delete();
    }


    if (tempDBF.dbtobj != null) {
      //   tempDBF.dbtobj.file.close();
      tempDBF.dbtobj.rename(dosname);
      dbtobj = tempDBF.dbtobj;
      Field tField;
      MemoField mField;
      for (i=1; i<=fldcount;i++) {
        tField = getField(i);
        if (tField instanceof MemoField) {
          mField = (MemoField) tField;
View Full Code Here

   {
    int reading;
    String wb;
    MNode lNode = null;
    int Index_record;
    Field field = null;
    database = iDBF;
    mfile = ifile;
    tagDesc =  mfile.getTagDescriptor(ipos);
    dosname = tagDesc.name;
    tagHead = new TagHeader(ifile, (short) tagDesc.indheaderpage);
View Full Code Here

  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;
View Full Code Here

    public void createLpuInfo() throws xBaseJException, IOException, ClipsException {
        openLpuInfo(true);
        inf = new InfoFields();
        try {
            for (int i = 0; i < inf.getFields().length; i++) {
                Field f = inf.getFields()[i];
                lpuInfo.addField(f);
            }
        } catch (xBaseJException ex) {
            throw new ClipsException("Ошибка при чтении данных из файла " + lpuInfo.getName(), ex);
        }
View Full Code Here

    public void createRegLpu() throws xBaseJException, IOException, ClipsException {
        openRegLpu(true);
        lf = new LpuFields();
        try {
            for (int i = 0; i < lf.getFields().length; i++) {
                Field f = lf.getFields()[i];
                regLpu.addField(f);
            }
        } catch (xBaseJException ex) {
            throw new ClipsException("Ошибка при чтении данных из файла " + regLpu.getName(), ex);
        }
View Full Code Here

TOP

Related Classes of org.xBaseJ.micro.fields.Field

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.