Coverage Report - org.jtheque.primary.utils.web.analyzers.generic.operation.iterator.AppendTextFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
AppendTextFactory
0 %
0/4
N/A
1
AppendTextFactory$1
N/A
N/A
1
AppendTextFactory$AppendTextIteratorOperation
0 %
0/6
N/A
1
 
 1  
 package org.jtheque.primary.utils.web.analyzers.generic.operation.iterator;
 2  
 
 3  
 /*
 4  
  * This file is part of JTheque.
 5  
  *            
 6  
  * JTheque is free software: you can redistribute it and/or modify
 7  
  * it under the terms of the GNU General Public License as published by
 8  
  * the Free Software Foundation, either version 3 of the License. 
 9  
  *
 10  
  * JTheque 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 JTheque.  If not, see <http://www.gnu.org/licenses/>.
 17  
  */
 18  
 
 19  
 import org.jdom.Element;
 20  
 import org.jtheque.core.utils.file.XMLException;
 21  
 import org.jtheque.core.utils.file.XMLReader;
 22  
 import org.jtheque.primary.utils.web.analyzers.generic.Factory;
 23  
 import org.jtheque.primary.utils.web.analyzers.generic.operation.ScannerPossessor;
 24  
 import org.jtheque.primary.utils.web.analyzers.generic.value.BuilderPossessor;
 25  
 
 26  
 /**
 27  
  * @author Baptiste Wicht
 28  
  */
 29  0
 final class AppendTextFactory implements Factory<IteratorOperation> {
 30  
         @Override
 31  
         public boolean canFactor(Element element, XMLReader reader){
 32  0
                 return "appendText".equals(element.getName());
 33  
         }
 34  
 
 35  
         @Override
 36  
         public IteratorOperation factor(Element n, XMLReader reader) throws XMLException{
 37  0
                 return new AppendTextIteratorOperation(n.getText());
 38  
         }
 39  
 
 40  
         /**
 41  
          * An operation which append some text to the builder.
 42  
          *
 43  
          * @author Baptiste Wicht
 44  
          */
 45  0
         private static final class AppendTextIteratorOperation implements IteratorOperation {
 46  
                 private final String text;
 47  
 
 48  
                 /**
 49  
                  * Construct a new AppendTextIteratorOperation.
 50  
                  *
 51  
                  * @param text The text to append to the value.
 52  
                  */
 53  
                 private AppendTextIteratorOperation(String text){
 54  0
                         super();
 55  
 
 56  0
                         this.text = text;
 57  0
                 }
 58  
 
 59  
                 @Override
 60  
                 public String perform(String line, ScannerPossessor analyzer, BuilderPossessor iterator){
 61  0
                         iterator.getBuilder().append(text);
 62  
 
 63  0
                         return line;
 64  
                 }
 65  
         }
 66  
 }