1 package org.apache.torque.generator.control.existingtargetstrategy; 2 3 /* 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 */ 21 22 import org.apache.torque.generator.GeneratorException; 23 import org.apache.torque.generator.configuration.UnitConfiguration; 24 import org.apache.torque.generator.outlet.OutletResult; 25 26 /** 27 * A handler which implements a strategy on how to deal with existing targets. 28 * 29 * @version $Id: ExistingTargetStrategy.java 1368426 2012-08-02 11:46:37Z tfischer $ 30 */ 31 public interface ExistingTargetStrategy 32 { 33 /** 34 * Will be called before the generation is started and decides whether 35 * the generation process for this file should proceed. 36 * 37 * @param outputDirKey the key for the output directory 38 * into which the generated file should be written, 39 * null for the default output directory. 40 * @param outputPath the path to which the output should be written, 41 * relative to the output base directory. 42 * @param encoding The character encoding of the generated file, 43 * or null for the platform default encoding. 44 * @param unitConfiguration the configuration of the current configuration 45 * unit, not null. 46 * 47 * @return true if generation should proceed, 48 * false if generation should be aborted. 49 * 50 * @throws GeneratorException on an error. 51 */ 52 boolean beforeGeneration( 53 String outputDirKey, 54 String outputPath, 55 String encoding, 56 UnitConfiguration unitConfiguration) 57 throws GeneratorException; 58 59 /** 60 * Processes the results of the generation. 61 * 62 * @param outputDirKey the key for the output directory 63 * into which the generated file should be written, 64 * null for the default output directory. 65 * @param outputPath the path to which the output should be written, 66 * relative to the output base directory. 67 * @param encoding The character encoding of the generated file, 68 * or null for the platform default encoding. 69 * @param generationResult the result of the generation, not null. 70 * @param unitConfiguration the configuration of the current configuration 71 * unit, not null. 72 * 73 * @throws GeneratorException on an error. 74 */ 75 void afterGeneration( 76 String outputDirKey, 77 String outputPath, 78 String encoding, 79 OutletResult generationResult, 80 UnitConfiguration unitConfiguration) 81 throws GeneratorException; 82 83 /** 84 * Returns the name of the existing target strategy. 85 * 86 * @return the strategy name, not null, must be different from the names of 87 * other strategies. 88 */ 89 String getStrategyName(); 90 }