Coverage Report - org.simpleframework.xml.strategy.Visitor
 
Classes in this File Line Coverage Branch Coverage Complexity
Visitor
N/A
N/A
1
 
 1  
 /*
 2  
  * Visitor.java January 2010
 3  
  *
 4  
  * Copyright (C) 2010, Niall Gallagher <niallg@users.sf.net>
 5  
  *
 6  
  * Licensed under the Apache License, Version 2.0 (the "License");
 7  
  * you may not use this file except in compliance with the License.
 8  
  * You may obtain a copy of the License at
 9  
  *
 10  
  *     http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 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 
 15  
  * implied. See the License for the specific language governing 
 16  
  * permissions and limitations under the License.
 17  
  */
 18  
 
 19  
 package org.simpleframework.xml.strategy;
 20  
 
 21  
 import org.simpleframework.xml.stream.InputNode;
 22  
 import org.simpleframework.xml.stream.NodeMap;
 23  
 import org.simpleframework.xml.stream.OutputNode;
 24  
 
 25  
 /**
 26  
  * The <code>Visitor</code> interface represents an object that is 
 27  
  * used to visit each XML element during serialization. For the
 28  
  * deserialization process each XML element is visited before 
 29  
  * control is returned to the serializer. This allows a visitor
 30  
  * implementation to perform some operation based on the node 
 31  
  * that is being deserialized. Typically a visitor is used to
 32  
  * edit the node, for example it may remove or insert attributes.
 33  
  * <p>
 34  
  * In effect this can act much like a transformer that sits
 35  
  * between a <code>Strategy</code> implementation and the core
 36  
  * serializer. It enables interception and manipulation of the
 37  
  * node so that the resulting XML document can be customized in 
 38  
  * a way that can not be performed by the underlying strategy.
 39  
  * 
 40  
  * @author Niall Gallagher
 41  
  * 
 42  
  * @see org.simpleframework.xml.strategy.VisitorStrategy
 43  
  */
 44  
 public interface Visitor {
 45  
    
 46  
    /**
 47  
     * This is used to intercept an XML element before it is read
 48  
     * by the underlying <code>Strategy</code> implementation. When
 49  
     * a node is intercepted it can be manipulated in such a way
 50  
     * that its semantics change. For example, this could be used 
 51  
     * to change the way a "class" attribute is represented, which
 52  
     * would allow the XML to appear in a language neutral format.
 53  
     *
 54  
     * @param type this is the type that represents the element
 55  
     * @param node this is the XML element to be intercepted
 56  
     */
 57  
    void read(Type type, NodeMap<InputNode> node) throws Exception;
 58  
    
 59  
    /**
 60  
     * This is used to intercept an XML element after it is written
 61  
     * by the underlying <code>Strategy</code> implementation. When
 62  
     * a node is intercepted it can be manipulated in such a way
 63  
     * that its semantics change. For example, this could be used 
 64  
     * to change the way a "class" attribute is represented, which
 65  
     * would allow the XML to appear in a language neutral format.
 66  
     *
 67  
     * @param type this is the type that represents the element
 68  
     * @param node this is the XML element to be intercepted
 69  
     */
 70  
    void write(Type type, NodeMap<OutputNode> node) throws Exception;
 71  
 }