CN103605748A - Object definition validity check method and device - Google Patents

Object definition validity check method and device Download PDF

Info

Publication number
CN103605748A
CN103605748A CN201310591070.4A CN201310591070A CN103605748A CN 103605748 A CN103605748 A CN 103605748A CN 201310591070 A CN201310591070 A CN 201310591070A CN 103605748 A CN103605748 A CN 103605748A
Authority
CN
China
Prior art keywords
definition
value
legitimacy
destination object
returning
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.)
Granted
Application number
CN201310591070.4A
Other languages
Chinese (zh)
Other versions
CN103605748B (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.)
Beijing Gridsum Technology Co Ltd
Original Assignee
Beijing Gridsum 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 Gridsum Technology Co Ltd filed Critical Beijing Gridsum Technology Co Ltd
Priority to CN201310591070.4A priority Critical patent/CN103605748B/en
Publication of CN103605748A publication Critical patent/CN103605748A/en
Application granted granted Critical
Publication of CN103605748B publication Critical patent/CN103605748B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/80Information retrieval; Database structures therefor; File system structures therefor of semi-structured data, e.g. markup language structured data such as SGML, XML or HTML
    • G06F16/84Mapping; Conversion
    • G06F16/88Mark-up to mark-up conversion

Abstract

The invention discloses an object definition validity check method and device. The method includes: calling an object string returning method for a target object, and acquiring a first returned value returned by the object string returning method; forcibly converting the target object into a basic value type; calling another object string returning method for the target object subjected to forcible conversion, and acquiring a second returned value returned by the object string returning method; determining validity of a definition of the target object according to the first and second returned values. Through the application of the method and device, the problem that validity check for enumerated definitions in related technologies is high in technical complexity and low in execution efficiency is solved, implementation is easier, and execution is more efficient.

Description

