-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMySqlDatensatz.java
87 lines (70 loc) · 2.05 KB
/
MySqlDatensatz.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import java.util.ArrayList;
/**
* Klasse Datensatz repraesentiert einen Datensatz (Zeile) in einer Datenbank-Tabelle.
* Alle Attribute werden als String gespeichert und als String wieder ausgegeben.
* Der Benutzer muss die zurueck erhaltenen Werte bei Bedarf SELBST wieder zum richtigen Typ casten !!!
*
* @author mike ganshorn, manuel hengge
*
* @version 1.1 (2017-04-10)
*/
public class MySqlDatensatz
{
private int anzahlAttribute;
private ArrayList<String> attribute;
/**
* Konstruktor der Klasse Datensatz.
*/
public MySqlDatensatz()
{
this.anzahlAttribute = 0;
this.attribute = new ArrayList<String>();
}
/**
* Fuegt dem Datensatz-Objekt ein weiteres Attribut hinzu.
*
* @param attributWert Der Wert des neuen Attributs
*/
public void attributHinzufuegen( String attributWert )
{
this.attribute.add( attributWert );
this.anzahlAttribute++;
}
/**
* Gibt den Attributwert zu einem Index zurueck.
*
* @param index Der Index (die Nummer) des Attributs, beginnend mit 0
*
* @return Der Attributwert mit diesr Nummer
*/
public String nenneAttributWert( int index )
{
String attributWert = "NULL";
if ( index >= 0 && index < this.anzahlAttribute )
{
attributWert = this.attribute.get( index );
}
return attributWert;
}
/**
* Gibt die Anzahl an enthaltenen Attributen zurueck.
*
* @return Anzahl der Attribute dieses Datensatzes
*/
public int nenneAnzahlAttribute()
{
return this.anzahlAttribute;
}
/**
* Gibt eine komplette Zeile mit Tabulator getrennt als einzelnen String zurück.
*/
public String datensatzAlsString()
{
String zeile = "";
for(int i = 0; i<attribute.size();i++){
zeile = zeile + attribute.get(i)+"\t";
}
zeile = zeile + "\n";
return zeile;
}
}