Initial commit of Java backend to hidl-gen.

Change-Id: I38b62637df74d3e5daf702a8996502d0d5726033
diff --git a/Type.cpp b/Type.cpp
index bec4655..1e7e2d5 100644
--- a/Type.cpp
+++ b/Type.cpp
@@ -45,6 +45,11 @@
     return std::string();
 }
 
+std::string Type::getJavaSuffix() const {
+    CHECK(!"Should not be here");
+    return std::string();
+}
+
 void Type::emitReaderWriter(
         Formatter &,
         const std::string &,
@@ -68,6 +73,20 @@
     CHECK(!"Should not be here");
 }
 
+void Type::emitJavaReaderWriter(
+        Formatter &out,
+        const std::string &parcelObj,
+        const std::string &argName,
+        bool isReader) const {
+    emitJavaReaderWriterWithSuffix(
+            out,
+            parcelObj,
+            argName,
+            isReader,
+            getJavaSuffix(),
+            "" /* extra */);
+}
+
 void Type::handleError(Formatter &out, ErrorMode mode) const {
     switch (mode) {
         case ErrorMode_Ignore:
@@ -189,6 +208,10 @@
     return OK;
 }
 
+status_t Type::emitJavaTypeDeclarations(Formatter &) const {
+    return OK;
+}
+
 bool Type::needsEmbeddedReadWrite() const {
     return false;
 }
@@ -209,5 +232,28 @@
     return getCppType(StorageMode_Argument, extra);
 }
 
+void Type::emitJavaReaderWriterWithSuffix(
+        Formatter &out,
+        const std::string &parcelObj,
+        const std::string &argName,
+        bool isReader,
+        const std::string &suffix,
+        const std::string &extra) const {
+    out << parcelObj
+        << "."
+        << (isReader ? "read" : "write")
+        << suffix
+        << "(";
+
+    if (isReader) {
+        out << extra;
+    } else {
+        out << (extra.empty() ? "" : (extra + ", "));
+        out << argName;
+    }
+
+    out << ");\n";
+}
+
 }  // namespace android