001 /*
002 GRANITE DATA SERVICES
003 Copyright (C) 2012 GRANITE DATA SERVICES S.A.S.
004
005 This file is part of Granite Data Services.
006
007 Granite Data Services is free software; you can redistribute it and/or modify
008 it under the terms of the GNU Library General Public License as published by
009 the Free Software Foundation; either version 2 of the License, or (at your
010 option) any later version.
011
012 Granite Data Services is distributed in the hope that it will be useful, but
013 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
014 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
015 for more details.
016
017 You should have received a copy of the GNU Library General Public License
018 along with this library; if not, see <http://www.gnu.org/licenses/>.
019 */
020
021 package org.granite.client.validation;
022
023 import java.io.Externalizable;
024 import java.io.IOException;
025 import java.io.ObjectInput;
026 import java.io.ObjectOutput;
027
028 import org.granite.messaging.amf.RemoteClass;
029
030 /**
031 * @author William DRAI
032 */
033 @RemoteClass("org.granite.tide.validators.InvalidValue")
034 public class InvalidValue implements Externalizable {
035
036 private Object rootBean;
037 private Object bean;
038 private Class<?> beanClass;
039 private String path;
040 private Object value;
041 private String message;
042
043
044 public InvalidValue(Object rootBean, Object bean, String path, Object value, String message) {
045 if (bean == null || path == null)
046 throw new NullPointerException("bean and path parameters cannot be null");
047 this.rootBean = rootBean;
048 this.bean = bean;
049 this.beanClass = bean.getClass();
050 this.path = path;
051 this.value = value;
052 this.message = message;
053 }
054
055 public Object getRootBean() {
056 return rootBean;
057 }
058
059 public Object getBean() {
060 return bean;
061 }
062
063 public Class<?> getBeanClass() {
064 return beanClass;
065 }
066
067 public String getPath() {
068 return path;
069 }
070
071 public Object getValue() {
072 return value;
073 }
074
075 public String getMessage() {
076 return message;
077 }
078
079
080 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
081 rootBean = in.readObject();
082 bean = in.readObject();
083 in.readObject();
084 path = (String)in.readObject();
085 value = in.readObject();
086 message = (String)in.readObject();
087 }
088
089 public void writeExternal(ObjectOutput out) throws IOException {
090 throw new IOException("Cannot serialize InvalidValue from client");
091 }
092 }