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

Object definition validity check method and device Download PDF

Info

Publication number
CN103605748B
CN103605748B CN201310591070.4A CN201310591070A CN103605748B CN 103605748 B CN103605748 B CN 103605748B CN 201310591070 A CN201310591070 A CN 201310591070A CN 103605748 B CN103605748 B CN 103605748B
Authority
CN
China
Prior art keywords
definition
value
destination object
return value
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.)
Active
Application number
CN201310591070.4A
Other languages
Chinese (zh)
Other versions
CN103605748A (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

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

The definition validity check and device of object
Technical field
The present invention relates to the communications field, in particular to the definition validity check and device of a kind of object.
Background technology
.NET it is Microsoft's extensible markup language Page Service(Microsoft XML Web services)Platform.XML Web services allow application program to pass through internet(Internet)Communicated and shared data, but regardless of adopted It is which kind of operating system, equipment or programming language.Microsoft.NET platforms provide create XML Web services and by this A little Services Integrations are together required.
Enumeration type(Also referred to as enumerate)Have to define one group of name integer constant that can be assigned to variable and providing one kind The method of effect..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.
A certain type is inherited from when enumerating, when the arbitrary value of this type pays enumeration object, no matter when .NET is compiled Or .NET can normally run when running.Arbitrary value is it is generally desirable in service logic should constrain in our enumeration definitions Within the scope of.
The validity checking of enumeration definition is realized in correlation technique using following two schemes:
Scheme one:Enumerated value definition is checked using Enum.IsDefined methods, the method is referred to:Microsoft official document Middle Enum.IsDefined methods definition(http://msdn.microsoft.com/en-us/library/ system.enum.isdefined.aspx).
Inventor has found that scheme one cannot be detected to the situation for enumerating combination in research process.
Scheme two:Enumeration definition is obtained by reflection, by the way that value to be checked is converted into into binary numeral, is reexamined each Individual bit(bit)Whether corresponding definition is had in enumerating on position, for example:
1st, bit flag is checked, checks in enumeration definition whether apply System.FlagsAttribute characteristics;
If the 2, do not applied, checked by the Enum.IsDefined methods provided in scheme one;
If the 3, applying System.FlagsAttribute characteristics, all numbers currently enumerated are obtained by reflection Value definition.
Inventor has found that the technical sophistication degree that scheme two is realized is high, and the execution efficiency of program is low in research process.
High for the mode technical sophistication degree of the validity checking of enumeration definition in correlation technique, execution efficiency is low to ask Topic, not yet proposes at present effective solution.
The content of the invention
The invention provides the definition validity check and device of a kind of object, at least to solve in correlation technique piece The mode technical sophistication degree for lifting the validity checking of definition is high, the low problem of execution efficiency.
According to an aspect of the invention, there is provided a kind of definition validity check of object, including:Invocation target The returning an object value character string method of object, and obtain the first return value of returning an object value character string method return;Unsteady state operation institute Destination object is stated for basic value type;The returning an object value character string method of the destination object after unsteady state operation is called, and Obtain the second return value that returning an object value character string method is returned;According to first return value and second return value, really The legitimacy of the definition of the fixed destination object.
Preferably, according to first return value and second return value, the conjunction of the definition of the destination object is determined Method includes:Judge whether first return value is consistent with second return value;In the case where judged result is consistent, The legitimacy for determining the definition of the destination object is no.
Preferably, it is determined that the destination object definition legitimacy for after no, methods described also includes:Show institute State the result that the legitimacy of the definition of destination object is no.
Preferably, in the case where judged result is inconsistent, methods described also includes:Determine determining for the destination object The legitimacy of justice is yes.
Preferably, the basic value type includes one below:Integer, long.
Preferably, the destination object includes:Be inherited from primary object enumerate or be inherited from primary object enumerate group Close.
According to another aspect of the present invention, a kind of definition validity checking device of object is additionally provided, including:First Processing module, for the returning an object value character string method of invocation target object, and obtains the return of returning an object value character string method First return value;Modular converter, is basic value type for destination object described in unsteady state operation;Second processing module, is used for The returning an object value character string method of the destination object after unsteady state operation is called, and obtains the return of returning an object value character string method The second return value;Determining module, for according to first return value and second return value, determining the destination object Definition legitimacy.
Preferably, the determining module includes:Judging unit, for judging that first return value and described second is returned Whether value is consistent;First determining unit, in the case of being consistent in judged result, determines the definition of the destination object Legitimacy is no.
Preferably, described device also includes:Display module, for showing that the legitimacy of definition of the destination object is no Result.
Preferably, the determining module also includes:Second determining unit, for being inconsistent situation in judged result Under, the legitimacy for determining the definition of the destination object is yes.
By the present invention, using the returning an object value character string method of invocation target object, and returning an object value character string is obtained The first return value that method is returned;Unsteady state operation destination object is basic value type;Call the destination object after unsteady state operation Returning an object value character string method, and obtain returning an object value character string method return the second return value;According to the first return value With the second return value, the mode of the legitimacy of the definition of destination object is determined, solve the legal of enumeration definition in correlation technique Property the mode technical sophistication degree that checks it is high, the low problem of execution efficiency reduces the complexity of realization, improves execution efficiency.
Description of the drawings
Accompanying drawing described herein is used for providing a further understanding of the present invention, constitutes the part of the application, this Bright schematic description and description does not constitute inappropriate limitation of the present invention for explaining the present invention.In the accompanying drawings:
Fig. 1 is the schematic flow sheet of the definition validity check of object according to embodiments of the present invention;
Fig. 2 is the structural representation for defining validity checking device of object according to embodiments of the present invention;
Fig. 3 is the preferred structure schematic diagram one for defining validity checking device of object according to embodiments of the present invention;
Fig. 4 is the preferred structure schematic diagram two for defining validity checking device of object according to embodiments of the present invention;
Fig. 5 is the preferred structure schematic diagram three for defining validity checking device of object according to embodiments of the present invention;
Fig. 6 is that the workflow of the invalid value detection device of enumerated value under .NET according to the preferred embodiment of the invention is illustrated Figure.
Specific embodiment
It should be noted that in the case where not conflicting, the feature in embodiment and embodiment in the application can phase Mutually combination.Below with reference to the accompanying drawings and in conjunction with the embodiments describing the present invention in detail.
Can be in the such as computer system of one group of computer executable instructions the step of the flow process of accompanying drawing is illustrated Perform, and, although show logical order in flow charts, but in some cases, can be with suitable different from herein Sequence performs shown or described step.For example, in the examples below that the step of S104, step S106 the step of and step The step of S102 can be exchange.
Present embodiments provide a kind of definition validity check of object, Fig. 1 is according to embodiments of the present invention right The schematic flow sheet of the definition validity check of elephant, as shown in figure 1, the flow process comprises the steps:
Step S102, the returning an object value character string method of invocation target object, and obtain returning an object value character string method and return The first return value returned;
Step S104, unsteady state operation destination object is basic value type;
Step S106, calls the returning an object value character string method of the destination object after unsteady state operation, and obtains returning an object value The second return value that character string method is returned;
Step S108, according to the first return value and the second return value, determines the legitimacy of the definition of destination object.
By above-mentioned steps, respectively to the returning an object value character of the destination object after destination object and unsteady state operation type The mode that the result that string method is returned is compared, to determine the legitimacy of the definition of destination object, relative to correlation technique For the scheme two of middle offer, due to no longer needing for value to be checked to be converted into binary numeral, each bit is reexamined On whether have corresponding definition in enumerating, so as to solve correlation technique in enumeration definition validity checking mode technology Complexity is high, and the low problem of execution efficiency reduces the complexity of realization, improves execution efficiency.
Preferably, step S108 includes:Judge whether the first return value is consistent with the second return value;It is one in judged result In the case of cause, the legitimacy for determining the definition of destination object is no.
Preferably, it is determined that destination object definition legitimacy for after no, can be with the definition of display target object The legitimacy result that is no, to notify that the definition of ownership goal object is illegal.
Preferably, also include in step S108:In the case where judged result is inconsistent, determining for destination object is determined Justice is legal.
Preferably, above-mentioned basic value type includes one below:Integer, long.
Preferably, destination object includes:Be inherited from primary object enumerate or be inherited from primary object enumerate combination.It is logical The such scheme provided in the present embodiment is provided, is not only able to check the legitimacy of single enumeration object, additionally it is possible to Hold the legitimacy to enumerating combination to check, fill up the defect existing for scheme one in correlation technique.
The present embodiment additionally provides a kind of definition validity checking device of object, and the device is used to realize above-mentioned object Definition validity check, the functional realiey in the device embodiment had carried out detailed in said method embodiment Illustrate, here will not be described in great detail.
Fig. 2 is the structural representation for defining validity checking device of object according to embodiments of the present invention, such as Fig. 2 institutes Show, the device includes:First processing module 22, modular converter 24, Second processing module 26 and determining module 28, wherein, first Processing module 22, for the returning an object value character string method of invocation target object, and obtains the return of returning an object value character string method The first return value;Modular converter 24, is basic value type for unsteady state operation destination object;Second processing module 26 is coupled To modular converter 24, for calling unsteady state operation after destination object returning an object value character string method, and obtain returning an object value The second return value that character string method is returned;Determining module 28 is coupled respectively to first processing module 22 and Second processing module 26, for according to the first return value and the second return value, determining the legitimacy of the definition of destination object.
Involved module, unit can be realized by way of software in embodiments of the invention, it is also possible to be passed through The mode of hardware is realizing.Described module, unit in the present embodiment can also be arranged within a processor, for example, can be with It is described as:A kind of processor includes first processing module 22, modular converter 24, Second processing module 26 and determining module 28.Its In, the title of these modules is not constituted under certain conditions to the module restriction of itself, and for example, first processing module may be used also To be described as " being used for the returning an object value character string method of invocation target object and obtaining the return of returning an object value character string method The module of the first return value ".
Fig. 3 is the preferred structure schematic diagram one for defining validity checking device of object according to embodiments of the present invention, excellent Selection of land, determining module 28 includes:Judging unit 282, for judging whether the first return value is consistent with the second return value;First is true Order unit 284 is coupled to judging unit 282, in the case of being consistent in judged result, determines the definition of destination object Legitimacy is no.
Fig. 4 is the preferred structure schematic diagram two for defining validity checking device of object according to embodiments of the present invention, excellent Selection of land, the device also includes:Display module 42 is coupled to the first determining unit 284, for the conjunction of the definition of display target object The result that method is no.
Fig. 5 is the preferred structure schematic diagram three for defining validity checking device of object according to embodiments of the present invention, excellent Selection of land, determining module 28 also includes:Second determining unit 286 is coupled to judging unit 282, for being inconsistent in judged result In the case of, the legitimacy for determining the definition of destination object is yes.
Preferably, above-mentioned basic value type includes one below:Integer, long.
Preferably, destination object includes:Be inherited from primary object enumerate or be inherited from primary object enumerate combination.
It is described with reference to preferred embodiment and illustrates.
This preferred embodiment provides one kind invalid value detection device of enumerated value under .NET, and Fig. 6 is excellent according to the present invention The workflow schematic diagram of the invalid value detection device of enumerated value under .NET of embodiment is selected, as shown in Figure 6, it is assumed that need detection Whether some enumeration object M is legal, and the course of work of the device comprises the steps:
Step S1, by existing object M its returning an object value character string is called(ToString())Method, obtains its ToString Return value afterwards is referred to as A;
Step S2, is transformed into existing object M long types and obtains an object B;
Step S3, will call the return value after B object ToString () methods to be referred to as C;
Step S4, compares whether A and C is identical, if the same proves that M is belonging to the content of non-primary definition(Do not conform to Method), prove that M is the content of original definition if inconsistent(It is i.e. legal)
Seen from the above description, can be supported to enumerating mark in .NET by the above embodiment of the present invention(Flag)It is special Property mark detection, and realize and simple efficient define validity checking.In a preferred embodiment of the invention, inspection is put forth effort on Find and enumerate legal definition(Check that value is the combination of enumerated value definition or enumeration definition), and if illegal can also Enough dish out run-time exception.It can be seen that, the embodiment of the present invention solve at least the validity checking of enumeration definition in correlation technique Mode technical sophistication degree is high, and the low problem of execution efficiency reduces the complexity of realization, improves execution efficiency.
Obviously, those skilled in the art should be understood that above-mentioned each module of the invention or each step can be with general Computing device realizing, they can be concentrated on single computing device, or are distributed in multiple computing devices and are constituted Network on, alternatively, they can be realized with the executable program code of computing device, it is thus possible to they are stored Performed by computing device in the storage device, or they be fabricated to respectively each integrated circuit modules, or by they In multiple modules or step be fabricated to single integrated circuit module to realize.So, the present invention is not restricted to any specific Hardware and software is combined.
The preferred embodiments of the present invention are more than above are only, the present invention is not limited to, for the skill of this area For art personnel, the present invention can have various modifications and variations.It is all within the spirit and principles in the present invention, made any repair Change, equivalent, improvement etc., should be included within the scope of the present invention.

Claims (8)

1. a kind of definition validity check of object, it is characterised in that include:
The returning an object value character string method of invocation target object, and obtain the first return of returning an object value character string method return Value, wherein, the destination object is enumeration object;
Destination object described in unsteady state operation is basic value type;
The returning an object value character string method of the destination object after unsteady state operation is called, and obtains returning an object value character string method The second return value for returning;
According to first return value and second return value, the legitimacy of the definition of the destination object is determined;
Wherein, according to first return value and second return value, the legitimacy bag of the definition of the destination object is determined Include:
Judge whether first return value is consistent with second return value;
In the case where judged result is consistent, the legitimacy for determining the definition of the destination object is no.
2. method according to claim 1, it is characterised in that it is determined that the legitimacy of definition of the destination object is no Afterwards, methods described also includes:
Show the result that the legitimacy of the definition of the destination object is no.
3. method according to claim 1, it is characterised in that in judged result in the case of inconsistent, methods described Also include:
The legitimacy for determining the definition of the destination object is yes.
4. method according to claim 1, it is characterised in that the basic value type includes one below:Integer, length Integer.
5. method according to any one of claim 1 to 4, it is characterised in that the destination object includes:It is inherited from original Source object enumerate or be inherited from primary object enumerate combination.
6. the definition validity checking device of a kind of object, it is characterised in that include:
First processing module, for the returning an object value character string method of invocation target object, and obtains returning an object value character string side The first return value that method is returned, wherein, the destination object is enumeration object;
Modular converter, is basic value type for destination object described in unsteady state operation;
Second processing module, for calling unsteady state operation after the destination object returning an object value character string method, and obtain The second return value that returning an object value character string method is returned;
Determining module, for according to first return value and second return value, determining the definition of the destination object Legitimacy;
Wherein, the determining module includes:
Judging unit, for judging whether first return value is consistent with second return value;
First determining unit, in the case of being consistent in judged result, determines the legitimacy of the definition of the destination object It is no.
7. device according to claim 6, it is characterised in that described device also includes:
Display module, for showing the result that the legitimacy of definition of the destination object is no.
8. device according to claim 6, it is characterised in that the determining module also includes:
Second determining unit, for judged result in the case of inconsistent, determine the destination object definition it is legal Property 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 CN103605748A (en) 2014-02-26
CN103605748B true 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
基于Java类加载器的安全检查代码;谢春明;《乐山师范学院学报》;20050520;第20卷(第05期);77-78 *
字符串转换成实数在转换成字符串,判断输入是否合法;chaojikugua;《http://bbs.csdn.net/topics/390299433》;20121129;1 *

Also Published As

Publication number Publication date
CN103605748A (en) 2014-02-26

Similar Documents

Publication Publication Date Title
US8595700B2 (en) Method and apparatus for reusing components of a component-based software system
CN107438107B (en) Method and device for calling background service in micro-service architecture
CN104866327B (en) A kind of PHP development approaches and framework
US8448163B2 (en) Deploying J2EE web applications in an OSGI environment
CN102831344B (en) Course handling method and device
US8661404B2 (en) Method for improving execution efficiency of a software package customization
CN110058864B (en) Micro-service deployment method and device
CN102929656A (en) Method for using ActiveX plug-in in browser, and client
CN105471968B (en) A kind of method for interchanging data, system and data platform server
US20090144711A1 (en) System and method for common compiler services based on an open services gateway initiative architecture
US7519972B2 (en) Real-time multi-modal business transformation interaction
CN103186455A (en) Method and system for generating automatic test script on page
EP2069921A2 (en) Predicting trustworthiness for component software
CN110908908B (en) Method and device for testing micro-service Dubbo interface
US7900213B2 (en) Generic markup specified object descriptor for a modularized computing application
CN109656567B (en) Dynamic method and system for heterogeneous service data processing logic
CN108140089A (en) Analytical equipment, analysis method and analysis program
CN103605748B (en) Object definition validity check method and device
CN102810065B (en) For the method and system of loader module
US20090276856A1 (en) License management facility
Sharma et al. Detecting performance antipatterns before migrating to the cloud
CN105760293B (en) The method and system of muti-language support test
CN102722396A (en) Method and system for loading components
CN105912468A (en) Method of operating scripts by open platform and open platform system
CN112306496A (en) Block chain operation information analysis method, device, equipment and computer storage medium

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

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

PE01 Entry into force of the registration of the contract for pledge of patent right
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.

CP02 Change in the address of a patent holder