Coverage Report - org.jtheque.primary.utils.web.analyzers.generic.operation.iterator.AppendFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
AppendFactory
0 %
0/4
N/A
1
AppendFactory$1
N/A
N/A
1
AppendFactory$AppendIteratorOperation
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  
 import org.jtheque.primary.utils.web.analyzers.generic.value.ValueGetter;
 26  
 import org.jtheque.primary.utils.web.analyzers.generic.value.ValueGetterFactory;
 27  
 
 28  
 /**
 29  
  * A factory for append iterator operation.
 30  
  *
 31  
  * @author Baptiste Wicht
 32  
  */
 33  0
 final class AppendFactory implements Factory<IteratorOperation> {
 34  
         @Override
 35  
         public boolean canFactor(Element element, XMLReader reader){
 36  0
                 return "append".equals(element.getName());
 37  
         }
 38  
 
 39  
         @Override
 40  
         public IteratorOperation factor(Element n, XMLReader reader) throws XMLException{
 41  0
                 return new AppendIteratorOperation(ValueGetterFactory.getValueGetter(n, reader));
 42  
         }
 43  
 
 44  
         /**
 45  
          * An operation which append some value to the builder.
 46  
          *
 47  
          * @author Baptiste Wicht
 48  
          */
 49  0
         private static final class AppendIteratorOperation implements IteratorOperation {
 50  
                 private final ValueGetter getter;
 51  
 
 52  
                 /**
 53  
                  * Construct a new AppendIteratorOperation.
 54  
                  *
 55  
                  * @param getter The value getter to use.
 56  
                  */
 57  0
                 private AppendIteratorOperation(ValueGetter getter){
 58  0
                         this.getter = getter;
 59  0
                 }
 60  
 
 61  
                 @Override
 62  
                 public String perform(String line, ScannerPossessor analyzer, BuilderPossessor iterator){
 63  0
                         iterator.getBuilder().append(getter.getValue(line));
 64  
 
 65  0
                         return line;
 66  
                 }
 67  
         }
 68  
 }