Coverage Report - net.sf.jmatchparser.template.engine.parameter.EntityWrapperTag
 
Classes in this File Line Coverage Branch Coverage Complexity
EntityWrapperTag
100%
17/17
100%
6/6
1,714
 
 1  
 /*
 2  
  * Copyright (c) 2006 - 2011 Michael Schierl
 3  
  * All rights reserved.
 4  
  * 
 5  
  * This program is free software: you can redistribute it and/or modify
 6  
  * it under the terms of the GNU General Public License as published by
 7  
  * the Free Software Foundation, either version 2 of the License, or
 8  
  * (at your option) any later version.
 9  
  * 
 10  
  * This program 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
 13  
  * GNU General Public License for more details.
 14  
  * 
 15  
  * You should have received a copy of the GNU General Public License
 16  
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 17  
  */
 18  
 package net.sf.jmatchparser.template.engine.parameter;
 19  
 
 20  
 import net.sf.jmatchparser.template.engine.DefaultCallbackFunctions;
 21  
 import net.sf.jmatchparser.template.engine.ParserState;
 22  
 
 23  
 class EntityWrapperTag extends Tag {
 24  
 
 25  
         private final Tag baseTag;
 26  
 
 27  6
         EntityWrapperTag(Tag baseTag) {
 28  6
                 this.baseTag = baseTag;
 29  6
         }
 30  
 
 31  
         @Override
 32  
         void applyMatch(ParserState ps, String[] matches) {
 33  3
                 String[] m = new String[matches.length];
 34  4
                 for (int i = 0; i < m.length; i++) {
 35  1
                         m[i] = DefaultCallbackFunctions.stripEntities(matches[i]);
 36  
                 }
 37  3
                 baseTag.applyMatch(ps, m);
 38  3
         }
 39  
 
 40  
         @Override
 41  
         boolean isStatic() {
 42  6
                 return baseTag.isStatic();
 43  
         }
 44  
 
 45  
         @Override
 46  
         String getRegex(ParserState state) {
 47  4
                 if (baseTag.isParsingOnly()) {
 48  2
                         return baseTag.getRegex(state);
 49  
                 }
 50  2
                 return DefaultCallbackFunctions.addEntities(baseTag.getRegex(state));
 51  
         }
 52  
 
 53  
         @Override
 54  
         String getString(ParserState state) {
 55  3
                 if (baseTag.isParsingOnly()) {
 56  1
                         return baseTag.getString(state);
 57  
                 }
 58  2
                 return DefaultCallbackFunctions.addEntities(baseTag.getString(state));
 59  
         }
 60  
 
 61  
         @Override
 62  
         int getUsedGroupCount() {
 63  3
                 return baseTag.getUsedGroupCount();
 64  
         }
 65  
 
 66  
         @Override
 67  
         boolean isParsingOnly() {
 68  2
                 return baseTag.isParsingOnly();
 69  
         }
 70  
 }