root / branches / v10 / libraries / libGDBMS / src / main / java / com / hardcode / gdbms / engine / data / DataSourceCommonImpl.java @ 11007
History | View | Annotate | Download (1.46 KB)
1 | 3199 | fjp | package com.hardcode.gdbms.engine.data; |
---|---|---|---|
2 | |||
3 | import com.hardcode.gdbms.engine.data.driver.DriverException; |
||
4 | import com.hardcode.gdbms.engine.values.Value; |
||
5 | |||
6 | /**
|
||
7 | * @author Fernando Gonz?lez Cort?s
|
||
8 | */
|
||
9 | public abstract class DataSourceCommonImpl implements DataSource{ |
||
10 | |||
11 | /**
|
||
12 | * @see com.hardcode.gdbms.engine.data.DataSource#getRow(long)
|
||
13 | */
|
||
14 | public Value[] getRow(long rowIndex) throws DriverException { |
||
15 | Value[] ret = new Value[getFieldCount()]; |
||
16 | |||
17 | for (int i = 0; i < ret.length; i++) { |
||
18 | ret[i] = getFieldValue(rowIndex, i); |
||
19 | } |
||
20 | |||
21 | return ret;
|
||
22 | } |
||
23 | |||
24 | /**
|
||
25 | * @see com.hardcode.gdbms.engine.data.DataSource#getFieldNames()
|
||
26 | */
|
||
27 | public String[] getFieldNames() throws DriverException { |
||
28 | String[] ret = new String[getFieldCount()]; |
||
29 | |||
30 | for (int i = 0; i < ret.length; i++) { |
||
31 | ret[i] = getFieldName(i); |
||
32 | } |
||
33 | |||
34 | return ret;
|
||
35 | } |
||
36 | |||
37 | /**
|
||
38 | * gets a string representation of this datasource
|
||
39 | *
|
||
40 | * @return String
|
||
41 | *
|
||
42 | * @throws DriverException
|
||
43 | */
|
||
44 | public String getAsString() throws DriverException { |
||
45 | |||
46 | StringBuffer aux = new StringBuffer(); |
||
47 | int fc = getFieldCount();
|
||
48 | int rc = (int) getRowCount(); |
||
49 | |||
50 | for (int i = 0; i < fc; i++) { |
||
51 | aux.append(getFieldName(i).toUpperCase()).append("\t");
|
||
52 | } |
||
53 | |||
54 | for (int row = 0; row < rc; row++) { |
||
55 | for (int j = 0; j < fc; j++) { |
||
56 | aux.append(getFieldValue(row, j)).append("\t");
|
||
57 | } |
||
58 | } |
||
59 | |||
60 | return aux.toString();
|
||
61 | } |
||
62 | |||
63 | } |