View Javadoc

1   package org.apache.torque.generator.java;
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.commons.logging.Log;
23  import org.apache.commons.logging.LogFactory;
24  import org.apache.torque.generator.GeneratorException;
25  import org.apache.torque.generator.control.ControllerState;
26  import org.apache.torque.generator.outlet.OutletImpl;
27  import org.apache.torque.generator.outlet.OutletResult;
28  import org.apache.torque.generator.qname.QualifiedName;
29  /**
30   * A test java outlet.
31   */
32  public class JavaOutlet extends OutletImpl
33  {
34      /** The class log. */
35      private static Log log = LogFactory.getLog(JavaOutlet.class);
36  
37      /** A generator configuration option. */
38      private String foo;
39  
40      /** Another generator configuration option. */
41      private String bar;
42  
43      public JavaOutlet(QualifiedName name)
44      {
45          super(name);
46      }
47  
48      @Override
49      public OutletResult execute(ControllerState controllerState)
50              throws GeneratorException
51      {
52          return new OutletResult(
53                  "Test Outlet output; foo=" + foo + "; bar=" + bar);
54      }
55  
56      public void setFoo(String foo)
57      {
58          log.info("foo set to " + foo);
59          this.foo = foo;
60      }
61  
62      public void setBar(String bar)
63      {
64          log.info("bar set to " + bar);
65          this.bar = bar;
66      }
67  
68      public String getBar()
69      {
70          return bar;
71      }
72  
73      public String getFoo()
74      {
75          return foo;
76      }
77  
78      @Override
79      public int hashCode()
80      {
81          final int prime = 31;
82          int result = 1;
83          result = prime * result + ((bar == null) ? 0 : bar.hashCode());
84          result = prime * result + ((foo == null) ? 0 : foo.hashCode());
85          result = prime * result + getName().hashCode();
86          result = prime * result + ((getInputElementName() == null)
87                  ? 0
88                  : getInputElementName().hashCode());
89          return result;
90      }
91  
92      @Override
93      public boolean equals(Object obj)
94      {
95          if (this == obj)
96          {
97              return true;
98          }
99          if (obj == null)
100         {
101             return false;
102         }
103         if (getClass() != obj.getClass())
104         {
105             return false;
106         }
107         JavaOutlet other = (JavaOutlet) obj;
108         if (bar == null)
109         {
110             if (other.bar != null)
111             {
112                 return false;
113             }
114         }
115         else if (!bar.equals(other.bar))
116         {
117             return false;
118         }
119         if (foo == null)
120         {
121             if (other.foo != null)
122             {
123                 return false;
124             }
125         }
126         else if (!foo.equals(other.foo))
127         {
128             return false;
129         }
130         if (!getName().equals(other.getName()))
131         {
132             return false;
133         }
134         if (getInputElementName() == null)
135         {
136             if (other.getInputElementName() != null)
137             {
138                 return false;
139             }
140         }
141         else if (!getInputElementName().equals(other.getInputElementName()))
142         {
143             return false;
144         }
145         return true;
146     }
147 }