From 34b2926d5ca9b6068fa863e7d5e0a4055cbbef30 Mon Sep 17 00:00:00 2001 From: Mark Slee Date: Tue, 9 Oct 2007 20:55:10 +0000 Subject: [PATCH] Java Thrift objects implement common base interface Reviewed By: dreiss Test Plan: Generate java code and run against new library. Revert: OK DiffCamp Revision: 900 git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665296 13f79535-47bb-0310-9956-ffa450edef68 --- compiler/cpp/src/generate/t_java_generator.cc | 2 +- lib/java/src/TBase.java | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 lib/java/src/TBase.java diff --git a/compiler/cpp/src/generate/t_java_generator.cc b/compiler/cpp/src/generate/t_java_generator.cc index eef82af7..ea27854d 100644 --- a/compiler/cpp/src/generate/t_java_generator.cc +++ b/compiler/cpp/src/generate/t_java_generator.cc @@ -362,7 +362,7 @@ void t_java_generator::generate_java_struct_definition(ofstream &out, if (is_exception) { out << "extends Exception "; } - out << "implements java.io.Serializable "; + out << "implements TBase, java.io.Serializable "; scope_up(out); diff --git a/lib/java/src/TBase.java b/lib/java/src/TBase.java new file mode 100644 index 00000000..6a30ae08 --- /dev/null +++ b/lib/java/src/TBase.java @@ -0,0 +1,31 @@ +// Copyright (c) 2006- Facebook +// Distributed under the Thrift Software License +// +// See accompanying file LICENSE or visit the Thrift site at: +// http://developers.facebook.com/thrift/ + +package com.facebook.thrift; + +import com.facebook.thrift.protocol.TProtocol; + +/** + * Generic base interface for generated Thrift objects. + * + * @author Mark Slee + */ +public interface TBase { + + /** + * Reads the TObject from the given input protocol. + * + * @param iprot Input protocol + */ + public void read(TProtocol iprot) throws TException; + + /** + * Writes the objects out to the protocol + * + * @param oprot Output protocol + */ + public void write(TProtocol oprot) throws TException; +} -- 2.17.1