CN116737122A - Processing method, processing device, terminal equipment and medium - Google Patents

Processing method, processing device, terminal equipment and medium Download PDF

Info

Publication number
CN116737122A
CN116737122A CN202210195642.6A CN202210195642A CN116737122A CN 116737122 A CN116737122 A CN 116737122A CN 202210195642 A CN202210195642 A CN 202210195642A CN 116737122 A CN116737122 A CN 116737122A
Authority
CN
China
Prior art keywords
class
processing
packing
determining
information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210195642.6A
Other languages
Chinese (zh)
Inventor
贺宇成
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Zitiao Network Technology Co Ltd
Original Assignee
Beijing Zitiao Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Zitiao Network Technology Co Ltd filed Critical Beijing Zitiao Network Technology Co Ltd
Priority to CN202210195642.6A priority Critical patent/CN116737122A/en
Publication of CN116737122A publication Critical patent/CN116737122A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Computer Security & Cryptography (AREA)
  • Stored Programmes (AREA)

Abstract

The disclosure discloses a processing method, a processing device, terminal equipment and a medium. The method comprises the following steps: according to the obtained target class, determining a related class related to the target class; determining whether the related class has packaging capability; if not, generating parameters required by the related class to realize the packing capacity; the information to be processed is processed based on the generated required parameters, and the processing includes serialization processing or deserialization processing. According to the method, the related class related to the acquired target class is determined, the parameters required for realizing the packing capacity are generated for the related class without the packing capacity, and the information to be processed is processed in a serialization or anti-serialization mode based on the parameters, so that the time-consuming condition of the processing process caused by the complex structure of the incoming class can be avoided, and the processing efficiency is effectively improved.

Description

