public Test() { Context context = new Context(); context.execute(); context.setState(new FirstState()); context.execute(); context.execute(); context.execute(); context.execute(); }
public static void main(String[] args) { Context context; System.out.println("-----执行策略1------"); context = new Context(new ConcreteStrategy1()); context.execute(); System.out.println("----执行策略2---"); context = new Context(new ConcreteStrategy2()); context.execute(); }
@Override public void execute(Context context) throws SQLException { VarcharColumnDef propKey = newVarcharColumnDefBuilder() .setColumnName("prop_key") .setLimit(512) .setIsNullable(false) .setIgnoreOracleUnit(true) .build(); List<String> stmts = new CreateTableBuilder(getDialect(), TABLE_NAME) .addPkColumn( newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) .addColumn(propKey) .addColumn( newBigIntegerColumnDefBuilder() .setColumnName("resource_id") .setIsNullable(true) .build()) .addColumn( newBigIntegerColumnDefBuilder() .setColumnName("user_id") .setIsNullable(true) .build()) .addColumn( newBooleanColumnDefBuilder().setColumnName("is_empty").setIsNullable(false).build()) .addColumn( newVarcharColumnDefBuilder() .setColumnName("text_value") .setLimit(MAX_SIZE) .setIgnoreOracleUnit(true) .build()) .addColumn( newClobColumnDefBuilder().setColumnName("clob_value").setIsNullable(true).build()) .addColumn( newBigIntegerColumnDefBuilder() .setColumnName("created_at") .setIsNullable(false) .build()) // table with be renamed to properties in following migration, use final constraint name // right away .withPkConstraintName("pk_properties") .build(); context.execute(stmts); context.execute( new CreateIndexBuilder(getDialect()) .setTable(TABLE_NAME) .setName("properties2_key") .addColumn(propKey) .build()); }
@Override protected void perform(Context context) { // Obtain the change final Change<?> change = this.getChange(this.woofChanges, context); if (change == null) { return; // no change to perform } // Execute the change context.execute(new ChangeCommand(change)); }
@Override public void execute(Context context) throws SQLException { context.execute( new AlterColumnsBuilder(getDatabase().getDialect(), TABLE_ACTIVITIES) .updateColumn( newVarcharColumnDefBuilder() .setColumnName("profile_key") .setLimit(255) .setIsNullable(false) .setIgnoreOracleUnit(true) .build()) .build()); }
public static void main(String args[]) { Scanner userInput; try { userInput = new Scanner(System.in); } catch (Exception e) { userInput = null; } System.out.print("Please Enter Value: "); inputChars = (userInput.nextLine() + '\0').toCharArray(); Context context = new Context(); for (int i = 0; i < inputChars.length; i++) { context.execute(inputChars[i]); } System.out.println(context.getValue()); }
@Override public void execute(Context context) throws SQLException { context.execute( new DropColumnsBuilder(getDatabase().getDialect(), TABLE, "snapshot_id").build()); }
@Override public void execute(Context context) throws SQLException { context.execute(generateSql()); }