View Javadoc

1   package org.apache.maven.jelly.tags;
2   
3   /* ====================================================================
4    *   Licensed to the Apache Software Foundation (ASF) under one or more
5    *   contributor license agreements.  See the NOTICE file distributed with
6    *   this work for additional information regarding copyright ownership.
7    *   The ASF licenses this file to You under the Apache License, Version 2.0
8    *   (the "License"); you may not use this file except in compliance with
9    *   the License.  You may obtain a copy of the License at
10   *
11   *       http://www.apache.org/licenses/LICENSE-2.0
12   *
13   *   Unless required by applicable law or agreed to in writing, software
14   *   distributed under the License is distributed on an "AS IS" BASIS,
15   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   *   See the License for the specific language governing permissions and
17   *   limitations under the License.
18   * ====================================================================
19   */
20  
21  import org.apache.commons.jelly.MissingAttributeException;
22  import org.apache.commons.jelly.TagSupport;
23  import org.apache.maven.jelly.MavenJellyContext;
24  
25  /**
26   * A class for Maven Jelly tags
27   */
28  public abstract class BaseTagSupport
29      extends TagSupport
30  {
31      /**
32       * Create an instance
33       */
34      public BaseTagSupport()
35      {
36          super();
37      }
38  
39      /**
40       * @return the maven context (used to retrieve variables)
41       */
42      public MavenJellyContext getMavenContext()
43      {
44          return (MavenJellyContext) getContext();
45      }
46  
47      /**
48       * Check a given 'attribute' has a value and throw the corresponding
49       * exception if it doesn't
50       *
51       * @param attribute the attribute to check
52       * @param message the message to pass in with the exception
53       * @throws MissingAttributeException when the attribute is null
54       */
55      protected void checkAttribute( Object attribute, String message )
56          throws MissingAttributeException
57      {
58          if ( attribute == null )
59          {
60              throw new MissingAttributeException( message );
61          }
62      }
63  
64  }