Processing method, processing device, terminal equipment and medium
Technical Field
The embodiment of the disclosure relates to the technical field of computers, in particular to a processing method, a processing device, terminal equipment and a medium.
Background
Serialization and deserialization are one means commonly used in applications to store and transmit data. For example, common serialization and deserialization application scenarios may be: data transfer in network requests, object local persistence, etc. Among them, json (JavaScript Object Notation, which may be referred to as an object representation) is a commonly used data format for serialization and deserialization.
Currently, the Gson framework is used in most applications to sequence or de-sequence Json data. The Gson framework is designed to reflect according to the class (class) before the actual serialization or deserialization operation to obtain the mapping relation of the current class. However, if the structure of the current class is complex, it may result in a time consuming actual serialization or deserialization process.
Disclosure of Invention
The embodiment of the disclosure provides a processing method, a processing device, terminal equipment and a medium, so as to improve the efficiency of data processing.
In a first aspect, an embodiment of the present disclosure provides a processing method, including:
according to the obtained target class, determining a related class related to the target class;
determining whether the related class has packaging capability;
if not, generating parameters required by the related class to realize the packing capacity;
the information to be processed is processed based on the generated required parameters, and the processing includes serialization processing or deserialization processing.
In a second aspect, embodiments of the present disclosure further provide a processing apparatus, including:
the first determining module is used for determining a related class related to the target class according to the acquired target class;
A second determining module, configured to determine whether the related class has a packing capability;
the parameter generation module is used for generating parameters required by the related class to realize the packing capacity if not;
and the first processing module is used for processing the information to be processed based on the generated required parameters, wherein the processing comprises serialization processing or deserialization processing.
In a third aspect, an embodiment of the present disclosure further provides a terminal device, including:
one or more processing devices;
a storage means for storing one or more programs;
the one or more programs are executed by the one or more processing devices, so that the one or more processing devices implement the processing methods provided by the embodiments of the present disclosure.
In a fourth aspect, the embodiments of the present disclosure further provide a computer readable medium having stored thereon a computer program which, when executed by a processing device, implements the processing method provided by the embodiments of the present disclosure.
The embodiment of the disclosure provides a processing method, a processing device, terminal equipment and a medium, wherein the processing method, the processing device, the terminal equipment and the medium are used for determining a related class related to an object class according to the acquired object class; then determining whether the related class has packing capability; if not, generating parameters required by the related class to realize the packing capacity; finally, the information to be processed is processed based on the generated required parameters, and the processing comprises serialization processing or deserialization processing. According to the method, the related class related to the acquired target class is determined, the parameters required for realizing the packing capacity are generated for the related class without the packing capacity, and the serialization or the reverse serialization processing is performed based on the parameters, so that the time-consuming condition of the processing process caused by the complex structure of the incoming class can be avoided, and the processing efficiency is effectively improved.
Drawings
The above and other features, advantages, and aspects of embodiments of the present disclosure will become more apparent by reference to the following detailed description when taken in conjunction with the accompanying drawings. The same or similar reference numbers will be used throughout the drawings to refer to the same or like elements. It should be understood that the figures are schematic and that elements and components are not necessarily drawn to scale.
Fig. 1 is a schematic flow chart of a processing method according to a first embodiment of the disclosure;
fig. 2 is a schematic flow chart of a processing method according to a second embodiment of the disclosure;
FIG. 3 is a schematic diagram of an implementation of determining a correlation class according to a second embodiment of the present invention;
fig. 4 is a schematic implementation diagram of a Parcelable interface and related methods according to a second embodiment of the present invention;
fig. 5 is a schematic diagram of a mapping relationship according to a second embodiment of the present invention;
fig. 6 is a schematic structural diagram of a processing device according to a third embodiment of the disclosure;
fig. 7 is a schematic structural diagram of a terminal device according to a fourth embodiment of the present disclosure.
Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure have been shown in the accompanying drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustration purposes only and are not intended to limit the scope of the present disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order and/or performed in parallel. Furthermore, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "including" and variations thereof as used herein are intended to be open-ended, i.e., including, but not limited to. The term "based on" is based at least in part on. The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments. Related definitions of other terms will be given in the description below.
It should be noted that the terms "first," "second," and the like in this disclosure are merely used to distinguish between different devices, modules, or units and are not used to define an order or interdependence of functions performed by the devices, modules, or units.
It should be noted that references to "one", "a plurality" and "a plurality" in this disclosure are intended to be illustrative rather than limiting, and those of ordinary skill in the art will appreciate that "one or more" is intended to be understood as "one or more" unless the context clearly indicates otherwise.
The names of messages or information interacted between the various devices in the embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
In the following embodiments, optional features and examples are provided in each embodiment at the same time, and the features described in the embodiments may be combined to form multiple alternatives, and each numbered embodiment should not be considered as only one technical solution. Furthermore, embodiments of the present disclosure and features of embodiments may be combined with each other without conflict.
Example 1
Fig. 1 is a flow chart of a processing method provided in a first embodiment of the disclosure, where the method may be applicable to a case of processing information to be processed, and the method may be performed by a processing apparatus, where the apparatus may be implemented by software and/or hardware and is generally integrated on a terminal device, and in this embodiment, the terminal device includes but is not limited to: computers, notebook computers, smart phones, tablet computers, and the like.
As shown in fig. 1, a processing method provided in a first embodiment of the present disclosure includes the following steps:
s110, determining a related class related to the target class according to the acquired target class.
In this embodiment, a class may be understood as a type of user-defined reference data, which may also be referred to as a class type, may be represented by class, and may also be referred to as a type. The target class may be understood as a root class in the class library used; specifically, the relationships between all classes included in the class library may correspond to an overall mapping relationship, a root class may refer to a root node pointed by all other classes in the overall mapping relationship, and the root class may be represented as a root class. How the target class is obtained is not limited here, and for example, the corresponding root class may be obtained in a Gradle plugin by utilizing the capability of a compile (transform) byte of Gradle (Gradle may refer to a plugin that packages reusable build logic).
In the overall mapping relation corresponding to the target class, the target class is used as a root node to be connected with a plurality of sub-nodes, and each sub-node is respectively connected with other sub-nodes, so that a mapping relation similar to a network is formed. The related class may be understood as a child node which is associated with the root node of the target class and can be serialized or de-serialized as determined from the overall mapping relation according to the acquired target class.
How the correlation class is determined is not limited herein and may be determined based on actual circumstances of serialization or deserialization. And if the non-system class in the mapping relation corresponding to the target class is determined to be the related class of the target class.
Optionally, determining, according to the obtained target class, a related class related to the target class includes: obtaining a target class; determining a next class based on the attribute list of the target class; when the next class is a class in the application program and is not traversed, recording the next class and taking the next class as a new target class to continue to execute the operation of determining the next class based on the attribute list of the target class until all classes related to the target class are traversed; and taking the recorded next class as a related class related to the target class after traversing.
The attribute list can be understood as a list formed by taking a target class as a root node and connecting the target class with the root node in the whole mapping relation; an attribute may be understood as a type of data that describes characteristics of a target class. From the obtained target class, the specific process of determining the related class related to the target class may be: firstly, obtaining a target class, and determining the next class connected with the target class in an attribute list based on the attribute list of the target class; it will be appreciated that the next class in the attribute list associated with the target class may be multiple, each requiring traversal. Then, determining whether the next class is a class in the application program, if so, determining whether the next class is traversed before, and if not, recording the next class as a related class; and continuing to execute the operation of determining the next class based on the attribute list of the target class by taking the next class as the new target class until all classes related to the target class are traversed. Finally, all the next classes recorded are used as related classes related to the target class after the traversing is completed.
S120, determining whether the related class has packing capability, and if not, executing S130.
In this embodiment, the package may be denoted as Parcel, which may be understood as a container for packaging and storing data, and is a method for implementing a binary sequence serialization protocol; on this basis, the packing capability is understood to be a capability with a packing function. Determining whether the related classes have packing capabilities may be by determining whether each related class has a packing interface; and/or determining whether the method list corresponding to each related class lacks method information of a method required for realizing the packaging capability. The method information can be understood as byte code information corresponding to a method required for realizing the packing capability.
Optionally, determining whether the related class has packing capability includes: determining whether the current class in the related classes has a packing interface; and/or determining whether the method list of the current class lacks method information of a method required to implement the packaging capability.
The package interface may be referred to as a Parcelable interface, which is understood to be an interface that defines writing data to and reading data from the package. In addition to the basic class, only classes that implement the Parcelable interface can be put into Parcel. A method list may be understood as a list for storing the methods needed for the relevant class to implement the packing capability. It can be understood that if the method information of the method required for realizing the packing capability is missing in the method list of the related class, it can be indicated that the related class cannot realize the packing capability according to the method list of the missing method information.
The process of determining whether the related class has packing capability may be: may be determined by determining whether a current one of the related classes has a packing interface; for example, all the determined related classes are traversed, whether the current class has a packing interface is judged, and if the current class does not have the packing interface, the related class can be indicated to have no packing capability. Alternatively, it may be determined by determining whether the method list of the current class lacks method information of a method required to implement the packing capability; for example, traversing all the determined related classes, judging whether the method information of the method required by realizing the packing capability is missing in the method list of the current class, if so, determining that the current class does not have the packing capability. Or, the method information of the method required by realizing the packing capability is deleted or not according to whether the current class in the related classes has a packing interface or not and whether the method list lacks the method information of the method required by realizing the packing capability or not; for example, traversing all the determined related classes, judging whether the current class has a packing interface and whether the method list lacks method information of a method required for realizing the packing capability, if the current class has the packing interface and the method list does not lack method information of the method required for realizing the packing capability, determining that the current class has the packing capability, otherwise, the current class does not have the packing capability.
S130, generating parameters required by the related class to realize the packing capability.
In this embodiment, if the related class does not have the packing capability, parameters required by the related class to implement the packing capability may be generated, for example, parameters required by the related class to implement the packing capability may be generated according to method information of a method required by the packing capability implemented by the missing packing interface and/or method list.
Optionally, generating parameters required by the related class to realize the packing capability includes: if the current class does not have the packing interface, injecting byte codes for realizing the packing interface for the current class; and/or generating parameters required by the related class to realize the packing capability, including: converting the attribute list of the current class into a required data structure; determining method information of a method which is missing from a current method list and is required by the realization of packaging capacity, wherein the current method list is a current class of method list; and generating a method for realizing the missing packing capability according to the method information and the converted attribute list.
The process of generating parameters required by the related class to realize the packing capability can comprise three cases:
in the first case, traversing all related classes, and if the current class does not have a packing interface in the traversing process, indicating that the current class does not have packing capability; in this case, the byte code implementing the packing interface may be injected for the current class, and the byte code implementing the packing interface may be considered as a parameter required for the generated related class to implement the packing capability. The byte code may refer to a binary file comprising a sequence of operation code (op) code/data pairs, which is an intermediate code, including an executable program.
In the second case, traversing all relevant classes, and if method information of a method required for realizing the packing capability is missing in a method list of the current class in the traversing process, indicating that the current class does not have the packing capability; in this case, the list of attributes of the current class may be converted into a desired data structure, which may be understood as a collection of data elements that have one or more specific relationships with each other; determining the missing method information of the method required by realizing the packing capability in the method list of the current class; and generating a method for realizing the missing packing capability according to the method information and the converted attribute list. The converted attribute list may be understood as an attribute list after converting the attributes of the attribute list into a desired data structure. The method of how the missing capability of achieving packaging is generated from the method information and the converted attribute list is not limited here.
And traversing all related classes, wherein in the traversing process, if the current class does not have a packaging interface and a method list of the current class lacks method information of a method required by realizing packaging capability, the current class can be indicated to not have the packaging capability. In this case, bytecodes implementing the packing interface may be injected for the current class; on this basis, the attribute list of the current class can be converted into a required data structure; determining method information of a method which is missing from a method list of the current class and is required by realizing packaging capability; and generating a method for realizing the missing packing capability according to the method information and the converted attribute list. The byte code for realizing the packing interface and the method for realizing the missing packing capability can be regarded as parameters required by the generated related class for realizing the packing capability.
And S140, processing the information to be processed based on the generated required parameters, wherein the processing comprises serialization processing or anti-serialization processing.
In this embodiment, the information to be processed is processed based on the parameters required for realizing the packing capability of the generated related class. The processing may include a serialization process or an anti-serialization process. The information to be processed may refer to information to be processed. Where each class contains a data specification and a set of functions that manipulate data or transfer messages, an instance of a class may be referred to as an object. Serialization processing may refer to the process of converting an object into a form of data that can be stored or transmitted; the form of data that can be stored or transmitted may refer to a sequence of binary bytes. The deserialization process corresponds to a serialization process, which may refer to a process of restoring a storable or transmittable form of data to an object. There is no limitation here as to how the information to be processed is processed based on the generated required parameters. It is understood that the information to be processed corresponding to the serialization process and the deserialization process may be different; for example, in the case of serialization processing, the information to be processed is an object; in the process of deserialization, the information to be processed is data which can be stored or transmitted.
According to the processing method provided by the first embodiment of the disclosure, firstly, according to the obtained target class, determining a related class related to the target class; then determining whether the related class has packing capability; if not, generating parameters required by the related class to realize the packing capacity; finally, the information to be processed is processed based on the generated required parameters, and the processing comprises serialization processing or deserialization processing. According to the method, the related class related to the acquired target class is determined, the parameters required for realizing the packing capacity are generated for the related class without the packing capacity, and the information to be processed is processed in a serialization or anti-serialization mode based on the parameters, so that the time-consuming condition of the processing process caused by the complex structure of the incoming class can be avoided, and the processing efficiency is effectively improved.
Example two
Fig. 2 is a schematic flow chart of a processing method according to a second embodiment of the present disclosure, where the second embodiment is implemented based on each of the alternatives in the foregoing embodiments. In the present embodiment, processing procedures before and after application program upgrade are specifically described. For details not yet described in detail in this embodiment, refer to embodiment one.
Since parcel is a binary sequential serialization protocol implementation method, the architecture cannot be guaranteed, and thus compatibility problems may exist after each application upgrade. Therefore, the present embodiment proposes a processing method, in which the data is serialized by using the parcel and Gson at the same time, and in the case of reverse serialization, the parcel is preferentially used to perform the reverse serialization processing, and if the parcel has a compatibility problem, the method can be returned to the reverse serialization mode of Gson.
As shown in fig. 2, a processing method provided in a second embodiment of the disclosure includes the following steps:
s210, serializing the data through packing and Gson modes.
In this embodiment, the Gson method is understood as a framework method that can be used for the serialization and deserialization conversion processes. The data may be serialized first by packing and Gson. There is no limitation here on how the data can be serialized by packing and Gson. The data may refer to Json data.
S220, determining whether the application program version is upgraded, and if not, executing S230; if yes, then S270 is performed.
In this embodiment, whether the corresponding application version is updated is determined, and if no update is performed, it may be indicated that the version compatibility problem does not occur when the package is adopted for the deserialization; in this case, S230 may be performed, that is, the related class operation of determining the related class to the target class according to the acquired target class is continued. If the version is updated, the version compatibility problem can be possibly caused by adopting packaging for deserialization; in this case, S270, that is, the deserialization process by the Gson method may be performed.
S230, according to the obtained target class, determining a related class related to the target class.
In this embodiment, after determining that the application is not upgraded, the deserialization may be performed using packaging. First, a related class related to the target class may be determined according to the acquired target class. Specifically, a target class may be obtained; determining a next class based on the attribute list of the target class; when the next class is a class in the application program and is not traversed, recording the next class and taking the next class as a new target class to continue to execute the operation of determining the next class based on the attribute list of the target class until all classes related to the target class are traversed; the next class recorded after the traversal is completed is taken as the related class related to the target class.
S240, determining whether the related class has packing capability, and if not, executing S250.
In this embodiment, after determining the related class related to the target class, it may be determined whether the related class has packing capability. Whether the related class has packing capability may be determined by determining whether the current class has a packing interface and/or determining whether a method list of the current class lacks method information of a method required to implement the packing capability.
If the related class has packing capability, it can be processed directly, such as directly by serialization or deserialization.
S250, generating parameters required by the related class to realize the packing capability.
S260, processing the information to be processed based on the generated required parameters, and ending the operation.
In the present embodiment, the information to be processed may be subjected to the deserialization processing based on the generated required parameters.
S270, processing the information to be processed in a Gson mode.
In this embodiment, after determining that the application program is updated, the information to be processed may be deserialized by the Gson method.
Optionally, the processing the information to be processed by the Gson method includes: determining a mapping relation required by processing based on the class required to be accessed; and processing the information to be processed based on the mapping relation.
Wherein if the processed information to be processed is a composite type of data, the mapping relation required for processing can be determined based on the class to be accessed. The composite type can correspond to a complete mapping relation, and the mapping relation can be understood as the corresponding relation between each class and the class describing the attribute characteristics of the class; the classes that need to be accessed can be understood as one or more classes in the composite type that are currently needed to be accessed. On this basis, the information to be processed may be processed in a deserialized manner based on the mapping relationship, and there is no limitation on how the information to be processed is processed based on the mapping relationship.
The second embodiment provides a processing method, which embodies the processing process before and after the application program is upgraded. The method comprises the steps of serializing data in a packing and Gson mode, and processing by using packing preferentially under the condition that an application program is not upgraded; under the condition of upgrading an application program, determining and processing the required mapping relation based on the classes required to be accessed in a Gson mode, so that resource waste caused by creating the undesirable mapping relation can be avoided. In addition, the packaging and Gson modes are used for processing before and after the application program is upgraded, so that the processing flexibility and efficiency can be improved.
The present disclosure is exemplarily described below:
the present disclosure proposes a processing method, and the specific implementation method is as follows:
1. searching corresponding related classes according to the target class (namely determining related classes related to the target class according to the acquired target class)
The deserialization may be considered to be for a particular class for which a root class may be located. root class is the root node of the overall mapping relationship. From this root node, it can find all the class it depends on. In implementation, the capability of the transfer byte of the Gradle can be utilized to obtain the corresponding root class in the Gradle plug-in. Fig. 3 is a schematic diagram of implementation of determining a correlation class according to a second embodiment of the present invention. As shown in fig. 3, the specific implementation procedure is as follows:
Step 1, accessing an attribute list of a target class;
step 2, obtaining the next class in the attribute list;
step 3, judging whether the next class is class in the current application program;
step 4, if the class is a class in the current application program and is not accessed, recording the next class and taking the next class as a target class to be executed from the step 1 until all class traversals related to the target class are completed;
and step 5, after all relevant class is traversed, all relevant classes can be obtained (namely all the recorded next classes are used as relevant classes).
2. Parcelable interfaces and related methods (Parcelable interfaces and related methods, i.e., parameters needed by related classes to achieve packaging capability) are implemented for all related classes
Fig. 4 is a schematic implementation diagram of a Parcelable interface and related method according to a second embodiment of the present invention. As shown in fig. 4, according to the obtained related classes, the injecting of the byte codes for implementing the Parcelable interface is performed for the related classes in the process of traversing the byte codes, and the injecting steps are as follows:
step 1, traversing all relevant classes, determining whether the current class in the relevant classes realizes a Parcelable interface (namely whether the relevant classes have packaging interfaces), not processing the current class, and injecting the byte codes of the Parcelable interface into the current class;
Step 2, accessing an attribute list of the current class, and converting the attribute list into a required data structure;
step 3, accessing a method list of the current class, and recording method information missing in a method required by realizing packaging capability;
and 4, whether a related method (the related method can be understood as a method for realizing the missing of the packing capability) needs to be generated, if so, generating a related method in the Parcelable (namely, a method for realizing the missing of the packing capability) according to the method information for realizing the missing of the packing capability and the converted attribute list, and if not, ending.
3. After the application program version is updated, the problem of compatibility of the parcel version needs to be solved
Because parcel is a binary sequential protocol implementation, the architecture cannot be guaranteed, and therefore, compatibility problems may exist after each version update. Therefore, the data can be serialized by using the parcel and Gson modes at the same time, and during the reverse serialization, the parcel is preferentially used for the reverse serialization, and if the parcel has a compatibility problem, the method can be returned to the Gson reverse serialization mode.
The back-to-Gson reverse serialization approach results in a multiple increase in the time consuming of the next reverse serialization. To optimize the time consumption of this part, it is possible to modify the logical implementation of the Gson framework. The Gson approach may obtain a type adapter (TypeAdapter) for the corresponding class through the getAdapter () function before serialization or deserialization. If the class is a compound class, the TypeAdapter contains the mapping relation of the whole class, namely a complete mapping tree. But the flow of serialization and deserialization is to handle non-null (null) instances on the access path. If the path actually traversed is only a small part of the mapping tree, then the remaining part is created too early. Fig. 5 is a schematic diagram of a mapping relationship according to a second embodiment of the present invention. As shown in fig. 5, only Person and TypeAdapter corresponding to String are actually used in the mapping relationship. For this deserialization, the unused TypeAdapter may be created as needed, i.e., it may not be processed when it is not needed. On this basis, the class of the attribute is not immediately removed from the recursive reflection at the time of creating the TypeAdapter, but the class of the attribute is removed from the current node when the current node needs to be accessed in the actual deserialization process (i.e. the mapping relation required by the processing is determined based on the class required to be accessed).
Example III
Fig. 6 is a schematic structural diagram of a processing apparatus according to a third embodiment of the present disclosure, where the apparatus may be implemented by software and/or hardware and is generally integrated on a terminal device.
As shown in fig. 6, the apparatus includes: a first determination module 310, a second determination module 320, a parameter generation module 330, and a first processing module 340;
wherein, the first determining module 310 is configured to determine, according to the obtained target class, a related class related to the target class;
a second determining module 320, configured to determine whether the related class has a packing capability;
a parameter generating module 330, configured to generate parameters required by the related class to implement the packing capability if not;
the first processing module 340 is configured to process information to be processed based on the generated required parameter, where the processing includes a serialization process or a deserialization process.
In this embodiment, the apparatus first determines, through the first determining module 310, a related class related to the target class according to the obtained target class; then, through the second determining module 320, it is determined whether the related class has packing capability; then, through the parameter generating module 330, if not, generating parameters required by the related class to realize the packing capability; finally, the information to be processed is processed based on the generated required parameters by the first processing module 340, where the processing includes serialization processing or deserialization processing. The device generates parameters required for realizing the packing capacity aiming at the related class without the packing capacity by determining the related class related to the acquired target class, and then carries out serialization or anti-serialization processing on the information to be processed based on the parameters, so that the time-consuming condition of the processing process caused by the complex structure of the incoming class can be avoided, and the processing efficiency is effectively improved.
Optionally, the first determining module 310 includes:
the acquisition unit is used for acquiring the target class;
a first determining unit, configured to determine a next class based on the attribute list of the target class;
a recording unit, configured to record the next class and continue to perform an operation of determining the next class based on the attribute list of the target class with the next class as a new target class if the next class is a class in the application program and has not been traversed, until all classes related to the target class are traversed;
and the second determining unit is used for taking the recorded next class as a related class related to the target class after the traversing is completed.
Optionally, the second determining module 320 is specifically configured to:
determining whether the current class in the related classes has a packing interface; and/or the number of the groups of groups,
determining whether the method list of the current class lacks method information of a method required for realizing the packaging capability.
Optionally, generating parameters required by the related class to implement packaging capability includes:
if the current class does not have the packing interface, injecting byte codes for realizing the packing interface for the current class; and/or generating parameters required by the related class to realize packing capability, including:
Converting the attribute list of the current class into a required data structure;
determining method information of a method required by the realization of packaging capability, which is missing from the current method list, wherein the current method list is the current class of method list;
and generating a method for realizing the missing packing capability according to the method information and the converted attribute list.
Optionally, the apparatus further includes:
the upgrade determining module is used for determining whether the application program version is upgraded before determining the related class related to the target class according to the acquired target class;
the execution module is used for executing related class operation related to the obtained target class if not;
and the second processing module is used for processing the information to be processed in a Gson mode if yes.
Optionally, the second processing module specifically includes:
a relationship determination unit for determining a mapping relationship required for processing based on the class to be accessed;
and the processing unit is used for processing the information to be processed based on the mapping relation.
Optionally, the method further comprises:
the data is serialized by packing and Gson.
The processing device can execute the processing method provided by any embodiment of the disclosure, and has the corresponding functional modules and beneficial effects of the execution method.
Example IV
Fig. 7 is a schematic structural diagram of a terminal device according to a fourth embodiment of the present disclosure. Fig. 7 shows a schematic diagram of a structure of a terminal device 400 suitable for use in implementing embodiments of the present disclosure. The terminal device 400 in the embodiments of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, personal digital assistants (Personal Digital Assistant, PDA), tablet computers (Portable Android Device, PAD), portable multimedia players (Portable Media Player, PMP), in-vehicle terminals (e.g., in-vehicle navigation terminals), and the like, and fixed terminals such as digital TVs, desktop computers, and the like. The terminal device 400 shown in fig. 7 is only one example, and should not impose any limitation on the functions and scope of use of the embodiments of the present disclosure.
As shown in fig. 7, the terminal apparatus 400 may include one or more processing devices (e.g., a central processor, a graphic processor, etc.) 401, which may perform various appropriate actions and processes according to a program stored in a Read-Only Memory (ROM) 402 or a program loaded from a storage device 408 into a random access Memory (Random Access Memory, RAM) 403. The one or more processing devices 401 implement the methods as provided by the present disclosure. In the RAM403, various programs and data necessary for the operation of the electronic device 400 are also stored. The processing device 401, the ROM 402, and the RAM403 are connected to each other by a bus 404. An Input/Output (I/O) interface 405 is also connected to bus 404.
In general, the following devices may be connected to the I/O interface 405: input devices 406 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 407 including, for example, a liquid crystal display (Liquid Crystal Display, LCD), a speaker, a vibrator, and the like; storage 408 including, for example, magnetic tape, hard disk, etc., storage 408 being for storing one or more programs; and a communication device 409. The communication means 409 may allow the terminal device 400 to communicate with other devices wirelessly or by wire to exchange data. While fig. 7 shows a terminal device 400 having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network via communications device 409, or from storage 408, or from ROM 402. The above-described functions defined in the methods of the embodiments of the present disclosure are performed when the computer program is executed by the processing device 401.
It should be noted that the computer readable medium described in the present disclosure may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-Only Memory (ROM), an erasable programmable read-Only Memory (EPROM or flash Memory), an optical fiber, a portable compact disc read-Only Memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this disclosure, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present disclosure, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
In some implementations, the clients, servers may communicate using any currently known or future developed network protocol, such as the hypertext transfer protocol (Hyper Text Transfer Protocol, HTTP), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a Local Area Network (LAN), a Wide Area Network (WAN), the internet (e.g., the internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed networks.
The computer readable medium may be contained in the terminal device 400; or may exist alone without being assembled into the terminal device 400.
The computer readable medium stores one or more computer programs which when executed by a processing device implement the method of: the computer-readable medium carries one or more programs that, when executed by the electronic device, cause the terminal device 400 to: computer program code for carrying out operations of the present disclosure may be written in one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. Each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present disclosure may be implemented in software or hardware. The name of a module does not in some cases define the module itself.
The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: a field programmable gate array (Field Programmable Gate Array, FPGA), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), a special standard product (Application Specific Standard Parts, ASSP), a System On Chip (SOC), a complex programmable logic device (Complex Programming logic device, CPLD), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
According to one or more embodiments of the present disclosure, example 1 provides a processing method, comprising:
according to the obtained target class, determining a related class related to the target class;
determining whether the related class has packaging capability;
if not, generating parameters required by the related class to realize the packing capacity;
the information to be processed is processed based on the generated required parameters, and the processing includes serialization processing or deserialization processing.
In accordance with one or more embodiments of the present disclosure, example 2 is in accordance with the method of example 1,
according to the obtained target class, determining a related class related to the target class, including:
obtaining a target class;
determining a next class based on the attribute list of the target class;
recording the next class and taking the next class as a new target class to continue to execute the operation of determining the next class based on the attribute list of the target class until all classes related to the target class are traversed;
and taking the recorded next class as a related class related to the target class after traversing.
In accordance with one or more embodiments of the present disclosure, example 3 is in accordance with the method of example 1,
Determining whether the related class has packaging capabilities includes:
determining whether the current class in the related classes has a packing interface; and/or the number of the groups of groups,
determining whether the method list of the current class lacks method information of a method required for realizing the packaging capability.
In accordance with one or more embodiments of the present disclosure, example 4 is in accordance with the method of example 3,
generating parameters required by the related class to realize packing capability, including:
if the current class does not have the packing interface, injecting byte codes for realizing the packing interface for the current class; and/or generating parameters required by the related class to realize packing capability, including:
converting the attribute list of the current class into a required data structure;
determining method information of a method required by the realization of packaging capability, which is missing from the current method list, wherein the current method list is the current class of method list;
and generating a method for realizing the missing packing capability according to the method information and the converted attribute list.
In accordance with one or more embodiments of the present disclosure, example 5 is in accordance with the method of example 1,
before determining the related class related to the target class according to the acquired target class, the method further comprises:
Determining whether the application version is upgraded;
if not, executing related class operation related to the target class according to the acquired target class;
if yes, the information to be processed is processed in a Gson mode.
In accordance with one or more embodiments of the present disclosure, example 6 is in accordance with the method of example 5,
processing the information to be processed in a Gson mode, including:
determining a mapping relation required by processing based on the class required to be accessed;
and processing the information to be processed based on the mapping relation.
In accordance with one or more embodiments of the present disclosure, example 7 is in accordance with the method of example 5,
further comprises:
the data is serialized by packing and Gson.
According to one or more embodiments of the present disclosure, example 8 provides a processing apparatus comprising:
the first determining module is used for determining a related class related to the target class according to the acquired target class;
a second determining module, configured to determine whether the related class has a packing capability;
the parameter generation module is used for generating parameters required by the related class to realize the packing capacity if not;
and the first processing module is used for processing the information to be processed based on the generated required parameters, wherein the processing comprises serialization processing or deserialization processing.
According to one or more embodiments of the present disclosure, example 9 provides a terminal device, comprising:
one or more processing devices;
a storage means for storing one or more programs;
the one or more programs, when executed by the one or more processing devices, cause the one or more processing devices to implement the methods of any of examples 1-7.
According to one or more embodiments of the present disclosure, example 10 provides a computer-readable medium having stored thereon a computer program which, when executed by a processing device, implements a method as described in any of examples 1-7.
The foregoing description is only of the preferred embodiments of the present disclosure and description of the principles of the technology being employed. It will be appreciated by persons skilled in the art that the scope of the disclosure referred to in this disclosure is not limited to the specific combinations of features described above, but also covers other embodiments which may be formed by any combination of features described above or equivalents thereof without departing from the spirit of the disclosure. Such as those described above, are mutually substituted with the technical features having similar functions disclosed in the present disclosure (but not limited thereto).
Moreover, although operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. In certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are example forms of implementing the claims.

