001 package org.apache.commons.digester3;
002
003 /*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements. See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership. The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License. You may obtain a copy of the License at
011 *
012 * http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied. See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022 import org.xml.sax.Attributes;
023
024 /**
025 * <p>
026 * Interface for use with {@link FactoryCreateRule}. The rule calls {@link #createObject} to create an object to be
027 * pushed onto the <code>Digester</code> stack whenever it is matched.
028 * </p>
029 * <p>
030 * {@link AbstractObjectCreationFactory} is an abstract implementation suitable for creating anonymous
031 * <code>ObjectCreationFactory</code> implementations.
032 *
033 * @param <T> The object type created byt the factory.
034 */
035 public interface ObjectCreationFactory<T>
036 {
037
038 /**
039 * Factory method called by {@link FactoryCreateRule} to supply an object based on the element's attributes.
040 *
041 * @param attributes the element's attributes
042 * @return the object to be pushed onto the <code>Digester</code> stack
043 * @throws Exception any exception thrown will be propagated upwards
044 */
045 T createObject( Attributes attributes )
046 throws Exception;
047
048 /**
049 * Returns the {@link Digester} that was set by the {@link FactoryCreateRule} upon initialization.
050 *
051 * @return the {@link Digester} that was set by the {@link FactoryCreateRule} upon initialization
052 */
053 Digester getDigester();
054
055 /**
056 * Set the {@link Digester} to allow the implementation to do logging, classloading based on the digester's
057 * classloader, etc.
058 *
059 * @param digester parent Digester object
060 */
061 void setDigester( Digester digester );
062
063 }