1
/* $Id: StackAction.java 476205 2006-11-17 16:43:10Z dennisl $
3
* Licensed to the Apache Software Foundation (ASF) under one or more
4
* contributor license agreements. See the NOTICE file distributed with
5
* this work for additional information regarding copyright ownership.
6
* The ASF licenses this file to You under the Apache License, Version 2.0
7
* (the "License"); you may not use this file except in compliance with
8
* the License. You may obtain a copy of the License at
10
* http://www.apache.org/licenses/LICENSE-2.0
12
* Unless required by applicable law or agreed to in writing, software
13
* distributed under the License is distributed on an "AS IS" BASIS,
14
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
* See the License for the specific language governing permissions and
16
* limitations under the License.
20
package org.apache.commons.digester;
23
* An interface that can be implemented in order to get notifications of
24
* objects being pushed onto a digester stack or popped from one.
26
* Because objects are pushed onto the main object stack when a rule
27
* has created a new object, this gives the ability to intercept such
28
* operations and perform modifications on created objects.
30
* One use expected for this interface is to store information about the xml
31
* line that a particular object was created from. An implementation of this
32
* interface can detect whenever an object is pushed onto the digester object
33
* stack, call Digester.getDocumentLocator() to get the location within the
34
* current xml file, and store this either on the object on the stack (if it
35
* supports some user-specific interface for this purpose), or build a map of
36
* (object->locationinfo) separately.
38
* It is recommended that objects implementing this interface provide
39
* a method to set a "next" action, and invoke it from the callback
40
* methods. This allows multiple actions to be "chained" together.
42
* See also Digester.setStackAction.
46
public interface StackAction {
48
* Invoked just before an object is to be pushed onto a digester stack.
50
* @param d is the digester instance.
52
* @param stackName is the name of the stack onto which the object
53
* has been pushed. Null is passed to indicate the default stack.
55
* @param o is the object that has just been pushed. Calling peek on the
56
* specified stack will return the same object.
58
* @return the object to be pushed. Normally, parameter o is returned
59
* but this method could return an alternate object to be pushed
60
* instead (eg a proxy for the provided object).
62
public Object onPush(Digester d, String stackName, Object o);
65
* Invoked just after an object has been popped from a digester stack.
67
* @param d is the digester instance.
69
* @param stackName is the name of the stack from which the object
70
* has been popped. Null is passed to indicate the default stack.
72
* @param o is the object that has just been popped.
74
* @return the object to be returned to the called. Normally, parameter
75
* o is returned but this method could return an alternate object.
77
public Object onPop(Digester d, String stackName, Object o);