@Override public int hashCode() { int result = characters.hashCode(); result = 31 * result + backgroundColor.hashCode(); result = 31 * result + textColor.hashCode(); result = 31 * result + type.hashCode(); return result; }
public String getAsString() { StringBuilder builder = new StringBuilder(); builder.append(ANSI.getStart()); builder.append(type.getValue()).append(';'); builder.append(this.getTextColor().getValue()).append(';'); builder.append(this.getBackgroundColor().getValue()); builder.append('m'); builder.append(getCharacters()); return builder.toString(); }
/** Initializes the controller class. */ @Override public void initialize(URL url, ResourceBundle rb) { Config config = new ConfigLoader().load(); generateLengthComboBox.getItems().clear(); for (int i = 1; i < config.getMaxCharacterLength() + 1; i++) { generateLengthComboBox.getItems().add(i); } generateLengthComboBox .getSelectionModel() .select(Integer.valueOf(config.getDefaultCharacterLength())); generateCharacterTypeComboBox.getItems().clear(); generateCharacterTypeComboBox.getItems().addAll(CharacterType.allTextValues()); generateCharacterTypeComboBox.getSelectionModel().select(CharacterType.ALPHA_NUMERIC.text); }
/** type, text color, background color */ public String getAsString(TerminalString prev) { if (equalsIgnoreCharacter(prev)) return characters; else { StringBuilder builder = new StringBuilder(); builder.append(ANSI.getStart()); builder.append(type.getValueComparedToPrev(prev.getType())); if (this.getTextColor() != prev.getTextColor() || prev.getType() == CharacterType.INVERT) builder.append(';').append(this.getTextColor().getValue()); if (this.getBackgroundColor() != prev.getBackgroundColor() || prev.getType() == CharacterType.INVERT) builder.append(';').append(this.getBackgroundColor().getValue()); builder.append('m'); builder.append(getCharacters()); return builder.toString(); } }
@FXML protected void handleButtonAction(ActionEvent event) { // TODO vaidation... Integer length = generateLengthComboBox.getValue(); if (length == null) { // TODO return; } String characterTypeText = generateCharacterTypeComboBox.getValue(); if (characterTypeText == null) { return; } String generatedText = CharacterType.characterTypeOfText(characterTypeText).generate(length.intValue()); generatedTextField.setText(generatedText); }
/** Enforces precision and scale limits on type */ public static Type getType(int type, int collation, long precision, int scale) throws HsqlException { switch (type) { case Types.SQL_ALL_TYPES: return null; // return SQL_ALL_TYPES; // needs changes to Expression type resolution case Types.SQL_CHAR: case Types.SQL_VARCHAR: case Types.VARCHAR_IGNORECASE: case Types.SQL_CLOB: return CharacterType.getCharacterType(type, precision); case Types.SQL_INTEGER: return SQL_INTEGER; case Types.SQL_SMALLINT: return SQL_SMALLINT; case Types.SQL_BIGINT: return SQL_BIGINT; case Types.TINYINT: return TINYINT; case Types.SQL_FLOAT: if (precision > 53) { throw Trace.error(Trace.NUMERIC_VALUE_OUT_OF_RANGE, "" + precision); } case Types.SQL_REAL: case Types.SQL_DOUBLE: return SQL_DOUBLE; case Types.SQL_NUMERIC: case Types.SQL_DECIMAL: if (precision == 0) { precision = NumberType.defaultNumericPrecision; } return NumberType.getNumberType(type, precision, scale); case Types.SQL_BOOLEAN: return SQL_BOOLEAN; case Types.SQL_BINARY: case Types.SQL_VARBINARY: case Types.SQL_BLOB: return BinaryType.getBinaryType(type, precision); case Types.SQL_DATE: case Types.SQL_TIME: case Types.SQL_TIMESTAMP: return DateTimeType.getDateTimeType(type, scale); case Types.SQL_INTERVAL_YEAR: case Types.SQL_INTERVAL_YEAR_TO_MONTH: case Types.SQL_INTERVAL_MONTH: case Types.SQL_INTERVAL_DAY: case Types.SQL_INTERVAL_DAY_TO_HOUR: case Types.SQL_INTERVAL_DAY_TO_MINUTE: case Types.SQL_INTERVAL_DAY_TO_SECOND: case Types.SQL_INTERVAL_HOUR: case Types.SQL_INTERVAL_HOUR_TO_MINUTE: case Types.SQL_INTERVAL_HOUR_TO_SECOND: case Types.SQL_INTERVAL_MINUTE: case Types.SQL_INTERVAL_MINUTE_TO_SECOND: case Types.SQL_INTERVAL_SECOND: return IntervalType.getIntervalType(type, precision, scale); case Types.OTHER: return OTHER; default: throw Trace.runtimeError(Trace.UNSUPPORTED_INTERNAL_OPERATION, "Type"); } }
/** Enforces precision and scale limits on type */ public static Type getType(int type, int collation, long precision, int scale) { switch (type) { case Types.SQL_ALL_TYPES: return SQL_ALL_TYPES; // return SQL_ALL_TYPES; // needs changes to Expression type resolution case Types.SQL_CHAR: case Types.SQL_VARCHAR: case Types.VARCHAR_IGNORECASE: case Types.SQL_CLOB: return CharacterType.getCharacterType(type, precision); case Types.SQL_INTEGER: return SQL_INTEGER; case Types.SQL_SMALLINT: return SQL_SMALLINT; case Types.SQL_BIGINT: return SQL_BIGINT; case Types.TINYINT: return TINYINT; case Types.SQL_FLOAT: if (precision > 53) { throw Error.error(ErrorCode.X_42592, "" + precision); } // fall through case Types.SQL_REAL: case Types.SQL_DOUBLE: return SQL_DOUBLE; case Types.SQL_NUMERIC: case Types.SQL_DECIMAL: if (precision == 0) { precision = NumberType.defaultNumericPrecision; } return NumberType.getNumberType(type, precision, scale); case Types.SQL_BOOLEAN: return SQL_BOOLEAN; case Types.SQL_BINARY: case Types.SQL_VARBINARY: case Types.SQL_BLOB: return BinaryType.getBinaryType(type, precision); case Types.SQL_BIT: case Types.SQL_BIT_VARYING: return BitType.getBitType(type, precision); case Types.SQL_DATE: case Types.SQL_TIME: case Types.SQL_TIME_WITH_TIME_ZONE: case Types.SQL_TIMESTAMP: case Types.SQL_TIMESTAMP_WITH_TIME_ZONE: return DateTimeType.getDateTimeType(type, scale); case Types.SQL_INTERVAL_YEAR: case Types.SQL_INTERVAL_YEAR_TO_MONTH: case Types.SQL_INTERVAL_MONTH: case Types.SQL_INTERVAL_DAY: case Types.SQL_INTERVAL_DAY_TO_HOUR: case Types.SQL_INTERVAL_DAY_TO_MINUTE: case Types.SQL_INTERVAL_DAY_TO_SECOND: case Types.SQL_INTERVAL_HOUR: case Types.SQL_INTERVAL_HOUR_TO_MINUTE: case Types.SQL_INTERVAL_HOUR_TO_SECOND: case Types.SQL_INTERVAL_MINUTE: case Types.SQL_INTERVAL_MINUTE_TO_SECOND: case Types.SQL_INTERVAL_SECOND: return IntervalType.getIntervalType(type, precision, scale); case Types.OTHER: return OTHER; default: throw Error.runtimeError(ErrorCode.U_S0500, "Type"); } }