Method of generating a file, method of configuring a page and device
By converting layout files and logic information into Java classes and generating executable files, the problem of low page display efficiency in existing technologies is solved, achieving more efficient page configuration and display.
Patent Information
- Application Number
- CN202210062987.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-19
- Publication Date
- 2026-03-17
- Estimated Expiration
- 2042-01-19
AI Technical Summary
Existing technologies suffer from low efficiency in parsing layout files when dynamically changing application pages, resulting in inefficient page display.
The page layout file and logic information are converted into Java classes and an executable file is generated. The executable file is used to generate Java class instances to configure the page layout and logic, thus avoiding the parsing process of the layout file.
This improves the efficiency of page configuration and reduces the steps involved in parsing layout files, thereby increasing the speed and efficiency of page display.
Smart Images

Figure CN114398023B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and more particularly to the field of client-side technology. Background Technology
[0002] In application development, the need for dynamic page layout is common. For example, during holidays, an application might need to launch promotional activities corresponding to the holiday, presented as an activity page. Therefore, the application's pages need to be dynamically changed to display these activity pages. Summary of the Invention
[0003] This disclosure provides a method for generating files, a method for configuring pages, an apparatus, a device, a storage medium, and a program product.
[0004] According to one aspect of this disclosure, a method for generating a file is provided, comprising: determining a layout file and logical information of a page; generating a target Java class based on the layout file and the logical information; and generating a target executable file based on the target Java class.
[0005] According to another aspect of this disclosure, a method for configuring a page is provided, comprising: obtaining a target executable file corresponding to a target page; generating a class instance of a target Java class based on the target executable file; and configuring the layout and logic of the target page based on the class instance; wherein the target executable file is generated using the method described in the embodiments of this disclosure.
[0006] According to another aspect of this disclosure, an apparatus for generating a file is provided, comprising: a determining module for determining a layout file and logical information of a page; a first generating module for generating a target Java class based on the layout file and the logical information; and a second generating module for generating a target executable file based on the target Java class.
[0007] According to another aspect of this disclosure, an apparatus for configuring a page is provided, comprising: an acquisition module for acquiring a target executable file corresponding to a target page; a third generation module for generating a class instance of a target Java class based on the target executable file; and a configuration module for configuring the layout and logic of the target page based on the class instance, wherein the target executable file is generated using the method described in the embodiments of this disclosure.
[0008] Another aspect of this disclosure provides an electronic device including: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the methods shown in embodiments of this disclosure.
[0009] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to perform the methods shown in the embodiments of the present disclosure.
[0010] According to another aspect of the present disclosure, a computer program product is provided, including a computer program / instructions, characterized in that, when the computer program / instructions are executed by a processor, they implement the steps of the method shown in the embodiments of the present disclosure.
[0011] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0012] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein:
[0013] Figure 1 The illustration schematically depicts an exemplary system architecture in which methods for generating files and configuring pages can be applied according to embodiments of the present disclosure;
[0014] Figure 2 A flowchart illustrating a method for generating a file according to an embodiment of the present disclosure is shown schematically;
[0015] Figure 3 A flowchart illustrating a method for generating a target Java class according to an embodiment of the present disclosure is shown schematically.
[0016] Figure 4 A flowchart illustrating a method for generating a target executable file according to an embodiment of the present disclosure is shown schematically;
[0017] Figure 5 A flowchart illustrating a method for generating a target Java class according to an embodiment of the present disclosure is shown schematically.
[0018] Figure 6 A flowchart illustrating a method for generating a target executable file according to an embodiment of the present disclosure is shown schematically;
[0019] Figure 7A flowchart illustrating a method for obtaining a target executable file corresponding to a target page according to an embodiment of the present disclosure is shown schematically.
[0020] Figure 8 A flowchart illustrating a method for generating a class instance of a target Java class according to an embodiment of the present disclosure is shown schematically.
[0021] Figure 9 The illustration shows a method for generating a file and a method for configuring a page according to another embodiment of the present disclosure;
[0022] Figure 10 A block diagram of an apparatus for generating a file according to an embodiment of the present disclosure is shown schematically;
[0023] Figure 11 A block diagram illustrating an apparatus for configuring a page according to an embodiment of the present disclosure is shown schematically; and
[0024] Figure 12 A block diagram of an example electronic device that can be used to implement embodiments of the present disclosure is illustrated schematically. Detailed Implementation
[0025] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0026] The following will combine Figure 1 An exemplary system architecture for the methods and apparatus provided in this disclosure is described.
[0027] Figure 1 An exemplary system architecture 100, illustrating methods for generating files and configuring pages according to embodiments of this disclosure, is shown schematically. It should be noted that... Figure 1 The examples shown are merely examples of system architectures that can be applied to the embodiments of this disclosure, in order to help those skilled in the art understand the technical content of this disclosure, but do not mean that the embodiments of this disclosure cannot be used in other devices, systems, environments or scenarios.
[0028] like Figure 1 As shown, the system architecture 100 according to this embodiment may include terminal devices 101 and 102, a network 103, and a server 104. The network 103 serves as a medium for providing a communication link between the terminal devices 101 and 102 and the server 104. The network 103 may include various connection types, such as wired or wireless communication links or fiber optic cables, etc.
[0029] Users can use terminal devices 101 and 102 to interact with server 104 via network 103 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101 and 102, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social media platform software, etc. (for example only).
[0030] Terminal devices 101 and 102 can be various electronic devices with displays and support web browsing, including but not limited to smartphones, tablets, laptops, and desktop computers.
[0031] Server 104 can be a server that provides various services, such as a backend management server that supports the applications used by users through terminal devices 101 and 102. The backend management server can analyze and process data such as received user requests, and feed back the processing results (such as pages, information, or data obtained or generated according to user requests) to the terminal devices.
[0032] Server 104 can be a cloud server, also known as a cloud computing server or cloud host. It is a hosting product in the cloud computing service system, which solves the shortcomings of traditional physical hosts and VPS (Virtual Private Server, or VPS) services, such as high management difficulty and weak business scalability. Server 104 can also be a server for a distributed system or a server combined with blockchain.
[0033] According to embodiments of this disclosure, application developers can use terminal device 101 to write code for implementing page re-layout and code for implementing page business logic, obtaining layout files and logic information. Then, based on the layout files and logic information, a target Java class can be generated. Next, based on the target Java class, a target executable file is generated and uploaded to server 104.
[0034] According to other embodiments of this disclosure, developers can also generate the target executable file via server 104. The method for generating the target executable file can be found above and will not be repeated here.
[0035] According to embodiments of this disclosure, a user can trigger a target page of an application via a terminal device 102. When the target page is triggered, the terminal device 102 can obtain the target executable file corresponding to the target page from the server 104. Then, based on the target executable file, a class instance of the target Java class is generated. Next, based on the class instance, the layout and logic of the target page are configured. Finally, the configured target page is displayed.
[0036] The relevant technology parses the corresponding layout file when a program needs to display a page. Since parsing the layout file involves two steps—loading the layout file into memory and generating a Java class using reflection—it is relatively inefficient.
[0037] According to embodiments of this disclosure, the layout file and logic information of a page are converted into a Java class, and the Java class is packaged to generate an executable file. Thus, when displaying the page, it is only necessary to generate a class instance of the Java class based on the executable file and then add it to the root layout of the page to display the page, thereby improving efficiency.
[0038] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0039] The following will combine Figure 2 The method for generating files provided in this disclosure is described.
[0040] Figure 2 A flowchart illustrating a method for generating a file according to an embodiment of the present disclosure is shown schematically.
[0041] like Figure 2 As shown, the method 200 for generating files includes operation S210, which determines the layout file and logical information of the page.
[0042] Then, in operation S220, the target Java class is generated based on the layout file and logic information.
[0043] When operating S230, a target executable file is generated based on the target Java class.
[0044] According to embodiments of this disclosure, the layout file and logic information of a page are converted into a Java class, and the Java class is packaged to generate an executable file. Therefore, when displaying the page, only an instance of the Java class needs to be generated based on the executable file, and then the layout and logic of the target page can be configured based on the class instance to complete the page configuration. This eliminates the need to parse the layout file, thus resulting in higher efficiency.
[0045] According to embodiments of this disclosure, the executable file may include, for example, a dex file.
[0046] According to embodiments of this disclosure, the format of the layout file may include, for example, XML (Extensible Markup Language).
[0047] According to embodiments of this disclosure, the layout file may include attributes such as the type of page controls, the identifier of page controls, and the style of page controls. Page controls may include, for example, view components.
[0048] The following is for reference. Figure 3 The method for generating the target Java class shown above will be further explained.
[0049] Figure 3 A flowchart illustrating a method for generating a target Java class according to an embodiment of the present disclosure is shown schematically.
[0050] like Figure 3 As shown, the method 320 for generating the target Java class includes operation S321, which determines the first Java class based on the attributes of the outermost view component in the layout file.
[0051] Then, in operation S322, the second Java class is determined based on the properties of each view component in the layout file, excluding the outermost view component.
[0052] In operation S323, according to the constructor of the first Java class, the second Java class is added to the first Java class to obtain the third Java class.
[0053] In operation S324, logical information is added to the third Java class to obtain the target Java class.
[0054] For example, in this embodiment, the layout file may include properties of multiple view components, wherein the multiple view components have a nested relationship.
[0055] According to embodiments of this disclosure, for the outermost view component among multiple view components, a Java class, namely the first Java class, can be defined. Then, the first Java class is set according to the properties of the view component in the layout file.
[0056] Alternatively, a separate Java class, or second Java class, can be defined for each view component (excluding the outermost view component). This second Java class can then be set according to the properties of that view component in the layout file.
[0057] Next, using the constructor of the first Java class, the second Java class is added to the first Java class according to the nesting relationship between the view components. For example, if view component A is nested within view component B, then the Java class corresponding to view component B is added to the Java class corresponding to view component A.
[0058] The following is for reference. Figure 4The method for generating the target executable file shown above will be further explained.
[0059] Figure 4 A flowchart illustrating a method for generating a target executable file according to an embodiment of the present disclosure is shown schematically.
[0060] like Figure 4 As shown, the method 430 for generating the target executable file includes operation S431, which compiles the target Java class into a class file.
[0061] According to embodiments of this disclosure, for example, a target Java class can be compiled into a class file using the javac tool.
[0062] Then, in operation S432, the class file is compiled into the target executable file.
[0063] According to embodiments of this disclosure, the target executable file may include, for example, a dex file. In this embodiment, for example, a dx tool can be used to compile a class file into a target executable file.
[0064] According to another embodiment of this disclosure, the target Java class can also be given a class name for differentiation. See below for reference. Figure 5 The method for generating the target Java class shown above will be further explained.
[0065] Figure 5 A flowchart illustrating a method for generating a target Java class according to an embodiment of the present disclosure is shown schematically.
[0066] like Figure 5 As shown, the method 500 for generating the target Java class includes, in operation S510, obtaining the class name of the Activity in which the target Java class resides.
[0067] When operating S520, the class name of the target Java class is set according to the class name of the activity and the version identifier of the target Java class.
[0068] According to embodiments of this disclosure, a version identifier can be used to identify the version of a target page. The version identifier can include, but is not limited to, numbers, letters, symbols, and any combination thereof.
[0069] According to embodiments of this disclosure, for example, the version identifier can be used as a prefix or suffix and combined with the class name of the activity to obtain the class name of the target Java class. For example, if the class name of the Activity containing the target Java class is UserActivity, and the version identifier of the target Java class is Layout5, then the class name of the target Java class can be determined to be UserActivityLayout5.
[0070] The following will combine Figure 6 The method for configuring the page provided in this disclosure is described.
[0071] Figure 6 A flowchart illustrating a method for generating a target executable file according to an embodiment of the present disclosure is shown schematically.
[0072] like Figure 6 As shown, the method 600 for generating a target executable file includes operation S610, obtaining the target executable file corresponding to the target page.
[0073] Then, in operation of S620, a class instance of the target Java class is generated based on the target executable file.
[0074] When operating S630, configure the layout and logic of the target page based on the class instance.
[0075] According to embodiments of this disclosure, the target executable file can be generated, for example, by the file generation method shown in embodiments of this disclosure.
[0076] According to embodiments of this disclosure, a class instance of a Java class is generated based on the executable file, and then the layout and logic of the target page are configured based on the class instance. This eliminates the need to parse the layout file, thus resulting in higher efficiency.
[0077] The following is for reference. Figure 7 The method described above for obtaining the target executable file corresponding to the target page will be further explained.
[0078] Figure 7 A flowchart illustrating a method for obtaining a target executable file corresponding to a target page according to an embodiment of the present disclosure is shown.
[0079] like Figure 7 As shown, the method 710 for obtaining the target executable file corresponding to the target page includes operation S711, which determines whether the target executable file is stored in the local memory.
[0080] If the target executable file is stored in the local memory, operation S712 is executed. If the target executable file is not stored in the local memory, operations S713 to S714 are executed.
[0081] When operating the S712, the target executable file is read from local memory.
[0082] When operating S713, obtain the storage address of the target executable file on the server.
[0083] When operating the S714, the target executable file is downloaded from the server according to the storage address and stored in the local storage.
[0084] According to embodiments of this disclosure, for example, the class name of the target Java class can be obtained from the server. Then, based on the class name, it can be determined whether the target executable file is stored in local storage.
[0085] According to embodiments of this disclosure, if the target executable file is stored in the local storage, it indicates that the layout of the target page on the server has not been updated. Therefore, the target page can be configured based on the target executable file in the local storage. If the target executable file is not stored in the local storage, it indicates that the layout of the target page has been updated on the server. Therefore, the updated target executable file can be downloaded from the server, and then the target page can be configured based on the target executable file.
[0086] Figure 8 A flowchart illustrating a method for generating a class instance of a target Java class according to an embodiment of the present disclosure is shown schematically.
[0087] like Figure 8 As shown, the method 820 for generating a class instance of the target Java class includes operation S821, loading the target executable file.
[0088] In operation S822, the constructor object corresponding to the target Java class in the target executable file is determined.
[0089] When operating S823, a class instance of the target Java class is generated based on the constructor object.
[0090] According to embodiments of this disclosure, for example, a class instance can be added to the root layout of the target page to configure the layout and logic of the target page.
[0091] According to embodiments of this disclosure, instances of Java classes can be generated using reflection. For example, an instance of BaseDexClassLoader in the system can be created to load an executable file from local storage into memory. Then, the loadClass method in the BaseDexClassLoader instance can be called to obtain the Class instance corresponding to the Java class. The loadClass method takes a fully qualified path string of the Java class as its parameter, indicating the path of the Java class within the executable file. The required constructor object can then be obtained from this Class instance, and an instance of the Java class can be generated using the constructor object. Finally, the Java class instance can be set to the root layout of the page using the setContentView method.
[0092] The following is for reference. Figure 9 The methods for generating files and configuring pages described above will be further explained in conjunction with specific embodiments. Those skilled in the art will understand that the following example embodiments are only for understanding this disclosure, and this disclosure is not limited thereto.
[0093] Figure 9 The illustration shows a method for generating a file and a method for configuring a page according to another embodiment of the present disclosure.
[0094] exist Figure 9 The diagram illustrates that developers can modify the layout file and corresponding page logic as needed. The layout file can be, for example, in XML format. A Java class can then be defined, inheriting from the outermost View component in the layout file, and its properties can be set according to the attributes declared in the layout file. These attributes can include, for example, width, height, margins, font, background, etc.
[0095] Next, the Java class can be named based on the class name of the Activity it resides in. For example, if the Activity's class name is UserActivity, the Java class could be named UserActivityLayout. However, since Android applications uniquely distinguish classes based on their fully qualified class paths, the generated Java class name for each dynamically modified page must be different from the previous one. Therefore, in this embodiment, an auto-incrementing numeric suffix can be added to the Java class name for differentiation. For example, after this update, the Java class name could be UserActivityLayout5, and after the next update, it could be changed to UserActivityLayout6.
[0096] Additionally, other non-outermost View components in the layout file are converted into corresponding Java classes, and instances of these Java classes are created. The properties declared in the layout file are set to these instances, and then, based on the constructor of the Java class corresponding to the outermost View component, these instances are added to the Java class corresponding to the outermost View component.
[0097] The logic within the page's Activity is extracted, and this logic information is added to the generated Java class. By adding this logic information to the generated Java class, you can set up logical operations related to view components within the Java class, such as setting attributes for a TextView.
[0098] The generated Java classes are packaged into a single dex file, which is the target executable file, using the javac and dx tools. The generated dex file is then uploaded to a server, where the server records its mapping relationship with the fully qualified names of the generated Java classes and the pages they reside on.
[0099] When the program runs, in response to the user triggering the display of the page, if the page is a dynamic page, it will query the server for the latest dex file URL and the full path string of the Java class corresponding to the current page each time the page is accessed.
[0100] If the dex file has already been downloaded to local storage, it means the page has not changed and the existing dex file in local storage can be used directly. The path to the dex file in local storage is denoted as dexPath.
[0101] If the file has not been downloaded before, it will be downloaded based on the URL of the dex file returned by the server and stored in the local storage at the storage location corresponding to the application. The path is denoted as dexPath.
[0102] Instances of the generated Java class are created using reflection. For example, an instance of `BaseDexClassLoader` in the system is created, loading the dex file with the path `dexPath` from the previous steps into memory. Then, the `loadClass` method in the `BaseClassLoader` instance is called, taking the fully qualified path string of the Java class generated in step one as the parameter, to obtain the corresponding `Class` instance. Next, the required constructor object is obtained from this `Class` instance, and an instance of the Java class is generated using the constructor object. The generated Java class instance is then set to the root layout of the page using the `setContentView` method to display the new page style and logic.
[0103] Figure 10 A block diagram of an apparatus for generating files according to an embodiment of the present disclosure is shown schematically.
[0104] like Figure 10 As shown, the device 1000 for generating files includes a determining module 1010, a first generating module 1020, and a second generating module 1030.
[0105] Module 1010 is used to determine the layout file and logical information of the page.
[0106] The first generation module 1020 is used to generate the target Java class based on the layout file and logical information.
[0107] The second generation module 1030 is used to generate the target executable file based on the target Java class.
[0108] Figure 11 A block diagram of an apparatus for configuring a page according to an embodiment of the present disclosure is shown schematically.
[0109] like Figure 11 As shown, the device 1100 for the configuration page includes an acquisition module 1110, a third generation module 1120, and a configuration module 1130.
[0110] The acquisition module 1110 is used to acquire the target executable file corresponding to the target page.
[0111] The third generation module 1120 is used to generate class instances of the target Java class based on the target executable file.
[0112] Configuration module 1130 is used to configure the layout and logic of the target page based on the class instance.
[0113] The target executable file is generated using the method shown in the embodiments of this disclosure.
[0114] The collection, storage, use, processing, transmission, provision, and disclosure of data involved in the technical solution disclosed herein all comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0115] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0116] Figure 12 A block diagram of an example electronic device 1200 that can be used to implement embodiments of the present disclosure is illustrated schematically. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0117] like Figure 12As shown, device 1200 includes a computing unit 1201, which can perform various appropriate actions and processes according to a computer program stored in read-only memory (ROM) 1202 or a computer program loaded from storage unit 1208 into random access memory (RAM) 1203. The RAM 1203 may also store various programs and data required for the operation of device 1200. The computing unit 1201, ROM 1202, and RAM 1203 are interconnected via bus 1204. Input / output (I / O) interface 1205 is also connected to bus 1204.
[0118] Multiple components in device 1200 are connected to I / O interface 1205, including: input unit 1206, such as keyboard, mouse, etc.; output unit 1207, such as various types of monitors, speakers, etc.; storage unit 1208, such as disk, optical disk, etc.; and communication unit 1209, such as network card, modem, wireless transceiver, etc. Communication unit 1209 allows device 1200 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0119] The computing unit 1201 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 1201 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 1201 performs the various methods and processes described above, such as methods for generating files and methods for configuring pages. For example, in some embodiments, the methods for generating files and methods for configuring pages can be implemented as computer software programs tangibly contained in a machine-readable medium, such as storage unit 1208. In some embodiments, part or all of the computer program can be loaded and / or installed on device 1200 via ROM 1202 and / or communication unit 1209. When the computer program is loaded into RAM 1203 and executed by the computing unit 1201, one or more steps of the methods for generating files and methods for configuring pages described above can be performed. Alternatively, in other embodiments, the computing unit 1201 may be configured by any other suitable means (e.g., by means of firmware) to perform methods for generating files or configuring pages.
[0120] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0121] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0122] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0123] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0124] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with embodiments of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0125] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other.
[0126] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.
[0127] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A method for generating a file, comprising: determining a layout file and logical information of a page; generating a target Java class according to the layout file and the logical information; and generating a target executable file according to the target Java class, wherein the layout file comprises attributes of a plurality of view components having a nested relationship therebetween; and the generating of the target Java class comprises: determining a first Java class according to the attributes of an outermost view component in the layout file; determining a second Java class according to the attributes of each of the view components other than the outermost view component in the layout file; adding the second Java class into the first Java class according to the nested relationship between the plurality of view components by using a constructor method of the first Java class to obtain a third Java class; and adding the logical information into the third Java class to obtain the target Java class. 2.The method of claim 1, further comprising: obtaining a class name of an activity in which the target Java class is located; and setting a class name of the target Java class according to the class name of the activity and a version identifier of the target Java class. the generating of the target executable file comprises:
3. The method of claim 1, wherein, compiling the target Java class into a class file; and compiling the class file into the target executable file. the executable file comprises a dex file.
4. The method of any one of claims 1-3, wherein, a format of the layout file comprises an extensible markup language (XML).
5. The method of any one of claims 1-3, wherein, 6.A method for configuring a page, comprising: obtaining a target executable file corresponding to a target page; generating a class instance of a target Java class according to the target executable file; and configuring a layout and logic of the target page according to the class instance; wherein the target executable file is generated by the method according to any one of claims 1-5. the obtaining of the target executable file corresponding to the target page comprises:
7. The method of claim 6, wherein, reading the target executable file from a local storage in a case that the target executable file is stored in the local storage; and in a case that the target executable file is not stored in the local storage, obtaining a storage address of the target executable file in a server, and downloading the target executable file from the server according to the storage address and storing the target executable file into the local storage. 8.The method of claim 7, further comprising: obtaining a class name of the target Java class from a server; and determining whether the target executable file is stored in a local storage according to the class name. the generating of the class instance of the target Java class according to the target executable file comprises:
9. The method of claim 6, wherein, loading the target executable file; determining a constructor method object corresponding to the target Java class in the target executable file; and generating the class instance of the target Java class according to the constructor method object. the configuring of the layout and logic of the target page according to the class instance comprises:
10. The method of claim 6, wherein, adding the class instance to a root layout of the target page so as to configure the layout and the logic of the target page.
11. An apparatus for generating a file, comprising: a determining module configured to determine a layout file and logic information of a page; a first generating module configured to generate a target Java class according to the layout file and the logic information; and a second generating module configured to generate a target executable file according to the target Java class, wherein the layout file comprises attributes of a plurality of view components having a nested relationship therebetween; and the first generating module is further configured to: determine a first Java class according to the attributes of an outermost view component in the layout file; determine a second Java class according to the attributes of each of the view components other than the outermost view component in the layout file; add the second Java class to the first Java class according to the nested relationship between the plurality of view components by using a constructor method of the first Java class to obtain a third Java class; and add the logic information to the third Java class to obtain the target Java class.
12. An apparatus for configuring a page, comprising: an obtaining module configured to obtain a target executable file corresponding to a target page; a third generating module configured to generate a class instance of a target Java class according to the target executable file; and a configuring module configured to configure the layout and the logic of the target page according to the class instance, wherein the target executable file is generated by the method according to any one of claims 1-5.
13. An electronic device, comprising: at least one processor; and a memory connected with the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1-10. The computer instructions are used to make the computer perform the method according to any one of claims 1-10. The computer program / instructions, when executed by the processor, implement the steps of the method according to any one of claims 1-10. The computer program / instructions, when executed by the processor, implement the steps of the method according to any one of claims 1-10.
14. A non-transitory computer readable storage medium having stored thereon computer instructions, wherein, 15. A computer program product comprising computer programs / instructions, characterized in that,
Citation Information
Patent Citations
Automatic android mobile device oriented application generation method
CN104317587A
Live streaming application program management method and apparatus
CN106686420A