def import_android_parameter(cur, session): android_parameter_data = read_parameter_data(cur) for each in android_parameter_data: # print(each) method_id = each[0] method_name = each[1] qualified_type_list = get_qualified_type_list(method_id, method_name, cur) full_declaration = each[2] simple_parameter_list = get_simple_parameter_list(full_declaration) if qualified_type_list is not None and simple_parameter_list is not None and len(qualified_type_list) == len(simple_parameter_list): for i in range(0, len(qualified_type_list)): parameter_var = simple_parameter_list[i].split(" ")[-1] qualified_type_list[i] += (" " + parameter_var) qualified_type_list[i] = qualified_type_list[i].replace("[]", "").replace("...", "").strip() simple_parameter_list[i] = simple_parameter_list[i].replace("[]", "").replace("...", "").strip() if qualified_type_list[i] != "" and simple_parameter_list[i] != "": print(qualified_type_list[i]) print(simple_parameter_list[i]) api_entity = APIEntity(qualified_type_list[i], APIEntity.API_TYPE_PARAMETER, simple_parameter_list[i]) api_entity.find_or_create(session, autocommit=False) session.commit()
def import_android_exception_condition(cur, session): exception_data = read_android_exception_data(cur) for each in exception_data: exception_name = each[0] exception_text = each[1].replace("\n", '').replace( " ", '').replace(" ", '').replace(" ", '').replace(" ", '') exception_url = each[2] qualified_name_list = exception_url.replace( "https://developer.android.google.cn/reference/", '').replace(".html", "").split("/") qualified_name = "" for i in range(0, len(qualified_name_list)): if i == 0: qualified_name += qualified_name_list[i] else: qualified_name += ("." + qualified_name_list[i]) qualified_name += " (E)" print(qualified_name) api_entity = APIEntity(qualified_name, APIEntity.API_TYPE_EXCEPTION_CONDITION, exception_name, exception_text) api_entity.find_or_create(session, autocommit=False) session.commit()
"description": "float is a keyword which designates the 32 bit float primitive type. The java.lang.Float class is the nominal wrapper class when you need to store a float value but an object reference is required." }, { "name": "double", "description": "double is a keyword which designates the 64 bit float primitive type. The java.lang.Double class is the nominal wrapper class when you need to store a double value but an object reference is required." }, { "name": "boolean", "description": "boolean is a keyword which designates the boolean primitive type. There are only two possible boolean values: true and false. The default value for boolean fields is false." }, { "name": "void", "description": "void is a Java keyword. Used at method declaration and definition to specify that the method does not return any type, the method returns void. It is not a type and there is no void references/pointers as in C/C++." }, ] session = EngineFactory.create_session() for item in type_list: api_entity = APIEntity(qualified_name=item["name"], api_type=APIEntity.API_TYPE_PRIMARY_TYPE, short_description=item["description"]) print(api_entity) api_entity.find_or_create(session=session) print(api_entity)