Coverage Report - org.xembly.Directive
 
Classes in this File Line Coverage Branch Coverage Complexity
Directive
N/A
N/A
1
Directive$Cursor
N/A
N/A
1
Directive$Stack
N/A
N/A
1
 
 1  
 /**
 2  
  * Copyright (c) 2013-2017, xembly.org
 3  
  * All rights reserved.
 4  
  *
 5  
  * Redistribution and use in source and binary forms, with or without
 6  
  * modification, are permitted provided that the following conditions
 7  
  * are met: 1) Redistributions of source code must retain the above
 8  
  * copyright notice, this list of conditions and the following
 9  
  * disclaimer. 2) Redistributions in binary form must reproduce the above
 10  
  * copyright notice, this list of conditions and the following
 11  
  * disclaimer in the documentation and/or other materials provided
 12  
  * with the distribution. 3) Neither the name of the xembly.org nor
 13  
  * the names of its contributors may be used to endorse or promote
 14  
  * products derived from this software without specific prior written
 15  
  * permission.
 16  
  *
 17  
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 18  
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
 19  
  * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 20  
  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
 21  
  * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 22  
  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 23  
  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 24  
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 25  
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 26  
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 27  
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 28  
  * OF THE POSSIBILITY OF SUCH DAMAGE.
 29  
  */
 30  
 package org.xembly;
 31  
 
 32  
 import java.util.Collection;
 33  
 import org.w3c.dom.Node;
 34  
 
 35  
 /**
 36  
  * Directive.
 37  
  *
 38  
  * <p>Use {@link Directives} to create a collection of them. You don't
 39  
  * need to use this interface directly and make instances of it. Everything
 40  
  * is done through {@link Directives} and {@link Xembler}.
 41  
  *
 42  
  * @author Yegor Bugayenko (yegor256@gmail.com)
 43  
  * @version $Id: df1e6d87d7ff158cf49e2f7965008527968eeb16 $
 44  
  * @since 0.1
 45  
  */
 46  
 public interface Directive {
 47  
 
 48  
     /**
 49  
      * Execute it in the given document with current position at the given node.
 50  
      * @param dom Document
 51  
      * @param cursor Nodes we're currently at
 52  
      * @param stack Execution stack
 53  
      * @return New current nodes
 54  
      * @throws ImpossibleModificationException If can't do it
 55  
      */
 56  
     Directive.Cursor exec(Node dom, Directive.Cursor cursor,
 57  
         Directive.Stack stack) throws ImpossibleModificationException;
 58  
 
 59  
     /**
 60  
      * Cursor.
 61  
      * @since 0.16
 62  
      */
 63  
     interface Cursor extends Collection<Node> {
 64  
     }
 65  
 
 66  
     /**
 67  
      * Stack.
 68  
      * @since 0.16
 69  
      */
 70  
     interface Stack {
 71  
         /**
 72  
          * Push cursor (runtime exception if stack is full).
 73  
          * @param cursor Cursor to push
 74  
          * @throws ImpossibleModificationException If fails
 75  
          */
 76  
         void push(Directive.Cursor cursor)
 77  
             throws ImpossibleModificationException;
 78  
         /**
 79  
          * Pop cursor (runtime exception if stack is empty).
 80  
          * @return Cursor recently added
 81  
          * @throws ImpossibleModificationException If fails
 82  
          */
 83  
         Directive.Cursor pop()
 84  
             throws ImpossibleModificationException;
 85  
     }
 86  
 
 87  
 }