View Javadoc

1   /*
2    * $Id: MockDefinitionsReader.java 537196 2007-05-11 14:07:35Z apetrelli $
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  package org.apache.tiles.definition;
23  
24  import java.util.Collections;
25  import java.util.Map;
26  
27  import org.apache.tiles.Definition;
28  
29  /***
30   * Mock Defintions Reader implementation.  Stubs out all functionality.
31   *
32   * @version $Rev: 537196 $ $Date: 2007-05-11 16:07:35 +0200 (Fri, 11 May 2007) $
33   */
34  public class MockDefinitionsReader implements DefinitionsReader {
35  
36      /***
37       * Hokey way to verify that this was created.
38       */
39      private static int instanceCount = 0;
40  
41      /***
42       * Hokey way to verify that this class was created.
43       *
44       * @return The number of created instances.
45       */
46      public static int getInstanceCount() {
47          return instanceCount;
48      }
49  
50      /*** Creates a new instance of MockDefinitionsReader. */
51      public MockDefinitionsReader() {
52          instanceCount++;
53      }
54  
55      /***
56       * Reads <code>{@link Definition}</code> objects from a source.
57       *
58       * Implementations should publish what type of source object is expected.
59       *
60       * @param source The source from which definitions will be read.
61       * @return a Map of <code>Definition</code> objects read from
62       *  the source.
63       * @throws org.apache.tiles.definition.DefinitionsFactoryException if the source is invalid or
64       *  an error occurs when reading definitions.
65       */
66      @SuppressWarnings("unchecked")
67      public Map<String, Definition> read(Object source)
68              throws DefinitionsFactoryException {
69          return Collections.EMPTY_MAP;
70      }
71  
72      /***
73       * Initializes the <code>DefinitionsReader</code> object.
74       *
75       * This method must be called before the {@link #read} method is called.
76       *
77       * @param params A map of properties used to set up the reader.
78       * @throws org.apache.tiles.definition.DefinitionsFactoryException if required properties are not
79       *  passed in or the initialization fails.
80       */
81      public void init(Map<String, String> params) throws DefinitionsFactoryException {
82      }
83  
84  }