1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.velocity.internal.util

File VelocityParserContext.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart9.png
41% of files have more coverage

Code metrics

0
6
6
1
95
32
6
1
1
6
1

Classes

Class Line # Actions
VelocityParserContext 31 6 0% 6 2
0.833333383.3%
 

Contributing tests

This file is covered by 13 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.velocity.internal.util;
21   
22    import java.util.Stack;
23   
24    import org.xwiki.velocity.internal.util.VelocityBlock.VelocityType;
25   
26    /**
27    * Provided to {@link VelocityParser} helpers to return some information.
28    *
29    * @version $Id: f9ff145aaef738d2a0c2a21eac1d4416ab5fd723 $
30    */
 
31    public class VelocityParserContext
32    {
33    /**
34    * The type of found velocity block.
35    */
36    private VelocityType type;
37   
38    /**
39    * The current blocks.
40    */
41    private Stack<VelocityBlock> blocks = new Stack<VelocityBlock>();
42   
43    /**
44    * @param type the type of found velocity block.
45    */
 
46  57 toggle public void setType(VelocityType type)
47    {
48  57 this.type = type;
49    }
50   
51    /**
52    * @return The type of found velocity block.
53    */
 
54  76 toggle public VelocityType getType()
55    {
56  76 return this.type;
57    }
58   
59    /**
60    * @return the Velocity block in which the process is.
61    */
 
62  0 toggle public VelocityBlock getCurrentElement()
63    {
64  0 return this.blocks.peek();
65    }
66   
67    /**
68    * Enter a Velocity block.
69    *
70    * @param block the Velocity block in which the process is.
71    * @return the Velocity block in which the process is.
72    */
 
73  11 toggle public VelocityBlock pushVelocityElement(VelocityBlock block)
74    {
75  11 return this.blocks.push(block);
76    }
77   
78    /**
79    * Go out of a Velocity block.
80    *
81    * @return the previous Velocity block in which the process was.
82    */
 
83  8 toggle public VelocityBlock popVelocityElement()
84    {
85  8 return this.blocks.pop();
86    }
87   
88    /**
89    * @return indicate if the current process is inside a Velocity block.
90    */
 
91  4 toggle public boolean isInVelocityBlock()
92    {
93  4 return !this.blocks.isEmpty();
94    }
95    }