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