Method and device for converting Java object list and DBF file
By determining the correspondence between the Java object list and the DBF file based on the configuration information, the mutual conversion between the Java object list and the DBF file is realized, which solves the problems of large amount of code development and low interface reuse in the existing technology, and improves the conversion efficiency and ability Maintenance.
Patent Information
- Application Number
- CN202210043464.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-14
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2042-01-14
AI Technical Summary
When converting Java object lists and DBF files with each other, a large amount of code and interfaces are required to be written, resulting in high development costs and low reuse. The interface processing logic and business processing logic are highly coupled, making it difficult to dynamically modify configuration information. .
By obtaining the object to be processed and determining the correspondence between the class attributes in the Java object list and the column information of the DBF file based on the configuration information, generating corresponding objects, realizing the mutual conversion between the Java object list and the DBF file, reducing interface writing and analyze the requirements of the landing surface, and support dynamic modification of configuration information.
It reduces the coupling between the code development volume and the interface processing logic and the business processing logic, improves the conversion speed and code maintainability, can quickly respond to business needs, and reduces development difficulty and cost.
Smart Images

Figure CN114385572B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to data processing technology, and in particular to a method and device for converting a Java object list and a DBF file. Background Art
[0002] In computer technology and data processing technology, Java object lists and DBF files are used in various scenarios in computer technology and data processing technology. It is often necessary to convert Java object lists and DBF files to each other, that is, convert Java object lists to DBF files in DBF format, and convert DBF files in DBF format to Java object lists.
[0003] In the prior art, when converting between a Java object list and a DBF file, different interfaces can be written in a coded manner, each interface corresponding to the conversion relationship between each data in the Java object list and each data in the DBF file, thereby completing the conversion between the Java object list and the DBF file based on the interface.
[0004] However, in the prior art, the coding method requires a lot of code development to write interfaces, and the interface reuse is not high; for different Java object lists or different DBF files, the interface needs to be rewritten, which requires a lot of development. Therefore, writing interfaces based on the coding method to complete file conversion results in a lot of code development and high costs. Summary of the invention
[0005] The present application provides a method and device for converting a Java object list and a DBF file, so as to solve the problem of large code development and high cost.
[0006] In a first aspect, the present application provides a method for converting a Java object list and a DBF file, the method comprising:
[0007] Acquire a first object to be processed, wherein the first object involves a plurality of first data;
[0008] Determine, according to configuration information, a correspondence between class attributes of a Java object in a Java object list and column information of a DBF file, second data corresponding to each first data in the first object;
[0009] Generate a second object according to the second data, and output the second object;
[0010] Among them, if the first object is a Java object list, and the Java object list includes at least one Java object, the second object is a DBF file, the first data is the data of the class attributes of the Java object in the Java object list, and the second data is the data of the column information; if the first object is a DBF file, the second object is a Java object list, the first data is the data of the column information, and the second data is the data of the class attributes of the Java object in the Java object list.
[0011] In a feasible implementation, the class attribute includes a class attribute name; the column information includes a column name, a column data type, a column length, a column format, a column description, and a column sequence number; if the first object is a DBF file, the class attribute also includes a full path class name of an object class in a Java object list;
[0012] The configuration information also includes a processing object type code, a processing object type name, and a conversion type code.
[0013] In a feasible implementation, if the first object is a Java object list, determining, according to the configuration information, second data corresponding to each first data in the first object includes: for each Java object in the first object, determining, according to the configuration information, column information corresponding to each type of attribute name of the object;
[0014] Generating a second object according to the second data includes:
[0015] For each Java object in the first object, according to the data format category corresponding to the class attribute name and the format conversion method between DBF data, the attribute value under each class attribute name in the Java object is converted into a character string of column information corresponding to each class attribute name of the Java object;
[0016] The second object is generated based on the character string of the column information corresponding to each type of attribute name of each Java object.
[0017] In a feasible implementation, before generating the second object according to the second data, the method further includes: establishing a column array of the second object in DBF format, and establishing a column object in each column array;
[0018] Generate a second object according to the character string of column information corresponding to each type of attribute name of each Java object, including:
[0019] The character string of column information corresponding to each type of attribute name of each Java object is placed into the column object corresponding to the column information in the column array corresponding to each Java object to generate a second object.
[0020] In a feasible implementation, if the first object is a DBF file, determining the second data corresponding to each first data in the first object according to the configuration information includes: for each row in the first object, determining the class attribute name corresponding to the column information in the row according to the configuration information;
[0021] Generating a second object according to the second data includes:
[0022] For each column of information in each row of the first object, according to the data format category corresponding to the class attribute name and the format conversion method between DBF data, convert the character string of each column of information in each row into the attribute value under each class attribute name corresponding to each column of information in each row;
[0023] A second object is generated according to the attribute values under each type of attribute name corresponding to each column of information in each row.
[0024] In a feasible implementation, before generating the second object according to the second data, the method further includes: determining the full path class name of the object class in the Java object list corresponding to each row in the first object according to the column information in each row in the first object and the configuration information, and determining the full path class name of the object class in the Java object list corresponding to each row in the first object, and establishing a Java object corresponding to each row in the first object;
[0025] Generate a second object according to the attribute value under each type of attribute name corresponding to each column of information in each row, including:
[0026] For each row of the first object, the attribute value under each type of attribute name corresponding to each column of information in each row is placed into the class attribute of the Java object corresponding to each row in the first object to generate a second object.
[0027] In a feasible implementation, if the first object is a Java object list, generating a second object includes: generating the second object based on a DBFWriter class in a JavaDBF tool;
[0028] If the first object is a DBF file, obtaining the first object to be processed includes: reading the first object based on the DBFReader class in the JavaDBF tool.
[0029] In a feasible implementation, the method further includes:
[0030] In response to the opening instruction, displaying the configuration information in a table form on the interface;
[0031] In response to a modification instruction from a user, the information indicated by the modification instruction in the configuration information is modified, and the modified configuration information is saved.
[0032] In a second aspect, the present application provides a device for converting a Java object list and a DBF file, the device comprising:
[0033] An acquiring unit, configured to acquire a first object to be processed, wherein the first object involves a plurality of first data;
[0034] A determining unit, configured to determine second data corresponding to each first data in the first object according to configuration information representing a correspondence between a class attribute of a Java object in a Java object list and column information of a DBF file;
[0035] A generating unit, configured to generate a second object according to the second data;
[0036] an output unit, configured to output the second object;
[0037] Among them, if the first object is a Java object list, and the Java object list includes at least one Java object, the second object is a DBF file, the first data is the data of the class attributes of the Java object in the Java object list, and the second data is the data of the column information; if the first object is a DBF file, the second object is a Java object list, the first data is the data of the column information, and the second data is the data of the class attributes of the Java object in the Java object list.
[0038] In a feasible implementation, the class attribute includes a class attribute name; the column information includes a column name, a column data type, a column length, a column format, a column description, and a column sequence number; if the first object is a DBF file, the class attribute also includes a full path class name of an object class in a Java object list;
[0039] The configuration information also includes a processing object type code, a processing object type name, and a conversion type code.
[0040] In a feasible implementation, if the first object is a Java object list, the determining unit is specifically configured to: determine, for each Java object in the first object, column information corresponding to each type of attribute name of the object according to the configuration information;
[0041] The generating unit comprises:
[0042] A first conversion module is used to convert, for each Java object in the first object, the attribute value under each class attribute name in the Java object into a character string of column information corresponding to each class attribute name of the Java object according to the data format category corresponding to the class attribute name and the format conversion method between the DBF data;
[0043] The first generating module is used to generate a second object according to a character string of column information corresponding to each type of attribute name of each Java object.
[0044] In a feasible implementation, the device further includes:
[0045] A first establishing unit is used to establish a column array of the second object in DBF format and establish a column object in each column array before the generating unit generates the second object according to the second data;
[0046] The first generating module is specifically used for:
[0047] The character string of column information corresponding to each type of attribute name of each Java object is placed into the column object corresponding to the column information in the column array corresponding to each Java object to generate a second object.
[0048] In a feasible implementation, if the first object is a DBF file, the determining unit is specifically configured to: for each row in the first object, determine, according to the configuration information, a class attribute name corresponding to the column information in the row;
[0049] The generating unit comprises:
[0050] A second conversion module is used to convert the character string of each column of information in each row of the first object into an attribute value under each class attribute name corresponding to each column of information in each row according to the data format category corresponding to the class attribute name and the format conversion method between DBF data;
[0051] The second generating module is used to generate a second object according to the attribute value under each type of attribute name corresponding to each column of information in each row.
[0052] In a feasible implementation, the device further includes:
[0053] a second establishing unit, configured to determine, before the generating unit generates the second object according to the second data, the full path class name of the object class in the Java object list corresponding to each row in the first object according to the column information in each row in the first object and the configuration information, and determine the full path class name of the object class in the Java object list corresponding to each row in the first object, and establish a Java object corresponding to each row in the first object;
[0054] The second generating module is specifically used for:
[0055] For each row of the first object, the attribute value under each type of attribute name corresponding to each column of information in each row is placed into the class attribute of the Java object corresponding to each row in the first object to generate a second object.
[0056] In a feasible implementation, if the first object is a Java object list, then when generating the second object, the generating unit is specifically used to: generate the second object based on the DBFWriter class in the JavaDBF tool;
[0057] If the first object is a DBF file, the acquisition unit is specifically configured to read the first object based on the DBFReader class in the JavaDBF tool.
[0058] In a feasible implementation, the device further includes:
[0059] A display unit, configured to display the configuration information in a table form on an interface in response to an opening instruction;
[0060] The modification unit is used to modify the information indicated by the modification instruction in the configuration information in response to the modification instruction of the user, and save the modified configuration information.
[0061] In a third aspect, an embodiment of the present application provides an electronic device, the electronic device comprising: a memory, a processor;
[0062] Memory; Memory for storing instructions executable by the processor;
[0063] The processor is configured to execute the method described in the first aspect.
[0064] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the method described in the first aspect.
[0065] In a fifth aspect, an embodiment of the present application provides a computer program product, comprising: a computer program, wherein the computer program is stored in a readable storage medium, at least one processor of an electronic device can read the computer program from the readable storage medium, and the at least one processor executes the computer program so that the electronic device executes the method described in the first aspect.
[0066] The method and device for converting a Java object list and a DBF file provided by the present application obtain a first object to be processed, wherein the first object involves multiple first data; according to the configuration information, the configuration information represents the correspondence between the class attribute of the Java object list and the column information of the DBF file, and determines the second data corresponding to each first data in the first object; according to the second data, a second object is generated and the second object is output; wherein, if the first object is a Java object list, and the Java object list includes at least one Java object, the second object is a DBF file, the first data is the data of the class attribute in the Java object list, and the second data is the data of the column information; if the first object is a DBF file, the second object is a Java object list, the first data is the data of the column information, and the second data is the data of the class attribute in the Java object list. Thus, the mutual conversion between the Java object list and the DBF file is completed based on the configuration information. It is no longer necessary to write an interface, which reduces the amount of code development and reduces the coupling between the interface processing logic and the business processing logic. In addition, the configuration information can be dynamically modified, and the modification process does not require a large amount of code development, which improves the speed of conversion; and reduces the development difficulty and improves the maintainability of the code. Since there is no need to write interfaces or parse landing tables, and the configuration information can be quickly and dynamically modified, the conversion between Java object lists and DBF files can be quickly completed, and business needs can be responded to in a timely manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0068] Figure 1 A flowchart of a method for converting a Java object list and a DBF file provided in an embodiment of the present application;
[0069] Figure 2 A conversion diagram provided for an application embodiment;
[0070] Figure 3 A flowchart of another method for converting a Java object list and a DBF file provided in an embodiment of the present application;
[0071] Figure 4A flowchart of another method for converting a Java object list and a DBF file provided in an embodiment of the present application;
[0072] Figure 5 A schematic diagram of the structure of a device for converting a Java object list and a DBF file provided in an embodiment of the present application;
[0073] Figure 6 A schematic diagram of the structure of another device for converting a Java object list and a DBF file provided in an embodiment of the present application;
[0074] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0075] Figure 8 It is a block diagram of an electronic device according to an exemplary embodiment.
[0076] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0077] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0078] In computer technology and data processing technology, Java object lists and DBF files are used in various scenarios in computer technology and data processing technology.
[0079] Java is a system programming language that can be used to write large business systems. You can use Java to get a list of Java objects. The list of Java objects includes multiple Java objects; a Java object is a specific instance of a class, and a Java object contains the behavior and state of the object.
[0080] DBF file is a data file format that can be used for data exchange between financial industry systems. DBF file is a database file that stores data in binary format; the data format of DBF file includes header record and data record. The header record is used to define the structure of the database and information related to the database. The data record includes the actual text content of each field corresponding to the header record.
[0081] It is often necessary to convert between Java object lists and DBF files, that is, to convert a Java object list into a DBF file in DBF format, and to convert a DBF file in DBF format into a Java object list.
[0082] In an example, when converting between a Java object list and a DBF file, a hard-coded method can be used; different interfaces are written, each interface corresponds to the conversion relationship between each data in the Java object list and each data in the DBF file, and then the conversion between the Java object list and the DBF file is completed based on the interface.
[0083] When converting a Java object list to a DBF file, you can define the file header information of the DBF file according to the business logic and the different interfaces of the DBF file. The file header information includes column name, type, length, etc. Then, assemble the attributes of each Java object in the Java object list into a row record of the DBF file, and then use the JavaDBF tool to write the attributes of each Java object in the Java object list into the DBF file. However, in this process, it is necessary to write interface processing logic separately for different interfaces, and the coupling between the interface processing logic and the business processing logic is high. Then, for different business logics, different Java object lists, and different DBF files, write interfaces corresponding to the business logic, Java object list, and DBF file; the amount of code development is large.
[0084] When converting a DBF file to a Java object list, you can use the JavaDBF tool to read the DBF file, and then assign the information record of each line in the DBF file to the Java object, and convert the information record of each line in the DBF file into data in the format that conforms to the Java object; then get the Java object list based on each Java object. However, in this process, it is also necessary to write interface processing logic separately for different interfaces, and the coupling between the interface processing logic and the business processing logic is high, and then write interfaces corresponding to the business logic, Java object list, and DBF file for different business logics, different Java object lists, and different DBF files; the amount of code development is large.
[0085] Alternatively, when converting a DBF file into a Java object list, you can use file parsing to parse the DBF file into a parsing landing table, then read the data in the parsing landing table in the business processing logic, and then obtain a Java object; when reading the data in the parsing landing table, convert the data in the parsing landing table into data in a format that conforms to the Java object; and then you can get a Java object list. However, in this method, you need to create a parsing landing table for each DBF file, and then you need to define different parsing landing tables and different parsing processing logics according to different interfaces, which results in a large workload.
[0086] The Java object list and DBF file conversion method and device provided in this application are intended to solve the above technical problems in the prior art.
[0087] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0088] Figure 1 A flowchart of a method for converting a Java object list and a DBF file provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, the method includes:
[0089] 101. Obtain a first object to be processed, where the first object involves multiple first data.
[0090] Exemplarily, when a Java object list needs to be converted into a DBF file, a Java object list to be processed is obtained, wherein the Java object list includes at least one Java object, and each Java object has data of various attributes. At this time, the first object is the Java object list, and the first data is the data of the class attribute of the Java object in the Java object list. The class in the Java object list is used to describe the behavior and state of a class of objects.
[0091] The Java object list includes at least one Java object, and the Java object has a Java object type. The Java object types of the Java objects included in the same Java object list are the same. For example, a Java object list includes Java object 1 and Java object 2, and the Java object types of Java object 1 and Java object 2 are both bsnDo. Each Java object in the Java object list has a class attribute, and the class attribute is multiple.
[0092] When it is necessary to convert a DBF file into a Java object list, obtain the DBF file to be processed, wherein the DBF file includes information of each column of each row. At this time, the first object is a DBF file, and the first data is data of the column information. At this time, a JavaDBF tool can be used to read the DBF file; wherein the JavaDBF tool is an open source Java tool class library for reading and writing DBF files.
[0093] 102. Determine, according to configuration information, the configuration information representing a correspondence between a class attribute of a Java object in a Java object list and column information of a DBF file, second data corresponding to each first data in the first object.
[0094] In one example, the class attributes include the class attribute name; the column information includes the column name, column data type, column length, column format, column description and column sequence number; if the first object is a DBF file, the class attributes also include the full path class name of the object class in the Java object list; the configuration information also includes the processing object type code, the processing object type name and the conversion type code.
[0095] Exemplarily, there is configuration information in advance, which indicates the corresponding relationship between the class attributes of the Java object list and the column information of the DBF file.
[0096] If the first object to be processed is a Java object list, the data of the column information corresponding to the data of the class attribute of each Java object in the Java object list can be determined according to the configuration information; in this case, the second data is the data of the column information.
[0097] If the first object to be processed is a DBF file, the class attribute data corresponding to the column information of each row in the DBF file can be determined according to the configuration information; at this time, the second data is the class attribute data of the Java object in the Java object list.
[0098] In an example, the configuration information can be seen in Table 1. The configuration information includes the processing object type code, the processing object type name, the conversion type code, the full path class name of the object class in the Java object list, each column information, and the class attribute name. Among them, the column information is the column name, column data type, column length, column format, column description, and column sequence number.
[0099] Table 1 Configuration information
[0100]
[0101]
[0102] As shown in Table 1, the processing object type code is used to indicate the first object to be processed; the processing object type code indicates the object type to be converted currently, and the processing object type code is used to filter the configuration information. The processing object type name is used to indicate the name of the first object to be processed; the processing object type name indicates the Chinese description of the processing object type code, and the processing object type name facilitates the user to identify the configuration information. The conversion type code is used to indicate the conversion method; the conversion type code includes two code values 01 and 02, which are used to filter the configuration information; if the conversion type code is 01, it is determined that the Java object list is converted to a DBF file; if the conversion type code is 02, it is determined that the DBF file is converted to a Java object list. The full path class name of the object class in the Java object list indicates the target class type in the process of converting the DBF file to the Java object, and the full path class name of the object class in the Java object list is set to the configuration information according to the package path format of the class; when the conversion type code is 01, the full path class name of the object class in the Java object list does not need to be set; when the conversion type code is 02, the full path class name of the object class in the Java object list needs to be set. The column information (column name, column data type, column length, column format, column description, column sequence number) corresponds to the class attribute name; each column of information is the information of each column of the row in the DBF file; each class attribute name is the name of each class attribute in the object in the Java object list.
[0103] Among them, the column name is used to indicate the column name of the header record of the DBF file. The column data type is used to indicate the column data type of the header record of the DBF file; B represents binary, C represents character type, D represents date type, N represents numeric type, and L represents logical type. The column length is used to indicate the column length limit of the header record of the DBF file. If the column value filled in is not long enough, the JavaDBF tool will automatically fill in spaces before the string when writing. The column format is used to indicate the format of the column value of the header record of the DBF file, which is used to identify the date and time format; when operating a DBF file, the column value will be written or read according to the column format.
[0104] The column description is used to indicate the Chinese description of the column name in the header record of the DBF file, which is convenient for users to manually read the configuration information. The column sequence number is used to indicate the column position sequence number of the current column in the header record of the DBF file; the column sequence number can be automatically or manually modified through the background, thereby dynamically adjusting the format of the DBF file.
[0105] The class attribute name is used to indicate the name of the class attribute of the Java object corresponding to each column of the DBF file.
[0106] In one example, Figure 2 The conversion diagram provided for the application embodiment is as follows: Figure 2As shown, when the Java object list needs to be converted into a DBF file, the Java object list is obtained during the business processing context; when the Java object list is obtained, the Java object after the Java class com.xxx.BsnDo is instantiated is included in the Java object list, wherein the Java class com.xxx.BsnDo includes multiple class attributes, namely String dclid, DatedataDate, Bigdecimal amt, Timestamp dlvTm, int num. The Java object list includes 2 Java objects, namely Java object bsnDo1 and Java object bsnDo 2. The Java object bsnDo1 includes 5 class attributes, namely: the class attribute with the class attribute name dclid, the value of the class attribute dclid is 'RCRD001'; the class attribute with the attribute name dataDate, the value of the class attribute dataDate is 2021-04-25; the class attribute with the class attribute name amt, the value of the class attribute amt is 5.2343; the class attribute with the class attribute name dlvTm, the value of the class attribute dlvTm is 10:23:34 234; the class attribute with the class attribute name num, the value of the class attribute num is 8796. The Java object bsnDo2 includes 5 class attributes, namely: the class attribute with the class attribute name dclid, the value of the class attribute dclid is 'RCRD002'; the class attribute with the attribute name dataDate, the value of the class attribute dataDate is 2021-04-26; the class attribute with the class attribute name amt, the value of the class attribute amt is 3.21; the class attribute with the class attribute name dlvTm, the value of the class attribute dlvTm is 9:15:22 312; the class attribute with the class attribute name num, the value of the class attribute num is 6587.
[0107] Call the configuration information; then based on the configuration information, convert the data of each type of attribute of the Java object bsnDo1 into the data of each column of information in a row of the DBF file. Then obtain a DBF data record 1, which includes the data of the column name SBBH with the value of RCRD001, the column name SJRQ with the value of 2021 / 04 / 25, the column name JE with the value of 5.2343, the column name TJSJ with the value of 10 / 23 / 34, and the column name SL with the value of 8796. Convert the data of each type of attribute of the Java object bsnDo2 into the data of each column of information in a row of the DBF file. Then obtain a DBF data record 2, which includes the data of the column name SBBH with the value of RCRD002, the column name SJRQ with the value of 2021 / 04 / 26, the column name JE with the value of 2 spaces + 3.21, the column name TJSJ with the value of 09 / 15 / 22, and the column name SL with the value of 6587. Therefore, the class attribute data in each Java object will be automatically filled into the corresponding column information of each row of the DBF file according to the format; in this process, the class attribute data is written into the DBF file based on the JavaDBF tool.
[0108] like Figure 2 As shown, when the DBF file needs to be converted into a Java object list, the DBF file is read based on the JavaDBF tool and the DBF file path, and the DBF file includes two DBF data records, namely, DBF data record 1 and DBF data record 2. Each DBF data record includes data of five column information, namely, the value of the column name SBBH, the value of the column name SJRQ, the value of the column name JE, the value of the column name TJSJ, and the value of the column name SL.
[0109] The configuration information is called; then based on the configuration information, the data of each column of a row of the DBF file is converted into the data of each class attribute of the Java object bsnDo1. Then a Java object list is obtained, which includes two Java objects, namely Java object bsnDo1 and Java object bsnDo 2. Thus, the data of the column information of each column in the data record of the DBF file is automatically assigned to the class attribute of the corresponding Java object according to the type of the Java class attribute.
[0110] 103. Generate a second object according to the second data, and output the second object. If the first object is a Java object list, and the Java object list includes at least one Java object, the second object is a DBF file, the first data is the data of the class attribute of the Java object in the Java object list, and the second data is the data of the column information; if the first object is a DBF file, the second object is a Java object list, the first data is the data of the column information, and the second data is the data of the class attribute of the Java object in the Java object list.
[0111] Exemplarily, each second data is obtained through step 102, and then the second object can be generated. Then the second object is output. Through the solution of this embodiment, the Java object list can be quickly converted into a DBF file, that is, each Java object in the Java object list is converted into a byte sequence and persisted as a DBF file; each Java object corresponds to each row of records in the DBF file.
[0112] The DBF file can be converted into a Java object list, that is, the DBF file is converted into a byte sequence and instantiated into a Java object; each row of records in the DBF file corresponds to each Java object in the Java object list.
[0113] In this embodiment, a first object to be processed is obtained, wherein the first object involves multiple first data; according to the configuration information, the configuration information represents the correspondence between the class attribute of the Java object in the Java object list and the column information of the DBF file, and the second data corresponding to each first data in the first object is determined; according to the second data, a second object is generated and the second object is output; wherein, if the first object is a Java object list, and the Java object list includes at least one Java object, then the second object is a DBF file, the first data is the data of the class attribute of the Java object, and the second data is the data of the column information; if the first object is a DBF file, then the second object is a Java object list, the first data is the data of the column information, and the second data is the data of the class attribute of the Java object. Thus, the mutual conversion between the Java object list and the DBF file is completed based on the configuration information. It is no longer necessary to write an interface, which reduces the amount of code development and reduces the coupling between the interface processing logic and the business processing logic. In addition, the configuration information can be dynamically modified, and the modification process does not require a large amount of code development, which improves the speed of conversion; and reduces the development difficulty and improves the maintainability of the code. Since there is no need to write interfaces or parse landing tables, and the configuration information can be quickly and dynamically modified, the conversion between Java object lists and DBF files can be quickly completed, and business needs can be responded to in a timely manner.
[0114] Figure 3A flowchart of another method for converting a Java object list and a DBF file provided in an embodiment of the present application is shown in FIG. Figure 3 As shown, the method includes:
[0115] 301. Obtain a first object to be processed, wherein the first object involves multiple first data; the first object is a Java object list; and the first data is data of a class attribute of a Java object in the Java object list.
[0116] Exemplarily, when a Java object list needs to be converted into a DBF file, a Java object list to be processed is obtained, wherein the Java object list includes at least one Java object, and each Java object has data of various attributes. At this time, the first object is a Java object list, and the first data is data of class attributes of the Java object.
[0117] Then, the configuration information can be loaded. In one example, the configuration information can be loaded according to the processing object type code and the conversion type code passed in by the business processing context; wherein each row of information in the configuration information is arranged in ascending order according to the column number. In this embodiment, since it is necessary to convert the Java object list into a DBF file, the configuration information can only include data with a conversion type code of 01. For example, as shown in Table 1, only data of each row with class numbers 1 to 5 and a conversion type code of 01 can be included.
[0118] Furthermore, the format and data of the configuration information can be modified dynamically to meet the requirements of the current Java object list and the DBF file to be generated.
[0119] 302. Create a column array of a second object in DBF format, and create a column object in each column array.
[0120] Exemplarily, a DBFWriter object is first created, wherein the DBFWriter object includes a file header record, a file data record, etc. The DBFWriter object is used to record the second data generated subsequently, and then in step 306, the second data in the DBFWriter object is written into the DBF file.
[0121] Then, a column array of the DBF file is established (in this embodiment, the second object in the DBF format is the DBF file), and a column object DBFFileld column is established in each column array. As an example, the configuration information obtained in step 301 can be looped through, and the column name, column data type, and column length of the column object corresponding to each column are first initialized; then, the column name, column data type, and column length of the column object DBFFileld column corresponding to each column are assembled into a column array DBFField[]header, and then each column object DBFFileld column is stored in the column array DBFField[]header in sequence; then, the DBFWriter class in the JavaDBF tool is called to initialize the header record of the DBF file, and the header record is as follows: Figure 2 Then, the header record of the column array is assigned to the DBFWriter object.
[0122] 303. For each Java object in the first object, determine the column information corresponding to each class attribute name of the object according to the configuration information. The configuration information represents the correspondence between the class attributes of the Java object in the Java object list and the column information of the DBF file.
[0123] Exemplarily, for each Java object in the Java object list, column information corresponding to each type of attribute name of the object is determined according to the configuration information.
[0124] 304. For each Java object in the first object, according to the data format category corresponding to the class attribute name and the format conversion method between the DBF data, convert the attribute value under each class attribute name in the Java object into a character string of column information corresponding to each class attribute name of the Java object.
[0125] The data of the column information is the second data. Each type of attribute name corresponds to each type of attribute.
[0126] Exemplarily, a file data record object String[]record is created, and the file data record object String[]record is used to represent data of a row in a DBF file.
[0127] For each Java object in the Java object list, determine the attribute value under each attribute name in the Java object; each attribute name has a corresponding data format category, and the DBF file is a character file (character type can be called DBF data). It is necessary to convert the attribute value under each attribute name in the Java object according to the data format category corresponding to the attribute name and the format conversion method between DBF data, and then obtain a string of column information corresponding to each attribute name of the Java object. Among them, each attribute name corresponds to each attribute.
[0128] In one example, for each Java object in the Java object list, based on the reflection mechanism, the attribute value of each class attribute of the Java object is determined according to the configuration information; then, based on the reflection mechanism, the data format category of the class attribute under the class attribute name is obtained (the data format category is the Java type in Table 2); then, according to the format conversion method between different data format categories and DBF data, the attribute value of the class attribute under the class attribute name is converted into a string of column information corresponding to the class attribute name; then, the obtained string is recorded in the record array of the file data record object, and the element position of the currently recorded string is the column number of the class attribute corresponding to the string in the configuration information. For each Java object, after converting the attribute value under each class attribute of the Java object, each string corresponding to the Java object is obtained. For each Java object in the Java object list, the above method is adopted to convert the data in the Java object list into a string.
[0129] Among them, in the above conversion process, if there is an unsupported data format category (data format category, that is, the Java type in Table 2) or the class attribute is inconsistent with the configuration information, an exception handling mechanism can be used to skip the data conversion process of such attributes.
[0130] Among them, the Java reflection mechanism means that, in the running state of the program, a Java object of any class can be constructed, the class to which any Java object belongs can be understood, the member variables and methods of any class can be understood, and the properties and methods of any Java object can be called.
[0131] In the above conversion process, since DBF files usually use character data format, this application supports the following type conversion between Java types and DBF file data types (i.e., DBF data, or DBF data), as shown in Table 2. The above "data format category corresponding to the class attribute name" is the "Java type corresponding to the class attribute"; the above "DBF data" is the "data type of the DBF file".
[0132] Table 2 Type correspondence between Java types and DBF file data types
[0133]
[0134] Therefore, this embodiment can convert the data in the Java object list into data that meets the format requirements of the DBF file, and supports common Java data types and common field formats of DBF files.
[0135] 305. Generate a second object according to the character string of column information corresponding to each type of attribute name of each Java object; the second object is a DBF file.
[0136] In one example, step 305 includes: placing the character string of column information corresponding to each type of attribute name of each Java object into a column object corresponding to the column information in a column array corresponding to each Java object, so as to generate a second object.
[0137] In one example, when generating the second object, the second object is generated based on the DBFWriter class in the JavaDBF tool.
[0138] Exemplarily, the character string of column information corresponding to each type of attribute name of each Java object obtained in the above steps is put into the column object corresponding to the column information in the column array corresponding to each Java object, and then a DBF file can be generated.
[0139] In one example, for each Java object, after converting the attribute values under each attribute of the Java object, the strings corresponding to the Java object are obtained; at this time, the strings are assigned to the record array of the file data record object. Then, the addRecord() interface of the DBFWriter class in the JavaDBF tool is called to add the record array of the file data record object to the DBFWriter object, thereby adding a new line of file data record, see Figure 2 As shown, a row of DBF data records is added.
[0140] The DBFWriter class in the JavaDBF tool provides the function of writing DBF files.
[0141] Create an empty DBF file in the preset specified path, define the file output stream of this DBF file, pass the file output stream to the writer() method of the DBFWriter class of the JavaDBF tool, write the file header record and data record in the DBFWriter into the DBF file according to the DBF format requirements, and then generate a DBF file.
[0142] 306. Output a second object; wherein the second object is a DBF file.
[0143] For example, after obtaining the DBF file based on the DBFWriter class in the JavaDBF tool, the DBF file can be output.
[0144] 307. In response to the opening instruction, display the configuration information in a table form on the interface; in response to the user's modification instruction, modify the information indicated by the modification instruction in the configuration information, and save the modified configuration information.
[0145] Exemplarily, a function of modifying configuration information is provided. An interface is provided, and the user can operate on the interface and then input an opening instruction, which is used to instruct to display the configuration information; then the electronic device displays the configuration information in a table based on the user's opening instruction. Thus, the user can view all the information in the configuration information, see Table 1.
[0146] The user can directly modify the information in the displayed configuration information. The user directly operates the input interface (the input interface is, for example, a keyboard or a touch screen) to input a modification instruction, and then the electronic device modifies the information indicated by the modification instruction, thereby modifying the configuration information and saving the modified configuration information. The modified configuration information is used for the next conversion.
[0147] For example, when converting a Java object list to a DBF file, if the requirements of the DBF file to be generated have changed, for example, the internal format of the DBF file to be generated has changed (for example, the date format of the DBF format file has changed), the column order of the DBF file needs to be adjusted (for example, the first column of the DBF file is the submission time, but now, the second column of the DBF file is the submission time), the length of a column of the DBF file has changed, the columns required by the DBF file have been reduced, and the class attributes in the Java object need to be output to the new DBF column, then the information in the configuration information needs to be adjusted. Then, according to step 307, the configuration information can be maintained and adjusted through the interface, and the configuration information can be intuitively displayed to the staff, and the configuration information can be modified in real time according to the requirements, and the modified configuration information can be directly displayed to the staff; then, based on the modified configuration information, the conversion between the Java object list and the DBF file is performed. There is no need to write code or modify the system to complete the conversion between the Java object list and the DBF file.
[0148] For another example, when converting a DBF file to a Java object list, if the requirements of the DBF file to be generated have changed, for example, the internal format of the DBF file to be generated has changed (for example, the date format of the DBF format file has changed), the column order of the DBF file needs to be adjusted (for example, the first column of the DBF file is the submission time, but now, the second column of the DBF file is the submission time), the length of a column of the DBF file has changed, the columns required by the DBF file have been reduced, and the value of a column in the DBF file needs to be stored in the existing class attributes of the Java object, then the information in the configuration information needs to be adjusted. Then, according to step 307, the configuration information can be maintained and adjusted through the interface, and the configuration information can be intuitively displayed to the staff, and the configuration information can be modified in real time according to the requirements, and the modified configuration information can be directly displayed to the staff; then, based on the modified configuration information, the conversion between the Java object list and the DBF file is performed. There is no need to write code or modify the system to complete the conversion between the Java object list and the DBF file.
[0149] In this embodiment, based on the above embodiment, there is no need to write interfaces or parse landing tables, and the configuration information can be quickly and dynamically modified, so that the conversion between the Java object list and the DBF file can be quickly completed, and business needs can be responded to in a timely manner. In addition, based on the reflection mechanism and configuration information, the Java object list is converted into a DBF file; in the conversion process, according to the format conversion method between different data format categories and DBF data, the attribute value of the class attribute under the class attribute name is converted into a string of column information corresponding to the class attribute name; then, the DBF file is obtained based on the obtained string. The data in the Java object list can be converted into data that meets the format requirements of the DBF file, supporting Java common data types and DBF file common field formats. In addition, the configuration information can be intuitively displayed to the staff, and the configuration information can be modified in real time according to the needs, and the modified configuration information can be directly displayed to the staff; then, based on the modified configuration information, the conversion between the Java object list and the DBF file is performed. There is no need to write code or modify the system to complete the conversion between the Java object list and the DBF file.
[0150] Figure 4 A flowchart of another method for converting a Java object list and a DBF file provided in an embodiment of the present application is shown as follows: Figure 4 As shown, the method includes:
[0151] 401. Obtain a first object to be processed, wherein the first object involves multiple first data; the first object is a DBF file, and the first data is data of column information.
[0152] In one example, step 401 includes: reading the first object based on the DBFReader class in the JavaDBF tool.
[0153] For example, when a DBF file needs to be converted into a Java object list, a DBF file to be processed is obtained, wherein the DBF file includes information of each column of each row. The DBFReader class in the JavaDBF tool can be used to read the DBF file; wherein the DBFReader class in the JavaDBF tool provides a function of reading a DBF file.
[0154] Then, the configuration information can be loaded. In one example, the configuration information can be loaded according to the processing object type code and the conversion type code passed in by the business processing context; wherein each row of information in the configuration information is arranged in ascending order according to the column number. In this embodiment, since it is necessary to convert the Java object list into a DBF file, the configuration information can only include data with a conversion type code of 02. For example, as shown in Table 1, only data of each row with class numbers 1 to 5 and a conversion type code of 02 can be included.
[0155] Furthermore, the format and data of the configuration information can be modified dynamically to meet the requirements of the current Java object list and the DBF file to be generated.
[0156] 402. Determine the full path class name of the object class in the Java object list corresponding to each row in the first object based on the column information in each row in the first object and the configuration information, and determine the full path class name of the object class in the Java object list corresponding to each row in the first object, and establish a Java object corresponding to each row in the first object.
[0157] Exemplarily, according to the full path class name of the object class in the Java object list in the configuration information, the Class.forName() method is called to obtain the class object cls corresponding to the full path class name of the object class in the Java object list. Then, according to the path of the DBF file to be converted introduced by the business context, a file object of the File type is established. Then, according to the file input stream of the file object, a DBFReader object is established, and the DBFReader object contains the file header record and the file data record related operation interface, and then the number of rows of the DBF file and the file data record content are obtained.
[0158] In this implementation, the DBF file needs to be converted into a Java object list, so it is necessary to first determine the full path class name of the object class in the Java object list corresponding to each line in the DBF file based on the column information of each line in the DBF file and the configuration information. This is because each line in the DBF file corresponds to each Java object in the Java object list; the Java object has the full path class name of the object class in the Java object list. Thus, an empty Java object corresponding to each line in the DBF file can be established; the Java object is of Object type, and the method cls.newInstance() can be used to establish an empty Java object.
[0159] 403. For each row in the first object, determine the class attribute name corresponding to the column information in the row according to the configuration information. The configuration information represents the correspondence between the class attribute of the Java object in the Java object list and the column information of the DBF file.
[0160] Exemplarily, for each row of the DBF file, the class attribute name corresponding to the column information in the row is determined according to the configuration information. Each column information of each row corresponds to each class attribute name.
[0161] 404. For each column of information in each row of the first object, according to the data format category corresponding to the class attribute name and the format conversion method between DBF data, convert the character string of each column of information in each row into the attribute value under each class attribute name corresponding to each column of information in each row.
[0162] Exemplarily, a DBF file is read, and a file data record Object[]record is used to record data of a row in the DBF file, and each array element is used to represent each column of data in a row.
[0163] For each row in a DBF file, the row has multiple columns of information, and then according to the configuration information, the class attribute under the class attribute name corresponding to the column information is determined; because each class attribute name has a corresponding data format category, and the DBF file is a character file (character type can be called DBF data), it is necessary to convert the characters of each column of information in the row into the attribute value of the class attribute under the class attribute name corresponding to each column of information according to the data format category corresponding to the class attribute name and the format conversion method between DBF data. Among them, each class attribute name corresponds to each class attribute.
[0164] In one example, for each row in a DBF file, the row has multiple columns of information, and each row of the DBF file can be looped through, and the following process can be performed for each row. For each row in the DBF file, in the above process of reading the DBF file, each row of the DBF file has been recorded in the file data record Object[]record; then, the information in a row in the configuration information can be obtained first, and then, according to the column sequence number in the configuration information, the string of each column of information in a row of the DBF file in the file data record Object[]record can be read; then, the class attribute name corresponding to each column of information in the row in the configuration information has been determined, and then the reflection mechanism is used to obtain the data format category of the class attribute under the class attribute name (the data format category is the Java type in Table 2); then, according to the format conversion method between different data format categories and DBF data, the string of each column of information in the row is converted into the attribute value of the class attribute under the class attribute name corresponding to each column of information in the row;. For each row of the DBF file, after converting the string of each column of information in the row, the attribute value of the class attribute under each class attribute name corresponding to the row is obtained. By using the above method for each line of the DBF file, the data in the DBF file can be converted into data that meets the format requirements of the Java object list.
[0165] 405. Generate a second object according to the attribute value under each type of attribute name corresponding to each column of information in each row.
[0166] In one example, step 405 includes: for each row of the first object, putting the attribute value under each type of attribute name corresponding to each column information in each row into the class attribute of the Java object corresponding to each row in the first object to generate the second object. The data of the class attribute of the Java object is the second data.
[0167] Exemplarily, for each row in the DBF file, the attribute value obtained in step 404 needs to be assigned to a Java object, thereby obtaining a Java object list.
[0168] In one example, for each row of a DBF file, the attribute values of the class attributes under the class attribute names corresponding to the row are recorded in an array, and then the reflection mechanism can be used to assign each element in the array (i.e., the attribute values of each attribute) to each attribute of a Java object, thereby obtaining a Java object corresponding to the row. The obtained Java object is then added to a Java object list to generate a Java object list, which includes multiple Java objects.
[0169] 406. Output a second object; wherein the second object is a Java object list.
[0170] Exemplarily, based on obtaining the Java object list, the Java object list may be output, where the Java object list includes at least one Java object.
[0171] 407. In response to the opening instruction, display the configuration information in a table form on the interface; in response to the user's modification instruction, modify the information indicated by the modification instruction in the configuration information, and save the modified configuration information.
[0172] Exemplarily, this step may refer to the above step 307 and will not be described in detail.
[0173] In this embodiment, based on the above embodiment, there is no need to write interfaces or parse landing tables, and the configuration information can be quickly and dynamically modified, so that the conversion between the Java object list and the DBF file can be quickly completed, and the business needs can be responded to in time. In addition, based on the reflection mechanism and configuration information, the DBF file is converted into a Java object list; in the conversion process, for each row of the DBF file, according to the format conversion method between different data format categories and DBF data, the characters of each column of information in the row of the DBF file are converted into the attribute value of the class attribute under the class attribute name corresponding to each column of information; then, based on the obtained attribute value, a Java object is generated; each Java object is added to the Java object list to generate a Java object list. The data in the DBF file can be converted into data in the Java object list that meets the requirements of the Java object, supporting Java common data types and DBF file common field formats. In addition, the configuration information can be intuitively displayed to the staff, and the configuration information can be modified in real time according to the needs, and the modified configuration information can be directly displayed to the staff; then, based on the modified configuration information, the conversion of the Java object list and the DBF file is performed. There is no need to write code or modify the system to complete the conversion of the Java object list and the DBF file.
[0174] Figure 5 A schematic diagram of a conversion device between a Java object list and a DBF file provided in an embodiment of the present application is shown in FIG. Figure 5 As shown, the device comprises:
[0175] The acquisition unit 51 is configured to acquire a first object to be processed, wherein the first object involves a plurality of first data.
[0176] The determining unit 52 is configured to determine second data corresponding to each first data in the first object according to the configuration information, wherein the configuration information represents the correspondence between the class attributes of the Java object in the Java object list and the column information of the DBF file.
[0177] The generating unit 53 is configured to generate a second object according to the second data.
[0178] The output unit 54 is used to output the second object; wherein, if the first object is a Java object list, and the Java object list includes at least one Java object, the second object is a DBF file, the first data is the data of the class attribute of the Java object in the Java object list, and the second data is the data of the column information; if the first object is a DBF file, the second object is a Java object list, the first data is the data of the column information, and the second data is the data of the class attribute of the Java object in the Java object list.
[0179] For example, this embodiment can refer to the above method embodiment, and its principles and technical effects are similar and will not be described in detail.
[0180] Figure 6 A schematic diagram of another structure of a device for converting a Java object list and a DBF file provided in an embodiment of the present application, Figure 5 Based on the embodiment shown, Figure 6 As shown, the class attributes include the class attribute name; the column information includes the column name, column data type, column length, column format, column description and column sequence number; if the first object is a DBF file, the class attributes also include the full path class name of the object class in the Java object list; the configuration information also includes the processing object type code, the processing object type name and the conversion type code.
[0181] In an example, if the first object is a Java object list, the determining unit 52 is specifically configured to: determine, for each Java object in the first object, column information corresponding to each type of attribute name of the object according to the configuration information.
[0182] The generating unit 53 includes:
[0183] The first conversion module 531 is used to convert the attribute value under each class attribute name in the Java object into a character string of column information corresponding to each class attribute name of the Java object according to the data format category corresponding to the class attribute name and the format conversion method between DBF data for each Java object in the first object.
[0184] The first generating module 532 is used to generate a second object according to the character string of the column information corresponding to each type of attribute name of each Java object.
[0185] In one example, the device provided by this embodiment further includes:
[0186] The first establishing unit is used to establish a column array of the second object in DBF format and establish a column object in each column array before the generating unit 53 generates the second object according to the second data.
[0187] The first generating module 532 is specifically used to put the character string of column information corresponding to each type of attribute name of each Java object into the column object corresponding to the column information in the column array corresponding to each Java object, so as to generate a second object.
[0188] In an example, if the first object is a DBF file, the determining unit 52 is specifically configured to: for each row in the first object, determine the class attribute name corresponding to the column information in the row according to the configuration information.
[0189] The generating unit 53 includes:
[0190] The second conversion module 533 is used to convert the character string of each column of information in each row of the first object into the attribute value under each class attribute name corresponding to each column of information in each row according to the data format category corresponding to the class attribute name and the format conversion method between DBF data.
[0191] The second generating module 534 is used to generate a second object according to the attribute value under each type of attribute name corresponding to each column of information in each row.
[0192] In one example, the device provided by this embodiment further includes:
[0193] The second establishing unit is used to determine the full path class name of the object class in the Java object list corresponding to each row in the first object based on the column information in each row in the first object and the configuration information before the generating unit 53 generates the second object based on the second data, and determine the full path class name of the object class in the Java object list corresponding to each row in the first object, and establish a Java object corresponding to each row in the first object.
[0194] The second generation module 534 is specifically used to: for each row of the first object, put the attribute value under each type of attribute name corresponding to each column information in each row into the class attribute of the Java object corresponding to each row in the first object to generate a second object.
[0195] In an example, if the first object is a Java object list, the generating unit 53 is specifically used to generate the second object based on the DBFWriter class in the JavaDBF tool when generating the second object.
[0196] If the first object is a DBF file, the acquiring unit 51 is specifically configured to read the first object based on the DBFReader class in the JavaDBF tool.
[0197] In one example, the device provided by this embodiment further includes:
[0198] The display unit 61 is used to display the configuration information in a table form on the interface in response to the opening instruction.
[0199] The modification unit 62 is used to modify the information indicated by the modification instruction in the configuration information in response to the modification instruction of the user, and save the modified configuration information.
[0200] For example, this embodiment can refer to the above method embodiment, and its principles and technical effects are similar and will not be described in detail.
[0201] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown in FIG. Figure 7 As shown, the electronic device includes: a memory 71, a processor 72;
[0202] Memory 71; a memory for storing instructions executable by the processor 72;
[0203] The processor 72 is configured to execute the method provided in the above embodiment.
[0204] The electronic device further includes a receiver 73 and a transmitter 74. The receiver 73 is used to receive instructions and data sent by an external device, and the transmitter 74 is used to send instructions and data to the external device.
[0205] Figure 8 It is a block diagram of an electronic device according to an exemplary embodiment, which device may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0206] The device 800 may include one or more of the following components: a processing component 802 , a memory 804 , a power component 806 , a multimedia component 808 , an audio component 810 , an input / output (I / O) interface 812 , a sensor component 814 , and a communication component 816 .
[0207] The processing component 802 generally controls the overall operation of the device 800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 802 may include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.
[0208] The memory 804 is configured to store various types of data to support operations on the device 800. Examples of such data include instructions for any application or method operating on the device 800, contact data, phone book data, messages, pictures, videos, etc. The memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0209] The power supply component 806 provides power to the various components of the device 800. The power supply component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 800.
[0210] The multimedia component 808 includes a screen that provides an output interface between the device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0211] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC), and when the device 800 is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 804 or sent via the communication component 816. In some embodiments, the audio component 810 also includes a speaker for outputting audio signals.
[0212] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: home button, volume button, start button, and lock button.
[0213] The sensor assembly 814 includes one or more sensors for providing various aspects of status assessment for the device 800. For example, the sensor assembly 814 can detect the open / closed state of the device 800, the relative positioning of components, such as the display and keypad of the device 800, the sensor assembly 814 can also detect the position change of the device 800 or a component of the device 800, the presence or absence of user contact with the device 800, the orientation or acceleration / deceleration of the device 800 and the temperature change of the device 800. The sensor assembly 814 can include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 814 can also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 can also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor or a temperature sensor.
[0214] The communication component 816 is configured to facilitate wired or wireless communication between the device 800 and other devices. The device 800 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0215] In an exemplary embodiment, the apparatus 800 may be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to perform the above method.
[0216] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, and the instructions can be executed by the processor 820 of the device 800 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0217] A non-transitory computer-readable storage medium, when the instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to perform the above method.
[0218] An embodiment of the present application also provides a computer program product, which includes: a computer program, which is stored in a readable storage medium, and at least one processor of an electronic device can read the computer program from the readable storage medium, and at least one processor executes the computer program so that the electronic device executes the solution provided by any of the above embodiments.
[0219] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0220] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A method for converting a Java object list and a DBF file, characterized in that: The method comprises: Acquire a first object to be processed, wherein the first object involves a plurality of first data; Determine, according to configuration information, a correspondence between class attributes of a Java object in a Java object list and column information of a DBF file, second data corresponding to each first data in the first object; Generate a second object according to the second data, and output the second object; Wherein, if the first object is a Java object list, and the Java object list includes at least one Java object, the second object is a DBF file, the first data is the data of the class attribute of the Java object in the Java object list, and the second data is the data of the column information; if the first object is a DBF file, the second object is a Java object list, the first data is the data of the column information, and the second data is the data of the class attribute of the Java object in the Java object list; If the first object is a Java object list, determining, according to the configuration information, second data corresponding to each first data in the first object, including: for each Java object in the first object, determining, according to the configuration information, column information corresponding to each type of attribute name of the object; Generating a second object according to the second data includes: For each Java object in the first object, according to the data format category corresponding to the class attribute name and the format conversion method between DBF data, the attribute value under each class attribute name in the Java object is converted into a character string of column information corresponding to each class attribute name of the Java object; The character string of column information corresponding to each type of attribute name of each Java object is placed into the column object corresponding to the column information in the column array corresponding to each Java object to generate a second object.
2. The method according to claim 1, characterized in that The class attribute includes a class attribute name; the column information includes a column name, a column data type, a column length, a column format, a column description, and a column sequence number; if the first object is a DBF file, the class attribute also includes a full path class name of an object class in a Java object list; The configuration information also includes a processing object type code, a processing object type name, and a conversion type code.
3. The method according to claim 1, characterized in that Before generating the second object according to the second data, the method further includes: establishing a column array of the second object in DBF format, and establishing a column object in each column array.
4. The method according to claim 2, characterized in that: If the first object is a DBF file, determining second data corresponding to each first data in the first object according to the configuration information includes: for each row in the first object, determining a class attribute name corresponding to column information in the row according to the configuration information; Generating a second object according to the second data includes: For each column of information in each row of the first object, according to the data format category corresponding to the class attribute name and the format conversion method between DBF data, convert the character string of each column of information in each row into the attribute value under each class attribute name corresponding to each column of information in each row; A second object is generated according to the attribute values under each type of attribute name corresponding to each column of information in each row.
5. The method according to claim 4, characterized in that Before generating the second object according to the second data, the method further includes: determining the full path class name of the object class in the Java object list corresponding to each row in the first object according to the column information in each row in the first object and the configuration information, and determining the full path class name of the object class in the Java object list corresponding to each row in the first object, and establishing a Java object corresponding to each row in the first object; Generate a second object according to the attribute value under each type of attribute name corresponding to each column of information in each row, including: For each row of the first object, the attribute value under each type of attribute name corresponding to each column of information in each row is placed into the class attribute of the Java object corresponding to each row in the first object to generate a second object.
6. The method according to any one of claims 1 to 5, characterized in that: If the first object is a Java object list, generating a second object includes: generating the second object based on a DBFWriter class in a JavaDBF tool; If the first object is a DBF file, obtaining the first object to be processed includes: reading the first object based on the DBFReader class in the JavaDBF tool.
7. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: In response to the opening instruction, displaying the configuration information in a table form on the interface; In response to a modification instruction from a user, the information indicated by the modification instruction in the configuration information is modified, and the modified configuration information is saved.
8. A device for converting a Java object list and a DBF file, characterized in that: The device comprises: An acquiring unit, configured to acquire a first object to be processed, wherein the first object involves a plurality of first data; A determining unit, configured to determine second data corresponding to each first data in the first object according to configuration information representing a correspondence between a class attribute of a Java object in a Java object list and column information of a DBF file; A generating unit, configured to generate a second object according to the second data; an output unit, configured to output the second object; Wherein, if the first object is a Java object list, and the Java object list includes at least one Java object, the second object is a DBF file, the first data is the data of the class attribute of the Java object in the Java object list, and the second data is the data of the column information; if the first object is a DBF file, the second object is a Java object list, the first data is the data of the column information, and the second data is the data of the class attribute of the Java object in the Java object list; If the first object is a Java object list, the determining unit is specifically configured to determine, for each Java object in the first object, column information corresponding to each type of attribute name of the object according to the configuration information; The generating unit is specifically configured to convert, for each Java object in the first object, the attribute value under each class attribute name in the Java object into a character string of column information corresponding to each class attribute name of the Java object according to the data format category corresponding to the class attribute name and the format conversion method between the DBF data; and put the character string of column information corresponding to each class attribute name of each Java object into a column object corresponding to the column information in the column array corresponding to each Java object, so as to generate a second object.
9. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 7 when executed by a processor.
11. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 7 when being executed by a processor.
Citation Information
Patent Citations
File processing method and device, equipment and computer readable storage medium
CN110457260A