Coverage Report - org.mule.example.geomail.components.ReceivedHeader
 
Classes in this File Line Coverage Branch Coverage Complexity
ReceivedHeader
0%
0/43
0%
0/26
0
 
 1  
 /*
 2  
  * $Id: ReceivedHeader.java 20321 2010-11-24 15:21:24Z dfeist $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.example.geomail.components;
 12  
 
 13  
 import java.util.regex.Matcher;
 14  
 import java.util.regex.Pattern;
 15  
 
 16  
 /**
 17  
  * TODO
 18  
  */
 19  0
 public class ReceivedHeader
 20  
 {
 21  
     private String id;
 22  
     private String from;
 23  
     private String by;
 24  
     private String via;
 25  
     private String with;
 26  
     private String _for;
 27  
     private String timestamp;
 28  
 
 29  
     public static ReceivedHeader getInstance(String receivedHeader)
 30  
     {
 31  0
         String fromPattern = "(?:from (.*?))?";
 32  0
         String byPattern = "(?:by (.*?))?";
 33  0
         String viaPattern = "(?:via (.*?))?";
 34  0
         String withPattern = "(?:with (.*?))?";
 35  0
         String idPattern = "(?:id (.*?))?";
 36  0
         String forPattern = "(?:for (.*?))?";
 37  0
         String timePattern = ";(.*)";
 38  
 
 39  0
         String pattern = fromPattern + byPattern + viaPattern + withPattern + idPattern + forPattern
 40  
                          + timePattern;
 41  
 
 42  0
         Matcher matcher = Pattern.compile(pattern, Pattern.DOTALL).matcher(receivedHeader);
 43  
 
 44  0
         ReceivedHeader result = null;
 45  0
         if (matcher.find())
 46  
         {
 47  0
             result = new ReceivedHeader();
 48  0
             result.setFrom(matcher.group(1));
 49  0
             result.setBy(matcher.group(2));
 50  0
             result.setVia(matcher.group(3));
 51  0
             result.setWith(matcher.group(4));
 52  0
             result.setId(matcher.group(5));
 53  0
             result.setFor(matcher.group(6));
 54  0
             result.setTimestamp(matcher.group(7));
 55  
         }
 56  
 
 57  0
         return result;
 58  
     }
 59  
 
 60  
     public String getId()
 61  
     {
 62  0
         return id;
 63  
     }
 64  
 
 65  
     private void setId(String id)
 66  
     {
 67  0
         this.id = (id != null ? id.trim() : null);
 68  0
     }
 69  
 
 70  
     public String getFrom()
 71  
     {
 72  0
         return from;
 73  
     }
 74  
 
 75  
     private void setFrom(String from)
 76  
     {
 77  0
         this.from = (from != null ? from.trim() : null);
 78  0
     }
 79  
 
 80  
     public String getBy()
 81  
     {
 82  0
         return by;
 83  
     }
 84  
 
 85  
     private void setBy(String by)
 86  
     {
 87  0
         this.by = (by != null ? by.trim() : null);
 88  0
     }
 89  
 
 90  
     public String getVia()
 91  
     {
 92  0
         return via;
 93  
     }
 94  
 
 95  
     private void setVia(String via)
 96  
     {
 97  0
         this.via = (via != null ? via.trim() : null);
 98  0
     }
 99  
 
 100  
     public String getWith()
 101  
     {
 102  0
         return with;
 103  
     }
 104  
 
 105  
     private void setWith(String with)
 106  
     {
 107  0
         this.with = (with != null ? with.trim() : null);
 108  0
     }
 109  
 
 110  
     public String getFor()
 111  
     {
 112  0
         return _for;
 113  
     }
 114  
 
 115  
     public void setFor(String _for)
 116  
     {
 117  0
         this._for = (_for != null ? _for.trim() : null);
 118  0
     }
 119  
 
 120  
     public String getTimestamp()
 121  
     {
 122  0
         return timestamp;
 123  
     }
 124  
 
 125  
     private void setTimestamp(String timestamp)
 126  
     {
 127  0
         this.timestamp = timestamp.trim();
 128  0
     }
 129  
 
 130  
     @Override
 131  
     public String toString()
 132  
     {
 133  0
         return "Received {\n  " + (getId() != null ? "id: " + getId() + "\n  " : "")
 134  
                + (getFrom() != null ? "from: " + getFrom() + "\n  " : "")
 135  
                + (getBy() != null ? "by: " + getBy() + "\n  " : "")
 136  
                + (getVia() != null ? "via: " + getVia() + "\n  " : "")
 137  
                + (getWith() != null ? "with: " + getWith() + "\n  " : "")
 138  
                + (getFor() != null ? "for: " + getFor() + "\n  " : "") + "date-time: " + getTimestamp()
 139  
                + "\n  " + "}";
 140  
     }
 141  
 }