Coverage Report - com.rexsl.w3c.Defect
 
Classes in this File Line Coverage Branch Coverage Complexity
Defect
62%
10/16
12%
4/32
1
Defect$AjcClosure1
0%
0/1
N/A
1
Defect$AjcClosure11
0%
0/1
N/A
1
Defect$AjcClosure3
0%
0/1
N/A
1
Defect$AjcClosure5
0%
0/1
N/A
1
Defect$AjcClosure7
0%
0/1
N/A
1
Defect$AjcClosure9
0%
0/1
N/A
1
 
 1  36
 /**
 2  
  * Copyright (c) 2011-2013, ReXSL.com
 3  
  * All rights reserved.
 4  
  *
 5  
  * Redistribution and use in source and binary forms, with or without
 6  
  * modification, are permitted provided that the following conditions
 7  
  * are met: 1) Redistributions of source code must retain the above
 8  
  * copyright notice, this list of conditions and the following
 9  
  * disclaimer. 2) Redistributions in binary form must reproduce the above
 10  
  * copyright notice, this list of conditions and the following
 11  
  * disclaimer in the documentation and/or other materials provided
 12  
  * with the distribution. 3) Neither the name of the ReXSL.com nor
 13  
  * the names of its contributors may be used to endorse or promote
 14  
  * products derived from this software without specific prior written
 15  
  * permission.
 16  
  *
 17  
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 18  
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
 19  
  * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 20  
  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
 21  
  * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 22  
  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 23  
  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 24  
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 25  
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 26  
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 27  
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 28  
  * OF THE POSSIBILITY OF SUCH DAMAGE.
 29  
  */
 30  
 package com.rexsl.w3c;
 31  
 
 32  
 import com.jcabi.aspects.Loggable;
 33  
 import com.jcabi.log.Logger;
 34  
 import javax.validation.constraints.NotNull;
 35  
 import lombok.EqualsAndHashCode;
 36  
 
 37  
 /**
 38  
  * Validation defect (error or warning) produced by {@link ValidationResponse}.
 39  
  *
 40  
  * <p>Objects of this class are immutable and thread-safe.
 41  
  *
 42  
  * @author Yegor Bugayenko (yegor@tpc2.com)
 43  
  * @version $Id$
 44  
  * @see <a href="http://validator.w3.org/docs/api.html">W3C API</a>
 45  
  * @checkstyle LineLength (2 lines)
 46  
  */
 47  
 @EqualsAndHashCode(of = { "iline", "icolumn", "isource", "iexplanation", "imessageId", "imessage" })
 48  
 @Loggable(Loggable.DEBUG)
 49  
 public final class Defect {
 50  
 
 51  
     /**
 52  
      * Line.
 53  
      */
 54  
     private final transient int iline;
 55  
 
 56  
     /**
 57  
      * Column.
 58  
      */
 59  
     private final transient int icolumn;
 60  
 
 61  
     /**
 62  
      * Source line.
 63  
      */
 64  
     @NotNull
 65  
     private final transient String isource;
 66  
 
 67  
     /**
 68  
      * Explanation.
 69  
      */
 70  
     @NotNull
 71  
     private final transient String iexplanation;
 72  
 
 73  
     /**
 74  
      * Message id.
 75  
      */
 76  
     @NotNull
 77  
     private final transient String imessageId;
 78  
 
 79  
     /**
 80  
      * The message.
 81  
      */
 82  
     @NotNull
 83  
     private final transient String imessage;
 84  
 
 85  
     /**
 86  
      * Protected ctor, to be called only from this package.
 87  
      * @param line Line number
 88  
      * @param column Column number
 89  
      * @param source Source line
 90  
      * @param explanation The explanation
 91  
      * @param mid ID of the message
 92  
      * @param message Message text
 93  
      * @checkstyle ParameterNumber (5 lines)
 94  
      */
 95  
     Defect(final int line, final int column, @NotNull final String source,
 96  
         @NotNull final String explanation, @NotNull final String mid,
 97  3
         @NotNull final String message) {
 98  3
         this.iline = line;
 99  3
         this.icolumn = column;
 100  3
         this.isource = source.trim();
 101  3
         this.iexplanation = explanation.trim();
 102  3
         this.imessageId = mid.trim();
 103  3
         this.imessage = message.trim();
 104  3
     }
 105  
 
 106  
     /**
 107  
      * {@inheritDoc}
 108  
      */
 109  
     @Override
 110  
     public String toString() {
 111  7
         return Logger.format(
 112  
             "[%d:%d] \"%s\", \"%s\", \"%s\", \"%s\"",
 113  
             this.iline,
 114  
             this.icolumn,
 115  
             this.isource,
 116  
             this.iexplanation,
 117  
             this.imessageId,
 118  
             this.imessage
 119  
         );
 120  
     }
 121  
 
 122  
     /**
 123  
      * Line number, where the defect was found.
 124  
      * @return Line number
 125  
      */
 126  
     public int line() {
 127  0
         return this.iline;
 128  
     }
 129  
 
 130  
     /**
 131  
      * Column number inside the line.
 132  
      * @return Column number
 133  
      */
 134  
     public int column() {
 135  0
         return this.icolumn;
 136  
     }
 137  
 
 138  
     /**
 139  
      * Source line, as quoted by W3C validator.
 140  
      * @return Full text of the source line
 141  
      */
 142  
     @NotNull
 143  
     public String source() {
 144  0
         return this.isource;
 145  
     }
 146  
 
 147  
     /**
 148  
      * Explanation of the problem.
 149  
      * @return Text
 150  
      */
 151  
     @NotNull
 152  
     public String explanation() {
 153  0
         return this.iexplanation;
 154  
     }
 155  
 
 156  
     /**
 157  
      * Message ID, according to W3C API.
 158  
      * @return The ID
 159  
      */
 160  
     @NotNull
 161  
     public String messageId() {
 162  0
         return this.imessageId;
 163  
     }
 164  
 
 165  
     /**
 166  
      * Text of the message.
 167  
      * @return The message returned by W3C server
 168  
      */
 169  
     @NotNull
 170  
     public String message() {
 171  0
         return this.imessage;
 172  
     }
 173  
 
 174  
 }