Definition validity checking method and the device of object
Technical field
The present invention relates to the communications field, in particular to a kind of definition validity checking method and device of object.
Background technology
.NET be Microsoft's extend markup language Page Service (Microsoft XML Web services) platform.XML Web services allows application program to carry out communication and shared data by the Internet (Internet), and is which kind of operating system, equipment or programming language regardless of what adopt.Microsoft.NET platform provide create XML Web services and these services are integrated required.
Enumeration type (also referred to as enumerating) provides a kind of effective method for defining one group of name integer constant that can be assigned to variable..NET the enumeration type that the enumerated value under permits using has byte (byte), sbyte, short (short), ushort, integer (int), uint, long (long) or ulong.
When enumerating, inherit from a certain type, when the arbitrary value of this type is paid enumeration object, no matter can normally move when .NET compiles or when .NET moves.Within in service logic, expectation arbitrary value should constrain in the scope of our enumeration definition conventionally.
In correlation technique, adopt following two schemes to realize the validity checking of enumeration definition:
Scheme one: use Enum.IsDefined method to check enumerated value definition, the method can reference: Enum.IsDefined method definition in official of Microsoft document ( http:// msdn.microsoft.com/en-us/library/system.enum.isdefined.a spx).
Inventor finds in research process, and scheme one cannot detect enumerating the situation of combination.
Scheme two: by reflection, obtain enumeration definition, by converting the value of examine to binary numeral, reexamine on each bit (bit) position whether in enumerating, have corresponding definition, for example:
1, check bit flag, check in enumeration definition whether apply System.FlagsAttribute characteristic;
If 2 not application, check by the Enum.IsDefined method providing in scheme one;
If 3 have applied System.FlagsAttribute characteristic, by reflection, obtain all current numerical value of enumerating and define.
Inventor finds in research process, and the technical sophistication degree that scheme two realizes is high, and the execution efficiency of program is low.
Mode technical sophistication degree for the validity checking of enumeration definition in correlation technique is high, and the problem that execution efficiency is low, not yet proposes effective solution at present.
Summary of the invention
The invention provides a kind of definition validity checking method and device of object, high at least to solve the mode technical sophistication degree of validity checking of enumeration definition in correlation technique, the problem that execution efficiency is low.
According to an aspect of the present invention, provide a kind of definition validity checking method of object, having comprised: the returning an object value character string method of invocation target object, and obtain the first rreturn value that returning an object value character string method is returned; Force to change described destination object into basic value type; Call the returning an object value character string method of forcing the described destination object after conversion, and obtain the second rreturn value that returning an object value character string method is returned; According to described the first rreturn value and described the second rreturn value, determine the legitimacy of the definition of described destination object.
Preferably, according to described the first rreturn value and described the second rreturn value, determine that the legitimacy of the definition of described destination object comprises: judge that whether described the first rreturn value is consistent with described the second rreturn value; Judgment result is that consistent in the situation that, the legitimacy of determining the definition of described destination object is no.
Preferably, the legitimacy of determining the definition of described destination object be no after, described method also comprises: the legitimacy that shows the definition of described destination object is no result.
Preferably, judgment result is that, in inconsistent situation, described method also comprises: the legitimacy of determining the definition of described destination object is yes.
Preferably, described basic value type comprises one of following: integer, long.
Preferably, described destination object comprises: inherit and to enumerate or to inherit the combination of enumerating from primary object from primary object.
According to another aspect of the present invention, also provide a kind of definition validity checking device of object, having comprised: the first processing module, for the returning an object value character string method of invocation target object, and obtain the first rreturn value that returning an object value character string method is returned; Modular converter, changes described destination object into basic value type for forcing; The second processing module, for calling the returning an object value character string method of forcing the described destination object after conversion, and obtains the second rreturn value that returning an object value character string method is returned; Determination module, for according to described the first rreturn value and described the second rreturn value, determines the legitimacy of the definition of described destination object.
Preferably, described determination module comprises: judging unit, for judging that whether described the first rreturn value is consistent with described the second rreturn value; The first determining unit, for judgment result is that consistent in the situation that, the legitimacy of determining the definition of described destination object is no.
Preferably, described device also comprises: display module, and for showing that the legitimacy of the definition of described destination object is no result.
Preferably, described determination module also comprises: the second determining unit, for judgment result is that in inconsistent situation, the legitimacy of determining the definition of described destination object is yes.
By the present invention, adopt the returning an object value character string method of invocation target object, and obtain the first rreturn value that returning an object value character string method is returned; Forcing switch target object is basic value type; Call the returning an object value character string method of forcing the destination object after conversion, and obtain the second rreturn value that returning an object value character string method is returned; According to the first rreturn value and the second rreturn value, determine the mode of legitimacy of the definition of destination object, the mode technical sophistication degree of validity checking that has solved enumeration definition in correlation technique is high, the problem that execution efficiency is low, reduce the complexity realizing, improved execution efficiency.
Accompanying drawing explanation
Accompanying drawing described herein is used to provide a further understanding of the present invention, forms the application's a part, and schematic description and description of the present invention is used for explaining the present invention, does not form inappropriate limitation of the present invention.In the accompanying drawings:
Fig. 1 is according to the schematic flow sheet of the definition validity checking method of the object of the embodiment of the present invention;
Fig. 2 is according to the structural representation of the definition validity checking device of the object of the embodiment of the present invention;
Fig. 3 is according to the preferred structure schematic diagram one of the definition validity checking device of the object of the embodiment of the present invention;
Fig. 4 is according to the preferred structure schematic diagram two of the definition validity checking device of the object of the embodiment of the present invention;
Fig. 5 is according to the preferred structure schematic diagram three of the definition validity checking device of the object of the embodiment of the present invention;
Fig. 6 is the workflow schematic diagram of enumerated value invalid value pick-up unit under .NET according to the preferred embodiment of the invention.
Embodiment
It should be noted that, in the situation that not conflicting, embodiment and the feature in embodiment in the application can combine mutually.Describe below with reference to the accompanying drawings and in conjunction with the embodiments the present invention in detail.
In the step shown in the process flow diagram of accompanying drawing, can in the computer system such as one group of computer executable instructions, carry out, and, although there is shown logical order in flow process, in some cases, can carry out shown or described step with the order being different from herein.For example, the step of the step of the step S104 in the following example, step S106 and step S102 can be exchanged.
The present embodiment provides a kind of definition validity checking method of object, and Fig. 1 is according to the schematic flow sheet of the definition validity checking method of the object of the embodiment of the present invention, and as shown in Figure 1, this flow process comprises the steps:
Step S102, the returning an object value character string method of invocation target object, and obtain the first rreturn value that returning an object value character string method is returned;
Step S104, forcing switch target object is basic value type;
Step S106, calls the returning an object value character string method of forcing the destination object after conversion, and obtains the second rreturn value that returning an object value character string method is returned;
Step S108, according to the first rreturn value and the second rreturn value, determines the legitimacy of the definition of destination object.
Pass through above-mentioned steps, the mode that the result of respectively the returning an object value character string method of the destination object after destination object and pressure translation type being returned compares, to determine the legitimacy of the definition of destination object, for the scheme two providing in correlation technique, owing to no longer needing the value by examine to convert binary numeral to, reexamine and on each bit, whether in enumerating, have corresponding definition, thereby the mode technical sophistication degree of validity checking that has solved enumeration definition in correlation technique is high, the problem that execution efficiency is low, reduced the complexity realizing, improved execution efficiency.
Preferably, step S108 comprises: judge that whether the first rreturn value is consistent with the second rreturn value; Judgment result is that consistent in the situation that, the legitimacy of determining the definition of destination object is no.
Preferably, the legitimacy of determining the definition of destination object be no after, the legitimacy of definition that can also display-object object is no result, to notify the definition of ownership goal object, is illegal.
Preferably, in step S108, also comprise: judgment result is that in inconsistent situation, determining that the definition of destination object is legal.
Preferably, above-mentioned basic value type comprises one of following: integer, long.
Preferably, destination object comprises: inherit and to enumerate or to inherit the combination of enumerating from primary object from primary object.By the such scheme providing in the present embodiment, not only can check the legitimacy of single enumeration object, can also support to check enumerating the legitimacy of combination, filled up the existing defect of scheme one in correlation technique.
The present embodiment also provides a kind of definition validity checking device of object, this device is for realizing the definition validity checking method of above-mentioned object, function in this device embodiment realizes had carried out detailed explanation in said method embodiment, at this, will repeat no more.
Fig. 2 is according to the structural representation of the definition validity checking device of the object of the embodiment of the present invention, as shown in Figure 2, this device comprises: the first processing module 22, modular converter 24, the second processing module 26 and determination module 28, wherein, the first processing module 22, for the returning an object value character string method of invocation target object, and obtain the first rreturn value that returning an object value character string method is returned; Modular converter 24 is basic value type for forcing switch target object; The second processing module 26 is coupled to modular converter 24, for calling the returning an object value character string method of forcing the destination object after conversion, and obtains the second rreturn value that returning an object value character string method is returned; Determination module 28 is coupled respectively to the first processing module 22 and the second processing module 26, for according to the first rreturn value and the second rreturn value, determines the legitimacy of the definition of destination object.
Module, unit involved in embodiments of the invention can be realized by the mode of software, also can realize by the mode of hardware.Described module in the present embodiment, unit also can be arranged in processor, for example, can be described as: a kind of processor comprises the first processing module 22, modular converter 24, the second processing modules 26 and determination module 28.Wherein, the title of these modules does not form the restriction to this module itself under certain conditions, for example, the first processing module can also be described to " for the returning an object value character string method of invocation target object and obtain the module of the first rreturn value that returning an object value character string method returns ".
Fig. 3 is that preferably, determination module 28 comprises according to the preferred structure schematic diagram one of the definition validity checking device of the object of the embodiment of the present invention: judging unit 282, for judging that whether the first rreturn value is consistent with the second rreturn value; The first determining unit 284 is coupled to judging unit 282, for judgment result is that consistent in the situation that, the legitimacy of determining the definition of destination object is no.
Fig. 4 is according to the preferred structure schematic diagram two of the definition validity checking device of the object of the embodiment of the present invention, preferably, this device also comprises: display module 42 is coupled to the first determining unit 284, for the legitimacy of the definition of display-object object, is no result.
Fig. 5 is according to the preferred structure schematic diagram three of the definition validity checking device of the object of the embodiment of the present invention, preferably, determination module 28 also comprises: the second determining unit 286 is coupled to judging unit 282, for judgment result is that in inconsistent situation, the legitimacy of determining the definition of destination object is yes.
Preferably, above-mentioned basic value type comprises one of following: integer, long.
Preferably, destination object comprises: inherit and to enumerate or to inherit the combination of enumerating from primary object from primary object.
Below in conjunction with preferred embodiment, be described and illustrate.
This preferred embodiment provide a kind of under .NET enumerated value invalid value pick-up unit, Fig. 6 is the workflow schematic diagram of enumerated value invalid value pick-up unit under .NET according to the preferred embodiment of the invention, as shown in Figure 6, whether legally suppose to detect some enumeration object M, the course of work of this device comprises the steps:
Step S1, calls its returning an object value character string (ToString ()) method by current object M, and the rreturn value of obtaining after its ToString is referred to as A;
Step S2, is transformed into long type by current object M and obtains an object B;
Step S3, is referred to as C by the rreturn value of calling after B object ToString () method;
Step S4, relatively whether A is identical with C, if the same proves that M is the content (illegal) that belongs to non-original definition, if inconsistent, proves that M is the content (being legal) of original definition
Seen from the above description, by the above embodiment of the present invention, can support enumerating the detection of mark (Flag) attribute tags in .NET, and realize the simple validity checking of definition efficiently.In a preferred embodiment of the invention, put forth effort on and check out and enumerate legal definition (checking out that value is the combination of enumerated value definition or enumeration definition), the run-time exception of can also dishing out and if illegal.Visible, the mode technical sophistication degree of validity checking that the embodiment of the present invention has at least solved enumeration definition in correlation technique is high, and the problem that execution efficiency is low has reduced the complexity realizing, and has improved execution efficiency.
Obviously, those skilled in the art should be understood that, above-mentioned each module of the present invention or each step can realize with general calculation element, they can concentrate on single calculation element, or be distributed on the network that a plurality of calculation elements form, alternatively, they can be realized with the executable program code of calculation element, thereby, they can be stored in memory storage and be carried out by calculation element, or they are made into respectively to each integrated circuit modules, or a plurality of modules in them or step are made into single integrated circuit module to be realized.Like this, the present invention is not restricted to any specific hardware and software combination.
More than above are only the preferred embodiments of the present invention, be not limited to the present invention, for a person skilled in the art, the present invention can have various modifications and variations.Within the spirit and principles in the present invention all, any modification of doing, be equal to replacement, improvement etc., within all should being included in protection scope of the present invention.

Claims (10)

1. a definition validity checking method for object, is characterized in that comprising:
The returning an object value character string method of invocation target object, and obtain the first rreturn value that returning an object value character string method is returned;
Force to change described destination object into basic value type;
Call the returning an object value character string method of forcing the described destination object after conversion, and obtain the second rreturn value that returning an object value character string method is returned;
According to described the first rreturn value and described the second rreturn value, determine the legitimacy of the definition of described destination object.
2. method according to claim 1, is characterized in that, according to described the first rreturn value and described the second rreturn value, determines that the legitimacy of the definition of described destination object comprises:
Judge that whether described the first rreturn value is consistent with described the second rreturn value;
Judgment result is that consistent in the situation that, the legitimacy of determining the definition of described destination object is no.
3. method according to claim 2, is characterized in that, the legitimacy of determining the definition of described destination object be no after, described method also comprises:
The legitimacy that shows the definition of described destination object is no result.
4. method according to claim 2, is characterized in that, judgment result is that, in inconsistent situation, described method also comprises:
The legitimacy of determining the definition of described destination object is yes.
5. method according to claim 1, is characterized in that, it is one of following that described basic value type comprises: integer, long.
6. according to the method described in any one in claim 1 to 5, it is characterized in that, described destination object comprises: inherit and to enumerate or to inherit the combination of enumerating from primary object from primary object.
7. a definition validity checking device for object, is characterized in that comprising:
The first processing module, for the returning an object value character string method of invocation target object, and obtains the first rreturn value that returning an object value character string method is returned;
Modular converter, changes described destination object into basic value type for forcing;
The second processing module, for calling the returning an object value character string method of forcing the described destination object after conversion, and obtains the second rreturn value that returning an object value character string method is returned;
Determination module, for according to described the first rreturn value and described the second rreturn value, determines the legitimacy of the definition of described destination object.
8. device according to claim 7, is characterized in that, described determination module comprises:
Judging unit, for judging that whether described the first rreturn value is consistent with described the second rreturn value;
The first determining unit, for judgment result is that consistent in the situation that, the legitimacy of determining the definition of described destination object is no.
9. method according to claim 8, is characterized in that, described device also comprises:
Display module, for showing that the legitimacy of the definition of described destination object is no result.
10. method according to claim 8, is characterized in that, described determination module also comprises:
The second determining unit, for judgment result is that in inconsistent situation, the legitimacy of determining the definition of described destination object is yes.
CN201310591070.4A 2013-11-20 2013-11-20 Object definition validity check method and device Active CN103605748B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310591070.4A CN103605748B (en) 2013-11-20 2013-11-20 Object definition validity check method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310591070.4A CN103605748B (en) 2013-11-20 2013-11-20 Object definition validity check method and device

Publications (2)

Publication Number Publication Date
CN103605748A true CN103605748A (en) 2014-02-26
CN103605748B CN103605748B (en) 2017-04-12

Family

ID=50123970

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310591070.4A Active CN103605748B (en) 2013-11-20 2013-11-20 Object definition validity check method and device

Country Status (1)

Country Link
CN (1) CN103605748B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6029207A (en) * 1990-01-05 2000-02-22 Apple Computer, Inc. Apparatus and method for dynamic linking of computer software components
CN1754151A (en) * 2000-09-21 2006-03-29 国际商业机器公司 Mutability analysis in java
CN1801093A (en) * 2006-01-17 2006-07-12 浙江大学 Class loading implementation method in Java operation system
CN101763271A (en) * 2008-12-26 2010-06-30 爱思开电讯投资(中国)有限公司 Method and device for loading classes and creating and accessing class objects

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6029207A (en) * 1990-01-05 2000-02-22 Apple Computer, Inc. Apparatus and method for dynamic linking of computer software components
CN1754151A (en) * 2000-09-21 2006-03-29 国际商业机器公司 Mutability analysis in java
CN1801093A (en) * 2006-01-17 2006-07-12 浙江大学 Class loading implementation method in Java operation system
CN101763271A (en) * 2008-12-26 2010-06-30 爱思开电讯投资(中国)有限公司 Method and device for loading classes and creating and accessing class objects

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
CHAOJIKUGUA: "字符串转换成实数在转换成字符串,判断输入是否合法", 《HTTP://BBS.CSDN.NET/TOPICS/390299433》, 29 November 2012 (2012-11-29) *
谢春明: "基于Java类加载器的安全检查代码", 《乐山师范学院学报》, vol. 20, no. 05, 20 May 2005 (2005-05-20), pages 77 - 78 *

Also Published As

Publication number Publication date
CN103605748B (en) 2017-04-12

Similar Documents

Publication Publication Date Title
CN102929656B (en) Use method and the client of ActiveX plug-in in browser
CN102831344B (en) Course handling method and device
CN111143087B (en) Interface calling method, device, storage medium and server
CN102567485B (en) The special parsing of provider for content retrieval
CN101216838A (en) XML interface configuration file distribute system and method based on WEB marker
CN110442502B (en) Point burying method, device, equipment and storage medium
CN109684008A (en) Card rendering method, device, terminal and computer readable storage medium
CN111427583A (en) Component compiling method and device, electronic equipment and computer readable storage medium
CN101146119A (en) A device and method for browser-cross self-adapted call of local function
CN104503768A (en) Call method and device for application programming interface (API)
CN112199556A (en) Automatic XML Schema file format conversion method, system and related equipment
US7900213B2 (en) Generic markup specified object descriptor for a modularized computing application
KR101117165B1 (en) Web platform unit for mobile terminal connectioned web-application program in heterogeneous operating system
CN109656567B (en) Dynamic method and system for heterogeneous service data processing logic
CN100383790C (en) HTTP web page dynamic outputting method and system
CN108509228A (en) Method, terminal device and the computer readable storage medium of loading page
CN102810065B (en) For the method and system of loader module
CN103605748A (en) Object definition validity check method and device
CN102984229B (en) For configuring the method and system of trust machine
CN111813385B (en) Page plug-in method, device and equipment based on Web application
WO2015010574A1 (en) Method, apparatus and terminal for webpage content browsing
CN112667491B (en) Function test method and device for virtual machine
CN109597952B (en) Webpage information processing method, system, electronic equipment and storage medium
CN111061576B (en) Method and system for creating entity object
CN111796817A (en) High-cohesion low-coupling processing method and system for iOS and electronic equipment

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
PE01 Entry into force of the registration of the contract for pledge of patent right
PE01 Entry into force of the registration of the contract for pledge of patent right

Denomination of invention: Object definition validity check method and device

Effective date of registration: 20190531

Granted publication date: 20170412

Pledgee: Shenzhen Black Horse World Investment Consulting Co., Ltd.

Pledgor: Beijing Guoshuang Technology Co.,Ltd.

Registration number: 2019990000503

CP02 Change in the address of a patent holder
CP02 Change in the address of a patent holder

Address after: 100083 No. 401, 4th Floor, Haitai Building, 229 North Fourth Ring Road, Haidian District, Beijing

Patentee after: Beijing Guoshuang Technology Co.,Ltd.

Address before: 100086 Beijing city Haidian District Shuangyushu Area No. 76 Zhichun Road cuigongfandian 8 layer A

Patentee before: Beijing Guoshuang Technology Co.,Ltd.