def import_android_return_value(cur, session): return_value_data = read_android_return_value_data(cur) for each in return_value_data: print(each) return_value_name = each[0] return_value_text = clean_html_text(each[1]) return_value_url = each[2] # print(return_value_name) # print(return_value_text) # print(return_value_url) qualified_name = "" if return_value_url != "": qualified_name_list = return_value_url.replace( "https://developer.android.google.cn/reference/", "").replace(".html", "").split("/") 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]) else: qualified_name = return_value_name qualified_name = qualified_name + " (R)" print(qualified_name) api_entity = APIEntity(qualified_name, APIEntity.API_TYPE_RETURN_VALUE, return_value_name, return_value_text) # print(api_entity) api_entity.find_or_create(session, autocommit=False) session.commit()
def import_jdk_return_value(cur, session): return_value_data = get_return_value_data(cur) for each in return_value_data: full_declaration = each[0] return_type = each[1] return_string = each[2] print(return_type) return_type = process_return_type_string(return_type) qualified_name = construct_qualified_name_by_full_declaration(full_declaration, return_type) if qualified_name is not None: qualified_name = qualified_name + " (R)" else: qualified_name = return_type + " (R)" return_string = clean_html_text(return_string) api_entity = APIEntity(qualified_name, APIEntity.API_TYPE_RETURN_VALUE, return_type, return_string) api_entity.find_or_create(session, autocommit=False) session.commit()
def import_jdk_exception_condition(cur, session): exception_condition_data = read_exception_condition_data(cur) for each in exception_condition_data: name = each[0] description = each[1] qualified_name = get_qualified_name_by_simple_name(name, cur) if qualified_name is not None: qualified_name = qualified_name + ' (E)' else: qualified_name = name + ' (E)' print(qualified_name) description = clean_html_text(description) api_entity = APIEntity(qualified_name, APIEntity.API_TYPE_EXCEPTION_CONDITION, name, description) api_entity.find_or_create(session, autocommit=False) session.commit()
def import_jdk_parameter(cur, session): jdk_parameter_data = read_jdk_parameter_data(cur) for each in jdk_parameter_data: print(each) name = each[0] type_class = each[1] type_string = each[2] description = each[3] qualified_class_name = get_qualified_class_name(type_class, cur) print(qualified_class_name) if qualified_class_name is not None: qualified_name = qualified_class_name[0] + " " + name else: qualified_name = type_string + " " + name full_declaration = type_string + " " + name print(qualified_name) print(full_declaration) description = clean_html_text(description) api_entity = APIEntity(qualified_name, APIEntity.API_TYPE_PARAMETER, full_declaration, description) api_entity.find_or_create(session, autocommit=False) session.commit()
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)