Package org.geotools.data.shapefile.dbf

Examples of org.geotools.data.shapefile.dbf.DbaseFileReader$Row


        Lists.newArrayList("column1", "column2", "column3"), Pql.getColumnLabels(resultSet));
  }

  @Test
  public void testGetRowStringValues() {
    Row row = new Row();
    row.getValues().addAll(Lists.newArrayList(textValue1, booleanValue1, numberValue2));
    assertEquals(Lists.newArrayList("value1", "false", "1.02"), Pql.getRowStringValues(row));
  }
View Full Code Here


    assertEquals(Lists.newArrayList("value1", "false", "1.02"), Pql.getRowStringValues(row));
  }

  @Test
  public void testCombineResultSet() {
    Row row1 = new Row();
    row1.getValues().addAll(Lists.newArrayList(textValue1, booleanValue1, numberValue1));

    Row row2 = new Row();
    row2.getValues().addAll(Lists.newArrayList(textValue2, booleanValue2, numberValue2));

    Row row3 = new Row();
    row3.getValues().addAll(Lists.newArrayList(textValue3, booleanValue3, numberValue3));

    ResultSet resultSet1 = new ResultSet();
    resultSet1.getColumnTypes().addAll(Lists.newArrayList(column1, column2, column3));
    resultSet1.getRows().addAll(Lists.newArrayList(row1, row2));
View Full Code Here

        combinedResultSet.getRows().get(2).getValues());
  }

  @Test(expected = IllegalArgumentException.class)
  public void testCombineResultSet_badColumns() {
    Row row1 = new Row();
    row1.getValues().addAll(Lists.newArrayList(textValue1, booleanValue1, numberValue1));

    Row row2 = new Row();
    row2.getValues().addAll(Lists.newArrayList(textValue2, booleanValue2, numberValue2));

    Row row3 = new Row();
    row3.getValues().addAll(Lists.newArrayList(textValue3, booleanValue3));

    ResultSet resultSet1 = new ResultSet();
    resultSet1.getColumnTypes().addAll(Lists.newArrayList(column1, column2, column3));
    resultSet1.getRows().addAll(Lists.newArrayList(row1, row2));
View Full Code Here

        Lists.newArrayList("column1", "column2", "column3"), Pql.getColumnLabels(resultSet));
  }

  @Test
  public void testGetRowStringValues() {
    Row row = new Row();
    row.getValues().addAll(Lists.newArrayList(textValue1, booleanValue1, numberValue2));
    assertEquals(Lists.newArrayList("value1", "false", "1.02"), Pql.getRowStringValues(row));
  }
View Full Code Here

    assertEquals(Lists.newArrayList("value1", "false", "1.02"), Pql.getRowStringValues(row));
  }

  @Test
  public void testCombineResultSet() {
    Row row1 = new Row();
    row1.getValues().addAll(Lists.newArrayList(textValue1, booleanValue1, numberValue1));

    Row row2 = new Row();
    row2.getValues().addAll(Lists.newArrayList(textValue2, booleanValue2, numberValue2));

    Row row3 = new Row();
    row3.getValues().addAll(Lists.newArrayList(textValue3, booleanValue3, numberValue3));

    ResultSet resultSet1 = new ResultSet();
    resultSet1.getColumnTypes().addAll(Lists.newArrayList(column1, column2, column3));
    resultSet1.getRows().addAll(Lists.newArrayList(row1, row2));
View Full Code Here

        combinedResultSet.getRows().get(2).getValues());
  }

  @Test(expected = IllegalArgumentException.class)
  public void testCombineResultSet_badColumns() {
    Row row1 = new Row();
    row1.getValues().addAll(Lists.newArrayList(textValue1, booleanValue1, numberValue1));

    Row row2 = new Row();
    row2.getValues().addAll(Lists.newArrayList(textValue2, booleanValue2, numberValue2));

    Row row3 = new Row();
    row3.getValues().addAll(Lists.newArrayList(textValue3, booleanValue3));

    ResultSet resultSet1 = new ResultSet();
    resultSet1.getColumnTypes().addAll(Lists.newArrayList(column1, column2, column3));
    resultSet1.getRows().addAll(Lists.newArrayList(row1, row2));
View Full Code Here

   * @return A list of attribute names in the DBF file
   */
  public static List<String> getAttributeNames(File dbfFile) throws IOException
  {
    FileInputStream fis = new FileInputStream(dbfFile);
    DbaseFileReader dbfReader = new DbaseFileReader(fis.getChannel(), false, Charset.forName("ISO-8859-1"));
   
    //contains the header columns
    DbaseFileHeader dbfHeader = dbfReader.getHeader();
   
    // get the names from the header
    List<String> names = new Vector<String>();
    int n = dbfHeader.getNumFields();
    for (int i = 0; i < n; i++)
View Full Code Here

   */
  public static Object[][] getDBFData(File dbfFile, String[] fieldNames) throws IOException
  {
    List<String> allFields = getAttributeNames(dbfFile);
    FileInputStream fis = new FileInputStream(dbfFile);
    DbaseFileReader dbfReader = new DbaseFileReader(fis.getChannel(), false, Charset.forName("ISO-8859-1"));
   
    //contains the header columns
    DbaseFileHeader dbfHeader = dbfReader.getHeader();
   
    List<Object[]> rowsList = new Vector<Object[]>();
   

    while(dbfReader.hasNext())
    {
      Object[] row;
      if (fieldNames != null)
      {
        dbfReader.read();
        row = new Object[fieldNames.length];
        for (int i = 0; i < fieldNames.length; i++)
        {
          int index = allFields.indexOf(fieldNames[i]);
          if (index < 0)
            row[i] = "";
          else
            row[i] = dbfReader.readField(index);
        }
      }
      else
      {
        row = dbfReader.readEntry();
      }
      rowsList.add(row);
    }
   
   
View Full Code Here

   
    // open each file, read each header, get the complete list of field names and types
    for (int i = 0; i < dbfFiles.length; i++)
    {
      inputStreams[i] = new FileInputStream(dbfFiles[i]);
      readers[i] = new DbaseFileReader(inputStreams[i].getChannel(), false, Charset.forName("ISO-8859-1"));
      headers[i] = readers[i].getHeader();
     
      int numFields = headers[i].getNumFields();
      // keep track of the full set of field names
      for (int col = 0; col < numFields; col++)
View Full Code Here

            writer.write(current);
        }
        writer.close();
        fos.flush();
        fos.close();
        DbaseFileReader reader = new DbaseFileReader(new FileInputStream(tmp).getChannel(), false, cs, tz);
        assertTrue("Number of records does not match", values.length == reader.getHeader().getNumRecords());
        for (int row = 0; row < values.length; row++) {
            Object[] current = reader.readEntry();
            assertTrue("Number of columns incorrect", current != null && current.length == values.length);
            for (int column = 0; column < values.length; column++) {
                if (column == row) {
                    assertTrue("Column was null and should not have been", current[column] != null);
                    assertTrue("Non-null column value " + current[column] +
View Full Code Here

TOP

Related Classes of org.geotools.data.shapefile.dbf.DbaseFileReader$Row

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.