Coverage Report - org.apache.commons.validator.Msg
 
Classes in this File Line Coverage Branch Coverage Complexity
Msg
0%
0/31
N/A
1.3
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.commons.validator;
 18  
 
 19  
 import java.io.Serializable;
 20  
 
 21  
 /**
 22  
  * An alternative message can be associated with a <code>Field</code>
 23  
  * and a pluggable validator instead of using the default message
 24  
  * stored in the <code>ValidatorAction</code> (aka pluggable validator).
 25  
  * Instances of this class are configured with a &lt;msg&gt; xml element.
 26  
  *
 27  
  * @version $Revision: 1739356 $
 28  
  */
 29  
 //TODO mutable non-private fields
 30  0
 public class Msg implements Cloneable, Serializable {
 31  
 
 32  
     private static final long serialVersionUID = 5690015734364127124L;
 33  
 
 34  
     /**
 35  
      * The resource bundle name that this Msg's <code>key</code> should be
 36  
      * resolved in (optional).
 37  
      * @since Validator 1.1
 38  
      */
 39  0
     protected String bundle = null;
 40  
 
 41  
     /**
 42  
      * The key or value of the argument.
 43  
      */
 44  0
     protected String key = null;
 45  
 
 46  
     /**
 47  
      * The name dependency that this argument goes with (optional).
 48  
      */
 49  0
     protected String name = null;
 50  
 
 51  
     /**
 52  
      * Whether or not the key is a message resource (optional).  Defaults to
 53  
      * true.  If it is 'true', the value will try to be resolved as a message
 54  
      * resource.
 55  
      * @since Validator 1.1.4
 56  
      */
 57  0
     protected boolean resource = true;
 58  
 
 59  
     /**
 60  
      * Returns the resource bundle name.
 61  
      * @return The bundle name.
 62  
      * @since Validator 1.1
 63  
      */
 64  
     public String getBundle() {
 65  0
         return this.bundle;
 66  
     }
 67  
 
 68  
     /**
 69  
      * Sets the resource bundle name.
 70  
      * @param bundle The new bundle name.
 71  
      * @since Validator 1.1
 72  
      */
 73  
     public void setBundle(String bundle) {
 74  0
         this.bundle = bundle;
 75  0
     }
 76  
 
 77  
     /**
 78  
      * Gets the name of the dependency.
 79  
      * @return The dependency name.
 80  
      */
 81  
     public String getName() {
 82  0
         return name;
 83  
     }
 84  
 
 85  
     /**
 86  
      * Sets the name of the dependency.
 87  
      * @param name The dependency name.
 88  
      */
 89  
     public void setName(String name) {
 90  0
         this.name = name;
 91  0
     }
 92  
 
 93  
     /**
 94  
      * Gets the key/value.
 95  
      * @return The message key/value.
 96  
      */
 97  
     public String getKey() {
 98  0
         return key;
 99  
     }
 100  
 
 101  
     /**
 102  
      * Sets the key/value.
 103  
      * @param key The message key/value.
 104  
      */
 105  
     public void setKey(String key) {
 106  0
         this.key = key;
 107  0
     }
 108  
 
 109  
     /**
 110  
      * Tests whether or not the key is a resource key or literal value.
 111  
      * @return <code>true</code> if key is a resource key.
 112  
      * @since Validator 1.1.4
 113  
      */
 114  
     public boolean isResource() {
 115  0
         return this.resource;
 116  
     }
 117  
 
 118  
     /**
 119  
      * Sets whether or not the key is a resource.
 120  
      * @param resource If true indicates the key is a resource.
 121  
      * @since Validator 1.1.4
 122  
      */
 123  
     public void setResource(boolean resource) {
 124  0
         this.resource = resource;
 125  0
     }
 126  
 
 127  
     /**
 128  
      * Creates and returns a copy of this object.
 129  
      * @return A copy of the Msg.
 130  
      */
 131  
     @Override
 132  
     public Object clone() {
 133  
         try {
 134  0
             return super.clone();
 135  
 
 136  0
         } catch(CloneNotSupportedException e) {
 137  0
             throw new RuntimeException(e.toString());
 138  
         }
 139  
     }
 140  
 
 141  
     /**
 142  
      * Returns a string representation of the object.
 143  
      * @return Msg String representation.
 144  
      */
 145  
     @Override
 146  
     public String toString() {
 147  0
         StringBuilder results = new StringBuilder();
 148  
 
 149  0
         results.append("Msg: name=");
 150  0
         results.append(name);
 151  0
         results.append("  key=");
 152  0
         results.append(key);
 153  0
         results.append("  resource=");
 154  0
         results.append(resource);
 155  0
         results.append("  bundle=");
 156  0
         results.append(bundle);
 157  0
         results.append("\n");
 158  
 
 159  0
         return results.toString();
 160  
     }
 161  
 
 162  
 }