ObjectError.java
Upload User: jiancairen
Upload Date: 2007-08-27
Package Size: 26458k
Code Size: 2k
Category:

Java Develop

Development Platform:

Java

  1. /*
  2.  * Copyright 2002-2004 the original author or authors.
  3.  *
  4.  * Licensed under the Apache License, Version 2.0 (the "License");
  5.  * you may not use this file except in compliance with the License.
  6.  * You may obtain a copy of the License at
  7.  *
  8.  *      http://www.apache.org/licenses/LICENSE-2.0
  9.  *
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  */
  16. package org.springframework.validation;
  17. import org.springframework.context.support.DefaultMessageSourceResolvable;
  18. /**
  19.  * Class that encapsulates an object error, i.e. a global reason for
  20.  * rejecting an object.
  21.  *
  22.  * <p>See DefaultMessageCodesResolver javadoc for details on how a message
  23.  * code list is built for an ObjectError.
  24.  *
  25.  * @author Juergen Hoeller
  26.  * @since 10.03.2003
  27.  * @see FieldError
  28.  * @see DefaultMessageCodesResolver
  29.  */
  30. public class ObjectError extends DefaultMessageSourceResolvable {
  31.   private final String objectName;
  32.   /**
  33.    * Create a new ObjectError instance.
  34.  * @param objectName the name of the affected object
  35.  * @param codes the codes to be used to resolve this message
  36.  * @param arguments the array of arguments to be used to resolve this message
  37.  * @param defaultMessage the default message to be used to resolve this message
  38.    */
  39. public ObjectError(String objectName, String[] codes, Object[] arguments, String defaultMessage) {
  40.     super(codes, arguments, defaultMessage);
  41.     this.objectName = objectName;
  42.   }
  43.   /**
  44.  * Return the name of the affected object.
  45.  */
  46. public String getObjectName() {
  47.     return objectName;
  48.   }
  49.   public String toString() {
  50.     return "Error in object '" + this.objectName + "': " + resolvableToString();
  51.   }
  52. }