Coverage Report - com.allanbank.mongodb.error.JsonParseException
 
Classes in this File Line Coverage Branch Coverage Complexity
JsonParseException
100%
26/26
N/A
1
 
 1  
 /*
 2  
  * #%L
 3  
  * JsonParseException.java - mongodb-async-driver - Allanbank Consulting, Inc.
 4  
  * %%
 5  
  * Copyright (C) 2011 - 2014 Allanbank Consulting, Inc.
 6  
  * %%
 7  
  * Licensed under the Apache License, Version 2.0 (the "License");
 8  
  * you may not use this file except in compliance with the License.
 9  
  * You may obtain a copy of the License at
 10  
  * 
 11  
  *      http://www.apache.org/licenses/LICENSE-2.0
 12  
  * 
 13  
  * Unless required by applicable law or agreed to in writing, software
 14  
  * distributed under the License is distributed on an "AS IS" BASIS,
 15  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 16  
  * See the License for the specific language governing permissions and
 17  
  * limitations under the License.
 18  
  * #L%
 19  
  */
 20  
 package com.allanbank.mongodb.error;
 21  
 
 22  
 /**
 23  
  * JsonParseException provides an exception to throw when parsing a JSON
 24  
  * document fails.
 25  
  * 
 26  
  * @api.yes This exception is part of the driver's API. Public and protected
 27  
  *          members will be deprecated for at least 1 non-bugfix release
 28  
  *          (version numbers are <major>.<minor>.<bugfix>)
 29  
  *          before being removed or modified.
 30  
  * @copyright 2012-2013, Allanbank Consulting, Inc., All Rights Reserved
 31  
  */
 32  
 public class JsonParseException extends JsonException {
 33  
 
 34  
     /** Serialization version of the class. */
 35  
     private static final long serialVersionUID = 8248891467581639959L;
 36  
 
 37  
     /** The approximate column where the parse failed. */
 38  
     private final int myColumn;
 39  
 
 40  
     /** The approximate line where the parse failed. */
 41  
     private final int myLine;
 42  
 
 43  
     /**
 44  
      * Creates a new JsonParseException.
 45  
      */
 46  
     public JsonParseException() {
 47  1
         super();
 48  1
         myLine = -1;
 49  1
         myColumn = -1;
 50  1
     }
 51  
 
 52  
     /**
 53  
      * Creates a new JsonParseException.
 54  
      * 
 55  
      * @param message
 56  
      *            Reason for the exception.
 57  
      */
 58  
     public JsonParseException(final String message) {
 59  2
         super(message);
 60  2
         myLine = -1;
 61  2
         myColumn = -1;
 62  2
     }
 63  
 
 64  
     /**
 65  
      * Creates a new JsonParseException.
 66  
      * 
 67  
      * @param message
 68  
      *            Reason for the exception.
 69  
      * @param line
 70  
      *            The approximate line where the parse failed.
 71  
      * @param column
 72  
      *            The approximate column where the parse failed.
 73  
      */
 74  
     public JsonParseException(final String message, final int line,
 75  
             final int column) {
 76  1
         super(message);
 77  1
         myLine = line;
 78  1
         myColumn = column;
 79  1
     }
 80  
 
 81  
     /**
 82  
      * Creates a new JsonParseException.
 83  
      * 
 84  
      * @param message
 85  
      *            Reason for the exception.
 86  
      * @param cause
 87  
      *            The exception causing the MongoDbException.
 88  
      */
 89  
     public JsonParseException(final String message, final Throwable cause) {
 90  1
         super(message, cause);
 91  1
         myLine = -1;
 92  1
         myColumn = -1;
 93  1
     }
 94  
 
 95  
     /**
 96  
      * Creates a new JsonParseException.
 97  
      * 
 98  
      * @param message
 99  
      *            Reason for the exception.
 100  
      * @param cause
 101  
      *            The exception causing the MongoDbException.
 102  
      * @param line
 103  
      *            The approximate line where the parse failed.
 104  
      * @param column
 105  
      *            The approximate column where the parse failed.
 106  
      */
 107  
     public JsonParseException(final String message, final Throwable cause,
 108  
             final int line, final int column) {
 109  12
         super(message, cause);
 110  12
         myLine = line;
 111  12
         myColumn = column;
 112  12
     }
 113  
 
 114  
     /**
 115  
      * Creates a new JsonParseException.
 116  
      * 
 117  
      * @param cause
 118  
      *            The exception causing the MongoDbException.
 119  
      */
 120  
     public JsonParseException(final Throwable cause) {
 121  2
         super(cause);
 122  2
         myLine = -1;
 123  2
         myColumn = -1;
 124  2
     }
 125  
 
 126  
     /**
 127  
      * Returns the approximate column where the parse failed. Returns a negative
 128  
      * value if the column is not known.
 129  
      * 
 130  
      * @return The approximate column where the parse failed.
 131  
      */
 132  
     public int getColumn() {
 133  6
         return myColumn;
 134  
     }
 135  
 
 136  
     /**
 137  
      * Returns the approximate line where the parse failed. Returns a negative
 138  
      * value if the line is not known.
 139  
      * 
 140  
      * @return The approximate line where the parse failed.
 141  
      */
 142  
     public int getLine() {
 143  6
         return myLine;
 144  
     }
 145  
 }