CN112416312B - Object acquisition method and device, electronic equipment and storage medium - Google Patents

Object acquisition method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN112416312B
CN112416312B CN201910780683.XA CN201910780683A CN112416312B CN 112416312 B CN112416312 B CN 112416312B CN 201910780683 A CN201910780683 A CN 201910780683A CN 112416312 B CN112416312 B CN 112416312B
Authority
CN
China
Prior art keywords
target object
source
target
identification
members included
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.)
Active
Application number
CN201910780683.XA
Other languages
Chinese (zh)
Other versions
CN112416312A (en
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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201910780683.XA priority Critical patent/CN112416312B/en
Publication of CN112416312A publication Critical patent/CN112416312A/en
Application granted granted Critical
Publication of CN112416312B publication Critical patent/CN112416312B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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

Landscapes

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

Abstract

The embodiment of the invention provides an object acquisition method and device, electronic equipment and storage medium, wherein the method can comprise the following steps: acquiring a call request of an application program for an object acquisition function, wherein the call request comprises identifications of a source object and a target object, and the target object is one member of multiple layers of members included by the source object; invoking the object acquisition function and acquiring the target object from a plurality of layers of members included in the source object by utilizing the identifications of the source object and the target object; and returning the target object to the application program. By adopting the method and the device, the code writing process of object acquisition can be simplified, so that the development efficiency is improved.

Description

Object acquisition method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and apparatus for acquiring an object, an electronic device, and a storage medium.
Background
With the increase in global informatization speed, computer programming languages are widely used in development work of related persons as a formal language for defining computer programs.
For a computer programming language such as Java, when an application program is to acquire a certain member or make a judgment on a certain member, it is required to acquire the member layer by layer according to a hierarchy. For example, a d object is a member of a c object, a c object is a member of a b object, and a b object is a member of a c object. When the d member of the a object is to be acquired, the application program can be acquired by adopting an if/else judgment mode, namely a, b, c, d is needed to acquire the d member, and none of a, b and c can be empty objects. However, in the above-described hierarchical layer-by-layer acquisition method, when the number of hierarchical layers is large, the code written for the object acquisition method is complex, resulting in low development efficiency.
Disclosure of Invention
The embodiment of the invention provides an object acquisition method and device, electronic equipment and storage medium, which can simplify the code writing process of object acquisition and further improve the development efficiency.
In one aspect, an embodiment of the present invention provides an object obtaining method, including:
Acquiring a call request of an application program for an object acquisition function, wherein the call request comprises identifications of a source object and a target object, and the target object is one member of multiple layers of members included by the source object;
Invoking the object acquisition function and acquiring the target object from a plurality of layers of members included in the source object by utilizing the identifications of the source object and the target object;
and returning the target object to the application program.
In another aspect, an embodiment of the present invention provides an object acquisition apparatus, including:
An acquisition unit, configured to acquire a call request of an application program for an object acquisition function, where the call request includes an identifier of a source object and an identifier of a target object, and the target object is one member of multiple layers of members included in the source object;
And the processing unit is used for calling the object acquisition function, acquiring the target object from the multi-layer members included in the source object by utilizing the identification of the source object and the target object, and returning the target object to the application program.
Correspondingly, the embodiment of the invention also provides electronic equipment, which comprises: a processor and a memory; the memory is used for storing program instructions; and the processor calls the program instructions for executing the object acquisition method.
Accordingly, an embodiment of the present invention provides a computer storage medium having stored therein program instructions for implementing the above-described object acquisition method when executed.
In the embodiment of the invention, the call request of the application program for the object acquisition function can be acquired, and the call request comprises the identifications of the source object and the target object; the object acquisition function is invoked and the identification of the source object and the target object is utilized to acquire the target object from the multi-layer members included in the source object, thereby returning the target object to the application program. The object acquisition mode can rely on the existing object acquisition function to realize the object acquisition process according to the identifications of the source object and the target object, and compared with the mode of acquiring the object layer by layer according to the hierarchy in the prior art, the code writing process aiming at the object acquisition is simpler, and the development efficiency can be improved.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic flow chart of an object acquisition method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a membership network provided by an embodiment of the present invention;
FIG. 3 is a schematic diagram of an object acquisition process according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of an object acquiring apparatus according to an embodiment of the present invention;
Fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be described below with reference to the accompanying drawings in the embodiments of the present invention.
The computer programming language may include Java, C, C++, phython, javaScript, and the like as a formal language for defining a computer program. Object acquisition is a common logical process flow in computer programming languages. Several mainstream object acquisition modes will be briefly described below.
Currently, koltin language has a compact writing on the grammar level for object acquisition of a multi-layer class structure, such as a? B? C? D, namely, the object a is not the blank object b, otherwise, returning to null, and so on, so as to obtain the object d. In one embodiment, the multi-layer class structure may also be referred to as a multi-layer structure. The multi-layer class structure may be made up of multiple layers of members that the source object includes. Where a source object refers to an object that includes multiple layers of members. No corresponding syntax and APIs in the Java language support object retrieval for such multi-level class structures, which can only be achieved through some conventional judgment, design mode or Java-based certain properties. For example, the object acquisition of the multi-layer class structure can be realized by using an if/else judgment mode, or the object acquisition of the multi-layer class structure can be realized by using a NullObject design mode to finish multi-layer empty judgment, or the object acquisition of the multi-layer class structure can be realized by using the Optional characteristic of Java 8 through a stream writing method.
However, the aforementioned object acquisition methods require writing out intermediate objects between the source object and the target object during the code writing process. If the intermediate states of the object acquisition modes are too long, for example, hundreds of intermediate objects are included between the source object and the target object, the development efficiency is low because the code written for the object acquisition modes is complex. For example, koltin, if/else, optional may be written as follows:
Furthermore, the Koltin language has a compact writing at the grammar level for object acquisition of the multi-level class structure, but for other Java applications, migration costs are too great if it is not practical to switch to Koltin for this. The mode of using NullObject design mode to complete multi-layer empty judgment requires program development software, such as installing corresponding plug-in on IDEA, and manually adapting the mode in code, so that the configuration process is complicated. Object acquisition using Optional features to achieve a multi-layer class structure requires JDK versions above 1.8, but JDK versions for many applications do not reach 1.8 at present, so adapting such features is not possible. Moreover, the large-scale application upgrade JDK version needs to make a lot of adaptations and bears some upgrade risks, and if the upgrade is not strongly dependent on the high-version JDK, the upgrade to the high-version JDK can occupy more resources of an operating system, so that the upgrade JDK is somewhat inexpensible only for realizing more concise acquisition of key objects of the multi-layer structure.
In order to solve the problems in the prior art, an object acquisition scheme is provided in the embodiment of the present invention, a target object of a multi-layer class structure may be acquired through the identifiers of the source object and the target object, that is, the target object may be acquired from multi-layer members included in the source object through the identifiers of the source object and the target object. The object obtaining scheme may be performed by an electronic device, which may be a terminal or a server. The terminal comprises, but is not limited to, intelligent terminals such as intelligent mobile phones, tablet computers, notebook computers, desktop computers and the like. A server may refer to a server or a cluster of servers. The electronic device can apply the object acquisition scheme to different application scenes according to different programming requirements, for example, the object acquisition scheme can be used in a scene that a multi-layer class structure of Java directly acquires a key object. The object acquisition scheme of the embodiment of the invention can rely on the existing object acquisition function to realize the process of object acquisition according to the identifications of the source object and the target object, and compared with the mode of acquiring the object layer by layer according to the hierarchy in the prior art, the code writing process aiming at the object acquisition of the embodiment of the invention is simpler, thereby improving the development efficiency. In addition, the object acquisition scheme of the embodiment of the invention has the following advantages: (1) Compared with a Koltin-based mode, the object acquisition scheme of the embodiment of the invention can be implemented without language switching or migration, and has higher feasibility; (2) Compared with a NullObject-based mode, the object acquisition scheme of the embodiment of the invention does not need configuration, and is simple to operate; (3) Compared with a Optional-based mode, the object acquisition scheme of the embodiment of the invention can realize more concise acquisition of the key object of the multi-layer class structure under the condition that the application does not need to upgrade the JDK.
In practical application, a developer can refer to the multi-layer class provided in the application program to obtain the extended library of the key object, and then use the method for obtaining the key object by the multi-layer class in the extended library in the application program. The extended library refers to a standard library that provides object acquisition functions. For example, it is necessary to use doSomething method of the member D below the member c below the member b of the object a, and the object acquisition function of the present invention can be abbreviated as D D =func (a, "D") in comparison with the aforementioned writing method of if/else.
The writing method after the expansion library is introduced can be as follows: func is specifically MultilayerAcquisition </SUB >. GETTARGET, at this point,
D d=MultilayerAcquisition<D>.getTarget(a,“D”);
d.doSomething();
Wherein MultilayerAcquisition < >. GETTARGET (, ") is an object acquisition function, D in < D > may refer to the type of object D, a may refer to the source object, and D in" D "may refer to the identity of object D.
Based on the above description, the embodiment of the invention provides an object acquisition method, which can be applied to electronic equipment, and the electronic equipment can be a terminal or a server. The electronic device is installed with an application. Referring to fig. 1, the object obtaining method specifically includes the following steps:
s101, acquiring a call request of an application program for an object acquisition function, wherein the call request comprises identification of a source object and a target object, and the target object is one member of multiple layers of members included by the source object.
Specifically, the application program can call the object acquisition function to acquire the required object, and when the target object needs to be acquired, a call request for the object acquisition function can be initiated, and at this time, the electronic device can detect the call request initiated by the application program for the object acquisition function. The application program may carry the identifications of the source object and the target object in the call request, where the identifications of the source object and the target object may be used as the incoming parameters when the function is acquired by the call object, and the target object is one member of the multiple layers of members included in the source object.
In one embodiment, the identification of the target object may be a full-type name of the target object, which may include directory information and names. For example, the full type name may be in the format of target information. In one embodiment, the full class name may also be referred to as a full class name. The directory information may be a package name, which may be a class name of the target object.
S102, calling the object acquisition function and acquiring the target object from the multi-layer members included in the source object by utilizing the identification of the source object and the target object.
In one embodiment, the object acquisition function includes an object traverser and an object reflection generator, and the specific manner in which the electronic device invokes the object acquisition function and acquires the target object from the multiple layers of members included in the source object by using the identifications of the source object and the target object may be: the electronic equipment calls an object traverser to generate a membership network among multiple layers of members included in the source object; the electronic equipment determines character description of the target object according to the identification of the target object and the membership network; the electronic device passes the identification of the target object and the character description to an object reflection generator to reflect the generated target object. Wherein the character description refers to a character string for describing the target object. The character description of the target object can be conveniently and quickly determined through the relational network, so that the target object is generated.
For example, the source object is object a and the target object is object D. The electronic device may invoke the object traverser to generate a membership network as shown in fig. 2. And the electronic equipment determines the character description of the object D according to the identification of the object D and the membership network. The electronic device passes the identification and character description of object D into an object reflection generator to reflect the generated object D.
In one embodiment, the electronic device may send the identification and character description of the target object to the object reflection generator in a specific manner of generating the target object by reflection, which may be: the electronic equipment transmits the identification and the character description of the target object into an object reflection generator, and the electronic equipment calls an object reflector to generate the target object by reflection technology according to the identification and the character description of the target object.
In one embodiment, the specific manner in which the electronic device invokes the object traverser to generate a membership network between the multiple layers of members included in the source object may be: invoking an object traverser to traverse the source object from top to bottom to obtain the dependency relationship among each member in the multi-layer members included in the source object; a membership network between the multiple layers of members included in the source object is generated from the dependencies.
For example, the electronic device may invoke an object traverser to traverse object a top-down to obtain the dependencies between the various members of the multi-layer members included in object a. As can be seen from fig. 2, the dependency relationships between the members in the multiple layers included in the source object include the dependency relationships among the object a, the object B, the object C1, the dependency relationships among the object a, the object B, the object C, the object D2, and the like. The electronic device may generate a membership network as shown in fig. 2 among the multiple layers of members included in the object a according to the dependency relationship.
In one embodiment, the electronic device may map out a membership network between multiple layers of members included in the source object according to the dependencies. For example, referring to FIG. 2, the membership network can be presented in the form of a tree structure, the source object and the multi-layer members comprised by the source object can be visually represented in the form of nodes, and the dependencies between the multi-layer members can be visually represented in the form of arrows.
In one embodiment, the object obtaining function further includes a decision maker, and the specific manner of determining, by the electronic device, the character description of the target object according to the identifier of the target object and the membership network may be: the electronic equipment determines character descriptions of a plurality of objects according to the identification of the target object and the membership network, and invokes a decision maker to determine the character descriptions of the target object from the character descriptions of the plurality of objects. Wherein the identity of each of the plurality of objects is the same as the identity of the target object. In one embodiment, the decision maker may also be referred to as an intelligent decision maker or an automatic decision maker. By adopting the mode, when the character descriptions of a plurality of objects are determined, the character descriptions of the target objects are determined through the decision maker, so that the obtained character descriptions of the target objects are more accurate and reliable.
In one embodiment, the specific manner in which the electronic device invokes the decision maker to determine the character description of the target object from the character descriptions of the plurality of objects may be: the electronic equipment acquires the type of the target object; the electronic equipment calls a decision maker to determine a first object with the same type as the target object from a plurality of objects, and determines the character description of the first object as the character description of the target object. In one embodiment, the electronic device may obtain the type of the target object from the application, or may also obtain the type of the target object that the call request includes when the call request includes the type of the target object.
In one embodiment, the electronic device may also incorporate context logic of the application program to determine the character description of the target object from the character descriptions of the plurality of objects, thereby achieving the goal of accurately identifying the character description of the target object. For example, the electronic device may determine whether the type of the target object is a type of a target object included in the application, and if so, may trigger the call decision maker to determine, from the plurality of objects, a first object having a type identical to the type of the target object, or trigger determining a character description of the first object as a character description of the target object.
In one embodiment, if the electronic device does not determine the character description of the target object from the character descriptions of the plurality of objects, the abnormality information may be output to prompt the relevant person.
S103, returning the target object to the application program.
In the embodiment of the invention, the electronic equipment can return the target object to the application program, so that the application program can acquire the target object.
In one embodiment, the specific way in which the electronic device returns the target object to the application may be: the electronic equipment acquires each father object of the target object; the electronic equipment judges whether null pointers exist in each father object; if so, the electronic device returns the null pointer to the application.
The electronic equipment can acquire each father object of the target object according to the membership network and judge whether a null pointer exists in each father object; when there is a null pointer to any of the various parent objects, the electronic device may return the null pointer to the application. For example, referring to fig. 2, the electronic device may determine whether or not there is a null pointer for object B and object C, and may return the null pointer to the application when there is a null pointer for either of object B and object C.
In the embodiment shown in fig. 1, the electronic device may obtain a call request of an application program for an object to obtain a function, where the call request includes an identifier of a source object and an identifier of a target object, the target object is one member of multiple layers of members included in the source object, call the object to obtain the function and obtain the target object from the multiple layers of members included in the source object by using the identifiers of the source object and the target object, and return the target object to the application program, so that the object of a specified key member for obtaining the multiple layers of objects can be obtained in one step, writing or judging of a middle layer is omitted, so that a process of obtaining the object by the application program is more concise, and error probability of a developer in writing codes is reduced, thereby improving development efficiency and robustness of the application program.
The object acquisition method according to the embodiment of the present invention will be briefly described with reference to fig. 3 by taking a source object as an object a and a target object as an object D. As shown in fig. 3, when an application invokes an object acquisition function, the identity of object a and object D may be passed into the object acquisition function. The object acquisition function passes these two parameters to the object traverser. The object traverser traverses the source object top-up to generate a membership network for object a. When determining a character description of an object based on the identity of object D and the membership network, the object traverser may send the character description of the object as the character description of the target object to the object reflection generator. When the character descriptions of the plurality of objects are determined according to the identification of the object D and the membership network, the object traverser may send a member list of the plurality of objects to the decision maker, the member list including the identification of each of the plurality of objects and the character description of each of the objects. The decision maker may screen the character description of the final object D from the member list according to the type of the object D and the context logic of the application and send the identity and character description of the final object D to the object reflection generator. In the filtering process, if the ambiguity is confirmed, the abnormal information is output, and if the ambiguity is confirmed, the identification and the character description of the object D are transmitted to the object reflection generator. The object reflection generator generates the object D by reflection technology according to the identification and character description of the final object D, and returns the object D to the application program through the return result of the object acquisition function, so that the application program can acquire the object D. If there is a null pointer in each parent object of object D, such as the upper level object or the upper level object of object D, the object retrieval function will eventually return the null pointer to the application.
When the application program calls the object obtaining function, the process that the application program transmits the identifiers of the object a and the object D into the object obtaining function may correspond to step S101 in the embodiment of fig. 1. The above-described processing of the object traverser to the object reflection generator may correspond to step S102 in the embodiment of fig. 1. The above procedure of confirming ambiguity may refer to that the character descriptions of the target objects cannot be determined from the character descriptions of the plurality of objects. The above procedure of confirming disambiguation may refer to determining a character description of a target object from character descriptions of a plurality of objects. The above-described process of returning the object D to the application by the object reflection generator may correspond to step S103 in the embodiment of fig. 1.
Based on the description of the method embodiment, in an embodiment, the embodiment of the present invention further provides a schematic structural diagram of the object obtaining apparatus shown in fig. 4. As shown in fig. 4, the object acquisition apparatus in the embodiment of the present invention may include:
an obtaining unit 401, configured to obtain a call request of an application program for an object to obtain a function, where the call request includes an identifier of a source object and an identifier of a target object, and the target object is one member of multiple layers of members included in the source object.
A processing unit 402, configured to invoke the object obtaining function, obtain the target object from the multiple layers of members included in the source object by using the identities of the source object and the target object, and return the target object to the application program.
In one embodiment, the processing unit 402 invokes the object obtaining function and obtains the target object from the multiple layers of members included in the source object by using the identities of the source object and the target object, specifically invokes the object traverser to generate a membership network between the multiple layers of members included in the source object; determining character description of the target object according to the identification of the target object and the membership network; and transmitting the identification and character description of the target object into the object reflection generator to generate the target object in a reflection mode.
In one embodiment, the processing unit 402 invokes the object traverser to generate a member relation network between multiple layers of members included in the source object, specifically invokes the object traverser to traverse the source object from top to bottom, so as to obtain a dependency relation between each of the multiple layers of members included in the source object; and generating a membership network among multiple layers of members included by the source object according to the dependency relationship.
In one embodiment, the object acquisition function further comprises a decision maker.
In one embodiment, the processing unit 402 determines the character description of the target object according to the identifier of the target object and the membership network, specifically determines the character descriptions of a plurality of objects according to the identifier of the target object and the membership network, where the identifier of each object in the plurality of objects is the same as the identifier of the target object; and calling the decision maker to determine the character description of the target object from the character descriptions of the plurality of objects.
In one embodiment, the processing unit 402 invokes the decision maker to determine a character description of a target object from the character descriptions of the plurality of objects, specifically to obtain a type of the target object; invoking the decision maker to determine a first object with the same type as the target object from the plurality of objects; and determining the character description of the first object as the character description of the target object.
In one embodiment, the processing unit 402 returns the target object to the application program, specifically, obtains each parent object of the target object; judging whether null pointers exist in the parent objects or not; if yes, returning the null pointer to the application program.
In one embodiment, the identification of the target object is a full-type name of the target object, the full-type name including directory information and a name.
It can be seen that, in the embodiment shown in fig. 4, the object obtaining device may obtain a call request of an application program for an object obtaining function, where the call request includes identifiers of a source object and a target object; the object acquisition function is called, and the target object is acquired from the multi-layer members included in the source object by utilizing the identification of the source object and the target object, so that the target object is returned to the application program.
Fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present invention. The electronic device in the present embodiment as shown in fig. 5 may include: one or more processors 501; one or more input devices 502, one or more output devices 503, and a memory 504. The processor 501, input device 502, output device 503, and memory 504 are connected by a bus or other means. Wherein the input device 502 and the output device 503 are optional means. The memory 504 is used for storing a computer program comprising program instructions, and the processor 501 is used for executing the program instructions stored by the memory 504 for implementing the various methods referred to above.
The memory 504 may include volatile memory (RAM), such as random-access memory (RAM); the memory 504 may also include a non-volatile memory (non-volatile memory), such as a flash memory (flash memory), a solid state disk (solid-state drive-STATE DRIVE, SSD), etc.; the memory 504 may also include a combination of the types of memory described above.
In one embodiment, the processor 501 may be a central processing unit (Central Processing Unit, CPU), which may also be other general purpose processors, i.e., microprocessors or any conventional processor. The memory 504 may include read only memory and random access memory. Accordingly, the processor 501 and the memory 504 are not limited herein.
In one embodiment, the processor 501 invokes program instructions stored in the memory 504, for obtaining a call request of an application program for an object obtaining function, where the call request includes an identifier of a source object and a target object, and the target object is one member of multiple layers of members included in the source object; invoking the object acquisition function and acquiring the target object from a plurality of layers of members included in the source object by utilizing the identifications of the source object and the target object; and returning the target object to the application program.
In one embodiment, the object acquisition function includes an object traverser and an object reflection generator, and the processor 501 invokes the object acquisition function and acquires the target object from the multi-layer members included in the source object by using the identifiers of the source object and the target object, and is specifically configured to invoke the object traverser to generate a membership network between the multi-layer members included in the source object; determining character description of the target object according to the identification of the target object and the membership network; and transmitting the identification and character description of the target object into the object reflection generator to generate the target object in a reflection mode.
In one embodiment, the processor 501 invokes the object traverser to generate a member relation network between multiple layers of members included in the source object, and is specifically configured to invoke the object traverser to traverse the source object from top to bottom, so as to obtain a dependency relation between each of the multiple layers of members included in the source object; and generating a membership network among multiple layers of members included by the source object according to the dependency relationship.
In one embodiment, the object obtaining function further includes a decision maker, where the processor 501 determines, according to the identifier of the target object and the membership network, a character description of the target object, and is specifically configured to determine, according to the identifier of the target object and the membership network, a character description of a plurality of objects, where the identifier of each of the plurality of objects is the same as the identifier of the target object; and calling the decision maker to determine the character description of the target object from the character descriptions of the plurality of objects.
In one embodiment, the processor 501 invokes the decision maker to determine a character description of a target object from the character descriptions of the plurality of objects, specifically for obtaining a type of the target object; invoking the decision maker to determine a first object with the same type as the target object from the plurality of objects; and determining the character description of the first object as the character description of the target object.
In one embodiment, the processor 501 returns the target object to the application, specifically for obtaining each parent object of the target object; judging whether null pointers exist in the parent objects or not; if yes, returning the null pointer to the application program.
In one embodiment, the identification of the target object is a full-type name of the target object, the full-type name including directory information and a name.
It should be noted that, the specific working process of the electronic device and the unit described above may refer to the related description in the foregoing embodiments, which is not repeated herein.
Those skilled in the art will appreciate that all or part of the processes in the methods of the embodiments described above may be implemented by a computer program for instructing relevant hardware, where the program may be stored in a computer storage medium, and the computer storage medium may be a computer readable storage medium, where the program when executed may include processes in the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a random-access Memory (Random Access Memory, RAM), or the like.
The above disclosure is only a few examples of the present invention, and it is not intended to limit the scope of the present invention, but it is understood by those skilled in the art that all or a part of the above embodiments may be implemented and equivalent changes may be made in the claims of the present invention.

Claims (9)

1. An object acquisition method, characterized by comprising:
Acquiring a call request of an application program for an object acquisition function, wherein the call request comprises identifications of a source object and a target object, and the target object is one member of multiple layers of members included by the source object;
Invoking the object acquisition function and acquiring the target object from a plurality of layers of members included in the source object by utilizing the identifications of the source object and the target object;
Returning the target object to the application program;
wherein the object acquisition function comprises an object traverser and an object reflection generator; the calling the object acquisition function and acquiring the target object from the multi-layer members included in the source object by using the identification of the source object and the target object comprises the following steps:
invoking the object traverser to generate a membership network among multiple layers of members included in the source object;
determining character description of the target object according to the identification of the target object and the membership network;
and transmitting the identification and character description of the target object into the object reflection generator to generate the target object in a reflection mode.
2. The method of claim 1, wherein the invoking the object traverser to generate a membership network between the plurality of layers of members comprised by the source object comprises:
invoking the object traverser to traverse the source object from top to bottom so as to obtain the dependency relationship among each member in the multi-layer members included in the source object;
And generating a membership network among multiple layers of members included by the source object according to the dependency relationship.
3. The method according to claim 1 or 2, wherein the object acquisition function further comprises a decider, the determining the character description of the target object from the identification of the target object and the membership network comprising:
Determining character descriptions of a plurality of objects according to the identification of the target object and the membership network, wherein the identification of each object in the plurality of objects is the same as the identification of the target object;
and calling the decision maker to determine the character description of the target object from the character descriptions of the plurality of objects.
4. A method according to claim 3, wherein said invoking said decision maker to determine a character description of a target object from character descriptions of said plurality of objects comprises:
Acquiring the type of the target object;
Invoking the decision maker to determine a first object with the same type as the target object from the plurality of objects;
and determining the character description of the first object as the character description of the target object.
5. The method of claim 1, wherein the returning the target object to the application comprises:
acquiring each father object of the target object;
Judging whether null pointers exist in the parent objects or not;
If yes, returning the null pointer to the application program.
6. The method of claim 1, wherein the identification of the target object is a full-type name of the target object, the full-type name comprising directory information and names.
7. An object acquisition apparatus, characterized by comprising:
An acquisition unit, configured to acquire a call request of an application program for an object acquisition function, where the call request includes an identifier of a source object and an identifier of a target object, and the target object is one member of multiple layers of members included in the source object;
the processing unit is used for calling the object acquisition function, acquiring the target object from the multi-layer members included in the source object by utilizing the identification of the source object and the target object, and returning the target object to the application program;
Wherein the object acquisition function comprises an object traverser and an object reflection generator; the processing unit is specifically configured to:
invoking the object traverser to generate a membership network among multiple layers of members included in the source object;
determining character description of the target object according to the identification of the target object and the membership network;
and transmitting the identification and character description of the target object into the object reflection generator to generate the target object in a reflection mode.
8. An electronic device, comprising: a processor and a memory; the memory is used for storing program instructions; the processor invoking the program instructions for performing the method of any of claims 1-6.
9. A computer storage medium, characterized in that the computer storage medium has stored therein program instructions, which when executed, are adapted to carry out the method according to any of claims 1-6.
CN201910780683.XA 2019-08-22 2019-08-22 Object acquisition method and device, electronic equipment and storage medium Active CN112416312B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910780683.XA CN112416312B (en) 2019-08-22 2019-08-22 Object acquisition method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910780683.XA CN112416312B (en) 2019-08-22 2019-08-22 Object acquisition method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN112416312A CN112416312A (en) 2021-02-26
CN112416312B true CN112416312B (en) 2024-06-07

Family

ID=74780220

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910780683.XA Active CN112416312B (en) 2019-08-22 2019-08-22 Object acquisition method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112416312B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005158030A (en) * 2003-08-28 2005-06-16 Ricoh Co Ltd Program code automatic generation method, apparatus, and computer readable medium
CN104407864A (en) * 2014-11-25 2015-03-11 广东欧珀移动通信有限公司 Encapsulation method and system for conducting multi-case calling through JNI (Java Native Interface)-layer algorithm
CN108628635A (en) * 2018-05-07 2018-10-09 广州视源电子科技股份有限公司 Method, apparatus, equipment and the storage medium of the name that gets parms and local variable name
CN109062554A (en) * 2018-06-23 2018-12-21 上海泽阳智能科技有限公司 A kind of programmed method towards multioperation object

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005158030A (en) * 2003-08-28 2005-06-16 Ricoh Co Ltd Program code automatic generation method, apparatus, and computer readable medium
CN104407864A (en) * 2014-11-25 2015-03-11 广东欧珀移动通信有限公司 Encapsulation method and system for conducting multi-case calling through JNI (Java Native Interface)-layer algorithm
CN108628635A (en) * 2018-05-07 2018-10-09 广州视源电子科技股份有限公司 Method, apparatus, equipment and the storage medium of the name that gets parms and local variable name
CN109062554A (en) * 2018-06-23 2018-12-21 上海泽阳智能科技有限公司 A kind of programmed method towards multioperation object

Also Published As

Publication number Publication date
CN112416312A (en) 2021-02-26

Similar Documents

Publication Publication Date Title
CN110249307B (en) System and method for executing native contracts on blockchains
WO2019024674A1 (en) Smart contract processing method and apparatus
US10824404B2 (en) Methods and systems for uploading a program based on a target network platform
CN109032825B (en) Fault injection method, device and equipment
CN109871290B (en) Call stack tracking method and device applied to Java and storage medium
US11537367B1 (en) Source code conversion from application program interface to policy document
US20220057999A1 (en) Method and apparatus for implementing an end-to-end api design and development module integrating with firmwide tools and processes
CN111679852B (en) Detection method and device for conflict dependency library
US9411618B2 (en) Metadata-based class loading using a content repository
CN113986402A (en) Function calling method and device, electronic equipment and storage medium
CN112579307A (en) Physical lock resource allocation detection method and device and electronic equipment
US11645070B1 (en) Documentation enforcement during compilation
CN111240772A (en) Data processing method and device based on block chain and storage medium
CN112416612B (en) Service calling method and device, computer equipment and readable storage medium
CN112817600A (en) Program annotation compiling method and corresponding device, equipment and medium
CN112416312B (en) Object acquisition method and device, electronic equipment and storage medium
US10671383B2 (en) Inferring code deprecation from module deprecation
US10394610B2 (en) Managing split packages in a module system
CN103250136B (en) The method quoted during for verifying operation
CN112711602B (en) Method and device for running stored procedure, database system and storage medium
US20220283789A1 (en) Methods and apparatuses for providing a function as a service platform
CN111580938A (en) Transaction processing method, device, equipment and medium for work unit
CN111984427B (en) Non-intrusive Web system mutual exclusion lock implementation method
CN109976765B (en) Application group deployment method, device, equipment and storage medium
US20230274031A1 (en) Method, electronic device, and computer program product for system feature management

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
GR01 Patent grant