1. /* $Id: AbstractObjectCreationFactory.java,v 1.12 2004/05/10 06:30:06 skitching Exp $
  2. *
  3. * Copyright 2001-2004 The Apache Software Foundation.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. package org.apache.commons.digester;
  18. import org.xml.sax.Attributes;
  19. /**
  20. * <p>Abstract base class for <code>ObjectCreationFactory</code>
  21. * implementations.</p>
  22. */
  23. abstract public class AbstractObjectCreationFactory implements ObjectCreationFactory {
  24. // ----------------------------------------------------- Instance Variables
  25. /**
  26. * The associated <code>Digester</code> instance that was set up by
  27. * {@link FactoryCreateRule} upon initialization.
  28. */
  29. protected Digester digester = null;
  30. // --------------------------------------------------------- Public Methods
  31. /**
  32. * <p>Factory method called by {@link FactoryCreateRule} to supply an
  33. * object based on the element's attributes.
  34. *
  35. * @param attributes the element's attributes
  36. *
  37. * @throws Exception any exception thrown will be propagated upwards
  38. */
  39. public abstract Object createObject(Attributes attributes) throws Exception;
  40. /**
  41. * <p>Returns the {@link Digester} that was set by the
  42. * {@link FactoryCreateRule} upon initialization.
  43. */
  44. public Digester getDigester() {
  45. return (this.digester);
  46. }
  47. /**
  48. * <p>Set the {@link Digester} to allow the implementation to do logging,
  49. * classloading based on the digester's classloader, etc.
  50. *
  51. * @param digester parent Digester object
  52. */
  53. public void setDigester(Digester digester) {
  54. this.digester = digester;
  55. }
  56. }