1 package org.apache.torque.generator.outlet; 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 java.util.Map; 23 24 import org.apache.torque.generator.GeneratorException; 25 import org.apache.torque.generator.configuration.ConfigurationException; 26 import org.apache.torque.generator.configuration.mergepoint.MergepointMapping; 27 import org.apache.torque.generator.control.ControllerState; 28 import org.apache.torque.generator.qname.QualifiedName; 29 30 /** 31 * Generates String output from the AST. 32 */ 33 public interface Outlet 34 { 35 /** 36 * Returns the name of the Template. The namespace part of the name defines 37 * the default context of the template. 38 * 39 * @return the name of the Template, not null. 40 */ 41 QualifiedName getName(); 42 43 /** 44 * Adds an mergepoint mapping to the outlet. No mergepoint 45 * mappings must exist with the given name. 46 * 47 * @param mergepointMapping the mergepointMapping to add, not null. 48 * 49 * @throws NullPointerException if mergepointMapping is null. 50 * @throws ConfigurationException if an mergepointMapping 51 * for the given name already exists. 52 */ 53 void addMergepointMapping(MergepointMapping mergepointMapping) 54 throws ConfigurationException; 55 56 /** 57 * Sets an mergepoint mapping in the outlet. If a mergepoint 58 * mapping with the given name already exists, it is replaced. 59 * 60 * @param mergepointMapping the mergepointMapping to add, not null. 61 * 62 * @return the replaced mergepoint mapping, not null. 63 * 64 * @throws NullPointerException if mergepointMapping is null. 65 */ 66 MergepointMapping setMergepointMapping(MergepointMapping mergepointMapping); 67 68 /** 69 * Returns the mergepoint mapping for the given mergepoint name. 70 * 71 * @param name the name of the mergepoint mapping. 72 * 73 * @return the mergepoint mapping for the given name, or null if no 74 * mergepoint mapping exists for this name. 75 */ 76 MergepointMapping getMergepointMapping(String name); 77 78 /** 79 * Returns the map of all mergepoint mappings, keyed by their name. 80 * 81 * @return the map of mergepoint mappings, not null. 82 */ 83 Map<String, MergepointMapping> getMergepointMappings(); 84 85 /** 86 * Sets the name of the input root element. If set, the outlet must 87 * check if the name of the input root element corresponds to the set 88 * element name and throw an exception if the names do not match. 89 * 90 * @param inputName the name of the root element of the source, 91 * or null to accept any input name. 92 */ 93 void setInputElementName(String inputName); 94 95 /** 96 * Returns the name of the input root element. If not null, the outlet 97 * checks if the name of the input root element corresponds to the set 98 * element name and throw an exception if the names do not match. 99 * 100 * @return inputName the name of the root element of the source, 101 * or if any input name is accepted. 102 */ 103 String getInputElementName(); 104 105 /** 106 * Adjusts the state of the Controller before generation. 107 * 108 * @param controllerState the current controller state, not null. 109 * 110 * @throws GeneratorException if adjusting the controller state fails. 111 */ 112 void beforeExecute(ControllerState controllerState) 113 throws GeneratorException; 114 115 /** 116 * Adjusts the state of the Controller after generation. 117 * 118 * @param controllerState the current controller state, not null. 119 * 120 * @throws GeneratorException if adjusting the controller state fails. 121 */ 122 void afterExecute(ControllerState controllerState) 123 throws GeneratorException; 124 125 /** 126 * Generates the output for this template into the Generated object. 127 * 128 * @param controllerState the current controller state, not null. 129 * 130 * @return the output of the Outlet. 131 * 132 * @throws GeneratorException if generation fails. 133 */ 134 OutletResult execute(ControllerState controllerState) 135 throws GeneratorException; 136 }