Claims (10)

1. A method of processing, the method comprising:
according to the obtained target class, determining a related class related to the target class;
Determining whether the related class has packaging capability;
if not, generating parameters required by the related class to realize the packing capacity;
the information to be processed is processed based on the generated required parameters, and the processing includes serialization processing or deserialization processing.
2. The method of claim 1, wherein determining a correlation class associated with the target class based on the obtained target class comprises:
obtaining a target class;
determining a next class based on the attribute list of the target class;
recording the next class and taking the next class as a new target class to continue to execute the operation of determining the next class based on the attribute list of the target class until all classes related to the target class are traversed;
and taking the recorded next class as a related class related to the target class after traversing.
3. The method of claim 1, wherein determining whether the related class has packing capability comprises:
determining whether the current class in the related classes has a packing interface; and/or the number of the groups of groups,
determining whether the method list of the current class lacks method information of a method required for realizing the packaging capability.
4. The method of claim 3, wherein generating parameters required by the related class to achieve packaging capabilities comprises:
if the current class does not have the packing interface, injecting byte codes for realizing the packing interface for the current class; and/or generating parameters required by the related class to realize packing capability, including:
converting the attribute list of the current class into a required data structure;
determining method information of a method required by the realization of packaging capability, which is missing from the current method list, wherein the current method list is the current class of method list;
and generating a method for realizing the missing packing capability according to the method information and the converted attribute list.
5. The method of claim 1, further comprising, prior to determining a correlation class associated with the target class based on the obtained target class:
determining whether the application version is upgraded;
if not, executing related class operation related to the target class according to the acquired target class;
if yes, the information to be processed is processed in a Gson mode.
6. The method of claim 5, wherein processing the information to be processed by Gson comprises:
Determining a mapping relation required by processing based on the class required to be accessed;
and processing the information to be processed based on the mapping relation.
7. The method as recited in claim 5, further comprising:
the data is serialized by packing and Gson.
8. A processing apparatus, comprising:
the first determining module is used for determining a related class related to the target class according to the acquired target class;
a second determining module, configured to determine whether the related class has a packing capability;
the parameter generation module is used for generating parameters required by the related class to realize the packing capacity if not;
and the first processing module is used for processing the information to be processed based on the generated required parameters, wherein the processing comprises serialization processing or deserialization processing.
9. A terminal device, comprising:
one or more processing devices;
a storage means for storing one or more programs;
when the one or more programs are executed by the one or more processing devices, the one or more processing devices are caused to implement the method of any of claims 1-7.
10. A computer readable medium, on which a computer program is stored, characterized in that the program, when being executed by a processing device, implements the method according to any of claims 1-7.
CN202210195642.6A 2022-03-01 2022-03-01 Processing method, processing device, terminal equipment and medium Pending CN116737122A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210195642.6A CN116737122A (en) 2022-03-01 2022-03-01 Processing method, processing device, terminal equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210195642.6A CN116737122A (en) 2022-03-01 2022-03-01 Processing method, processing device, terminal equipment and medium

