View Javadoc
1   /*
2    * Copyright 2008 Joachim Grueneis
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5    * in compliance with the License. You may obtain a copy of the License at
6    *
7    * http://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software distributed under the License
10   * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11   * or implied. See the License for the specific language governing permissions and limitations under
12   * the License.
13   */
14  package org.castor.xml;
15  
16  /**
17   * This class is responsible to adapt from new (1.2) UnmarshalListener interface to calls into the
18   * old interface.<br/>
19   * The old interface has been marked as deprecated but will be supported for some Castor releases to
20   * come. When the deprecated interface will be removed also this adapter implementation is useless
21   * and should be removed.
22   * 
23   * @author Joachim Grueneis, jgrueneis AT codehaus DOT org
24   * @version $Revision$
25   */
26  public class UnmarshalListenerAdapter implements UnmarshalListener {
27  
28    /**
29     * Old listener implementation - for delegation.
30     */
31    @SuppressWarnings("deprecation")
32    private org.exolab.castor.xml.UnmarshalListener _oldListener;
33  
34    public UnmarshalListenerAdapter() {
35      super();
36    }
37  
38    /**
39     * To set an 'old style' unmarshal listener to receive the callback calls.
40     * 
41     * @param exolabListener the 'old style' unmarshal listener
42     */
43    @SuppressWarnings("deprecation")
44    public void setOldListener(org.exolab.castor.xml.UnmarshalListener exolabListener) {
45      _oldListener = exolabListener;
46    }
47  
48    @Override
49    @SuppressWarnings("deprecation")
50    public void attributesProcessed(final Object target, final Object parent) {
51      if (_oldListener != null) {
52        _oldListener.attributesProcessed(target);
53      }
54    }
55  
56    @Override
57    @SuppressWarnings("deprecation")
58    public void fieldAdded(String fieldName, Object parent, Object child) {
59      if (_oldListener != null) {
60        _oldListener.fieldAdded(fieldName, parent, child);
61      }
62    }
63  
64    @Override
65    @SuppressWarnings("deprecation")
66    public void initialized(Object target, Object parent) {
67      if (_oldListener != null) {
68        _oldListener.initialized(target);
69      }
70    }
71  
72    @Override
73    @SuppressWarnings("deprecation")
74    public void unmarshalled(Object target, Object parent) {
75      if (_oldListener != null) {
76        _oldListener.unmarshalled(target);
77      }
78    }
79  
80  }