1 package org.apache.commons.digester3;
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.xml.sax.Attributes;
23
24 /**
25 * <p>
26 * Interface for use with {@link FactoryCreateRule}. The rule calls {@link #createObject} to create an object to be
27 * pushed onto the <code>Digester</code> stack whenever it is matched.
28 * </p>
29 * <p>
30 * {@link AbstractObjectCreationFactory} is an abstract implementation suitable for creating anonymous
31 * <code>ObjectCreationFactory</code> implementations.
32 *
33 * @param <T> The object type created byt the factory.
34 */
35 public interface ObjectCreationFactory<T>
36 {
37
38 /**
39 * Factory method called by {@link FactoryCreateRule} to supply an object based on the element's attributes.
40 *
41 * @param attributes the element's attributes
42 * @return the object to be pushed onto the <code>Digester</code> stack
43 * @throws Exception any exception thrown will be propagated upwards
44 */
45 T createObject( Attributes attributes )
46 throws Exception;
47
48 /**
49 * Returns the {@link Digester} that was set by the {@link FactoryCreateRule} upon initialization.
50 *
51 * @return the {@link Digester} that was set by the {@link FactoryCreateRule} upon initialization
52 */
53 Digester getDigester();
54
55 /**
56 * Set the {@link Digester} to allow the implementation to do logging, classloading based on the digester's
57 * classloader, etc.
58 *
59 * @param digester parent Digester object
60 */
61 void setDigester( Digester digester );
62
63 }