1 package org.apache.torque.generator.source; 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 23 import java.util.ArrayList; 24 import java.util.Collections; 25 import java.util.List; 26 27 import org.apache.torque.generator.configuration.ClassHelper; 28 import org.apache.torque.generator.configuration.ConfigurationException; 29 import org.apache.torque.generator.source.skipDecider.SkipDecider; 30 31 /** 32 * Contains the configuration how a source should be processed between 33 * obtaining the original source and feeding it to the outlets. 34 * 35 * @version $Id: SourceProcessConfiguration.java 1331190 2012-04-27 02:41:35Z tfischer $ 36 * 37 */ 38 public class SourceProcessConfiguration 39 { 40 /** The elements which should be used as starting points for generation. */ 41 private String startElementsPath; 42 43 /** The source transformers which are executed before transformation. */ 44 private List<SourceTransformerDefinition> transformerDefinitions 45 = new ArrayList<SourceTransformerDefinition>(); 46 47 /** The skip decider, or null if none exists. */ 48 private SkipDecider skipDecider; 49 50 /** 51 * Sets the start element path. 52 * 53 * @param startElementsPath the path to the elements which are used 54 * as starting points for generation, 55 * or null if the root element should be used. 56 */ 57 public void setStartElementsPath(String startElementsPath) 58 { 59 this.startElementsPath = startElementsPath; 60 } 61 62 /** 63 * Sets and instantiates the source filter class. 64 * 65 * @param skipDecider the fully qualified name of a class 66 * which determines whether a particular source is skipped, 67 * or null if every source should be used. 68 * 69 * @throws ConfigurationException if the class cannot be 70 * instantiated or does not implement the 71 * <code>SkipDecider</code> interface. 72 */ 73 public void setSkipDecider(String skipDecider) 74 throws ConfigurationException 75 { 76 if (skipDecider != null) 77 { 78 this.skipDecider = (SkipDecider) ClassHelper.getInstance( 79 skipDecider, 80 SkipDecider.class); 81 } 82 else 83 { 84 this.skipDecider = null; 85 } 86 } 87 88 /** 89 * Sets the transformer definitions. 90 * 91 * @param transformerDefinitions the transformer definitions, or null 92 * if the input should not be transformed before generation. 93 */ 94 public void setSourceTransformerDefinitions( 95 List<SourceTransformerDefinition> transformerDefinitions) 96 { 97 if (transformerDefinitions == null) 98 { 99 this.transformerDefinitions 100 = new ArrayList<SourceTransformerDefinition>(); 101 } 102 else 103 { 104 this.transformerDefinitions 105 = new ArrayList<SourceTransformerDefinition>( 106 transformerDefinitions); 107 } 108 } 109 110 /** 111 * Returns the path to elements which should be used as starting points for 112 * generation. 113 * 114 * @return the elements to use, or null, in which case the root element 115 * is used. 116 */ 117 public String getStartElementsPath() 118 { 119 return startElementsPath; 120 } 121 122 /** 123 * Return all currently registered source transformer definitions. 124 * 125 * @return the source transformer definitions, not null. 126 */ 127 public List<SourceTransformerDefinition> getTransformerDefinitions() 128 { 129 return Collections.unmodifiableList(transformerDefinitions); 130 } 131 132 /** 133 * Returns the current SkipDecider. 134 * 135 * @return the current SkipDecider, or null if the generation should 136 * always be started for all source files. 137 */ 138 public SkipDecider getSkipDecider() 139 { 140 return skipDecider; 141 } 142 }