/** * Inicializa. * * @param sds Capa. */ public void create(SelectableDataSource sds, BitSet bitset) { // if (layer instanceof AlphanumericData) { try { if (sds == null) { DbaseFileHeaderNIO myHeader = DbaseFileHeaderNIO.createNewDbaseHeader(); myHeader.setNumRecords(geometries.length); dbfWrite = new DbaseFileWriterNIO(myHeader, (FileChannel) getWriteChannel(dbfPath)); enteros = new Value[1]; } else { // VectorialFileAdapter // vfa=(VectorialFileAdapter)((SingleLayer)lv).getSource(); DbaseFileHeaderNIO myHeader; myHeader = DbaseFileHeaderNIO.createDbaseHeader(sds); myHeader.setNumRecords(geometries.length); dbfWrite = new DbaseFileWriterNIO(myHeader, (FileChannel) getWriteChannel(dbfPath)); record = new Object[sds.getFieldCount()]; } createdbf(sds, bitset); System.out.println("Acabado DBF"); } catch (IOException e) { e.printStackTrace(); // /} catch (DriverException e1) { // e1.printStackTrace(); } catch (ReadDriverException e2) { e2.printStackTrace(); } // return true; // } // return false; }
/** * Rellena los registros del dbf. * * @param sds DOCUMENT ME! */ private void createdbf(SelectableDataSource sds, BitSet bitset) { int i = 0; // for (int i = 0; i < fgs.length; i++) { try { if (sds == null) { for (int j = 0; j < geometries.length; j++) { enteros[0] = ValueFactory.createValue((double) i); dbfWrite.write(enteros); i++; } } else { for (int j = bitset.nextSetBit(0); j >= 0; j = bitset.nextSetBit(j + 1)) { for (int r = 0; r < sds.getFieldCount(); r++) { record[r] = sds.getFieldValue(j, r); } dbfWrite.write(record); } } } catch (IOException e1) { e1.printStackTrace(); } catch (ReadDriverException e) { e.printStackTrace(); } }