Coverage Report - org.codehaus.plexus.interpolation.fixed.InterpolationState
 
Classes in this File Line Coverage Branch Coverage Complexity
InterpolationState
25%
6/24
0%
0/8
2
 
 1  
 package org.codehaus.plexus.interpolation.fixed;
 2  
 
 3  
 /*
 4  
  * Copyright 2014 The Codehaus Foundation.
 5  
  *
 6  
  * Licensed under the Apache License, Version 2.0 (the "License");
 7  
  * you may not use this file except in compliance with the License.
 8  
  * You may obtain a copy of the License at
 9  
  *
 10  
  *      http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 17  
  */
 18  
 
 19  
 import org.codehaus.plexus.interpolation.RecursionInterceptor;
 20  
 import org.codehaus.plexus.interpolation.SimpleRecursionInterceptor;
 21  
 
 22  
 import java.util.ArrayList;
 23  
 import java.util.HashSet;
 24  
 import java.util.List;
 25  
 import java.util.Set;
 26  
 
 27  
 /**
 28  
  * AN error collector contains the errors accumulated during an interpolation.
 29  
  * It is stateful.
 30  
  */
 31  34
 public class InterpolationState
 32  
 {
 33  34
     private final List<String> messages = new ArrayList<String>(  );
 34  34
     private final List<Throwable> causes = new ArrayList<Throwable>(  );
 35  
 
 36  
     public void addFeedback( String message, Throwable cause )
 37  
     {
 38  0
         messages.add( message);
 39  0
         causes.add(cause);
 40  0
     }
 41  
 
 42  
     public List asList(){
 43  0
         ArrayList<Object> items = new ArrayList<Object>(  );
 44  0
         for (int i = 0; i < messages.size(); i++){
 45  0
             String msg = messages.get(i);
 46  0
             if (msg != null ) items.add( msg);
 47  0
             Throwable cause = causes.get(i);
 48  0
             if (cause != null) items.add(cause);
 49  
         }
 50  0
         return items.size() > 0 ? items: null;
 51  
     }
 52  
 
 53  
     public void clear()
 54  
     {
 55  0
         messages.clear();
 56  0
         causes.clear();
 57  0
         unresolvable.clear();
 58  0
         recursionInterceptor.clear();
 59  0
         root = null;
 60  0
     }
 61  
 
 62  34
     final Set<String> unresolvable = new HashSet<String>(  );
 63  34
     RecursionInterceptor recursionInterceptor = new SimpleRecursionInterceptor();
 64  
 
 65  
     public void setRecursionInterceptor( RecursionInterceptor recursionInterceptor )
 66  
     {
 67  0
         this.recursionInterceptor = recursionInterceptor;
 68  0
     }
 69  
 
 70  34
     FixedStringSearchInterpolator root = null;
 71  
 }