You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by hc...@apache.org on 2014/11/18 11:34:14 UTC

[22/37] thrift git commit: Revert "THRIFT-2729: C++ - .clang-format created and applied"

http://git-wip-us.apache.org/repos/asf/thrift/blob/240120c8/compiler/cpp/src/generate/t_javame_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_javame_generator.cc b/compiler/cpp/src/generate/t_javame_generator.cc
index b4a13fc..eb934ac 100644
--- a/compiler/cpp/src/generate/t_javame_generator.cc
+++ b/compiler/cpp/src/generate/t_javame_generator.cc
@@ -37,20 +37,22 @@ using std::string;
 using std::stringstream;
 using std::vector;
 
-static const string endl = "\n"; // avoid ostream << std::endl flushes
+static const string endl = "\n";  // avoid ostream << std::endl flushes
 
 /**
  * Java code generator.
  *
  */
 class t_javame_generator : public t_oop_generator {
-public:
-  t_javame_generator(t_program* program,
-                     const std::map<std::string, std::string>& parsed_options,
-                     const std::string& option_string)
-    : t_oop_generator(program) {
-    (void)parsed_options;
-    (void)option_string;
+ public:
+  t_javame_generator(
+      t_program* program,
+      const std::map<std::string, std::string>& parsed_options,
+      const std::string& option_string)
+    : t_oop_generator(program)
+  {
+    (void) parsed_options;
+    (void) option_string;
     std::map<std::string, std::string>::const_iterator iter;
     out_dir_base_ = "gen-javame";
   }
@@ -68,23 +70,15 @@ public:
    * Program-level generation functions
    */
 
-  void generate_typedef(t_typedef* ttypedef);
-  void generate_enum(t_enum* tenum);
-  void generate_struct(t_struct* tstruct);
-  void generate_union(t_struct* tunion);
-  void generate_xception(t_struct* txception);
-  void generate_service(t_service* tservice);
-
-  void print_const_value(std::ofstream& out,
-                         std::string name,
-                         t_type* type,
-                         t_const_value* value,
-                         bool in_static,
-                         bool defval = false);
-  std::string render_const_value(std::ofstream& out,
-                                 std::string name,
-                                 t_type* type,
-                                 t_const_value* value);
+  void generate_typedef (t_typedef*  ttypedef);
+  void generate_enum    (t_enum*     tenum);
+  void generate_struct  (t_struct*   tstruct);
+  void generate_union   (t_struct*   tunion);
+  void generate_xception(t_struct*   txception);
+  void generate_service (t_service*  tservice);
+
+  void print_const_value(std::ofstream& out, std::string name, t_type* type, t_const_value* value, bool in_static, bool defval=false);
+  std::string render_const_value(std::ofstream& out, std::string name, t_type* type, t_const_value* value);
 
   /**
    * Service-level generation functions
@@ -92,11 +86,7 @@ public:
 
   void generate_java_struct(t_struct* tstruct, bool is_exception);
 
-  void generate_java_struct_definition(std::ofstream& out,
-                                       t_struct* tstruct,
-                                       bool is_xception = false,
-                                       bool in_class = false,
-                                       bool is_result = false);
+  void generate_java_struct_definition(std::ofstream& out, t_struct* tstruct, bool is_xception=false, bool in_class=false, bool is_result=false);
   void generate_java_struct_equality(std::ofstream& out, t_struct* tstruct);
   void generate_java_struct_compare_to(std::ofstream& out, t_struct* tstruct);
   void generate_java_struct_reader(std::ofstream& out, t_struct* tstruct);
@@ -107,14 +97,8 @@ public:
   void generate_java_struct_clear(std::ofstream& out, t_struct* tstruct);
   void generate_field_value_meta_data(std::ofstream& out, t_type* type);
   std::string get_java_type_string(t_type* type);
-  void generate_reflection_setters(std::ostringstream& out,
-                                   t_type* type,
-                                   std::string field_name,
-                                   std::string cap_name);
-  void generate_reflection_getters(std::ostringstream& out,
-                                   t_type* type,
-                                   std::string field_name,
-                                   std::string cap_name);
+  void generate_reflection_setters(std::ostringstream& out, t_type* type, std::string field_name, std::string cap_name);
+  void generate_reflection_getters(std::ostringstream& out, t_type* type, std::string field_name, std::string cap_name);
   void generate_generic_field_getters_setters(std::ofstream& out, t_struct* tstruct);
   void generate_java_bean_boilerplate(std::ofstream& out, t_struct* tstruct);
 
@@ -125,12 +109,12 @@ public:
   void generate_isset_set(ofstream& out, t_field* field);
   std::string isset_field_id(t_field* field);
 
-  void generate_primitive_service_interface(t_service* tservice);
-  void generate_service_interface(t_service* tservice);
-  void generate_service_helpers(t_service* tservice);
-  void generate_service_client(t_service* tservice);
-  void generate_service_server(t_service* tservice);
-  void generate_process_function(t_service* tservice, t_function* tfunction);
+  void generate_primitive_service_interface (t_service* tservice);
+  void generate_service_interface (t_service* tservice);
+  void generate_service_helpers   (t_service* tservice);
+  void generate_service_client    (t_service* tservice);
+  void generate_service_server    (t_service* tservice);
+  void generate_process_function  (t_service* tservice, t_function* tfunction);
 
   void generate_java_union(t_struct* tstruct);
   void generate_union_constructor(ofstream& out, t_struct* tstruct);
@@ -150,52 +134,69 @@ public:
    * Serialization constructs
    */
 
-  void generate_deserialize_field(std::ofstream& out, t_field* tfield, std::string prefix = "");
+  void generate_deserialize_field        (std::ofstream& out,
+                                          t_field*    tfield,
+                                          std::string prefix="");
 
-  void generate_deserialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
+  void generate_deserialize_struct       (std::ofstream& out,
+                                          t_struct*   tstruct,
+                                          std::string prefix="");
 
-  void generate_deserialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
+  void generate_deserialize_container    (std::ofstream& out,
+                                          t_type*     ttype,
+                                          std::string prefix="");
 
-  void generate_deserialize_set_element(std::ofstream& out, t_set* tset, std::string prefix = "");
+  void generate_deserialize_set_element  (std::ofstream& out,
+                                          t_set*      tset,
+                                          std::string prefix="");
 
-  void generate_deserialize_map_element(std::ofstream& out, t_map* tmap, std::string prefix = "");
+  void generate_deserialize_map_element  (std::ofstream& out,
+                                          t_map*      tmap,
+                                          std::string prefix="");
 
-  void generate_deserialize_list_element(std::ofstream& out,
-                                         t_list* tlist,
-                                         std::string prefix = "");
+  void generate_deserialize_list_element (std::ofstream& out,
+                                          t_list*     tlist,
+                                          std::string prefix="");
 
-  void generate_serialize_field(std::ofstream& out, t_field* tfield, std::string prefix = "");
+  void generate_serialize_field          (std::ofstream& out,
+                                          t_field*    tfield,
+                                          std::string prefix="");
 
-  void generate_serialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
+  void generate_serialize_struct         (std::ofstream& out,
+                                          t_struct*   tstruct,
+                                          std::string prefix="");
 
-  void generate_serialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
+  void generate_serialize_container      (std::ofstream& out,
+                                          t_type*     ttype,
+                                          std::string prefix="");
 
-  void generate_serialize_map_element(std::ofstream& out,
-                                      t_map* tmap,
-                                      std::string iter,
-                                      std::string map);
+  void generate_serialize_map_element    (std::ofstream& out,
+                                          t_map*      tmap,
+                                          std::string iter,
+                                          std::string map);
 
-  void generate_serialize_set_element(std::ofstream& out, t_set* tmap, std::string iter);
+  void generate_serialize_set_element    (std::ofstream& out,
+                                          t_set*      tmap,
+                                          std::string iter);
 
-  void generate_serialize_list_element(std::ofstream& out, t_list* tlist, std::string iter);
+  void generate_serialize_list_element   (std::ofstream& out,
+                                          t_list*     tlist,
+                                          std::string iter);
 
-  void generate_java_doc(std::ofstream& out, t_field* field);
+  void generate_java_doc                 (std::ofstream& out,
+                                          t_field*    field);
 
-  void generate_java_doc(std::ofstream& out, t_doc* tdoc);
+  void generate_java_doc                 (std::ofstream& out,
+                                          t_doc*      tdoc);
 
-  void generate_java_doc(std::ofstream& out, t_function* tdoc);
+  void generate_java_doc                 (std::ofstream& out,
+                                          t_function* tdoc);
 
-  void generate_java_docstring_comment(std::ofstream& out, string contents);
+  void generate_java_docstring_comment   (std::ofstream &out,
+                                          string contents);
 
-  void generate_deep_copy_container(std::ofstream& out,
-                                    std::string source_name_p1,
-                                    std::string source_name_p2,
-                                    std::string result_name,
-                                    t_type* type);
-  void generate_deep_copy_non_container(std::ofstream& out,
-                                        std::string source_name,
-                                        std::string dest_name,
-                                        t_type* type);
+  void generate_deep_copy_container(std::ofstream& out, std::string source_name_p1, std::string source_name_p2, std::string result_name, t_type* type);
+  void generate_deep_copy_non_container(std::ofstream& out, std::string source_name, std::string dest_name, t_type* type);
 
   bool has_bit_vector(t_struct* tstruct);
 
@@ -206,13 +207,10 @@ public:
   std::string java_package();
   std::string java_type_imports();
   std::string java_thrift_imports();
-  std::string type_name(t_type* ttype,
-                        bool in_container = false,
-                        bool in_init = false,
-                        bool skip_generic = false);
-  std::string base_type_name(t_base_type* tbase, bool in_container = false);
-  std::string declare_field(t_field* tfield, bool init = false);
-  std::string function_signature(t_function* tfunction, std::string prefix = "");
+  std::string type_name(t_type* ttype, bool in_container=false, bool in_init=false, bool skip_generic=false);
+  std::string base_type_name(t_base_type* tbase, bool in_container=false);
+  std::string declare_field(t_field* tfield, bool init=false);
+  std::string function_signature(t_function* tfunction, std::string prefix="");
   std::string argument_list(t_struct* tstruct, bool include_types = true);
   std::string type_to_enum(t_type* ttype);
   std::string get_enum_class_name(t_type* type);
@@ -223,13 +221,18 @@ public:
   bool type_can_be_null(t_type* ttype) {
     ttype = get_true_type(ttype);
 
-    return ttype->is_container() || ttype->is_struct() || ttype->is_xception() || ttype->is_string()
-           || ttype->is_enum();
+    return
+      ttype->is_container() ||
+      ttype->is_struct() ||
+      ttype->is_xception() ||
+      ttype->is_string() ||
+      ttype->is_enum();
   }
 
   std::string constant_name(std::string name);
 
-private:
+ private:
+
   /**
    * File streams
    */
@@ -237,8 +240,10 @@ private:
   std::string package_name_;
   std::ofstream f_service_;
   std::string package_dir_;
+
 };
 
+
 /**
  * Prepares for file generation by opening up the necessary file output
  * streams.
@@ -256,7 +261,7 @@ void t_javame_generator::init_generator() {
   while ((loc = dir.find(".")) != string::npos) {
     subdir = subdir + "/" + dir.substr(0, loc);
     MKDIR(subdir.c_str());
-    dir = dir.substr(loc + 1);
+    dir = dir.substr(loc+1);
   }
   if (dir.size() > 0) {
     subdir = subdir + "/" + dir;
@@ -284,8 +289,11 @@ string t_javame_generator::java_package() {
  * @return List of imports for Java types that are used in here
  */
 string t_javame_generator::java_type_imports() {
-  return string() + "import java.util.Hashtable;\n" + "import java.util.Vector;\n"
-         + "import java.util.Enumeration;\n\n";
+  return
+    string() +
+    "import java.util.Hashtable;\n" +
+    "import java.util.Vector;\n" +
+    "import java.util.Enumeration;\n\n";
 }
 
 /**
@@ -294,15 +302,18 @@ string t_javame_generator::java_type_imports() {
  * @return List of imports necessary for thrift
  */
 string t_javame_generator::java_thrift_imports() {
-  return string() + "import org.apache.thrift.*;\n" + "import org.apache.thrift.meta_data.*;\n"
-         + "import org.apache.thrift.transport.*;\n" + "import org.apache.thrift.protocol.*;\n\n";
+  return
+    string() +
+    "import org.apache.thrift.*;\n" +
+    "import org.apache.thrift.meta_data.*;\n" +
+    "import org.apache.thrift.transport.*;\n" +
+    "import org.apache.thrift.protocol.*;\n\n";
 }
 
 /**
  * Nothing in Java
  */
-void t_javame_generator::close_generator() {
-}
+void t_javame_generator::close_generator() {}
 
 /**
  * Generates a typedef. This is not done in Java, since it does
@@ -312,7 +323,7 @@ void t_javame_generator::close_generator() {
  * @param ttypedef The type definition
  */
 void t_javame_generator::generate_typedef(t_typedef* ttypedef) {
-  (void)ttypedef;
+  (void) ttypedef;
 }
 
 /**
@@ -322,15 +333,18 @@ void t_javame_generator::generate_typedef(t_typedef* ttypedef) {
  */
 void t_javame_generator::generate_enum(t_enum* tenum) {
   // Make output file
-  string f_enum_name = package_dir_ + "/" + (tenum->get_name()) + ".java";
+  string f_enum_name = package_dir_+"/"+(tenum->get_name())+".java";
   ofstream f_enum;
   f_enum.open(f_enum_name.c_str());
 
   // Comment and package it
-  f_enum << autogen_comment() << java_package();
+  f_enum <<
+    autogen_comment() <<
+    java_package();
 
   generate_java_doc(f_enum, tenum);
-  indent(f_enum) << "public class " << tenum->get_name() << " implements org.apache.thrift.TEnum ";
+  indent(f_enum) <<
+    "public class " << tenum->get_name() << " implements org.apache.thrift.TEnum ";
   scope_up(f_enum);
   f_enum << endl;
 
@@ -339,8 +353,9 @@ void t_javame_generator::generate_enum(t_enum* tenum) {
   for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
     int value = (*c_iter)->get_value();
     generate_java_doc(f_enum, *c_iter);
-    indent(f_enum) << "public static final " << tenum->get_name() << " " << (*c_iter)->get_name()
-                   << " = new " << tenum->get_name() << "(" << value << ");" << endl;
+    indent(f_enum) << "public static final " << tenum->get_name() <<
+      " " << (*c_iter)->get_name() << " = new " << tenum->get_name() <<
+      "(" << value << ");" << endl;
   }
   f_enum << endl;
 
@@ -348,23 +363,21 @@ void t_javame_generator::generate_enum(t_enum* tenum) {
   indent(f_enum) << "private final int value;" << endl << endl;
 
   indent(f_enum) << "private " << tenum->get_name() << "(int value) {" << endl;
-  indent(f_enum) << "  this.value = value;" << endl;
+  indent(f_enum) << "  this.value = value;" <<endl;
   indent(f_enum) << "}" << endl << endl;
 
   indent(f_enum) << "/**" << endl;
-  indent(f_enum) << " * Get the integer value of this enum value, as defined in the Thrift IDL."
-                 << endl;
+  indent(f_enum) << " * Get the integer value of this enum value, as defined in the Thrift IDL." << endl;
   indent(f_enum) << " */" << endl;
   indent(f_enum) << "public int getValue() {" << endl;
-  indent(f_enum) << "  return value;" << endl;
+  indent(f_enum) << "  return value;" <<endl;
   indent(f_enum) << "}" << endl << endl;
 
   indent(f_enum) << "/**" << endl;
-  indent(f_enum) << " * Find a the enum type by its integer value, as defined in the Thrift IDL."
-                 << endl;
+  indent(f_enum) << " * Find a the enum type by its integer value, as defined in the Thrift IDL." << endl;
   indent(f_enum) << " * @return null if the value is not found." << endl;
   indent(f_enum) << " */" << endl;
-  indent(f_enum) << "public static " + tenum->get_name() + " findByValue(int value) { " << endl;
+  indent(f_enum) << "public static "+ tenum->get_name() + " findByValue(int value) { " << endl;
 
   indent_up();
 
@@ -401,14 +414,19 @@ void t_javame_generator::generate_consts(std::vector<t_const*> consts) {
     return;
   }
 
-  string f_consts_name = package_dir_ + "/" + program_name_ + "Constants.java";
+  string f_consts_name = package_dir_+ "/" + program_name_ +  "Constants.java";
   ofstream f_consts;
   f_consts.open(f_consts_name.c_str());
 
   // Print header
-  f_consts << autogen_comment() << java_package() << java_type_imports();
-
-  f_consts << "public class " << program_name_ << "Constants {" << endl << endl;
+  f_consts <<
+    autogen_comment() <<
+    java_package() <<
+    java_type_imports();
+
+  f_consts <<
+    "public class " << program_name_ << "Constants {" << endl <<
+    endl;
   indent_up();
   vector<t_const*>::iterator c_iter;
   for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
@@ -419,26 +437,25 @@ void t_javame_generator::generate_consts(std::vector<t_const*> consts) {
                       false);
   }
   indent_down();
-  indent(f_consts) << "}" << endl;
+  indent(f_consts) <<
+    "}" << endl;
   f_consts.close();
 }
 
+
 /**
  * Prints the value of a constant with the given type. Note that type checking
  * is NOT performed in this function as it is always run beforehand using the
  * validate_types method in main.cc
  */
-void t_javame_generator::print_const_value(std::ofstream& out,
-                                           string name,
-                                           t_type* type,
-                                           t_const_value* value,
-                                           bool in_static,
-                                           bool defval) {
+void t_javame_generator::print_const_value(std::ofstream& out, string name, t_type* type, t_const_value* value, bool in_static, bool defval) {
   type = get_true_type(type);
 
   indent(out);
   if (!defval) {
-    out << (in_static ? "" : "public static final ") << type_name(type) << " ";
+    out <<
+      (in_static ? "" : "public static final ") <<
+      type_name(type) << " ";
   }
   if (type->is_base_type()) {
     string v2 = render_const_value(out, name, type, value);
@@ -488,8 +505,8 @@ void t_javame_generator::print_const_value(std::ofstream& out,
     for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
       string key = render_const_value(out, name, ktype, v_iter->first);
       string val = render_const_value(out, name, vtype, v_iter->second);
-      indent(out) << name << ".put(" << box_type(ktype, key) << ", " << box_type(vtype, val) << ");"
-                  << endl;
+      indent(out) << name << ".put(" << box_type(ktype, key) << ", " <<
+	box_type(vtype, val) << ");" << endl;
     }
     if (!in_static) {
       indent_down();
@@ -513,10 +530,11 @@ void t_javame_generator::print_const_value(std::ofstream& out,
     for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
       string val = render_const_value(out, name, etype, *v_iter);
       if (type->is_list()) {
-        indent(out) << name << ".addElement(" << box_type(etype, val) << ");" << endl;
+	indent(out) << name << ".addElement(" << box_type(etype, val) << ");" << endl;
       } else {
-        indent(out) << name << ".put(" << box_type(etype, val) << ", " << box_type(etype, val)
-                    << ");" << endl;
+	indent(out) << name << ".put(" <<
+	  box_type(etype, val) << ", " <<
+	  box_type(etype, val) << ");" << endl;
       }
     }
     if (!in_static) {
@@ -529,11 +547,8 @@ void t_javame_generator::print_const_value(std::ofstream& out,
   }
 }
 
-string t_javame_generator::render_const_value(ofstream& out,
-                                              string name,
-                                              t_type* type,
-                                              t_const_value* value) {
-  (void)name;
+string t_javame_generator::render_const_value(ofstream& out, string name, t_type* type, t_const_value* value) {
+  (void) name;
   type = get_true_type(type);
   std::ostringstream render;
 
@@ -624,20 +639,28 @@ void t_javame_generator::generate_xception(t_struct* txception) {
   generate_java_struct(txception, true);
 }
 
+
 /**
  * Java struct definition.
  *
  * @param tstruct The struct definition
  */
-void t_javame_generator::generate_java_struct(t_struct* tstruct, bool is_exception) {
+void t_javame_generator::generate_java_struct(t_struct* tstruct,
+                                            bool is_exception) {
   // Make output file
-  string f_struct_name = package_dir_ + "/" + (tstruct->get_name()) + ".java";
+  string f_struct_name = package_dir_+"/"+(tstruct->get_name())+".java";
   ofstream f_struct;
   f_struct.open(f_struct_name.c_str());
 
-  f_struct << autogen_comment() << java_package() << java_type_imports() << java_thrift_imports();
+  f_struct <<
+    autogen_comment() <<
+    java_package() <<
+    java_type_imports() <<
+    java_thrift_imports();
 
-  generate_java_struct_definition(f_struct, tstruct, is_exception);
+  generate_java_struct_definition(f_struct,
+                                  tstruct,
+                                  is_exception);
   f_struct.close();
 }
 
@@ -648,18 +671,23 @@ void t_javame_generator::generate_java_struct(t_struct* tstruct, bool is_excepti
  */
 void t_javame_generator::generate_java_union(t_struct* tstruct) {
   // Make output file
-  string f_struct_name = package_dir_ + "/" + (tstruct->get_name()) + ".java";
+  string f_struct_name = package_dir_+"/"+(tstruct->get_name())+".java";
   ofstream f_struct;
   f_struct.open(f_struct_name.c_str());
 
-  f_struct << autogen_comment() << java_package() << java_type_imports() << java_thrift_imports();
+  f_struct <<
+    autogen_comment() <<
+    java_package() <<
+    java_type_imports() <<
+    java_thrift_imports();
 
   generate_java_doc(f_struct, tstruct);
 
   bool is_final = (tstruct->annotations_.find("final") != tstruct->annotations_.end());
 
-  indent(f_struct) << "public " << (is_final ? "final " : "") << "class " << tstruct->get_name()
-                   << " extends TUnion ";
+  indent(f_struct) <<
+    "public " << (is_final ? "final " : "") << "class " << tstruct->get_name()
+	      << " extends TUnion ";
 
   scope_up(f_struct);
 
@@ -702,8 +730,7 @@ void t_javame_generator::generate_union_constructor(ofstream& out, t_struct* tst
   indent(out) << "  super(setField, value);" << endl;
   indent(out) << "}" << endl << endl;
 
-  indent(out) << "public " << type_name(tstruct) << "(" << type_name(tstruct) << " other) {"
-              << endl;
+  indent(out) << "public " << type_name(tstruct) << "(" << type_name(tstruct) << " other) {" << endl;
   indent(out) << "  super(other);" << endl;
   indent(out) << "}" << endl;
 
@@ -715,8 +742,7 @@ void t_javame_generator::generate_union_constructor(ofstream& out, t_struct* tst
   const vector<t_field*>& members = tstruct->get_members();
   vector<t_field*>::const_iterator m_iter;
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
-    indent(out) << "public static " << type_name(tstruct) << " " << (*m_iter)->get_name() << "("
-                << type_name((*m_iter)->get_type()) << " value) {" << endl;
+    indent(out) << "public static " << type_name(tstruct) << " " << (*m_iter)->get_name() << "(" << type_name((*m_iter)->get_type()) << " value) {" << endl;
     indent(out) << "  " << type_name(tstruct) << " x = new " << type_name(tstruct) << "();" << endl;
     indent(out) << "  x.set" << get_cap_name((*m_iter)->get_name()) << "(value);" << endl;
     indent(out) << "  return x;" << endl;
@@ -739,24 +765,19 @@ void t_javame_generator::generate_union_getters_and_setters(ofstream& out, t_str
     t_field* field = (*m_iter);
 
     generate_java_doc(out, field);
-    indent(out) << "public " << type_name(field->get_type()) << " get"
-                << get_cap_name(field->get_name()) << "() {" << endl;
-    indent(out) << "  if (getSetField() == _Fields." << constant_name(field->get_name()) << ") {"
-                << endl;
-    indent(out) << "    return (" << type_name(field->get_type(), true) << ")getFieldValue();"
-                << endl;
+    indent(out) << "public " << type_name(field->get_type()) << " get" << get_cap_name(field->get_name()) << "() {" << endl;
+    indent(out) << "  if (getSetField() == _Fields." << constant_name(field->get_name()) << ") {" << endl;
+    indent(out) << "    return (" << type_name(field->get_type(), true) << ")getFieldValue();" << endl;
     indent(out) << "  } else {" << endl;
     indent(out) << "    throw new RuntimeException(\"Cannot get field '" << field->get_name()
-                << "' because union is currently set to \" + getFieldDesc(getSetField()).name);"
-                << endl;
+      << "' because union is currently set to \" + getFieldDesc(getSetField()).name);" << endl;
     indent(out) << "  }" << endl;
     indent(out) << "}" << endl;
 
     out << endl;
 
     generate_java_doc(out, field);
-    indent(out) << "public void set" << get_cap_name(field->get_name()) << "("
-                << type_name(field->get_type()) << " value) {" << endl;
+    indent(out) << "public void set" << get_cap_name(field->get_name()) << "(" << type_name(field->get_type()) << " value) {" << endl;
     if (type_can_be_null(field->get_type())) {
       indent(out) << "  if (value == null) throw new NullPointerException();" << endl;
     }
@@ -780,9 +801,7 @@ void t_javame_generator::generate_union_abstract_methods(ofstream& out, t_struct
 }
 
 void t_javame_generator::generate_check_type(ofstream& out, t_struct* tstruct) {
-  indent(out)
-      << "protected void checkType(_Fields setField, Object value) throws ClassCastException {"
-      << endl;
+  indent(out) << "protected void checkType(_Fields setField, Object value) throws ClassCastException {" << endl;
   indent_up();
 
   indent(out) << "switch (setField) {" << endl;
@@ -795,13 +814,12 @@ void t_javame_generator::generate_check_type(ofstream& out, t_struct* tstruct) {
     t_field* field = (*m_iter);
 
     indent(out) << "case " << constant_name(field->get_name()) << ":" << endl;
-    indent(out) << "  if (value instanceof " << type_name(field->get_type(), true, false, true)
-                << ") {" << endl;
+    indent(out) << "  if (value instanceof " << type_name(field->get_type(), true, false, true) << ") {" << endl;
     indent(out) << "    break;" << endl;
     indent(out) << "  }" << endl;
     indent(out) << "  throw new ClassCastException(\"Was expecting value of type "
-                << type_name(field->get_type(), true, false) << " for field '" << field->get_name()
-                << "', but got \" + value.getClass().getSimpleName());" << endl;
+      << type_name(field->get_type(), true, false) << " for field '" << field->get_name()
+      << "', but got \" + value.getClass().getSimpleName());" << endl;
     // do the real check here
   }
 
@@ -816,8 +834,7 @@ void t_javame_generator::generate_check_type(ofstream& out, t_struct* tstruct) {
 }
 
 void t_javame_generator::generate_read_value(ofstream& out, t_struct* tstruct) {
-  indent(out) << "protected Object readValue(TProtocol iprot, TField field) throws TException {"
-              << endl;
+  indent(out) << "protected Object readValue(TProtocol iprot, TField field) throws TException {" << endl;
 
   indent_up();
 
@@ -835,11 +852,9 @@ void t_javame_generator::generate_read_value(ofstream& out, t_struct* tstruct) {
 
     indent(out) << "case " << constant_name(field->get_name()) << ":" << endl;
     indent_up();
-    indent(out) << "if (field.type == " << constant_name(field->get_name()) << "_FIELD_DESC.type) {"
-                << endl;
+    indent(out) << "if (field.type == " << constant_name(field->get_name()) << "_FIELD_DESC.type) {" << endl;
     indent_up();
-    indent(out) << type_name(field->get_type(), true, false) << " " << field->get_name() << ";"
-                << endl;
+    indent(out) << type_name(field->get_type(), true, false) << " " << field->get_name() << ";" << endl;
     generate_deserialize_field(out, field, "");
     indent(out) << "return " << field->get_name() << ";" << endl;
     indent_down();
@@ -851,8 +866,7 @@ void t_javame_generator::generate_read_value(ofstream& out, t_struct* tstruct) {
   }
 
   indent(out) << "default:" << endl;
-  indent(out) << "  throw new IllegalStateException(\"setField wasn't null, but didn't match any "
-                 "of the case statements!\");" << endl;
+  indent(out) << "  throw new IllegalStateException(\"setField wasn't null, but didn't match any of the case statements!\");" << endl;
 
   indent_down();
   indent(out) << "}" << endl;
@@ -885,22 +899,23 @@ void t_javame_generator::generate_write_value(ofstream& out, t_struct* tstruct)
 
     indent(out) << "case " << constant_name(field->get_name()) << ":" << endl;
     indent_up();
-    indent(out) << type_name(field->get_type(), true, false) << " " << field->get_name() << " = ("
-                << type_name(field->get_type(), true, false) << ")value_;" << endl;
+    indent(out) << type_name(field->get_type(), true, false) << " " << field->get_name()
+      << " = (" <<  type_name(field->get_type(), true, false) << ")value_;" << endl;
     generate_serialize_field(out, field, "");
     indent(out) << "return;" << endl;
     indent_down();
   }
 
   indent(out) << "default:" << endl;
-  indent(out) << "  throw new IllegalStateException(\"Cannot write union with unknown field \" + "
-                 "setField_);" << endl;
+  indent(out) << "  throw new IllegalStateException(\"Cannot write union with unknown field \" + setField_);" << endl;
 
   indent_down();
   indent(out) << "}" << endl;
 
   indent_down();
 
+
+
   indent(out) << "}" << endl;
 }
 
@@ -931,7 +946,7 @@ void t_javame_generator::generate_get_field_desc(ofstream& out, t_struct* tstruc
 }
 
 void t_javame_generator::generate_get_struct_desc(ofstream& out, t_struct* tstruct) {
-  (void)tstruct;
+  (void) tstruct;
   indent(out) << "protected TStruct getStructDesc() {" << endl;
   indent(out) << "  return STRUCT_DESC;" << endl;
   indent(out) << "}" << endl;
@@ -950,17 +965,14 @@ void t_javame_generator::generate_union_comparisons(ofstream& out, t_struct* tst
   out << endl;
 
   indent(out) << "public boolean equals(" << tstruct->get_name() << " other) {" << endl;
-  indent(out) << "  return other != null && getSetField() == other.getSetField() && "
-                 "getFieldValue().equals(other.getFieldValue());" << endl;
+  indent(out) << "  return other != null && getSetField() == other.getSetField() && getFieldValue().equals(other.getFieldValue());" << endl;
   indent(out) << "}" << endl;
   out << endl;
 
   indent(out) << "public int compareTo(" << type_name(tstruct) << " other) {" << endl;
-  indent(out) << "  int lastComparison = TBaseHelper.compareTo(getSetField(), other.getSetField());"
-              << endl;
+  indent(out) << "  int lastComparison = TBaseHelper.compareTo(getSetField(), other.getSetField());" << endl;
   indent(out) << "  if (lastComparison == 0) {" << endl;
-  indent(out) << "    return TBaseHelper.compareTo(getFieldValue(), other.getFieldValue());"
-              << endl;
+  indent(out) << "    return TBaseHelper.compareTo(getFieldValue(), other.getFieldValue());" << endl;
   indent(out) << "  }" << endl;
   indent(out) << "  return lastComparison;" << endl;
   indent(out) << "}" << endl;
@@ -968,11 +980,9 @@ void t_javame_generator::generate_union_comparisons(ofstream& out, t_struct* tst
 }
 
 void t_javame_generator::generate_union_hashcode(ofstream& out, t_struct* tstruct) {
-  (void)tstruct;
+  (void) tstruct;
   indent(out) << "/**" << endl;
-  indent(out)
-      << " * If you'd like this to perform more respectably, use the hashcode generator option."
-      << endl;
+  indent(out) << " * If you'd like this to perform more respectably, use the hashcode generator option." << endl;
   indent(out) << " */" << endl;
   indent(out) << "public int hashCode() {" << endl;
   indent(out) << "  return 0;" << endl;
@@ -989,17 +999,18 @@ void t_javame_generator::generate_union_hashcode(ofstream& out, t_struct* tstruc
  * @param in_class     If inside a class, needs to be static class
  * @param is_result    If this is a result it needs a different writer
  */
-void t_javame_generator::generate_java_struct_definition(ofstream& out,
-                                                         t_struct* tstruct,
-                                                         bool is_exception,
-                                                         bool in_class,
-                                                         bool is_result) {
+void t_javame_generator::generate_java_struct_definition(ofstream &out,
+                                                       t_struct* tstruct,
+                                                       bool is_exception,
+                                                       bool in_class,
+                                                       bool is_result) {
   generate_java_doc(out, tstruct);
 
   bool is_final = (tstruct->annotations_.find("final") != tstruct->annotations_.end());
 
-  indent(out) << "public " << (is_final ? "final " : "") << (in_class ? "static " : "") << "class "
-              << tstruct->get_name() << " ";
+  indent(out) <<
+    "public " << (is_final ? "final " : "") <<
+     (in_class ? "static " : "") << "class " << tstruct->get_name() << " ";
 
   if (is_exception) {
     out << "extends Exception ";
@@ -1034,8 +1045,8 @@ void t_javame_generator::generate_java_struct_definition(ofstream& out,
     int i = 0;
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
       if (!type_can_be_null((*m_iter)->get_type())) {
-        indent(out) << "private static final int " << isset_field_id(*m_iter) << " = " << i << ";"
-                    << endl;
+        indent(out) << "private static final int " << isset_field_id(*m_iter)
+          << " = " << i << ";" <<  endl;
         i++;
       }
     }
@@ -1050,17 +1061,13 @@ void t_javame_generator::generate_java_struct_definition(ofstream& out,
   bool all_optional_members = true;
 
   // Default constructor
-  indent(out) << "public " << tstruct->get_name() << "() {" << endl;
+  indent(out) <<
+    "public " << tstruct->get_name() << "() {" << endl;
   indent_up();
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
     t_type* t = get_true_type((*m_iter)->get_type());
     if ((*m_iter)->get_value() != NULL) {
-      print_const_value(out,
-                        "this." + (*m_iter)->get_name(),
-                        t,
-                        (*m_iter)->get_value(),
-                        true,
-                        true);
+      print_const_value(out, "this." + (*m_iter)->get_name(), t, (*m_iter)->get_value(), true, true);
     }
     if ((*m_iter)->get_req() != t_field::T_OPTIONAL) {
       all_optional_members = false;
@@ -1071,7 +1078,8 @@ void t_javame_generator::generate_java_struct_definition(ofstream& out,
 
   if (!members.empty() && !all_optional_members) {
     // Full constructor for all fields
-    indent(out) << "public " << tstruct->get_name() << "(" << endl;
+    indent(out) <<
+      "public " << tstruct->get_name() << "(" << endl;
     indent_up();
     bool first = true;
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
@@ -1080,7 +1088,8 @@ void t_javame_generator::generate_java_struct_definition(ofstream& out,
           out << "," << endl;
         }
         first = false;
-        indent(out) << type_name((*m_iter)->get_type()) << " " << (*m_iter)->get_name();
+        indent(out) << type_name((*m_iter)->get_type()) << " " <<
+          (*m_iter)->get_name();
       }
     }
     out << ")" << endl;
@@ -1090,8 +1099,8 @@ void t_javame_generator::generate_java_struct_definition(ofstream& out,
     indent(out) << "this();" << endl;
     for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
       if ((*m_iter)->get_req() != t_field::T_OPTIONAL) {
-        indent(out) << "this." << (*m_iter)->get_name() << " = " << (*m_iter)->get_name() << ";"
-                    << endl;
+        indent(out) << "this." << (*m_iter)->get_name() << " = " <<
+          (*m_iter)->get_name() << ";" << endl;
         generate_isset_set(out, (*m_iter));
       }
     }
@@ -1103,13 +1112,11 @@ void t_javame_generator::generate_java_struct_definition(ofstream& out,
   indent(out) << "/**" << endl;
   indent(out) << " * Performs a deep copy on <i>other</i>." << endl;
   indent(out) << " */" << endl;
-  indent(out) << "public " << tstruct->get_name() << "(" << tstruct->get_name() << " other) {"
-              << endl;
+  indent(out) << "public " << tstruct->get_name() << "(" << tstruct->get_name() << " other) {" << endl;
   indent_up();
 
   if (has_bit_vector(tstruct)) {
-    indent(out) << "System.arraycopy(other.__isset_vector, 0, __isset_vector, 0, "
-                   "other.__isset_vector.length);" << endl;
+    indent(out) << "System.arraycopy(other.__isset_vector, 0, __isset_vector, 0, other.__isset_vector.length);" << endl;
   }
 
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
@@ -1171,19 +1178,25 @@ void t_javame_generator::generate_java_struct_definition(ofstream& out,
  *
  * @param tstruct The struct definition
  */
-void t_javame_generator::generate_java_struct_equality(ofstream& out, t_struct* tstruct) {
+void t_javame_generator::generate_java_struct_equality(ofstream& out,
+                                                     t_struct* tstruct) {
   out << indent() << "public boolean equals(Object that) {" << endl;
   indent_up();
-  out << indent() << "if (that == null)" << endl << indent() << "  return false;" << endl
-      << indent() << "if (that instanceof " << tstruct->get_name() << ")" << endl << indent()
-      << "  return this.equals((" << tstruct->get_name() << ")that);" << endl << indent()
-      << "return false;" << endl;
+  out <<
+    indent() << "if (that == null)" << endl <<
+    indent() << "  return false;" << endl <<
+    indent() << "if (that instanceof " << tstruct->get_name() << ")" << endl <<
+    indent() << "  return this.equals((" << tstruct->get_name() << ")that);" << endl <<
+    indent() << "return false;" << endl;
   scope_down(out);
   out << endl;
 
-  out << indent() << "public boolean equals(" << tstruct->get_name() << " that) {" << endl;
+  out <<
+    indent() << "public boolean equals(" << tstruct->get_name() << " that) {" << endl;
   indent_up();
-  out << indent() << "if (that == null)" << endl << indent() << "  return false;" << endl;
+  out <<
+    indent() << "if (that == null)" << endl <<
+    indent() << "  return false;" << endl;
 
   const vector<t_field*>& members = tstruct->get_members();
   vector<t_field*>::const_iterator m_iter;
@@ -1206,24 +1219,31 @@ void t_javame_generator::generate_java_struct_equality(ofstream& out, t_struct*
       that_present += " && that." + generate_isset_check(*m_iter);
     }
 
-    out << indent() << "boolean this_present_" << name << " = " << this_present << ";" << endl
-        << indent() << "boolean that_present_" << name << " = " << that_present << ";" << endl
-        << indent() << "if ("
-        << "this_present_" << name << " || that_present_" << name << ") {" << endl;
+    out <<
+      indent() << "boolean this_present_" << name << " = "
+               << this_present << ";" << endl <<
+      indent() << "boolean that_present_" << name << " = "
+               << that_present << ";" << endl <<
+      indent() << "if (" << "this_present_" << name
+               << " || that_present_" << name << ") {" << endl;
     indent_up();
-    out << indent() << "if (!("
-        << "this_present_" << name << " && that_present_" << name << "))" << endl << indent()
-        << "  return false;" << endl;
+    out <<
+      indent() << "if (!(" << "this_present_" << name
+               << " && that_present_" << name << "))" << endl <<
+      indent() << "  return false;" << endl;
 
     if (t->is_base_type() && ((t_base_type*)t)->is_binary()) {
-      unequal = "TBaseHelper.compareTo(this." + name + ", that." + name + ") != 0";
+      unequal = "TBaseHelper.compareTo(this." + name + ", that." +
+	name + ") != 0";
     } else if (can_be_null) {
       unequal = "!this." + name + ".equals(that." + name + ")";
     } else {
       unequal = "this." + name + " != that." + name;
     }
 
-    out << indent() << "if (" << unequal << ")" << endl << indent() << "  return false;" << endl;
+    out <<
+      indent() << "if (" << unequal << ")" << endl <<
+      indent() << "  return false;" << endl;
 
     scope_down(out);
   }
@@ -1245,8 +1265,7 @@ void t_javame_generator::generate_java_struct_compare_to(ofstream& out, t_struct
   indent_up();
 
   indent(out) << "if (!getClass().equals(otherObject.getClass())) {" << endl;
-  indent(out) << "  return getClass().getName().compareTo(otherObject.getClass().getName());"
-              << endl;
+  indent(out) << "  return getClass().getName().compareTo(otherObject.getClass().getName());" << endl;
   indent(out) << "}" << endl;
   out << endl;
   indent(out) << type_name(tstruct) << " other = (" << type_name(tstruct) << ")otherObject;";
@@ -1258,19 +1277,16 @@ void t_javame_generator::generate_java_struct_compare_to(ofstream& out, t_struct
   vector<t_field*>::const_iterator m_iter;
   for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
     t_field* field = *m_iter;
-    indent(out) << "lastComparison = TBaseHelper.compareTo(" << generate_isset_check(field)
-                << ", other." << generate_isset_check(field) << ");" << endl;
+    indent(out) << "lastComparison = TBaseHelper.compareTo(" << generate_isset_check(field) << ", other." << generate_isset_check(field) << ");" << endl;
     indent(out) << "if (lastComparison != 0) {" << endl;
     indent(out) << "  return lastComparison;" << endl;
     indent(out) << "}" << endl;
 
     indent(out) << "if (" << generate_isset_check(field) << ") {" << endl;
     if (field->get_type()->is_struct() || field->get_type()->is_xception()) {
-      indent(out) << "  lastComparison = this." << field->get_name() << ".compareTo(other."
-                  << field->get_name() << ");" << endl;
+      indent(out) << "  lastComparison = this." << field->get_name() << ".compareTo(other." << field->get_name() << ");" << endl;
     } else {
-      indent(out) << "  lastComparison = TBaseHelper.compareTo(this." << field->get_name()
-                  << ", other." << field->get_name() << ");" << endl;
+      indent(out) << "  lastComparison = TBaseHelper.compareTo(this." << field->get_name() << ", other." << field->get_name() << ");" << endl;
     }
 
     indent(out) << "  if (lastComparison != 0) {" << endl;
@@ -1290,75 +1306,93 @@ void t_javame_generator::generate_java_struct_compare_to(ofstream& out, t_struct
  *
  * @param tstruct The struct definition
  */
-void t_javame_generator::generate_java_struct_reader(ofstream& out, t_struct* tstruct) {
-  out << indent() << "public void read(TProtocol iprot) throws TException {" << endl;
+void t_javame_generator::generate_java_struct_reader(ofstream& out,
+                                                   t_struct* tstruct) {
+  out <<
+    indent() << "public void read(TProtocol iprot) throws TException {" << endl;
   indent_up();
 
   const vector<t_field*>& fields = tstruct->get_members();
   vector<t_field*>::const_iterator f_iter;
 
   // Declare stack tmp variables and read struct header
-  out << indent() << "TField field;" << endl << indent() << "iprot.readStructBegin();" << endl;
+  out <<
+    indent() << "TField field;" << endl <<
+    indent() << "iprot.readStructBegin();" << endl;
 
   // Loop over reading in fields
-  indent(out) << "while (true)" << endl;
-  scope_up(out);
+  indent(out) <<
+    "while (true)" << endl;
+    scope_up(out);
 
-  // Read beginning field marker
-  indent(out) << "field = iprot.readFieldBegin();" << endl;
+    // Read beginning field marker
+    indent(out) <<
+      "field = iprot.readFieldBegin();" << endl;
 
-  // Check for field STOP marker and break
-  indent(out) << "if (field.type == TType.STOP) { " << endl;
-  indent_up();
-  indent(out) << "break;" << endl;
-  indent_down();
-  indent(out) << "}" << endl;
-
-  // Switch statement on the field we are reading
-  indent(out) << "switch (field.id) {" << endl;
+    // Check for field STOP marker and break
+    indent(out) <<
+      "if (field.type == TType.STOP) { " << endl;
+    indent_up();
+    indent(out) <<
+      "break;" << endl;
+    indent_down();
+    indent(out) <<
+      "}" << endl;
 
-  indent_up();
+    // Switch statement on the field we are reading
+    indent(out) << "switch (field.id) {" << endl;
 
-  // Generate deserialization code for known cases
-  for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
-    indent(out) << "case " << (*f_iter)->get_key() << ": // "
-                << constant_name((*f_iter)->get_name()) << endl;
-    indent_up();
-    indent(out) << "if (field.type == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl;
     indent_up();
 
-    generate_deserialize_field(out, *f_iter, "this.");
-    generate_isset_set(out, *f_iter);
-    indent_down();
-    out << indent() << "} else { " << endl << indent() << "  TProtocolUtil.skip(iprot, field.type);"
-        << endl << indent() << "}" << endl << indent() << "break;" << endl;
-    indent_down();
-  }
+    // Generate deserialization code for known cases
+    for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
+      indent(out) <<
+        "case " << (*f_iter)->get_key() << ": // " << constant_name((*f_iter)->get_name()) << endl;
+      indent_up();
+      indent(out) <<
+        "if (field.type == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl;
+      indent_up();
 
-  indent(out) << "default:" << endl;
-  indent(out) << "  TProtocolUtil.skip(iprot, field.type);" << endl;
+      generate_deserialize_field(out, *f_iter, "this.");
+      generate_isset_set(out, *f_iter);
+      indent_down();
+      out <<
+        indent() << "} else { " << endl <<
+        indent() << "  TProtocolUtil.skip(iprot, field.type);" << endl <<
+        indent() << "}" << endl <<
+        indent() << "break;" << endl;
+      indent_down();
+    }
 
-  indent_down();
-  indent(out) << "}" << endl;
+    indent(out) << "default:" << endl;
+    indent(out) << "  TProtocolUtil.skip(iprot, field.type);" << endl;
+
+    indent_down();
+    indent(out) << "}" << endl;
 
-  // Read field end marker
-  indent(out) << "iprot.readFieldEnd();" << endl;
+    // Read field end marker
+    indent(out) <<
+      "iprot.readFieldEnd();" << endl;
 
-  indent_down();
-  indent(out) << "}" << endl;
+    indent_down();
+    indent(out) << "}" << endl;
 
-  out << indent() << "iprot.readStructEnd();" << endl;
+    out <<
+      indent() << "iprot.readStructEnd();" << endl;
 
-  // performs various checks (e.g. check that all required fields are set)
-  indent(out) << "validate();" << endl;
+    // performs various checks (e.g. check that all required fields are set)
+    indent(out) << "validate();" << endl;
 
   indent_down();
-  out << indent() << "}" << endl << endl;
+  out <<
+    indent() << "}" << endl <<
+    endl;
 }
 
 // generates java method to perform various checks
 // (e.g. check that all required fields are set)
-void t_javame_generator::generate_java_validator(ofstream& out, t_struct* tstruct) {
+void t_javame_generator::generate_java_validator(ofstream& out,
+                                                   t_struct* tstruct){
   indent(out) << "public void validate() throws TException {" << endl;
   indent_up();
 
@@ -1368,9 +1402,10 @@ void t_javame_generator::generate_java_validator(ofstream& out, t_struct* tstruc
   out << indent() << "// check for required fields" << endl;
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     if ((*f_iter)->get_req() == t_field::T_REQUIRED) {
-      out << indent() << "if (!" << generate_isset_check(*f_iter) << ") {" << endl << indent()
-          << "  throw new TProtocolException(\"Required field '" << (*f_iter)->get_name()
-          << "' is unset! Struct:\" + toString());" << endl << indent() << "}" << endl << endl;
+      out <<
+        indent() << "if (!" << generate_isset_check(*f_iter) << ") {" << endl <<
+        indent() << "  throw new TProtocolException(\"Required field '" << (*f_iter)->get_name() << "' is unset! Struct:\" + toString());" << endl <<
+        indent() << "}" << endl << endl;
     }
   }
 
@@ -1383,8 +1418,10 @@ void t_javame_generator::generate_java_validator(ofstream& out, t_struct* tstruc
  *
  * @param tstruct The struct definition
  */
-void t_javame_generator::generate_java_struct_writer(ofstream& out, t_struct* tstruct) {
-  out << indent() << "public void write(TProtocol oprot) throws TException {" << endl;
+void t_javame_generator::generate_java_struct_writer(ofstream& out,
+                                                   t_struct* tstruct) {
+  out <<
+    indent() << "public void write(TProtocol oprot) throws TException {" << endl;
   indent_up();
 
   string name = tstruct->get_name();
@@ -1399,7 +1436,8 @@ void t_javame_generator::generate_java_struct_writer(ofstream& out, t_struct* ts
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     bool null_allowed = type_can_be_null((*f_iter)->get_type());
     if (null_allowed) {
-      out << indent() << "if (this." << (*f_iter)->get_name() << " != null) {" << endl;
+      out <<
+        indent() << "if (this." << (*f_iter)->get_name() << " != null) {" << endl;
       indent_up();
     }
     bool optional = (*f_iter)->get_req() == t_field::T_OPTIONAL;
@@ -1408,14 +1446,14 @@ void t_javame_generator::generate_java_struct_writer(ofstream& out, t_struct* ts
       indent_up();
     }
 
-    indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name())
-                << "_FIELD_DESC);" << endl;
+    indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name()) << "_FIELD_DESC);" << endl;
 
     // Write field contents
     generate_serialize_field(out, *f_iter, "this.");
 
     // Write field closer
-    indent(out) << "oprot.writeFieldEnd();" << endl;
+    indent(out) <<
+      "oprot.writeFieldEnd();" << endl;
 
     if (optional) {
       indent_down();
@@ -1427,11 +1465,14 @@ void t_javame_generator::generate_java_struct_writer(ofstream& out, t_struct* ts
     }
   }
   // Write the struct map
-  out << indent() << "oprot.writeFieldStop();" << endl << indent() << "oprot.writeStructEnd();"
-      << endl;
+  out <<
+    indent() << "oprot.writeFieldStop();" << endl <<
+    indent() << "oprot.writeStructEnd();" << endl;
 
   indent_down();
-  out << indent() << "}" << endl << endl;
+  out <<
+    indent() << "}" << endl <<
+    endl;
 }
 
 /**
@@ -1442,8 +1483,10 @@ void t_javame_generator::generate_java_struct_writer(ofstream& out, t_struct* ts
  *
  * @param tstruct The struct definition
  */
-void t_javame_generator::generate_java_struct_result_writer(ofstream& out, t_struct* tstruct) {
-  out << indent() << "public void write(TProtocol oprot) throws TException {" << endl;
+void t_javame_generator::generate_java_struct_result_writer(ofstream& out,
+                                                          t_struct* tstruct) {
+  out <<
+    indent() << "public void write(TProtocol oprot) throws TException {" << endl;
   indent_up();
 
   string name = tstruct->get_name();
@@ -1456,7 +1499,9 @@ void t_javame_generator::generate_java_struct_result_writer(ofstream& out, t_str
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     if (first) {
       first = false;
-      out << endl << indent() << "if ";
+      out <<
+        endl <<
+        indent() << "if ";
     } else {
       out << " else if ";
     }
@@ -1465,38 +1510,38 @@ void t_javame_generator::generate_java_struct_result_writer(ofstream& out, t_str
 
     indent_up();
 
-    indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name())
-                << "_FIELD_DESC);" << endl;
+    indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name()) << "_FIELD_DESC);" << endl;
 
     // Write field contents
     generate_serialize_field(out, *f_iter, "this.");
 
     // Write field closer
-    indent(out) << "oprot.writeFieldEnd();" << endl;
+    indent(out) <<
+      "oprot.writeFieldEnd();" << endl;
 
     indent_down();
     indent(out) << "}";
   }
   // Write the struct map
-  out << endl << indent() << "oprot.writeFieldStop();" << endl << indent()
-      << "oprot.writeStructEnd();" << endl;
+  out <<
+    endl <<
+    indent() << "oprot.writeFieldStop();" << endl <<
+    indent() << "oprot.writeStructEnd();" << endl;
 
   indent_down();
-  out << indent() << "}" << endl << endl;
+  out <<
+    indent() << "}" << endl <<
+    endl;
 }
 
-void t_javame_generator::generate_reflection_getters(ostringstream& out,
-                                                     t_type* type,
-                                                     string field_name,
-                                                     string cap_name) {
+void t_javame_generator::generate_reflection_getters(ostringstream& out, t_type* type, string field_name, string cap_name) {
   indent(out) << "case " << constant_name(field_name) << ":" << endl;
   indent_up();
 
   if (type->is_base_type() && !type->is_string()) {
     t_base_type* base_type = (t_base_type*)type;
 
-    indent(out) << "return new " << type_name(type, true, false) << "("
-                << (base_type->is_bool() ? "is" : "get") << cap_name << "());" << endl << endl;
+    indent(out) << "return new " << type_name(type, true, false) << "(" << (base_type->is_bool() ? "is" : "get") << cap_name << "());" << endl << endl;
   } else {
     indent(out) << "return get" << cap_name << "();" << endl << endl;
   }
@@ -1504,10 +1549,7 @@ void t_javame_generator::generate_reflection_getters(ostringstream& out,
   indent_down();
 }
 
-void t_javame_generator::generate_reflection_setters(ostringstream& out,
-                                                     t_type* type,
-                                                     string field_name,
-                                                     string cap_name) {
+void t_javame_generator::generate_reflection_setters(ostringstream& out, t_type* type, string field_name, string cap_name) {
   indent(out) << "case " << constant_name(field_name) << ":" << endl;
   indent_up();
   indent(out) << "if (value == null) {" << endl;
@@ -1520,9 +1562,8 @@ void t_javame_generator::generate_reflection_setters(ostringstream& out,
   indent_down();
 }
 
-void t_javame_generator::generate_generic_field_getters_setters(std::ofstream& out,
-                                                                t_struct* tstruct) {
-  (void)out;
+void t_javame_generator::generate_generic_field_getters_setters(std::ofstream& out, t_struct* tstruct) {
+  (void) out;
   std::ostringstream getter_stream;
   std::ostringstream setter_stream;
 
@@ -1540,6 +1581,7 @@ void t_javame_generator::generate_generic_field_getters_setters(std::ofstream& o
     generate_reflection_getters(getter_stream, type, field_name, cap_name);
     indent_down();
   }
+
 }
 
 /**
@@ -1548,7 +1590,8 @@ void t_javame_generator::generate_generic_field_getters_setters(std::ofstream& o
  *
  * @param tstruct The struct definition
  */
-void t_javame_generator::generate_java_bean_boilerplate(ofstream& out, t_struct* tstruct) {
+void t_javame_generator::generate_java_bean_boilerplate(ofstream& out,
+                                                      t_struct* tstruct) {
   const vector<t_field*>& fields = tstruct->get_members();
   vector<t_field*>::const_iterator f_iter;
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
@@ -1563,8 +1606,8 @@ void t_javame_generator::generate_java_bean_boilerplate(ofstream& out, t_struct*
       out << get_cap_name("size() {") << endl;
 
       indent_up();
-      indent(out) << "return (this." << field_name << " == null) ? 0 : "
-                  << "this." << field_name << ".size();" << endl;
+      indent(out) << "return (this." << field_name << " == null) ? 0 : " <<
+        "this." << field_name << ".size();" << endl;
       indent_down();
       indent(out) << "}" << endl << endl;
     }
@@ -1583,8 +1626,8 @@ void t_javame_generator::generate_java_bean_boilerplate(ofstream& out, t_struct*
       out << get_cap_name("Enumeration() {") << endl;
 
       indent_up();
-      indent(out) << "return (this." << field_name << " == null) ? null : "
-                  << "this." << field_name << ".elements();" << endl;
+      indent(out) << "return (this." << field_name << " == null) ? null : " <<
+        "this." << field_name << ".elements();" << endl;
       indent_down();
       indent(out) << "}" << endl << endl;
 
@@ -1596,16 +1639,17 @@ void t_javame_generator::generate_java_bean_boilerplate(ofstream& out, t_struct*
       indent_up();
       indent(out) << "if (this." << field_name << " == null) {" << endl;
       indent_up();
-      indent(out) << "this." << field_name << " = new " << type_name(type, false, true) << "();"
-                  << endl;
+      indent(out) << "this." << field_name << " = new " << type_name(type, false, true) <<
+        "();" << endl;
       indent_down();
       indent(out) << "}" << endl;
       if (type->is_set()) {
-        indent(out) << "this." << field_name << ".put(" << box_type(element_type, "elem") << ", "
-                    << box_type(element_type, "elem") << ");" << endl;
+	indent(out) << "this." << field_name << ".put(" <<
+	  box_type(element_type, "elem") << ", " <<
+	  box_type(element_type, "elem") << ");" << endl;
       } else {
-        indent(out) << "this." << field_name << ".addElement(" << box_type(element_type, "elem")
-                    << ");" << endl;
+	indent(out) << "this." << field_name << ".addElement(" <<
+	  box_type(element_type, "elem") << ");" << endl;
       }
       indent_down();
       indent(out) << "}" << endl << endl;
@@ -1616,14 +1660,15 @@ void t_javame_generator::generate_java_bean_boilerplate(ofstream& out, t_struct*
       t_type* val_type = ((t_map*)type)->get_val_type();
 
       indent(out);
-      out << "public void putTo" << cap_name << "(" << type_name(key_type, true) << " key, "
-          << type_name(val_type, true) << " val) {" << endl;
+      out << "public void putTo"
+	  << cap_name << "(" << type_name(key_type, true) << " key, "
+	  << type_name(val_type, true) << " val) {" << endl;
 
       indent_up();
       indent(out) << "if (this." << field_name << " == null) {" << endl;
       indent_up();
-      indent(out) << "this." << field_name << " = new " << type_name(type, false, true) << "();"
-                  << endl;
+      indent(out) << "this." << field_name << " = new " <<
+        type_name(type, false, true) << "();" << endl;
       indent_down();
       indent(out) << "}" << endl;
       indent(out) << "this." << field_name << ".put(key, val);" << endl;
@@ -1634,7 +1679,8 @@ void t_javame_generator::generate_java_bean_boilerplate(ofstream& out, t_struct*
     // Simple getter
     generate_java_doc(out, field);
     indent(out) << "public " << type_name(type);
-    if (type->is_base_type() && ((t_base_type*)type)->get_base() == t_base_type::TYPE_BOOL) {
+    if (type->is_base_type() &&
+        ((t_base_type*)type)->get_base() == t_base_type::TYPE_BOOL) {
       out << " is";
     } else {
       out << " get";
@@ -1651,7 +1697,8 @@ void t_javame_generator::generate_java_bean_boilerplate(ofstream& out, t_struct*
     out << "void";
     out << " set" << cap_name << "(" << type_name(type) << " " << field_name << ") {" << endl;
     indent_up();
-    indent(out) << "this." << field_name << " = " << field_name << ";" << endl;
+    indent(out) << "this." << field_name << " = " << field_name << ";" <<
+      endl;
     generate_isset_set(out, field);
 
     indent_down();
@@ -1669,8 +1716,7 @@ void t_javame_generator::generate_java_bean_boilerplate(ofstream& out, t_struct*
     indent(out) << "}" << endl << endl;
 
     // isSet method
-    indent(out) << "/** Returns true if field " << field_name
-                << " is set (has been assigned a value) and false otherwise */" << endl;
+    indent(out) << "/** Returns true if field " << field_name << " is set (has been assigned a value) and false otherwise */" << endl;
     indent(out) << "public boolean is" << get_cap_name("set") << cap_name << "() {" << endl;
     indent_up();
     if (type_can_be_null(type)) {
@@ -1681,8 +1727,7 @@ void t_javame_generator::generate_java_bean_boilerplate(ofstream& out, t_struct*
     indent_down();
     indent(out) << "}" << endl << endl;
 
-    indent(out) << "public void set" << cap_name << get_cap_name("isSet") << "(boolean value) {"
-                << endl;
+    indent(out) << "public void set" << cap_name << get_cap_name("isSet") << "(boolean value) {" << endl;
     indent_up();
     if (type_can_be_null(type)) {
       indent(out) << "if (!value) {" << endl;
@@ -1701,12 +1746,13 @@ void t_javame_generator::generate_java_bean_boilerplate(ofstream& out, t_struct*
  *
  * @param tstruct The struct definition
  */
-void t_javame_generator::generate_java_struct_tostring(ofstream& out, t_struct* tstruct) {
+void t_javame_generator::generate_java_struct_tostring(ofstream& out,
+                                                     t_struct* tstruct) {
   out << indent() << "public String toString() {" << endl;
   indent_up();
 
-  out << indent() << "StringBuffer sb = new StringBuffer(\"" << tstruct->get_name() << "(\");"
-      << endl;
+  out <<
+    indent() << "StringBuffer sb = new StringBuffer(\"" << tstruct->get_name() << "(\");" << endl;
   out << indent() << "boolean first = true;" << endl << endl;
 
   const vector<t_field*>& fields = tstruct->get_members();
@@ -1714,7 +1760,7 @@ void t_javame_generator::generate_java_struct_tostring(ofstream& out, t_struct*
   bool first = true;
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     bool could_be_unset = (*f_iter)->get_req() == t_field::T_OPTIONAL;
-    if (could_be_unset) {
+    if(could_be_unset) {
       indent(out) << "if (" << generate_isset_check(*f_iter) << ") {" << endl;
       indent_up();
     }
@@ -1745,16 +1791,19 @@ void t_javame_generator::generate_java_struct_tostring(ofstream& out, t_struct*
     }
     indent(out) << "first = false;" << endl;
 
-    if (could_be_unset) {
+    if(could_be_unset) {
       indent_down();
       indent(out) << "}" << endl;
     }
     first = false;
   }
-  out << indent() << "sb.append(\")\");" << endl << indent() << "return sb.toString();" << endl;
+  out <<
+    indent() << "sb.append(\")\");" << endl <<
+    indent() << "return sb.toString();" << endl;
 
   indent_down();
-  indent(out) << "}" << endl << endl;
+  indent(out) << "}" << endl <<
+    endl;
 }
 
 /**
@@ -1762,7 +1811,7 @@ void t_javame_generator::generate_java_struct_tostring(ofstream& out, t_struct*
  * (e.g. for the type struct it returns "TType.STRUCT")
  */
 std::string t_javame_generator::get_java_type_string(t_type* type) {
-  if (type->is_list()) {
+  if (type->is_list()){
     return "TType.LIST";
   } else if (type->is_map()) {
     return "TType.MAP";
@@ -1776,58 +1825,37 @@ std::string t_javame_generator::get_java_type_string(t_type* type) {
     return get_java_type_string(((t_typedef*)type)->get_type());
   } else if (type->is_base_type()) {
     switch (((t_base_type*)type)->get_base()) {
-    case t_base_type::TYPE_VOID:
-      return "TType.VOID";
-      break;
-    case t_base_type::TYPE_STRING:
-      return "TType.STRING";
-      break;
-    case t_base_type::TYPE_BOOL:
-      return "TType.BOOL";
-      break;
-    case t_base_type::TYPE_BYTE:
-      return "TType.BYTE";
-      break;
-    case t_base_type::TYPE_I16:
-      return "TType.I16";
-      break;
-    case t_base_type::TYPE_I32:
-      return "TType.I32";
-      break;
-    case t_base_type::TYPE_I64:
-      return "TType.I64";
-      break;
-    case t_base_type::TYPE_DOUBLE:
-      return "TType.DOUBLE";
-      break;
-    default:
-      throw std::runtime_error("Unknown thrift type \"" + type->get_name()
-                               + "\" passed to t_javame_generator::get_java_type_string!");
-      break; // This should never happen!
+      case t_base_type::TYPE_VOID   : return      "TType.VOID"; break;
+      case t_base_type::TYPE_STRING : return    "TType.STRING"; break;
+      case t_base_type::TYPE_BOOL   : return      "TType.BOOL"; break;
+      case t_base_type::TYPE_BYTE   : return      "TType.BYTE"; break;
+      case t_base_type::TYPE_I16    : return       "TType.I16"; break;
+      case t_base_type::TYPE_I32    : return       "TType.I32"; break;
+      case t_base_type::TYPE_I64    : return       "TType.I64"; break;
+      case t_base_type::TYPE_DOUBLE : return    "TType.DOUBLE"; break;
+      default : throw std::runtime_error("Unknown thrift type \"" + type->get_name() + "\" passed to t_javame_generator::get_java_type_string!"); break; // This should never happen!
     }
   } else {
-    throw std::runtime_error(
-        "Unknown thrift type \"" + type->get_name()
-        + "\" passed to t_javame_generator::get_java_type_string!"); // This should never happen!
+    throw std::runtime_error("Unknown thrift type \"" + type->get_name() + "\" passed to t_javame_generator::get_java_type_string!"); // This should never happen!
   }
 }
 
-void t_javame_generator::generate_field_value_meta_data(std::ofstream& out, t_type* type) {
+void t_javame_generator::generate_field_value_meta_data(std::ofstream& out, t_type* type){
   out << endl;
   indent_up();
   indent_up();
-  if (type->is_struct()) {
+  if (type->is_struct()){
     indent(out) << "new StructMetaData(TType.STRUCT, " << type_name(type) << ".class";
-  } else if (type->is_container()) {
-    if (type->is_list()) {
+  } else if (type->is_container()){
+    if (type->is_list()){
       indent(out) << "new ListMetaData(TType.LIST, ";
       t_type* elem_type = ((t_list*)type)->get_elem_type();
       generate_field_value_meta_data(out, elem_type);
-    } else if (type->is_set()) {
+    } else if (type->is_set()){
       indent(out) << "new SetMetaData(TType.SET, ";
       t_type* elem_type = ((t_list*)type)->get_elem_type();
       generate_field_value_meta_data(out, elem_type);
-    } else { // map
+    } else{ // map
       indent(out) << "new MapMetaData(TType.MAP, ";
       t_type* key_type = ((t_map*)type)->get_key_type();
       t_type* val_type = ((t_map*)type)->get_val_type();
@@ -1848,6 +1876,7 @@ void t_javame_generator::generate_field_value_meta_data(std::ofstream& out, t_ty
   indent_down();
 }
 
+
 /**
  * Generates a thrift service. In C++, this comprises an entirely separate
  * header and source file. The header file defines the methods and includes
@@ -1858,12 +1887,18 @@ void t_javame_generator::generate_field_value_meta_data(std::ofstream& out, t_ty
  */
 void t_javame_generator::generate_service(t_service* tservice) {
   // Make output file
-  string f_service_name = package_dir_ + "/" + service_name_ + ".java";
+  string f_service_name = package_dir_+"/"+service_name_+".java";
   f_service_.open(f_service_name.c_str());
 
-  f_service_ << autogen_comment() << java_package() << java_type_imports() << java_thrift_imports();
+  f_service_ <<
+    autogen_comment() <<
+    java_package() <<
+    java_type_imports() <<
+    java_thrift_imports();
 
-  f_service_ << "public class " << service_name_ << " {" << endl << endl;
+  f_service_ <<
+    "public class " << service_name_ << " {" << endl <<
+    endl;
   indent_up();
 
   // Generate the three main parts of the service
@@ -1873,7 +1908,8 @@ void t_javame_generator::generate_service(t_service* tservice) {
   generate_service_helpers(tservice);
 
   indent_down();
-  f_service_ << "}" << endl;
+  f_service_ <<
+    "}" << endl;
   f_service_.close();
 }
 
@@ -1883,8 +1919,8 @@ void t_javame_generator::generate_service(t_service* tservice) {
  * @param tservice The service to generate a header definition for
  */
 void t_javame_generator::generate_primitive_service_interface(t_service* tservice) {
-  f_service_ << indent() << "public interface Iface extends " << service_name_ << "Iface { }"
-             << endl << endl;
+  f_service_ << indent() << "public interface Iface extends " <<
+    service_name_ << "Iface { }" << endl << endl;
 
   string f_interface_name = package_dir_ + "/" + service_name_ + "Iface.java";
   std::ofstream f_iface;
@@ -1895,10 +1931,14 @@ void t_javame_generator::generate_primitive_service_interface(t_service* tservic
     extends_iface = " extends " + type_name(tservice->get_extends()) + "Iface";
   }
 
-  f_iface << autogen_comment() << java_package() << java_type_imports() << java_thrift_imports();
+  f_iface <<
+    autogen_comment() <<
+    java_package() <<
+    java_type_imports() <<
+    java_thrift_imports();
   generate_java_doc(f_iface, tservice);
-  f_iface << "public interface " << service_name_ << "Iface" << extends_iface << " {" << endl
-          << endl;
+  f_iface <<
+    "public interface " << service_name_ << "Iface" << extends_iface << " {" << endl << endl;
   vector<t_function*> functions = tservice->get_functions();
   vector<t_function*>::iterator f_iter;
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
@@ -1922,7 +1962,8 @@ void t_javame_generator::generate_service_interface(t_service* tservice) {
   }
 
   generate_java_doc(f_service_, tservice);
-  f_service_ << indent() << "public interface Iface" << extends_iface << " {" << endl << endl;
+  f_service_ << indent() << "public interface Iface" << extends_iface <<
+    " {" << endl << endl;
   indent_up();
   vector<t_function*> functions = tservice->get_functions();
   vector<t_function*>::iterator f_iter;
@@ -1962,42 +2003,56 @@ void t_javame_generator::generate_service_client(t_service* tservice) {
     extends_client = " extends " + extends + ".Client";
   }
 
-  indent(f_service_) << "public static class Client" << extends_client
-                     << " implements TServiceClient, Iface {" << endl;
+  indent(f_service_) <<
+    "public static class Client" << extends_client << " implements TServiceClient, Iface {" << endl;
   indent_up();
 
-  indent(f_service_) << "public Client(TProtocol prot)" << endl;
+  indent(f_service_) <<
+    "public Client(TProtocol prot)" << endl;
   scope_up(f_service_);
-  indent(f_service_) << "this(prot, prot);" << endl;
+  indent(f_service_) <<
+    "this(prot, prot);" << endl;
   scope_down(f_service_);
   f_service_ << endl;
 
-  indent(f_service_) << "public Client(TProtocol iprot, TProtocol oprot)" << endl;
+  indent(f_service_) <<
+    "public Client(TProtocol iprot, TProtocol oprot)" << endl;
   scope_up(f_service_);
   if (extends.empty()) {
-    f_service_ << indent() << "iprot_ = iprot;" << endl << indent() << "oprot_ = oprot;" << endl;
+    f_service_ <<
+      indent() << "iprot_ = iprot;" << endl <<
+      indent() << "oprot_ = oprot;" << endl;
   } else {
-    f_service_ << indent() << "super(iprot, oprot);" << endl;
+    f_service_ <<
+      indent() << "super(iprot, oprot);" << endl;
   }
   scope_down(f_service_);
   f_service_ << endl;
 
   if (extends.empty()) {
-    f_service_ << indent() << "protected TProtocol iprot_;" << endl << indent()
-               << "protected TProtocol oprot_;" << endl << endl << indent()
-               << "protected int seqid_;" << endl << endl;
-
-    indent(f_service_) << "public TProtocol getInputProtocol()" << endl;
+    f_service_ <<
+      indent() << "protected TProtocol iprot_;"  << endl <<
+      indent() << "protected TProtocol oprot_;"  << endl <<
+      endl <<
+      indent() << "protected int seqid_;" << endl <<
+      endl;
+
+    indent(f_service_) <<
+      "public TProtocol getInputProtocol()" << endl;
     scope_up(f_service_);
-    indent(f_service_) << "return this.iprot_;" << endl;
+    indent(f_service_) <<
+      "return this.iprot_;" << endl;
     scope_down(f_service_);
     f_service_ << endl;
 
-    indent(f_service_) << "public TProtocol getOutputProtocol()" << endl;
+    indent(f_service_) <<
+      "public TProtocol getOutputProtocol()" << endl;
     scope_up(f_service_);
-    indent(f_service_) << "return this.oprot_;" << endl;
+    indent(f_service_) <<
+      "return this.oprot_;" << endl;
     scope_down(f_service_);
     f_service_ << endl;
+
   }
 
   // Generate client method implementations
@@ -2007,9 +2062,11 @@ void t_javame_generator::generate_service_client(t_service* tservice) {
     string funname = (*f_iter)->get_name();
 
     // Open function
-    indent(f_service_) << "public " << function_signature(*f_iter) << endl;
+    indent(f_service_) <<
+      "public " << function_signature(*f_iter) << endl;
     scope_up(f_service_);
-    indent(f_service_) << "send_" << funname << "(";
+    indent(f_service_) <<
+      "send_" << funname << "(";
 
     // Get the struct of function call params
     t_struct* arg_struct = (*f_iter)->get_arglist();
@@ -2033,7 +2090,8 @@ void t_javame_generator::generate_service_client(t_service* tservice) {
       if (!(*f_iter)->get_returntype()->is_void()) {
         f_service_ << "return ";
       }
-      f_service_ << "recv_" << funname << "();" << endl;
+      f_service_ <<
+        "recv_" << funname << "();" << endl;
     }
     scope_down(f_service_);
     f_service_ << endl;
@@ -2045,23 +2103,26 @@ void t_javame_generator::generate_service_client(t_service* tservice) {
     string argsname = (*f_iter)->get_name() + "_args";
 
     // Open function
-    indent(f_service_) << "public " << function_signature(&send_function) << endl;
+    indent(f_service_) <<
+      "public " << function_signature(&send_function) << endl;
     scope_up(f_service_);
 
     // Serialize the request
-    f_service_ << indent() << "oprot_.writeMessageBegin(new TMessage(\"" << funname << "\", "
-               << ((*f_iter)->is_oneway() ? "TMessageType.ONEWAY" : "TMessageType.CALL")
-               << ", ++seqid_));" << endl << indent() << argsname << " args = new " << argsname
-               << "();" << endl;
+    f_service_ <<
+      indent() << "oprot_.writeMessageBegin(new TMessage(\"" << funname << "\", " <<
+      ((*f_iter)->is_oneway() ? "TMessageType.ONEWAY" : "TMessageType.CALL") <<
+      ", ++seqid_));" << endl <<
+      indent() << argsname << " args = new " << argsname << "();" << endl;
 
     for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
-      f_service_ << indent() << "args.set" << get_cap_name((*fld_iter)->get_name()) << "("
-                 << (*fld_iter)->get_name() << ");" << endl;
+      f_service_ <<
+        indent() << "args.set" << get_cap_name((*fld_iter)->get_name()) << "(" << (*fld_iter)->get_name() << ");" << endl;
     }
 
-    f_service_ << indent() << "args.write(oprot_);" << endl << indent()
-               << "oprot_.writeMessageEnd();" << endl << indent()
-               << "oprot_.getTransport().flush();" << endl;
+    f_service_ <<
+      indent() << "args.write(oprot_);" << endl <<
+      indent() << "oprot_.writeMessageEnd();" << endl <<
+      indent() << "oprot_.getTransport().flush();" << endl;
 
     scope_down(f_service_);
     f_service_ << endl;
@@ -2075,43 +2136,49 @@ void t_javame_generator::generate_service_client(t_service* tservice) {
                                &noargs,
                                (*f_iter)->get_xceptions());
       // Open function
-      indent(f_service_) << "public " << function_signature(&recv_function) << endl;
+      indent(f_service_) <<
+        "public " << function_signature(&recv_function) << endl;
       scope_up(f_service_);
 
-      f_service_ << indent() << "TMessage msg = iprot_.readMessageBegin();" << endl << indent()
-                 << "if (msg.type == TMessageType.EXCEPTION) {" << endl << indent()
-                 << "  TApplicationException x = TApplicationException.read(iprot_);" << endl
-                 << indent() << "  iprot_.readMessageEnd();" << endl << indent() << "  throw x;"
-                 << endl << indent() << "}" << endl << indent() << "if (msg.seqid != seqid_) {"
-                 << endl << indent()
-                 << "  throw new TApplicationException(TApplicationException.BAD_SEQUENCE_ID, \""
-                 << (*f_iter)->get_name() << " failed: out of sequence response\");" << endl
-                 << indent() << "}" << endl << indent() << resultname << " result = new "
-                 << resultname << "();" << endl << indent() << "result.read(iprot_);" << endl
-                 << indent() << "iprot_.readMessageEnd();" << endl;
+      f_service_ <<
+        indent() << "TMessage msg = iprot_.readMessageBegin();" << endl <<
+        indent() << "if (msg.type == TMessageType.EXCEPTION) {" << endl <<
+        indent() << "  TApplicationException x = TApplicationException.read(iprot_);" << endl <<
+        indent() << "  iprot_.readMessageEnd();" << endl <<
+        indent() << "  throw x;" << endl <<
+        indent() << "}" << endl <<
+        indent() << "if (msg.seqid != seqid_) {" << endl <<
+        indent() << "  throw new TApplicationException(TApplicationException.BAD_SEQUENCE_ID, \"" << (*f_iter)->get_name() << " failed: out of sequence response\");" << endl <<
+        indent() << "}" << endl <<
+        indent() << resultname << " result = new " << resultname << "();" << endl <<
+        indent() << "result.read(iprot_);" << endl <<
+        indent() << "iprot_.readMessageEnd();" << endl;
 
       // Careful, only return _result if not a void function
       if (!(*f_iter)->get_returntype()->is_void()) {
-        f_service_ << indent() << "if (result." << generate_isset_check("success") << ") {" << endl
-                   << indent() << "  return result.success;" << endl << indent() << "}" << endl;
+        f_service_ <<
+          indent() << "if (result." << generate_isset_check("success") << ") {" << endl <<
+          indent() << "  return result.success;" << endl <<
+          indent() << "}" << endl;
       }
 
       t_struct* xs = (*f_iter)->get_xceptions();
       const std::vector<t_field*>& xceptions = xs->get_members();
       vector<t_field*>::const_iterator x_iter;
       for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
-        f_service_ << indent() << "if (result." << (*x_iter)->get_name() << " != null) {" << endl
-                   << indent() << "  throw result." << (*x_iter)->get_name() << ";" << endl
-                   << indent() << "}" << endl;
+        f_service_ <<
+          indent() << "if (result." << (*x_iter)->get_name() << " != null) {" << endl <<
+          indent() << "  throw result." << (*x_iter)->get_name() << ";" << endl <<
+          indent() << "}" << endl;
       }
 
       // If you get here it's an exception, unless a void function
       if ((*f_iter)->get_returntype()->is_void()) {
-        indent(f_service_) << "return;" << endl;
+        indent(f_service_) <<
+          "return;" << endl;
       } else {
-        f_service_ << indent()
-                   << "throw new TApplicationException(TApplicationException.MISSING_RESULT, \""
-                   << (*f_iter)->get_name() << " failed: unknown result\");" << endl;
+        f_service_ <<
+          indent() << "throw new TApplicationException(TApplicationException.MISSING_RESULT, \"" << (*f_iter)->get_name() << " failed: unknown result\");" << endl;
       }
 
       // Close function
@@ -2121,7 +2188,8 @@ void t_javame_generator::generate_service_client(t_service* tservice) {
   }
 
   indent_down();
-  indent(f_service_) << "}" << endl;
+  indent(f_service_) <<
+    "}" << endl;
 }
 
 /**
@@ -2143,64 +2211,72 @@ void t_javame_generator::generate_service_server(t_service* tservice) {
   }
 
   // Generate the header portion
-  indent(f_service_) << "public static class Processor" << extends_processor
-                     << " implements TProcessor {" << endl;
+  indent(f_service_) <<
+    "public static class Processor" << extends_processor << " implements TProcessor {" << endl;
   indent_up();
 
-  indent(f_service_) << "public Processor(Iface iface)" << endl;
+  indent(f_service_) <<
+    "public Processor(Iface iface)" << endl;
   scope_up(f_service_);
   if (!extends.empty()) {
-    f_service_ << indent() << "super(iface);" << endl;
+    f_service_ <<
+      indent() << "super(iface);" << endl;
   }
-  f_service_ << indent() << "iface_ = iface;" << endl;
+  f_service_ <<
+    indent() << "iface_ = iface;" << endl;
 
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
-    f_service_ << indent() << "processMap_.put(\"" << (*f_iter)->get_name() << "\", new "
-               << (*f_iter)->get_name() << "());" << endl;
+    f_service_ <<
+      indent() << "processMap_.put(\"" << (*f_iter)->get_name() << "\", new " << (*f_iter)->get_name() << "());" << endl;
   }
 
   scope_down(f_service_);
   f_service_ << endl;
 
   if (extends.empty()) {
-    f_service_
-        << indent() << "protected static interface ProcessFunction {" << endl << indent()
-        << "  public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException;"
-        << endl << indent() << "}" << endl << endl;
+    f_service_ <<
+      indent() << "protected static interface ProcessFunction {" << endl <<
+      indent() << "  public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException;" << endl <<
+      indent() << "}" << endl <<
+      endl;
   }
 
-  f_service_ << indent() << "private Iface iface_;" << endl;
+  f_service_ <<
+    indent() << "private Iface iface_;" << endl;
 
   if (extends.empty()) {
-    f_service_ << indent() << "protected final Hashtable processMap_ = new Hashtable();" << endl;
+    f_service_ <<
+      indent() << "protected final Hashtable processMap_ = new Hashtable();" << endl;
   }
 
   f_service_ << endl;
 
   // Generate the server implementation
-  indent(f_service_) << "public boolean process(TProtocol iprot, TProtocol oprot) throws TException"
-                     << endl;
+  indent(f_service_) <<
+    "public boolean process(TProtocol iprot, TProtocol oprot) throws TException" << endl;
   scope_up(f_service_);
 
-  f_service_ << indent() << "TMessage msg = iprot.readMessageBegin();" << endl;
+  f_service_ <<
+    indent() << "TMessage msg = iprot.readMessageBegin();" << endl;
 
   // TODO(mcslee): validate message, was the seqid etc. legit?
 
-  f_service_
-      << indent() << "ProcessFunction fn = (ProcessFunction)processMap_.get(msg.name);" << endl
-      << indent() << "if (fn == null) {" << endl << indent()
-      << "  TProtocolUtil.skip(iprot, TType.STRUCT);" << endl << indent()
-      << "  iprot.readMessageEnd();" << endl << indent()
-      << "  TApplicationException x = new "
-         "TApplicationException(TApplicationException.UNKNOWN_METHOD, \"Invalid method name: "
-         "'\"+msg.name+\"'\");" << endl << indent()
-      << "  oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));"
-      << endl << indent() << "  x.write(oprot);" << endl << indent() << "  oprot.writeMessageEnd();"
-      << endl << indent() << "  oprot.getTransport().flush();" << endl << indent()
-      << "  return true;" << endl << indent() << "}" << endl << indent()
-      << "fn.process(msg.seqid, iprot, oprot);" << endl;
-
-  f_service_ << indent() << "return true;" << endl;
+  f_service_ <<
+    indent() << "ProcessFunction fn = (ProcessFunction)processMap_.get(msg.name);" << endl <<
+    indent() << "if (fn == null) {" << endl <<
+    indent() << "  TProtocolUtil.skip(iprot, TType.STRUCT);" << endl <<
+    indent() << "  iprot.readMessageEnd();" << endl <<
+    indent() << "  TApplicationException x = new TApplicationException(TApplicationException.UNKNOWN_METHOD, \"Invalid method name: '\"+msg.name+\"'\");" << endl <<
+    indent() << "  oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));" << endl <<
+    indent() << "  x.write(oprot);" << endl <<
+    indent() << "  oprot.writeMessageEnd();" << endl <<
+    indent() << "  oprot.getTransport().flush();" << endl <<
+    indent() << "  return true;" << endl <<
+    indent() << "}" << endl <<
+    indent() << "fn.process(msg.seqid, iprot, oprot);" << endl;
+
+  f_service_ <<
+    indent() << "return true;" << endl;
 
   scope_down(f_service_);
   f_service_ << endl;
@@ -2211,7 +2287,9 @@ void t_javame_generator::generate_service_server(t_service* tservice) {
   }
 
   indent_down();
-  indent(f_service_) << "}" << endl << endl;
+  indent(f_service_) <<
+    "}" << endl <<
+    endl;
 }
 
 /**
@@ -2245,40 +2323,44 @@ void t_javame_generator::generate_function_helpers(t_function* tfunction) {
  *
  * @param tfunction The function to write a dispatcher for
  */
-void t_javame_generator::generate_process_function(t_service* tservice, t_function* tfunction) {
-  (void)tservice;
+void t_javame_generator::generate_process_function(t_service* tservice,
+                                                 t_function* tfunction) {
+  (void) tservice;
   // Open class
-  indent(f_service_) << "private class " << tfunction->get_name() << " implements ProcessFunction {"
-                     << endl;
+  indent(f_service_) <<
+    "private class " << tfunction->get_name() << " implements ProcessFunction {" << endl;
   indent_up();
 
   // Open function
-  indent(f_service_)
-      << "public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException"
-      << endl;
+  indent(f_service_) <<
+    "public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException" << endl;
   scope_up(f_service_);
 
   string argsname = tfunction->get_name() + "_args";
   string resultname = tfunction->get_name() + "_result";
 
-  f_service_ << indent() << argsname << " args = new " << argsname << "();" << endl << indent()
-             << "try {" << endl;
+  f_service_ <<
+    indent() << argsname << " args = new " << argsname << "();" << endl <<
+    indent() << "try {" << endl;
   indent_up();
-  f_service_ << indent() << "args.read(iprot);" << endl;
+  f_service_ <<
+    indent() << "args.read(iprot);" << endl;
   indent_down();
-  f_service_ << indent() << "} catch (TProtocolException e) {" << endl;
+  f_service_ <<
+    indent() << "} catch (TProtocolException e) {" << endl;
   indent_up();
-  f_service_ << indent() << "iprot.readMessageEnd();" << endl << indent()
-             << "TApplicationException x = new "
-                "TApplicationException(TApplicationException.PROTOCOL_ERROR, e.getMessage());"
-             << endl << indent() << "oprot.writeMessageBegin(new TMessage(\""
-             << tfunction->get_name() << "\", TMessageType.EXCEPTION, seqid));" << endl << indent()
-             << "x.write(oprot);" << endl << indent() << "oprot.writeMessageEnd();" << endl
-             << indent() << "oprot.getTransport().flush();" << endl << indent() << "return;"
-             << endl;
+  f_service_ <<
+    indent() << "iprot.readMessageEnd();" << endl <<
+    indent() << "TApplicationException x = new TApplicationException(TApplicationException.PROTOCOL_ERROR, e.getMessage());" << endl <<
+    indent() << "oprot.writeMessageBegin(new TMessage(\"" << tfunction->get_name() << "\", TMessageType.EXCEPTION, seqid));" << endl <<
+    indent() << "x.write(oprot);" << endl <<
+    indent() << "oprot.writeMessageEnd();" << endl <<
+    indent() << "oprot.getTransport().

<TRUNCATED>