What do you think about this read only table design, regarding performance?
package jsql
Main.java
package jsql;
public class Main {
public static void main(String[] args) {
Record head = new Record("given name", "family name", "street", "postal code", "city");
Record jimmy = new Record("James", "Blunt", "Rochesterfield 1", "1234", "Bloomville");
Record joey = new Record("John", "Smith", "Green Way 5", "5678", "Harrisburg");
Table friends = new Table(head, jimmy, joey);
if(friends.isValid) {
System.out.println(friends.toString());
}
else {
System.err.println("Error: Invalid table with hash code: " + friends.hashCode());
}
}
}
Record.java
package jsql;
class Record {
final String entry[];
private static final String SEPARATOR = "\t";
public String toString() {
String temp = this.entry[0];
for(int i = 1; i < this.entry.length; i++) {
temp = temp.concat(SEPARATOR);
temp = temp.concat(this.entry[i]);
}
return temp;
}
Record(String...entry) {
this.entry = entry;
}
}
Table.java
package jsql;
class Table {
final Record record[];
final boolean isValid;
private static final String NEWLINE = "\n";
public String toString() {
String temp = this.record[0].toString();
for(int i = 1; i < this.record.length; i++) {
temp = temp.concat(NEWLINE);
temp = temp.concat(this.record[i].toString());
}
return temp;
}
static boolean validate(Table t) {
for(int i = 1; i < t.record.length; i++) {
if(t.record[0].entry.length != t.record[i].entry.length) {
return false;
}
}
return true;
}
Table(Record...record) {
this.record = record;
this.isValid = validate(this);
}
}