io.odysz.module.xtable.DefaultTableStruct Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of semantic.DA Show documentation
Show all versions of semantic.DA Show documentation
JDBC Data Access with Semantics Support
package io.odysz.module.xtable;
import java.util.LinkedHashMap;
public class DefaultTableStruct implements ITableStruct {
protected static final String attrNameTableID = "tableID";
protected static final String attrNameColumns = "columns";
protected static final String attrNamePks = "pk";
protected LinkedHashMap pkIdx;
protected String pkDef;
protected LinkedHashMap colIdx;
protected String colDef;
public DefaultTableStruct(String colDefs, String pkDefs) {
pkDef = pkDefs;
colDef = colDefs;
}
@Override
public LinkedHashMap pkIdx() {
if (pkIdx == null) {
pkIdx = buildIdx(pkDef);
}
return pkIdx;
}
@Override
public String pkDefs() {
return pkDef;
}
@Override
public LinkedHashMap colIdx() {
if (colIdx == null) {
colIdx = buildIdx(colDef);
}
return colIdx;
}
protected static LinkedHashMap buildIdx(String defs) {
if (defs == null) return null;
LinkedHashMap idx = new LinkedHashMap();
String[] fns = defs.split(",");
if (fns == null) return null;
for (int i = 0; i < fns.length; i++)
idx.put(fns[i].trim(), i);
return idx;
}
@Override
public String colDefs() {
return colDef;
}
@Override
public String attrTableID() {
return attrNameTableID;
}
@Override
public String attrPks() {
return attrNamePks;
}
@Override
public String attrCols() {
return attrNameColumns;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy