Internationalization information generation method, device and computer-readable storage medium

Automatically obtain and generate internationalized information through the Java reflection mechanism, which solves the problem of low efficiency of internationalized information generation in the existing technology, realizes automated processing, and improves accuracy and efficiency.

CN109814839BActive Publication Date: 2024-10-11PING AN TECH (SHENZHEN) CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN201811518473.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2018-12-12
Publication Date
2024-10-11
Estimated Expiration
2038-12-12

AI Technical Summary

Technical Problem

In the software development process, especially in the generation process of internationalized information, the existing technology relies on manual compilation, which is inefficient and prone to omissions and errors, especially when there are many request parameters.

Method used

Use the Java reflection mechanism to find the class files of the Controller layer, obtain the full path names and attribute information of the action class and request class, and write them into the properties configuration file and express them in the form of equations to reduce manual operations.

Benefits of technology

It realizes automatic generation of international information, reduces development workload, avoids omissions and errors, and improves efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN109814839B_ABST
    Figure CN109814839B_ABST
Patent Text Reader

Abstract

The present invention relates to software development, and provides a method, device and storage medium for generating internationalized information. The method comprises: searching for class files of a controller layer, wherein the class files of the controller layer include an action class and a request class; using a reflection mechanism of Java to obtain the full path name of the action class and the full path attribute of the request class, wherein the full path name of the action class is the package name where the action class is located + the class name of the action class, and the full path attribute of the request class is the full path name of the request class + the attribute name of the request class, wherein the full path name of the request class is the package name where the request class is located + the class name of the request class; and writing the obtained full path name of the action class and the full path attribute information of the request class into a properties configuration file as part of the internationalized information. The present invention can automatically generate part of the internationalized information, reduce the development workload, and avoid tedious and inefficient repeated code development work.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of software development, and in particular to an internationalization information generation method, device and computer-readable storage medium. Background Art

[0002] With the vigorous development of Internet technology and communication technology, the application forms of new generation information technology such as mobile Internet, Internet of Things, social network, digital home, e-commerce, etc. have begun to integrate into people's daily life. People are accustomed to obtaining various information, handling various businesses, and daily entertainment through applications of mobile terminal devices or fixed terminal devices. During the development process of the application, it is necessary to edit and generate international information. The Controller is responsible for business scheduling. It accepts user input and calls models and views to meet user needs. In the cloud portal, the full path class name of the Controller layer in the request authentication service will give the international information prompt of the full path class name if a tenant does not have the permission for the request. In addition, the request class, that is, the class composed of request parameters, will give the international information prompt of the field when verifying the request parameters if the verification fails.

[0003] Therefore, during the development phase, internationalization information needs to include the full path class name of the Controller layer, the full path attributes of the request class, and other information. The current method is manually compiled by developers, which is tedious and inefficient, especially when there are many request parameters, which is prone to omissions and errors. Summary of the invention

[0004] In order to solve the deficiencies in the prior art, the present invention provides an internationalization information generation method, which is applied to an electronic device to search for class files of a Controller layer, wherein the class files of the Controller layer include an action class and a request class; the full path name of the action class and the full path attribute of the request class are obtained by using the reflection mechanism of Java, wherein the full path name of the action class is the package name where the action class is located + the class name of the action class, and the full path attribute of the request class is the full path name of the request class + the attribute name of the request class, wherein the full path name of the request class is the package name where the request class is located + the class name of the request class; the obtained full path name of the action class and the full path attribute information of the request class are written into a properties configuration file as part of the internationalization information, wherein the obtained full path name of the action class and the abbreviation of the action class are written into the properties configuration file as an expression in the form of an equation, and the obtained full path attribute of the request class and the attribute name of the request class are written into the properties configuration file as an expression in the form of an equation.

[0005] Preferably, the expression of the full path name of the action class and the abbreviation of the action class is as follows:

[0006] clazz.getName()+"="clazz.getSimpleName(),

[0007] Among them, clazz.getName() obtains the full path name of the action class through the following expression:

[0008] clazz=classLoader.loadClass(packName+"."+File.getName().replace(".class","")),

[0009] packName is the package name of the action class.

[0010] File.getName() is to get the class name of the current class.

[0011] getSimpleName() gets the abbreviation of the current class.

[0012] Preferably, the expression of the full path attribute of the request class and the attribute name of the request class is as follows:

[0013] clazz.getName()+"."+f.getName()+"="f.getName(),

[0014] Among them, each attribute of the request class is taken out in turn, and combined with the full path name respectively to form each full path attribute of the request class,

[0015] Among them, clazz.getName() obtains the full path attribute of the request class through the following expression:

[0016] clazz=classLoader.loadClass(packName+"."+File.getName().replace(".class","")),

[0017] packName is the package name of the request class.

[0018] File.getName() gets the class name of the current class.

[0019] Preferably, the FileFilter() function is used for filtering so as to obtain only the class path name ending in ".class".

[0020] Preferably, if the class name does not end with ".class", the output displays "Class not found".

[0021] Preferably, before searching for the class file of the Controller layer, the following method is used to generate relevant information according to different package names:

[0022] Use classLoader.getResource() function to get the package name;

[0023] Replace the "." in the package name with " / " to convert the package name into a file path;

[0024] Obtain the transmission protocol based on which the data is transmitted, and then determine whether the current type of the packet is a file type;

[0025] If the current type is a file type, relevant information of the corresponding package name is generated.

[0026] The present invention also provides an electronic device, which includes: a memory and a processor, wherein an internationalization information generation program is stored in the memory, and when the internationalization information generation program is executed by the processor, the following steps are implemented: searching for class files of the Controller layer, wherein the class files of the Controller layer include action classes and request classes; using Java's reflection mechanism to obtain the full path name of the action class and the full path attribute information of the request class, wherein the full path name of the action class is the package name of the action class plus the class name of the action class, and the full path attribute of the request class is the full path name of the request class plus the attribute name of the request class, wherein the full path name of the request class is the package name of the request class plus the class name of the request class; writing the obtained full path name of the action class and the full path attribute information of the request class into a properties configuration file as part of the internationalization information, wherein the obtained full path name of the action class and the abbreviation of the action class are written into the properties configuration file in the form of an equation, and the obtained full path attribute of the request class and the attribute name of the request class are written into the properties configuration file in the form of an equation.

[0027] Preferably, the expression of the full path name of the action class and the abbreviation of the action class is as follows:

[0028] clazz.getName()+"="clazz.getSimpleName(),

[0029] Among them, clazz.getName() obtains the full path name of the action class through the following expression:

[0030] clazz=classLoader.loadClass(packName+"."+File.getName().replace(".class","")),

[0031] packName is the package name of the action class.

[0032] File.getName() is to get the class name of the current class.

[0033] getSimpleName() gets the abbreviation of the current class.

[0034] Preferably, the expression of the full path attribute of the request class and the attribute name of the request class is as follows:

[0035] clazz.getName()+"."+f.getName()+"="f.getName(),

[0036] Among them, each attribute of the request class is taken out in turn, and combined with the full path name respectively to form each full path attribute of the request class,

[0037] Among them, clazz.getName() obtains the full path attribute of the request class through the following expression:

[0038] clazz=classLoader.loadClass(packName+"."+File.getName().replace(".class","")),

[0039] packName is the package name of the request class.

[0040] File.getName() gets the class name of the current class.

[0041] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the internationalization information generating method as described above is implemented.

[0042] The internationalization information generation method, device and computer-readable storage medium of the present invention can automatically generate part of the internationalization information, reduce the development workload, and avoid the situation where omissions and errors are easily generated in a tedious and inefficient manner, especially when there are many request parameters. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] The above-mentioned features and technical advantages of the present invention will become clearer and easier to understand by describing its embodiments in conjunction with the following drawings.

[0044] Figure 1 is a flow chart showing a method for generating internationalized information according to an embodiment of the present invention;

[0045] Figure 2is a schematic diagram showing the hardware architecture of an electronic device according to an embodiment of the present invention;

[0046] Figure 3 It is a module structure diagram showing the internationalization information generating method according to an embodiment of the present invention. DETAILED DESCRIPTION

[0047] The following will describe embodiments of the internationalization information generation method, device, and computer-readable storage medium of the present invention with reference to the accompanying drawings. It will be appreciated by those skilled in the art that the described embodiments may be modified in various ways or combinations thereof without departing from the spirit and scope of the present invention. Therefore, the drawings and descriptions are illustrative in nature and are not intended to limit the scope of protection of the claims. In addition, in this specification, the drawings are not drawn to scale, and the same reference numerals represent the same parts.

[0048] Figure 1 is a flow chart showing a method for generating international information according to an embodiment of the present invention. The method for generating international information according to this embodiment is applied to an electronic device, such as Figure 1 As shown, the internationalization information generation method includes the following steps:

[0049] Step S10, search for the class files of the Controller layer (control layer), which include action classes (Action) and request classes (Resquest). The Controller layer is responsible for processing all requests sent by the browser and deciding what content to respond to the browser. The interface of the Serice layer (service layer) is called in the Controller layer to control the business process. However, the Controller is not responsible for deciding how the content should be displayed, but responding to the MVC (model view controller) architecture with a specific form of content. Finally, the MVC architecture decides how to respond to the browser based on the form of the response.

[0050] The Controller layer is also a class (Class), which has many methods (Method). Each method is considered an action class (Action), which can receive the request (Request) of the request class through the action class and determine the response view.

[0051] Step S30, use Java's reflection mechanism to obtain the full path name of the action class and the full path attribute information of the request class, where the full path name of the action class is the package name of the action class + the class name of the action class, and the full path attribute of the request class is the full path name of the request class + the attribute name of the request class, where the full path name of the request class is the package name of the request class + the class name of the request class.

[0052] The JAVA reflection mechanism means that in the running state, for any class, all the properties and methods of this class can be known; for any object, any of its methods and properties can be called; this function of dynamically obtaining information and dynamically calling object methods is called the reflection mechanism of the Java language.

[0053] A package in Java can be understood as a folder where classes are located. Generally, it contains related classes, and each package name is unique. For example, the package name can be a domain name on the Internet plus a name customized by the developer. Since domain names on the Internet are not repeated, the package name is also unique. For example: the domain name is cn.com.paic..., plus the customized name pacloud.elb.controller, the final package name is cn.com.paic.pacloud.elb.controller.

[0054] Step S50, write the obtained full path name of the action class and the full path attribute information of the request class into the properties configuration file as part of the internationalization information, where:

[0055] Write the obtained full path name of the action class and the abbreviation of the action class into the properties configuration file in the form of an equation.

[0056] Write the obtained full path attribute of the request class and the attribute name of the request class into the properties configuration file in the form of an equation.

[0057] In an optional embodiment, the expression of the full path name of the action class and the abbreviation of the action class is as follows:

[0058] clazz.getName()+"="clazz.getSimpleName(),

[0059] The clazz.getName() function on the left side of the equation returns the name of the clazz object in the form of a String. The clazz.getSimpleName() function on the right side of the equation returns the abbreviation of the clazz object in the form of a String.

[0060] Among them, the clazz object is determined by the following expression,

[0061] clazz=classLoader.loadClass(packName+"."+File.getName().replace(".class","")),

[0062] Where packName is the package name of the action class.

[0063] File.getName() is used to get the class name of the action class.

[0064] getSimpleName() is used to obtain the short name of the action class.

[0065] Among them, whether to output the full path name is determined by querying whether the full path name of the class contains "Action". If the full path name of the class contains "Action", it indicates that the class is an action class, and then all full path names containing "Action" are output.

[0066] For example, the action class package name corresponding to packName is cn.com.paic.pacloud.elb.controller.

[0067] The class name of the action class obtained by File.getName() is ModifyPoolAttributeAction, so the name of the clazz object is cn.com.paic.pacloud.elb.controller.ModifyPoolAttributeAction. On the right side of the equation, the abbreviation of the action class is Modify Pool Attribute. Then you can generate

[0068] cn.com.paic.pacloud.elb.controller.ModifyPoolAttributeAction=ModifyPool Attribute expression.

[0069] In the above manner, equations of the full path names of all action classes and the abbreviations of the action classes can be generated.

[0070] In an optional embodiment, the expression of the full path attribute of the request class and the attribute name of the request class is as follows:

[0071] clazz.getName()+"."+f.getName()+"="f.getName(),

[0072] The clazz.getName() function returns the name of the clazz object in the form of a String. The f.getName() function returns the name of the f object in the form of a String, where the f object sequentially takes out each attribute of the request class and adds it to the full path name obtained by clazz.getName() to form each full path attribute of the request class.

[0073] Among them, the clazz object is determined by the following expression,

[0074] clazz=classLoader.loadClass(packName+"."+File.getName().replace(".class","")),

[0075] packName is the package name of the request class.

[0076] File.getName() is used to obtain the class name of the request class.

[0077] First, determine whether the full path name of the request class contains "request". If it does, then combine all declared fields of the request class (i.e., each attribute contained in the full path attribute) with the full path name to form each full path attribute.

[0078] For example, the package name of the request class corresponding to packName is cn.com.paic.pacloud.elb.controller.request, the class name of the request class obtained by File.getName() is CreatePoolRequest, and the attribute name of the request class obtained by f.getName() is backPort. Then the expression cn.com.paic.pacloud.elb.controller.request.CreatePoolRequest.backPort=Back Port can be generated.

[0079] In the above way, the equation of the full path attribute of all request classes and the attribute name of the request class can be generated.

[0080] In an optional embodiment, the FileFilter() function is used for filtering so as to obtain only the path name of the class ending in the form of ".class". And, if the name of the class does not end in ".class", the output displays "class not found".

[0081] In an optional embodiment, before searching for the class file of the Controller layer, the following method is used to generate relevant information according to different package names:

[0082] Use classLoader.getResource() function to get the package name;

[0083] Replace the "." in the package name with " / " to convert the package name into a file path;

[0084] Obtain the transmission protocol based on which the data is transmitted, and then determine whether the current type of the packet is a file type;

[0085] If the current type is a file type, relevant information of the corresponding package name is generated.

[0086] See also Figure 2 , which is a schematic diagram of the hardware architecture of an embodiment of the electronic device of the present invention. In this embodiment, the electronic device 2 is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions. For example, it can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a rack server, a blade server, a tower server or a cabinet server (including an independent server, or a server cluster composed of multiple servers), etc. Figure 2 As shown, the electronic device 2 at least includes, but is not limited to, a memory 21, a processor 22, and a network interface 23 that can be interconnected through a system bus. Wherein: the memory 21 includes at least one type of computer-readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 21 can be an internal storage unit of the electronic device 2, such as a hard disk or memory of the electronic device 2. In other embodiments, the memory 21 can also be an external storage device of the electronic device 2, such as a plug-in hard disk equipped on the electronic device 2, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), etc. Of course, the memory 21 can also include both the internal storage unit of the electronic device 2 and its external storage device. In this embodiment, the memory 21 is usually used to store the operating system and various application software installed in the electronic device 2, such as the internationalization information generation program code, etc. In addition, the memory 21 can also be used to temporarily store various data that have been output or will be output.

[0087] The processor 22 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 22 is generally used to control the overall operation of the electronic device 2, such as executing control and processing related to data interaction or communication with the electronic device 2. In this embodiment, the processor 22 is used to run the program code stored in the memory 21 or process data, such as running the internationalization information generation program.

[0088] The network interface 23 may include a wireless network interface or a wired network interface, and the network interface 23 is generally used to establish a communication connection between the electronic device 2 and other electronic devices. For example, the network interface 23 is used to connect the electronic device 2 to the push platform through the network, and to establish a data transmission channel and a communication connection between the electronic device 2 and the push platform. The network may be a wireless or wired network such as an intranet, the Internet, a global system of mobile communication (GSM), wideband code division multiple access (WCDMA), a 4G network, a 5G network, Bluetooth, or Wi-Fi.

[0089] Optionally, the electronic device 2 may further include a display, which may also be referred to as a display screen or a display unit. In some embodiments, it may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an organic light-emitting diode (OLED) display. The display is used to display information processed in the electronic device 2 and to display a visual user interface.

[0090] It should be pointed out that Figure 2 Only the electronic device 2 having components 21 to 23 is shown, but it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.

[0091] The memory 21 including a readable storage medium may include an operating system, an internationalization information generation program 50, etc. When the processor 22 executes the internationalization information generation program 50 in the memory 21, the following steps are implemented:

[0092] Step S10, search for the class files of the Controller layer (control layer), which include action classes (Action) and request classes (Resquest). The Controller layer is responsible for processing all requests sent by the browser and deciding what content to respond to the browser. The interface of the Serice layer (service layer) is called in the Controller layer to control the business process. However, the Controller is not responsible for deciding how the content should be displayed, but responding to the MVC architecture with a specific form of content. Finally, the MVC architecture decides how to respond to the browser based on the form of the response.

[0093] The Controller layer is also a class (Class), which has many methods (Method). Each method is considered an action class (Action), which can receive the request (Request) of the request class through the action class and determine the response view.

[0094] Step S30, use Java's reflection mechanism to obtain the full path name of the action class and the full path attribute information of the request class, where the full path name of the action class is the package name of the action class + the class name of the action class, and the full path attribute of the request class is the full path name of the request class + the attribute name of the request class, where the full path name of the request class is the package name of the request class + the class name of the request class.

[0095] A package in Java can be understood as a folder where classes are located. Generally, it contains related classes, and each package name is unique. For example, the package name can be a domain name on the Internet plus a name customized by the developer. Since domain names on the Internet are not repeated, the package name is also unique. For example: the domain name is cn.com.paic..., plus the customized name pacloud.elb.controller, the final package name is cn.com.paic.pacloud.elb.controller.

[0096] Step S50, write the obtained full path name of the action class and the full path attribute information of the request class into the .properties configuration file as part of the internationalization information, where:

[0097] The obtained full path name of the action class and the abbreviation of the action class are written into the .properties configuration file as an expression in the form of an equation, and the obtained full path attribute of the request class and the attribute name of the request class are written into the .properties configuration file as an expression in the form of an equation.

[0098] In this embodiment, the internationalization information generation program stored in the memory 21 can be divided into one or more program modules, and the program module refers to a series of computer program instruction segments that can perform specific functions, which is more suitable for describing the execution process of the internationalization information generation program in the electronic device 2 than a program. The following description will specifically introduce the specific functions of the program module. The one or more program modules are stored in the memory 21 and can be executed by one or more processors (processor 22 in this embodiment) to complete the present invention. For example, Figure 3 A program module diagram of the internationalization information generation program is shown. In this embodiment, the internationalization information generation program 50 can be divided into an action class full path name acquisition module 501, an action class abbreviation acquisition module 502, a request class full path attribute acquisition module 503, a request class attribute name acquisition module 504, and a properties configuration file writing module 505.

[0099] The action class full path name acquisition module 501 and the action class abbreviation acquisition module 502 acquire the full path name of the action class in the following manner. The expressions of the full path name of the action class and the abbreviation of the action class are as follows:

[0100] clazz.getName()+"="clazz.getSimpleName(),

[0101] The action class full path name acquisition module 501 returns the name of the clazz object in the form of String through the clazz.getName() function on the left side of the equation. The action class abbreviation acquisition module 502 returns the abbreviation of the clazz object in the form of String through the clazz.getSimpleName() function on the right side of the equation.

[0102] Among them, the clazz object is determined by the following expression,

[0103] clazz=classLoader.loadClass(packName+"."+File.getName().replace(".class","")),

[0104] Where packName is the package name of the action class.

[0105] File.getName() is used to get the class name of the action class.

[0106] getSimpleName() is used to obtain the short name of the action class.

[0107] Among them, whether to output the full path name is determined by querying whether the full path name of the class contains "Action". If the full path name of the class contains "Action", it indicates that the class is an action class, and then all full path names containing "Action" are output.

[0108] For example, the action class package name corresponding to packName is cn.com.paic.pacloud.elb.controller.

[0109] The class name of the action class obtained by File.getName() is ModifyPoolAttributeAction, so the name of the clazz object is cn.com.paic.pacloud.elb.controller.ModifyPoolAttributeAction. On the right side of the equation, the abbreviation of the action class is Modify Pool Attribute. Then you can generate

[0110] cn.com.paic.pacloud.elb.controller.ModifyPoolAttributeAction=ModifyPool Attribute expression.

[0111] In the above manner, equations of the full path names of all action classes and the abbreviations of the action classes can be generated.

[0112] The request class full path attribute acquisition module 503 and the request class attribute name acquisition module 504 acquire the full path attribute of the request class in the following manner. The expressions of the full path attribute of the request class and the attribute name of the request class are as follows:

[0113] clazz.getName()+"."+f.getName()+"="f.getName(),

[0114] The request class full path attribute acquisition module 503 returns the name of the clazz object in the form of a String through the clazz.getName() function. The request class attribute name acquisition module 504 returns the name of the f object in the form of a String through the f.getName() function, wherein the f object sequentially takes out each attribute of the request class and adds the full path name obtained by clazz.getName() to form each full path attribute of the request class.

