1 package org.apache.torque.generator.configuration.controller;
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.qname.Namespace;
23 import org.apache.torque.generator.qname.QualifiedName;
24
25 /**
26 * Represents a reference to a outlet.
27 *
28 * @version $Id: OutletReference.java 1331190 2012-04-27 02:41:35Z tfischer $
29 */
30 public class OutletReference
31 {
32 /** The name of the referenced outlet. */
33 private QualifiedName name;
34
35 /**
36 * The namespace under which the outlet should execute.
37 * Defaults to the namespace in the outlet's name.
38 */
39 private Namespace namespace;
40
41 /**
42 * Constructor.
43 *
44 * @param name the name of the referenced outlet, not null.
45 */
46 public OutletReference(String name)
47 {
48 if (name == null)
49 {
50 throw new IllegalArgumentException("name must not be null");
51 }
52 this.name = new QualifiedName(name, Namespace.ROOT_NAMESPACE);
53 namespace = this.name.getNamespace();
54 }
55
56 /**
57 * Constructor.
58 *
59 * @param name the name of the referenced outlet, not null.
60 */
61 public OutletReference(QualifiedName name)
62 {
63 if (name == null)
64 {
65 throw new IllegalArgumentException("name must not be null");
66 }
67 this.name = name;
68 namespace = this.name.getNamespace();
69 }
70
71 /**
72 * Returns the qualified name of the outlet.
73 *
74 * @return the qualified name of the outlet, not null.
75 */
76 public QualifiedName getName()
77 {
78 return name;
79 }
80
81 /**
82 * Returns the namespace under which the outlet executes.
83 *
84 * @return the namespace under which the outlet executes.
85 */
86 public Namespace getNamespace()
87 {
88 return namespace;
89 }
90
91 /**
92 * {@inheritDoc}
93 */
94 @Override
95 public String toString()
96 {
97 StringBuffer result = new StringBuffer();
98 result.append("(name=").append(name).append(")");
99 return result.toString();
100 }
101 }