/** * Creates the. * * @param reader the reader * @param debug the debug * @param path the path * @return the map * @throws IOException Signals that an I/O exception has occurred. */ public static Map<String, IDLProxyObject> create(Reader reader, boolean debug, File path) throws IOException { return create(reader, debug, path, true); }
/** * Creates the single. * * @param reader the reader * @return the IDL proxy object * @throws IOException Signals that an I/O exception has occurred. */ public static IDLProxyObject createSingle(Reader reader) throws IOException { return createSingle(reader, false); }
/** * Generate source. * * @param file the file * @param sourceOutputPath the source output path * @param cds the cds * @param compiledClass the compiled class * @throws IOException Signals that an I/O exception has occurred. */ public static void generateSource(File file, File sourceOutputPath, List<CodeDependent> cds, Set<String> compiledClass) throws IOException { doCreatePro(file, true, false, null, true, sourceOutputPath, cds, compiledClass, false); }
String simpleName = getProxyClassName(defaultClsName, uniMappedName, isUniName); List<Type> nestedTypes = fetchAllNestedTypes(type, true); List<Type> checkNestedTypes = new ArrayList<Type>(nestedTypes); for (Field field : fields) { generateProtobufDefinedForField(code, field, enumNames); if (fType == null) { String jType = field.getType(); javaType = getProxyClassName(jType, packages, uniMappedName, isUniName); if (!isNestedTypeDependency(field.getType(), checkNestedTypes)) { cd.addDependency(javaType); fqname = StringUtils.removeStart(t.getFullyQualifiedName(), packageName + PACKAGE_SPLIT_CHAR); String subClsName = getProxyClassName(fqname, uniMappedName, isUniName); nestedCd = createCodeByType((EnumType) t, false, packageName, uniMappedName, isUniName); enumNames.add(t.getName()); } else { nestedCd = createCodeByType(protoFile, (MessageType) t, enumNames, false, checkNestedTypes, cds, getPackages(cds), uniMappedName, isUniName);
Class checkClass = checkClass(protoFile, type, mappedUniName, isUniName); if (checkClass != null) { ret.add(checkClass); cd = createCodeByType(protoFile, (MessageType) mt, enumNames, true, new ArrayList<Type>(), cds, packages, mappedUniName, isUniName); while ((codeDependent = hasDependency(copiedCds, compiledClass)) != null) { if (debug) { CodePrinter.printCode(codeDependent.code, "generate jprotobuf code"); } else { writeSourceCode(codeDependent, sourceOutputDir);
/** * Do create pro. * * @param file the file * @param multi the multi * @param debug the debug * @param path the path * @param generateSouceOnly the generate souce only * @param sourceOutputDir the source output dir * @param cds the cds * @param compiledClass the compiled class * @param isUniName the is uni name * @return the map * @throws IOException Signals that an I/O exception has occurred. */ private static Map<String, IDLProxyObject> doCreatePro(File file, boolean multi, boolean debug, File path, boolean generateSouceOnly, File sourceOutputDir, List<CodeDependent> cds, Set<String> compiledClass, boolean isUniName) throws IOException { checkDirectory(generateSouceOnly, sourceOutputDir); // to find all PROTO file if using import command List<ProtoFile> protoFiles = findRelateProtoFiles(file, new HashSet<String>()); Collections.reverse(protoFiles); return doCreatePro(protoFiles, multi, debug, path, generateSouceOnly, sourceOutputDir, cds, compiledClass, new HashMap<String, String>(), isUniName); }
Class cls = checkClass(packageName, enumType, mappedUniName, isUniName); if (cls != null) { ret.add(cls); continue; CodeDependent codeDependent = createCodeByType(enumType, true, packageName, mappedUniName, isUniName); compiledClass.add(codeDependent.name); compiledClass.add(packageName + PACKAGE_SPLIT_CHAR + codeDependent.name); } else { writeSourceCode(codeDependent, sourceOutputDir);
/** * Generate source. * * @param is the is * @param sourceOutputPath the source output path * @throws IOException Signals that an I/O exception has occurred. */ public static void generateSource(InputStream is, File sourceOutputPath) throws IOException { ProtoFile protoFile = ProtoSchemaParser.parseUtf8(DEFAULT_FILE_NAME, is); List<CodeDependent> cds = new ArrayList<CodeDependent>(); doCreate(protoFile, true, false, null, true, sourceOutputPath, cds, new HashMap<String, String>(), false); }
List<Class<?>> clsList = createEnumClasses(enumTypes, packageMapping, generateSouceOnly, sourceOutputDir, compiledClass, mappedUniName, isUniName); createMessageClass(protoFile, multi, debug, generateSouceOnly, sourceOutputDir, cds, compiledClass, new HashSet<String>(enumTypes.keySet()), packages, mappedUniName, isUniName); clsList.addAll(messageClasses);
/** * Fetch all nested types. * * @param type the type * @param all the all * @return the list */ private static List<Type> fetchAllNestedTypes(MessageType type, boolean all) { List<Type> ret = new ArrayList<Type>(); List<Type> nestedTypes = type.getNestedTypes(); ret.addAll(nestedTypes); if (all) { for (Type t : nestedTypes) { if (t instanceof MessageType) { List<Type> subNestedTypes = fetchAllNestedTypes((MessageType) t, true); ret.addAll(subNestedTypes); } } } return ret; }
/** * Generate source. * * @param reader the reader * @param sourceOutputPath the source output path * @throws IOException Signals that an I/O exception has occurred. */ public static void generateSource(Reader reader, File sourceOutputPath) throws IOException { ProtoFile protoFile = ProtoSchemaParser.parse(DEFAULT_FILE_NAME, reader); List<CodeDependent> cds = new ArrayList<CodeDependent>(); doCreate(protoFile, true, false, null, true, sourceOutputPath, cds, new HashMap<String, String>(), false); }
/** * Creates the. * * @param data the data * @param debug the debug * @return the map */ public static Map<String, IDLProxyObject> create(String data, boolean debug) { return create(data, debug, null, true); }
/** * Creates the single. * * @param data the data * @param debug the debug * @return the IDL proxy object */ public static IDLProxyObject createSingle(String data, boolean debug) { return createSingle(data, debug, null, true); }
/** * Generate source. * * @param data the data * @param sourceOutputPath the source output path */ public static void generateSource(String data, File sourceOutputPath) { ProtoFile protoFile = ProtoSchemaParser.parse(DEFAULT_FILE_NAME, data); List<CodeDependent> cds = new ArrayList<CodeDependent>(); try { doCreate(protoFile, true, false, null, true, sourceOutputPath, cds, new HashMap<String, String>(), false); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } }
/** * Creates the. * * @param file the file * @param debug the debug * @param path the path * @param cds the cds * @param compiledClass the compiled class * @return the map * @throws IOException Signals that an I/O exception has occurred. */ public static Map<String, IDLProxyObject> create(File file, boolean debug, File path, List<CodeDependent> cds, Set<String> compiledClass) throws IOException { return doCreatePro(file, true, debug, path, false, null, cds, compiledClass, true); }
/** * Creates the. * * @param file the file * @param debug the debug * @param isUniName the is uni name * @return the map * @throws IOException Signals that an I/O exception has occurred. */ public static Map<String, IDLProxyObject> create(File file, boolean debug, boolean isUniName) throws IOException { return create(file, debug, null, true); }
/** * Creates the single. * * @param data the data * @param debug the debug * @param path the path * @return the IDL proxy object */ public static IDLProxyObject createSingle(String data, boolean debug, File path) { return createSingle(data, debug, path, true); }
/** * Creates the. * * @param is the is * @param debug the debug * @param path the path * @param isUniName the is uni name * @return the map * @throws IOException Signals that an I/O exception has occurred. */ public static Map<String, IDLProxyObject> create(InputStream is, boolean debug, File path, boolean isUniName) throws IOException { ProtoFile protoFile = ProtoSchemaParser.parseUtf8(DEFAULT_FILE_NAME, is); List<CodeDependent> cds = new ArrayList<CodeDependent>(); return doCreate(protoFile, true, debug, path, false, null, cds, new HashMap<String, String>(), isUniName); }
/** * Creates the. * * @param file the file * @param debug the debug * @param path the path * @param cds the cds * @param compiledClass the compiled class * @param isUniName the is uni name * @return the map * @throws IOException Signals that an I/O exception has occurred. */ public static Map<String, IDLProxyObject> create(File file, boolean debug, File path, List<CodeDependent> cds, Set<String> compiledClass, boolean isUniName) throws IOException { return doCreatePro(file, true, debug, path, false, null, cds, compiledClass, isUniName); }
/** * Creates the. * * @param is the is * @param debug the debug * @param path the path * @return the map * @throws IOException Signals that an I/O exception has occurred. */ public static Map<String, IDLProxyObject> create(InputStream is, boolean debug, File path) throws IOException { return create(is, debug, path, true); }