Publications (1)

Publication Number Publication Date
CN116737122A true CN116737122A (en) 2023-09-12

Family

ID=87913801

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210195642.6A Pending CN116737122A (en) 2022-03-01 2022-03-01 Processing method, processing device, terminal equipment and medium

Country Status (1)

Country Link
CN (1) CN116737122A (en)

Similar Documents

Publication Publication Date Title
CN111291103B (en) Interface data analysis method and device, electronic equipment and storage medium
CN109726217B (en) Database operation method, device, equipment and storage medium
CN111857720B (en) User interface state information generation method and device, electronic equipment and medium
CN111309304B (en) Method, device, medium and electronic equipment for generating IDL file
CN112631590A (en) Component library generation method and device, electronic equipment and computer readable medium
CN111124541A (en) Configuration file generation method, device, equipment and medium
CN111324258B (en) Method, device, equipment and medium for generating contents of configuration items of multilevel pull-down menu
CN113220281A (en) Information generation method and device, terminal equipment and storage medium
CN113391860B (en) Service request processing method and device, electronic equipment and computer storage medium
CN111752644A (en) Interface simulation method, device, equipment and storage medium
CN110704050B (en) Module initializing method and device, electronic equipment and computer readable storage medium
WO2023056841A1 (en) Data service method and apparatus, and related product
CN116226189A (en) Cache data query method, device, electronic equipment and computer readable medium
CN113709171B (en) Method and device for cross-component state communication
CN111399902B (en) Client source file processing method and device, readable medium and electronic equipment
CN115328506A (en) Application package generation method, loading method, device, medium and equipment
CN111796865B (en) Byte code file modification method, device, terminal equipment and medium
CN116737122A (en) Processing method, processing device, terminal equipment and medium
CN109669720B (en) Chain type asynchronous request processing method and device based on Promise and electronic equipment
CN112230986A (en) Project file generation method and device, electronic equipment and computer readable medium
CN112445820A (en) Data conversion method and device
CN112688863B (en) Gateway data processing method and device and electronic equipment
CN113448550B (en) Method and device for realizing collection management of classes, electronic equipment and computer medium
CN114047922B (en) Transcoding method, device, medium and equipment for precompiled device
CN117850956B (en) Application package data processing method, device, electronic equipment and computer readable medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination