001 /*
002 * Copyright 2006 Google Inc.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005 * use this file except in compliance with the License. You may obtain a copy of
006 * the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013 * License for the specific language governing permissions and limitations under
014 * the License.
015 */
016 package com.google.gwt.user.rebind.rpc;
017
018 import com.google.gwt.core.ext.TreeLogger;
019 import com.google.gwt.core.ext.typeinfo.JClassType;
020 import com.google.gwt.core.ext.typeinfo.JMethod;
021
022 public class CustomSerializerInfo {
023 JClassType serializeeClass;
024 JClassType serializerClass;
025 JMethod deserializeMethod;
026 JMethod instantiateMethod;
027 JMethod serializeMethod;
028
029 public JMethod getDeserializeMethod() {
030 return deserializeMethod;
031 }
032
033 public boolean setDeserializeMethod(TreeLogger logger,
034 JMethod deserializeMethod) {
035
036 if (this.deserializeMethod != null
037 && this.deserializeMethod != deserializeMethod) {
038 logger.log(TreeLogger.ERROR, "Type "
039 + serializeeClass.getQualifiedSourceName()
040 + " has more than one custom field serializer deserialze method, "
041 + this.deserializeMethod.getReadableDeclaration() + " and "
042 + deserializeMethod.getReadableDeclaration(), null);
043 return false;
044 }
045 this.deserializeMethod = deserializeMethod;
046 return true;
047 }
048
049 public JMethod getInstantiateMethod() {
050 return instantiateMethod;
051 }
052
053 public boolean setInstantiateMethod(TreeLogger logger,
054 JMethod instantiateMethod) {
055 if (this.instantiateMethod != null
056 && this.instantiateMethod != instantiateMethod) {
057 logger.log(TreeLogger.ERROR, "Type "
058 + serializeeClass.getQualifiedSourceName()
059 + " has more than one custom field serializer serialze method, "
060 + this.instantiateMethod.getReadableDeclaration() + " and "
061 + instantiateMethod.getReadableDeclaration(), null);
062 return false;
063 }
064
065 this.instantiateMethod = instantiateMethod;
066 return true;
067 }
068
069 public JMethod getSerializeMethod() {
070 return serializeMethod;
071 }
072
073 public boolean setSerializeMethod(TreeLogger logger, JMethod serializeMethod) {
074 if (this.serializeMethod != null && this.serializeMethod != serializeMethod) {
075 logger.log(TreeLogger.ERROR, "Type "
076 + serializeeClass.getQualifiedSourceName()
077 + " has more than one custom field serializer serialze method, "
078 + this.serializeMethod.getReadableDeclaration() + " and "
079 + serializeMethod.getReadableDeclaration(), null);
080 return false;
081 }
082
083 this.serializeMethod = serializeMethod;
084 return true;
085 }
086
087 public JClassType getSerializerClass() {
088 return serializerClass;
089 }
090
091 public boolean setSerializerClass(TreeLogger logger,
092 JClassType serializerClass) {
093 if (this.serializerClass != null
094 && this.serializerClass != serializerClass) {
095 logger.log(TreeLogger.ERROR, "Type "
096 + serializeeClass.getQualifiedSourceName()
097 + " has more than one custom field serializer, "
098 + this.serializerClass.getQualifiedSourceName() + " and "
099 + serializerClass.getQualifiedSourceName(), null);
100 return false;
101 }
102 this.serializerClass = serializerClass;
103 return true;
104 }
105
106 public JClassType getSerializeeClass() {
107 return serializeeClass;
108 }
109
110 public void setSerializeeClass(JClassType serializeeClass) {
111 this.serializeeClass = serializeeClass;
112 }
113 }