001    /*
002     * Copyright (c) 2007 Henri Sivonen
003     * Copyright (c) 2008 Mozilla Foundation
004     *
005     * Permission is hereby granted, free of charge, to any person obtaining a 
006     * copy of this software and associated documentation files (the "Software"), 
007     * to deal in the Software without restriction, including without limitation 
008     * the rights to use, copy, modify, merge, publish, distribute, sublicense, 
009     * and/or sell copies of the Software, and to permit persons to whom the 
010     * Software is furnished to do so, subject to the following conditions:
011     *
012     * The above copyright notice and this permission notice shall be included in 
013     * all copies or substantial portions of the Software.
014     *
015     * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
016     * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
017     * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
018     * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
019     * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
020     * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
021     * DEALINGS IN THE SOFTWARE.
022     */
023    
024    package nu.validator.saxtree;
025    
026    import org.xml.sax.Locator;
027    import org.xml.sax.SAXException;
028    
029    /**
030     * A processing instruction.
031     * @version $Id$
032     * @author hsivonen
033     */
034    public final class ProcessingInstruction extends Node {
035    
036        /**
037         * PI target.
038         */
039        private final String target;
040        
041        /**
042         * PI data.
043         */
044        private final String data;
045    
046        /**
047         * Constructor.
048         * @param locator the locator
049         * @param target PI target
050         * @param data PI data
051         */
052        public ProcessingInstruction(Locator locator, String target, String data) {
053            super(locator);
054            this.target = target;
055            this.data = data;
056        }
057    
058        /**
059         * 
060         * @see nu.validator.saxtree.Node#visit(nu.validator.saxtree.TreeParser)
061         */
062        @Override
063        void visit(TreeParser treeParser) throws SAXException {
064            treeParser.processingInstruction(target, data, this);
065        }
066    
067        /**
068         * 
069         * @see nu.validator.saxtree.Node#getNodeType()
070         */
071        @Override
072        public NodeType getNodeType() {
073            return NodeType.PROCESSING_INSTRUCTION;
074        }
075    
076        /**
077         * Returns the data.
078         * 
079         * @return the data
080         */
081        public String getData() {
082            return data;
083        }
084    
085        /**
086         * Returns the target.
087         * 
088         * @return the target
089         */
090        public String getTarget() {
091            return target;
092        }
093    
094    }