[0115] Among them, the clazz object is determined by the following expression,

[0116] clazz=classLoader.loadClass(packName+"."+File.getName().replace(".class","")),

[0117] packName is the package name of the request class.

[0118] File.getName() is used to obtain the class name of the request class.

[0119] First, determine whether the full path name of the request class contains "request". If it does, then combine all declared fields of the request class (i.e., each attribute contained in the full path attribute) with the full path name to form each full path attribute.

[0120] For example, the package name of the request class corresponding to packName is cn.com.paic.pacloud.elb.controller.request, the class name of the request class obtained by File.getName() is CreatePoolRequest, and the attribute name of the request class obtained by f.getName() is backPort. Then the expression cn.com.paic.pacloud.elb.controller.request.CreatePoolRequest.backPort=Back Port can be generated.

[0121] In the above way, the equation of the full path attribute of all request classes and the attribute name of the request class can be generated.

[0122] In an optional embodiment, a filtering module 506 is further provided, and the filtering module 506 uses the FileFilter() function to filter so as to obtain only the path name of the class ending in the form of ".class". And if the name of the class does not end in ".class", the output displays "class not found".

[0123] In an optional embodiment, a package information generation module 507 is further provided. Before searching for the class files of the Controller layer, the package information generation module 507 generates relevant information according to different package names in the following manner:

[0124] Use classLoader.getResource() function to get the package name;

[0125] Replace the "." in the package name with " / " to convert the package name into a file path;

[0126] Obtain the transmission protocol based on which the data is transmitted, and then determine whether the current type of the packet is a file type;

[0127] If the current type is a file type, relevant information of the corresponding package name is generated.

[0128] In addition, the embodiment of the present invention further proposes a computer-readable storage medium, which may be any one or any combination of a hard disk, a multimedia card, an SD card, a flash memory card, an SMC, a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a portable compact disk read-only memory (CD-ROM), a USB memory, etc. The computer-readable storage medium includes an internationalization information generation program 50, etc. When the internationalization information generation program 50 is executed by the processor 22, the following operations are implemented:

[0129] Step S10, search for the class files of the Controller layer (control layer), which include action classes (Action) and request classes (Resquest). The Controller layer is responsible for processing all requests sent by the browser and deciding what content to respond to the browser. The interface of the Serice layer (service layer) is called in the Controller layer to control the business process. However, the Controller is not responsible for deciding how the content should be displayed, but responding to the MVC architecture with a specific form of content. Finally, the MVC architecture decides how to respond to the browser based on the form of the response.

[0130] The Controller layer is also a class (Class), which has many methods (Method). Each method is considered an action class (Action), which can receive the request (Request) of the request class through the action class and determine the response view.

[0131] Step S30, use Java's reflection mechanism to obtain the full path name of the action class and the full path attribute information of the request class, where the full path name of the action class is the package name of the action class + the class name of the action class, and the full path attribute of the request class is the full path name of the request class + the attribute name of the request class, where the full path name of the request class is the package name of the request class + the class name of the request class.

[0132] A package in Java can be understood as a folder where classes are located. Generally, it contains related classes, and each package name is unique. For example, the package name can be a domain name on the Internet plus a name customized by the developer. Since domain names on the Internet are not repeated, the package name is also unique. For example: the domain name is cn.com.paic..., plus the customized name pacloud.elb.controller, the final package name is cn.com.paic.pacloud.elb.controller.

[0133] Step S50, write the obtained full path name of the action class and the full path attribute information of the request class into the .properties configuration file as part of the internationalization information, where:

[0134] Write the obtained full path name of the action class and the abbreviation of the action class into the .properties configuration file in the form of an equation.

[0135] Write the obtained full path property of the request class and the property name of the request class into the .properties configuration file in the form of an equation.

[0136] The specific implementation of the computer-readable storage medium of the present invention is substantially the same as the specific implementation of the internationalization information generating method and the electronic device 2 described above, and will not be described in detail herein.

