Coverage Report - com.damnhandy.uri.template.UriTemplateComponent
 
Classes in this File Line Coverage Branch Coverage Complexity
UriTemplateComponent
60%
3/5
N/A
1
 
 1  
 /*
 2  
  *
 3  
  *
 4  
  */
 5  
 package com.damnhandy.uri.template;
 6  
 
 7  
 import java.io.Serializable;
 8  
 import java.util.regex.Pattern;
 9  
 
 10  
 /**
 11  
  * A Component.
 12  
  * 
 13  
  * @author <a href="ryan@damnhandy.com">Ryan J. McDonough</a>
 14  
  * @version $Revision: 1.1 $
 15  
  */
 16  
 public abstract class UriTemplateComponent implements Serializable
 17  
 {
 18  
 
 19  
    /** The serialVersionUID */
 20  
    private static final long serialVersionUID = -3653287624355221784L;
 21  
    
 22  
    /**
 23  
     * 
 24  
     */
 25  
    private final int startPosition;
 26  
    
 27  
    public UriTemplateComponent(final int startPoistion)
 28  1608
    {
 29  1608
       this.startPosition = startPoistion;
 30  1608
    }
 31  
    
 32  
    public abstract String getValue();
 33  
 
 34  
    /**
 35  
     * Get the startPosition of the component within the template string.
 36  
     * 
 37  
     * @return the startPosition.
 38  
     */
 39  
    public int getStartPosition()
 40  
    {
 41  0
       return startPosition;
 42  
    }
 43  
 
 44  
    /**
 45  
     * Returns a string that contains a regular expression that matches the
 46  
     * URI template expression.
 47  
     * 
 48  
     * @return
 49  
     */
 50  
    public abstract Pattern getMatchPattern();
 51  
    /**
 52  
     * Get the endPosition.
 53  
     * 
 54  
     * @return the endPosition.
 55  
     */
 56  
    public int getEndPosition()
 57  
    {
 58  0
       return startPosition + getValue().length();
 59  
    }
 60  
 }