package test.order; import java.util.StringTokenizer; /** * */ public class ColumnDescriptor { /* * TODO * - bisher �berwiegend �bernommen aus C3.1, unfertig */ /** SAS-Spaltentyp. */ public static final int SAS_TYPE_INT = 1; /** SAS-Spaltentyp. */ public static final int SAS_TYPE_FLOAT = 2; /** SAS-Spaltentyp. */ public static final int SAS_TYPE_STRING = 3; /** SAS-Spaltentyp. */ public static final int SAS_TYPE_TIMEDATE = 4; /** Breiten-Faktor f�r Spaltenbreite (Original-Sas-Format). */ public static final int SAS_COL_FACTOR = 9; /** TODO selektierter Zeilenhintergrund?. */ public static final String BG_DARK = "#E6E6F3"; /** Tabellen-Anzeige: background color. */ protected String bgColor; /** SQL ColumnType. */ protected int colType; /** Initiale Spaltenposition. 1-basierend. */ protected int colPosInitial; /** Tabellen-Anzeige: width. */ protected String colWidth; /** Anzahl Nachkommastellen. */ protected int decimalLength; /** Spaltenangaben aus SAS. */ protected String format; /** SAS-Name ohne L�ngenangabe. */ protected String formatName; /** SAS-L�ngenangabe ohne Name. */ protected String formatSize; /** Spaltenangaben aus SAS. */ protected String informat; /** Ausgeblendete Spalte. */ protected boolean isHidden; /** Markierung aktuelle Viewer-Spalte (bei Spaltenviewer). */ protected boolean isSelected; /** Spaltenangaben aus SAS. */ protected String label; /** L�nge aus SAS. */ protected int length; /** Spaltenangaben aus SAS. */ protected String name; /** * Konstruktor * * @param name * Spaltenezeichnung wie von JDBC �bermittelt. * @param label * Label/Beschreibung wie von JDBC �bermittelt. * @param format * wie von SAS (per JDBC) �bermittelt, leer wenn kein spezifische * Format vergeben wurde. * @param informat * wie von SAS (per JDBC) �bermittelt, leer wenn kein spezifische * Informat vergeben wurde. * @param length * @param colType * SQL-Typ der Spalte. */ public ColumnDescriptor(int colPos, String name, String label, String format, String informat, int length, int colType) { this.colPosInitial = colPos; this.name = name; this.label = label; this.format = format; this.informat = informat; this.length = length; this.colType = colType; try { formatSize = format; } catch (NumberFormatException e) { StringTokenizer st = new StringTokenizer(format, "012345689.", true); while (st.hasMoreTokens()) { if (formatName == null) { formatName = st.nextToken(); formatSize = st.nextToken(); continue; } formatSize += st.nextToken(); } } } public String getBgColor() { return bgColor; } public int getColType() { return colType; } public int getColPosInitial() { return colPosInitial; } public int getDecimalLength() { return decimalLength; } public String getFormat() { return format; } public String getFormatName() { return formatName; } public String getFormatSize() { return formatSize; } public String getInformat() { return informat; } public boolean isHidden() { return isHidden; } public boolean isSelected() { return isSelected; } public String getLabel() { return label; } public int getLength() { return length; } public String getName() { return name; } /** * Spaltenfarbe. * * @return RGB-Wert als String oder Leerstring, wenn nicht selektiert. */ public String getColColor() { return isSelected ? BG_DARK : ""; } /** * Spaltentitel. * * @return Spaltentitel. */ public String getColTitle() { return name; } /** * Spaltenorientierung. * * @return */ public String getColAlign() { return getColType() == SAS_TYPE_STRING ? "left" : "right"; } /** * Spaltenbreite. * * @return */ public String getColWidth() { int dLength = getLength(); int tLength = getName().length(); // TODO alt return "" + (Math.max(dLength, tLength) * SAS_COL_FACTOR); } }