[0137] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for generating internationalized information, applied to an electronic device, characterized in that: Find the class files of the Controller layer, where the class files of the Controller layer include action classes and request classes; Use Java's reflection mechanism to obtain the full path name of the action class and the full path attribute of the request class. The full path name of the action class is the package name where the action class is located + dot + class name of the action class. The full path attribute of the request class is the full path name of the request class + dot + attribute name of the request class. The full path name of the request class is the package name where the request class is located + dot + class name of the request class. Write the obtained full path name of the action class and the full path attribute information of the request class into the properties configuration file as part of the internationalization information, where: Write the obtained full path name of the action class and the abbreviation of the action class into the properties configuration file in the form of an equation. Write the obtained full path attribute of the request class and the attribute name of the request class into the properties configuration file in the form of an equation. The full path name of the action class and the abbreviation of the action class are expressed in equation form as follows: clazz.getName() + " = " clazz.getSimpleName(), Among them, clazz.getName() obtains the full path name of the action class through the following expression: clazz=classLoader.loadClass(packName+"." + File.getName().replace(".class", "")), packName is the package name of the action class. File.getName() is used to get the class name of the action class. getSimpleName() is used to obtain the abbreviation of the action class. The expression of the full path attribute of the request class and the attribute name of the request class in the form of an equation is as follows: clazz.getName() + "." + f.getName() + " = " f.getName(), Among them, each attribute of the request class is taken out in turn, and combined with the full path name respectively to form each full path attribute of the request class, Among them, clazz.getName() obtains the full path attribute of the request class through the following expression: clazz=classLoader.loadClass(packName+"."+ File.getName().replace(".class", "")), packName is the package name of the request class. File.getName() is used to get the class name of the requested class.

2. The method for generating internationalized information according to claim 1, characterized in that: Use the FileFilter() function to filter to obtain only the class path names ending with ".class".

3. The method for generating internationalized information according to claim 1, characterized in that: If the class name does not end with ".class", the output will display "Class not found".

4. The method for generating internationalized information according to claim 1, characterized in that: Before searching for the class files of the Controller layer, the following method is used to generate relevant information according to different package names: Use classLoader.getResource() function to get the package name; Replace the "." in the package name with " / " to convert the package name into a file path; Obtain the transmission protocol based on which the data is transmitted, and then determine whether the current type of the packet is a file type; If the current type is a file type, relevant information of the corresponding package name is generated.

5. An electronic device, characterized in that: The electronic device includes: a memory and a processor, wherein the memory stores an internationalization information generation program, and when the internationalization information generation program is executed by the processor, the following steps are implemented: Find the class files of the Controller layer, where the class files of the Controller layer include action classes and request classes; Use Java's reflection mechanism to obtain the full path name of the action class and the full path attribute information of the request class. The full path name of the action class is the package name where the action class is located + dot + class name of the action class. The full path attribute of the request class is the full path name of the request class + dot + attribute name of the request class. The full path name of the request class is the package name where the request class is located + dot + class name of the request class. Write the obtained full path name of the action class and the full path attribute information of the request class into the properties configuration file as part of the internationalization information, where: Write the obtained full path name of the action class and the abbreviation of the action class into the properties configuration file in the form of an equation. Write the obtained full path attribute of the request class and the attribute name of the request class into the properties configuration file in the form of an equation. The full path name of the action class and the abbreviation of the action class are expressed in equation form as follows: clazz.getName() + " = " clazz.getSimpleName(), Among them, clazz.getName() obtains the full path name of the action class through the following expression: clazz=classLoader.loadClass(packName+"." + File.getName().replace(".class", "")), packName is the package name of the action class. File.getName() is to get the class name of the current class. getSimpleName() is to get the abbreviation of the current class. The expression of the full path attribute of the request class and the attribute name of the request class in the form of an equation is as follows: clazz.getName() + "." + f.getName() + " = " f.getName(), Among them, each attribute of the request class is taken out in turn, and combined with the full path name respectively to form each full path attribute of the request class, Among them, clazz.getName() obtains the full path attribute of the request class through the following expression: clazz=classLoader.loadClass(packName+"."+ File.getName().replace(".class", "")), packName is the package name of the request class. File.getName() gets the class name of the current class.

6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions. When the program instructions are executed by a processor, the internationalization information generating method according to any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • Method and system for treating internationalization resource

    CN101382888A

  • Automatic authority resource list generating method and device

    CN107480537A

  • Smart grid ontology update device

    US20130204847A1