CN109656744A - The method and apparatus for realizing data check and injection are explained based on Java - Google Patents

The method and apparatus for realizing data check and injection are explained based on Java Download PDF

Info

Publication number
CN109656744A
CN109656744A CN201710941311.1A CN201710941311A CN109656744A CN 109656744 A CN109656744 A CN 109656744A CN 201710941311 A CN201710941311 A CN 201710941311A CN 109656744 A CN109656744 A CN 109656744A
Authority
CN
China
Prior art keywords
label
field
file
injection
attribute
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201710941311.1A
Other languages
Chinese (zh)
Inventor
徐国英
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information 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 Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201710941311.1A priority Critical patent/CN109656744A/en
Publication of CN109656744A publication Critical patent/CN109656744A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/08Error detection or correction by redundancy in data representation, e.g. by using checking codes
    • G06F11/10Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses the method and apparatus for realizing data check and injection are explained based on Java, it is related to field of computer technology.One specific embodiment of this method includes: a kind of method explained based on Java and realize data check, comprising: determines the verification label explained based on Java according to interface specification, includes multiple constraints in interface specification;High-ranking officers' standard inspection label are added in source file, generate file to be verified;File to be verified is run using validator, realizes the verification to source file.Configurableization that the embodiment can greatly simplify the step of data check, realize data check, reusability is high, and versatility is good.

Description

The method and apparatus for realizing data check and injection are explained based on Java
Technical field
The present invention relates to field of computer technology more particularly to a kind of explained based on Java to realize data check and injection Method and apparatus.
Background technique
It is past in order to guarantee that transmitted data can satisfy the interface specification of data receiver in data transmission procedure It is past to need to verify data, such as syntax check and semantic checking.
The prior art when carrying out data check, mostly before generating xml first to related javabean object and The attribute of javabean object is judged that, when the attribute field of data check object is more, checking procedure is very numb one by one It is tired, poor universality.
When carrying out data injection, each field in data requires to generate javabean object the prior art, passes through It calls third party's interface or database to obtain attribute information, is then again infused attribute information by this mode of get and set Enter, data injection process is very troublesome, can not be multiplexed, scalability is poor.
Summary of the invention
In view of this, the embodiment of the present invention provides a kind of method and dress explained based on Java and realize data check and injection The step of setting, capable of greatly simplifying data check and injection, configurableization for realizing data check and injection, reusability is high, leads to It is good with property.
To achieve the above object, first aspect according to an embodiment of the present invention provides a kind of real based on Java note The method of existing data check, comprising:
The verification label explained based on Java is determined according to interface specification, includes multiple constraints in interface specification;
High-ranking officers' standard inspection label are added in source file, generate file to be verified;
File to be verified is run using validator, realizes the verification to source file.
Optionally, verification label includes at least one of:
Common verification label, for describing the attribute and value range of each field in source file;
Customized verification label, the constraint for describing not described with common label in interface specification;
Compound verification label, at least two constraints that must satisfy for describing either field in source file.
Optionally, file to be verified is run using validator, comprising:
Traverse each field of file to be verified, if comprising verification label in field, obtain verification label in field, And the attribute and value range of field;
Obtain the corresponding check information of verification label;
If the attribute and value range of field meet check information, the attribute and value range of field meet interface rule Model.
Optionally, validator includes at least one of: grammer validator, semantic verification device.
The second aspect according to an embodiment of the present invention provides a kind of side explained based on Java and realize data injection Method, comprising:
According to the attribute information of field each in source file, the injection label explained based on Java is determined;
Injection label is added in source file, file to be implanted is generated;
File to be implanted is run using annotation processor, realizes the injection to source file.
Optionally, injection label includes at least one of:
Constant injects label, for describing the attribute information of the immutable field of attribute information in source file;
Common injection label, the attribute information for describing not including in source file and need to obtain from third party's interface;
Customized injection label, at least two attribute informations for including for describing either field in source file.
Optionally, file to be implanted is run using annotation processor, comprising:
Each field of injected file is traversed, if obtaining the attribute of field comprising injection label on the attribute of field On injection label;
Obtain the corresponding attribute information of injection label;
Attribute information is injected on the attribute of the corresponding field of injection label.
Optionally, the embodiment of the present invention further comprises based on the Java method for explaining realization data injection:
For each field of file to be implanted, if field is set class object, loop iteration goes out to gather in class object Each attribute;Gathering class object includes at least two attributes.
In terms of third according to an embodiment of the present invention, a kind of side explained based on Java and realize data transmission is provided Method, comprising:
Source file is verified using the method for realizing data check is explained the present invention is based on Java;
The source file for meeting interface specification is injected using the method for realizing data injection is explained based on Java.
4th aspect according to an embodiment of the present invention, provides a kind of dress explained based on Java and realize data check It sets, comprising:
Tag generation module is verified, for determining the verification label explained based on Java, interface specification according to interface specification In include multiple constraints;
File generating module is verified, is added in source file for high-ranking officers' standard inspection label, generates file to be verified;
Execution module is verified, for running file to be verified using validator, realizes the verification to source file.
Optionally, verification label includes at least one of:
Common verification label, for describing the attribute and value range of each field in source file;
Customized verification label, the constraint for describing not described with common label in interface specification;
Compound verification label, at least two constraints that must satisfy for describing either field in source file.
Optionally, verification execution module runs file to be verified using validator, comprising:
Traverse each field of file to be verified, if comprising verification label in field, obtain verification label in field, And the attribute and value range of field;
Obtain the corresponding check information of verification label;
If the attribute and value range of field meet check information, the attribute and value range of field meet interface rule Model.
Optionally, validator includes at least one of: grammer validator, semantic verification device.
5th aspect according to an embodiment of the present invention, provides a kind of dress explained based on Java and realize data injection It sets, comprising:
Tag generation module is injected, for the attribute information according to field each in source file, determines and is explained based on Java Injection label;
File generating module is injected, is added in source file for label will to be injected, generates file to be implanted;
Execution module is injected, for running file to be implanted using annotation processor, realizes the injection to source file.
Optionally, injection label includes at least one of:
Constant injects label, for describing the attribute information of the immutable field of attribute information in source file;
Common injection label, the attribute for describing not including in the source file and need to obtain from third party's interface Information;
Customized injection label, at least two attribute informations for including for describing either field in source file.
Optionally, injection execution module runs file to be implanted using annotation processor, comprising:
Each field of file to be implanted is traversed, if obtaining the attribute of field comprising injection label on the attribute of field On injection label;
Obtain the corresponding attribute information of injection label;
Attribute information is injected on the attribute of the corresponding field of injection label.
Optionally, injection execution module is further used for:
For each field of file to be implanted, if field is set class object, loop iteration goes out to gather in class object Each attribute;Gathering class object includes at least two attributes.
It is according to an embodiment of the present invention 6th aspect, provide it is a kind of based on Java explain realize data transmission be System, comprising:
Realize that the device of data check verifies source file using explaining the present invention is based on Java;
Realize that the device of data injection infuses the source file for meeting interface specification using explaining the present invention is based on Java Enter.
7th aspect according to an embodiment of the present invention, provides a kind of end explained based on Java and realize data transmission End, comprising:
One or more processors;
Storage device, for storing one or more programs,
When one or more of programs are executed by one or more of processors, so that one or more of processing Device realizes the method that the embodiment of the present invention first is provided to the third aspect.
Still another aspect according to an embodiment of the present invention provides a kind of computer-readable medium, is stored thereon with calculating Machine program realizes the method that the embodiment of the present invention first is provided to the third aspect when described program is executed by processor.
One embodiment in foregoing invention has the following advantages that or the utility model has the advantages that is verified by being determined according to interface specification Label, simultaneously high-ranking officers' standard inspection label are added in source file, are able to solve verification step trouble, method of calibration does not have the technology of versatility Problem realizes that configurableization of data check and injection, reusability are high, practical good;By according to field each in source file Attribute information determines injection label and injection label is added in source file that being able to solve data injection cannot be multiplexed, extend Property difference technical problem, configurableization for greatly simplifying data injection step, realizing data injection, reusability is high, versatility is good.
Further effect possessed by above-mentioned non-usual optional way adds hereinafter in conjunction with specific embodiment With explanation.
Detailed description of the invention
Attached drawing for a better understanding of the present invention, does not constitute an undue limitation on the present invention.Wherein:
Fig. 1 is the signal according to an embodiment of the present invention explained based on Java and realize the main flow of method of data check Figure;
Fig. 2 is the key step signal according to an embodiment of the present invention that the method for realizing data check is explained based on Java Figure;
Fig. 3 is the signal according to an embodiment of the present invention explained based on Java and realize the main flow of method of data injection Figure;
Fig. 4 is the key step signal of the method according to an embodiment of the present invention explained based on Java and realize data injection Figure;
Fig. 5 is the flow diagram according to an embodiment of the present invention explained based on Java and realize the method for data transmission;
Fig. 6 is the main modular signal according to an embodiment of the present invention explained based on Java and realize the device of data check Figure;
Fig. 7 is the main modular signal according to an embodiment of the present invention explained based on Java and realize the device of data injection Figure;
Fig. 8 is the module diagram according to an embodiment of the present invention explained based on Java and realize the system of data transmission;
Fig. 9 is that the embodiment of the present invention can be applied to exemplary system architecture figure therein;
Figure 10 is adapted for showing for the structure of the computer system of the terminal device or server of realizing the embodiment of the present invention It is intended to.
Specific embodiment
Below in conjunction with attached drawing, an exemplary embodiment of the present invention will be described, including the various of the embodiment of the present invention Details should think them only exemplary to help understanding.Therefore, those of ordinary skill in the art should recognize It arrives, it can be with various changes and modifications are made to the embodiments described herein, without departing from scope and spirit of the present invention.Together Sample, for clarity and conciseness, descriptions of well-known functions and structures are omitted from the following description.
Without prejudice to inventive concept of the invention, the various features disclosed in the description can any and institute Some combinations use.
Fig. 1 is the signal according to an embodiment of the present invention explained based on Java and realize the main flow of method of data check Figure, as shown in Figure 1, comprising:
Step S101, the verification label explained based on Java is determined according to interface specification, include in interface specification it is multiple about Beam;
Step S102, high-ranking officers' standard inspection label are added in source file, generate file to be verified;
Step S103, file to be verified is run using validator, realizes the verification to source file.
In the present embodiment, Java adds, and is that a kind of program of object-oriented that can write cross-platform software is set Count language;Note is also metadata, is a kind of other explanation of code level, and class, interface, to enumerate be in the same level, it can To state before packet, class, field, method, local variable, method parameter etc., for being illustrated, infusing to these elements It releases;Label is verified, refers to that the Java that can be used in data check explains label.
Verification label in the present invention is to determine that the verification label can be realized according to the interface specification of data receiver Configurableization, it can be used repeatedly, without for multiple fields in different data to be verified or same group of data It is respectively created verification label, reusability is high, versatility is good, the step of capable of greatly simplifying data check, improves the effect of data check Rate.
Verification label is due to being to be marked by way of label in the interface specification data receiver to the constraint of data Out.The method of determination of verification label can be determined according to the actual conditions of interface specification and application program.Some In embodiment, verification label includes at least one of: commonly verifying label, customized verification label, compound verification label.It is general Logical verification label, customized verification label and compound verification label can flexible setting according to the actual situation, to greatly improve The versatility of data verification method of the invention.
Common verification label, for describing the attribute and value range of each field in source file;For example, if according to interface It standardizes, when the attribute of a certain field must be empty in source file, corresponding verification label is set as common label "@Null ";If According to interface specification, when the attribute of a certain field is necessary for non-empty in source file, corresponding verification label is set as common label "@NotNull";If the value of a certain field is a number and has to be larger than equal to specified in source file according to interface specification Minimum value when, corresponding verification label is set as common label "@Min (value) ";If according to interface specification, in source file When the value of a certain field is a number and is necessarily less than the maximum value for being equal to and specifying, corresponding verification label is set as general Logical label "@Max (value) ".
Customized verification label, the constraint for describing not described with common label in interface specification;For the ease of Common verification label and customized verification label are distinguished, "@interface " can be used and be used to state a note, it is therein Each method is actually to state a configuration parameter.It is automatic to inherit when verification label customized using@interface (Java.lang.annotation.Annotation provides branch for explaining facility for Java programming language to Java software packet Hold) interface, other details are automatically performed by compiler.When defining Java note, other notes or interface cannot be inherited. For example, fruit title can be described using following customized verification label:
public@interface FruitName{
String value()default"";
}。
Compound verification label, at least two constraints that must satisfy for describing either field in source file.Composite label The combination that can be common verification label is also possible to the combination of customized verification label, is also possible to comprising common verification mark The combination of label and customized verification label.For example, if the value range of a certain field is less than or equal to specified according to interface specification Maximum value and when being more than or equal to specified minimum value, will can commonly verify label "@Min (value) " and common verification is marked Label "@Max (value) " are applied in combination, and form compound verification label.
In some embodiments, file to be verified can be run using validator, comprising:
Traverse each field of file to be verified, if comprising verification label in field, obtain verification label in field, And the attribute and value range of field;
Obtain the corresponding check information of verification label;
If the attribute and value range of field meet check information, the attribute and value range of field meet interface rule Model.
Optionally, validator includes at least one of: grammer validator, semantic verification device.Syntax check is digital examination Whether the format of data meets the format required in interface specification, for example whether the length containing certain fields or field, big It is small to wait whether meet interface specification etc..Semantic checking is whether digital examination data semantic meets interface specification, such as checks account Whether title matches with modification logging.
Fig. 2 is an alternative embodiment according to the present invention, in this embodiment, is explained based on Java and realizes data check The key step of method include:
Judge whether to need to carry out data check to source data;
If not needing to carry out data check, verification terminates;If desired, then common verification is added in the field of source data Label and customized verification label, generate file to be verified;
Obtain the verification label in each field of file to be verified:
If the verification label is customized label, school is carried out to file to be verified using customized verification label Verification device It tests;If source data meets interface specification, verification passes through, and verification terminates;If source data does not meet interface specification, reported Mistake, verification do not pass through;
If the verification label is common verification label, school is carried out to file to be verified using common verification label Verification device It tests;If source data meets interface specification, verification passes through, and verification terminates;If source data does not meet interface specification, reported Mistake, verification do not pass through.
Fig. 3 shows the main flow of the method according to an embodiment of the present invention explained based on Java and realize data injection Schematic diagram, as shown in Figure 3, comprising:
Step S301, according to the attribute information of field each in source file, the injection label explained based on Java is determined;
Step S302, injection label is added in source file, generates file to be implanted;
Step S303, file to be implanted is run using annotation processor, realizes the injection to source file.
The prior art in the application, if necessary to the attribute assignment given in a class, generally uses the set of javabean The mode of method, this data injection cannot be multiplexed, and scalability is poor.It is true by the attribute information according to field each in source file Surely it injects label and injection label is added in source file, it can be with the mode that tag reflection injects to object value, when perhaps It, can be with when the multipair value assignment for thering is identical attribute to need to assign identical constant value as in or other interfaces being called to acquire It iterates through injection label and carries out assignment, it is simple and convenient.Further, since the injection label in the present invention can be repeatedly multiplexed, because This can greatly simplify the step of data injection, realize configurableization of data injection, reusability height, versatility and scalability It is good.
The attribute that injection label is used to define field in source data should inject what value and the source of this value.? In some embodiments, injection label includes at least one of: constant injects label, commonly injects label, customized injection mark Label.
Constant injects label, for describing the attribute information of the immutable field of attribute information in source file;For example, for The per capita household electricity consumption data in a certain area, the title of this area or other unique identifications of this area are a constants, therefore Label can be injected as constant;Data are recorded for the web page browsing of a certain user, the user name of the user is one Constant, therefore label can be injected using the user name of the user as constant.
Common injection label, the attribute information for describing not including in source file and need to obtain from third party's interface; For example, " value1=orderId " is stored in database, then it can be by the way that common note be arranged in a certain field of source data Enter label "@FieldMeta (fieldMapper=value1) ", so that " orderId " to be injected to the attribute of the field.
Customized injection label, at least two attribute informations for including for describing either field in source file.It is customized Injection label can be the combination of common injection label, be also possible to the group comprising constant injection label and common injection label It closes.For example, having attribute c and attribute d in same class A, attribute c needs to inject addressee's name, and attribute d needs to inject order total Valence can obtain addressee's name and order total price by a customized injection label " cc_defined_service ".
Optionally, file to be implanted is run using annotation processor, comprising:
Each field of file to be implanted is traversed, if obtaining the attribute of field comprising injection label on the attribute of field On injection label;For example, obtaining all properties of each field of file to be implanted using Java reflection reflect, pass through Java explains the injection label on calling interface API acquisition attribute;
Obtain the corresponding attribute information of injection label;
Attribute information is injected on the attribute of the corresponding field of injection label, for example, being infused using Java reflection reflect The mode entered is injected attribute information on the attribute of the corresponding field of injection label.
Optionally, the embodiment of the present invention further comprises based on the Java method for explaining realization data injection:
For each field of file to be implanted, if field is set class object, loop iteration goes out to gather in class object Each attribute;Gathering class object includes at least two attributes.
Fig. 4 is an alternative embodiment according to the present invention, in this embodiment, is explained based on Java and realizes data injection The key step of method include:
Judge whether to need to carry out data injection to source data;
If not needing to carry out data injection, injection terminates;If desired, then whether each field for judging source data is collection Close class object:
If gathering class object, then loop iteration goes out to gather each attribute in class object, converts set class object to Simple class object;Wherein, simple class object is only comprising an attribute;
If simple class object, then constant injection label, common injection label are added in the field of source data and makes by oneself Justice injection label, generates file to be implanted;
If the injection label is constant injection label, data are directly injected into such a way that Java reflects;
If the injection label is common injection label, data injection is carried out using common annotation processor;
If the injection label is customized injection label, data injection is carried out using customized annotation processor.
The embodiment of the invention also provides a kind of methods explained based on Java and realize data transmission, comprising:
Source file is verified using the method for realizing data check is explained the present invention is based on Java;In the present embodiment Data verification method can be any one in the various data verification methods that the present invention refers to, details are not described herein again;
The source file for meeting interface specification is injected using the method for realizing data injection is explained based on Java.This reality Applying the data method for implanting in example can be any one in the various data method for implanting that refer to of the present invention, no longer superfluous herein It states.
Fig. 5 shows an alternative embodiment of the invention, is explained in the embodiment based on Java and realizes data transmission Method includes:
Judge whether to need to carry out data check to source data;If not needing to carry out data check, the data transfer ends; If desired, then data check is carried out to source data:
If source data meets interface specification, verification passes through;Otherwise, it reports an error, verification does not pass through;
Judge whether to need to carry out data injection to the source data for meeting interface specification;If not needing to carry out data injection, Then the data transfer ends;If desired, then data injection is carried out to the source data for meeting interface specification.
Fig. 6 is that according to an embodiment of the present invention explained based on Java realizes that the main modular of the device 600 of data check is shown It is intended to, as shown in Figure 6, comprising:
Tag generation module 601 is verified, for determining the verification label explained based on Java, interface rule according to interface specification It include multiple constraints in model;
File generating module 602 is verified, is added in source file for high-ranking officers' standard inspection label, generates file to be verified;
Execution module 603 is verified, for running file to be verified using validator, realizes the verification to source file.
Optionally, verification label includes at least one of:
Common verification label, for describing the attribute and value range of each field in source file;
Customized verification label, the constraint for describing not described with common label in interface specification;
Compound verification label, at least two constraints that must satisfy for describing either field in source file.
Optionally, verification execution module 603 runs file to be verified using validator, comprising:
Traverse each field of file to be verified, if comprising verification label in field, obtain verification label in field, And the attribute and value range of field;
Obtain the corresponding check information of verification label;
If the attribute and value range of field meet check information, the attribute and value range of field meet interface rule Model.
Optionally, validator includes at least one of: grammer validator, semantic verification device.
Fig. 7 is that according to an embodiment of the present invention explained based on Java realizes that the main modular of the device 700 of data injection is shown It is intended to, as shown in fig. 7, comprises:
Tag generation module 701 is injected, for the attribute information according to field each in source file, determines and is infused based on Java The injection label of solution;
File generating module 702 is injected, is added in source file for label will to be injected, generates file to be implanted;
Execution module 703 is injected, for running file to be implanted using annotation processor, realizes the injection to source file.
Optionally, injection label includes at least one of:
Constant injects label, for describing the attribute information of the immutable field of attribute information in source file;
Common injection label, the attribute for describing not including in the source file and need to obtain from third party's interface Information;
Customized injection label, at least two attribute informations for including for describing either field in source file.
Optionally, injection execution module 703 runs file to be implanted using annotation processor, comprising:
Each field of file to be implanted is traversed, if obtaining the attribute of field comprising injection label on the attribute of field On injection label;
Obtain the corresponding attribute information of injection label;
Attribute information is injected on the attribute of the corresponding field of injection label.
Optionally, injection execution module is further used for:
For each field of file to be implanted, if field is set class object, loop iteration goes out to gather in class object Each attribute;Gathering class object includes at least two attributes.
Fig. 8 is that according to an embodiment of the present invention explained based on Java realizes that the main modular of the system 800 of data transmission is shown It is intended to, as shown in Figure 8, comprising:
Realize that the device 600 of data check verifies source file using explaining the present invention is based on Java;
Realize that the device 700 of data injection carries out the source file for meeting interface specification using explaining the present invention is based on Java Injection.
7th aspect according to an embodiment of the present invention, provides a kind of end explained based on Java and realize data transmission End, comprising:
One or more processors;
Storage device, for storing one or more programs,
When one or more of programs are executed by one or more of processors, so that one or more of processing Device realizes that the embodiment of the present invention is explained the method for realizing data check based on Java or explained based on Java and realizes data injection Method explains the method for realizing data transmission based on Java.
Fig. 9, which is shown, can apply explaining based on Java for the embodiment of the present invention to realize the method for data check or be based on Java is explained the method for realizing data injection or is explained the exemplary system architecture for realizing the method for data transmission based on Java 900。
As shown in figure 9, system architecture 900 may include terminal device 901,902,903, network 904 and server 905. Network 904 between terminal device 901,902,903 and server 905 to provide the medium of communication link.Network 904 can be with Including various connection types, such as wired, wireless communication link or fiber optic cables etc..
User can be used terminal device 901,902,903 and be interacted by network 904 with server 905, to receive or send out Send message etc..Various telecommunication customer end applications, such as the application of shopping class, net can be installed on terminal device 901,902,903 The application of page browsing device, searching class application, instant messaging tools, mailbox client, social platform software etc..
Terminal device 901,902,903 can be the various electronic equipments with display screen and supported web page browsing, packet Include but be not limited to smart phone, tablet computer, pocket computer on knee and desktop computer etc..
Server 905 can be to provide the server of various services, such as utilize terminal device 901,902,903 to user The shopping class website browsed provides the back-stage management server supported.Back-stage management server can believe the product received The data such as breath inquiry request carry out the processing such as analyzing, and processing result (such as target push information, product information) is fed back to Terminal device.
It should be noted that the method or base for realizing data check are explained provided by the embodiment of the present invention based on Java The method of realization data injection is explained in Java or the method for realizing data transmission is explained based on Java generally by server 905 Execute, correspondingly, based on Java explain realize data check device or based on Java explain realize data injection device, Or the system for realizing data transmission is explained based on Java and is generally positioned in server 905.
It should be understood that the number of terminal device, network and server in Fig. 9 is only schematical.According to realization need It wants, can have any number of terminal device, network and server.
Below with reference to Figure 10, it illustrates the computer systems for the terminal device for being suitable for being used to realize the embodiment of the present invention 1000 structural schematic diagram.Terminal device shown in Figure 10 is only an example, should not function to the embodiment of the present invention and Use scope brings any restrictions.
As shown in Figure 10, computer system 1000 include central processing unit (CPU) 1001, can according to be stored in only It reads the program in memory (ROM) 1002 or is loaded into random access storage device (RAM) 1003 from storage section 1008 Program and execute various movements appropriate and processing.In RAM 1003, also it is stored with system 1000 and operates required various journeys Sequence and data.CPU 1001, ROM 1002 and RAM 1003 are connected with each other by bus 1004.Input/output (I/O) interface 1005 are also connected to bus 1004.
I/O interface 1005 is connected to lower component: the importation 1006 including keyboard, mouse etc.;Including such as cathode The output par, c 1007 of ray tube (CRT), liquid crystal display (LCD) etc. and loudspeaker etc.;Storage section including hard disk etc. 1008;And the communications portion 1009 of the network interface card including LAN card, modem etc..Communications portion 1009 passes through Communication process is executed by the network of such as internet.Driver 1010 is also connected to I/O interface 1005 as needed.It is detachable to be situated between Matter 1011, such as disk, CD, magneto-optic disk, semiconductor memory etc. are mounted on as needed on driver 1010, so as to In being mounted into storage section 1008 as needed from the computer program read thereon.
Particularly, disclosed embodiment, the process described above with reference to flow chart may be implemented as counting according to the present invention Calculation machine software program.For example, embodiment disclosed by the invention includes a kind of computer program product comprising be carried on computer Computer program on readable medium, the computer program include the program code for method shown in execution flow chart.? In such embodiment, which can be downloaded and installed from network by communications portion 1009, and/or from can Medium 1011 is dismantled to be mounted.When the computer program is executed by central processing unit (CPU) 1001, executes and of the invention be The above-mentioned function of being limited in system.
It should be noted that computer-readable medium shown in the present invention can be computer-readable signal media or meter Calculation machine readable storage medium storing program for executing either the two any combination.Computer readable storage medium for example can be --- but not Be limited to --- electricity, magnetic, optical, electromagnetic, infrared ray or semiconductor system, device or device, or any above combination.Meter The more specific example of calculation machine readable storage medium storing program for executing can include but is not limited to: have the electrical connection, just of one or more conducting wires Taking formula computer disk, hard disk, random access storage device (RAM), read-only memory (ROM), erasable type may be programmed read-only storage Device (EPROM or flash memory), optical fiber, portable compact disc read-only memory (CD-ROM), light storage device, magnetic memory device, Or above-mentioned any appropriate combination.In the present invention, computer readable storage medium can be it is any include or storage journey The tangible medium of sequence, the program can be commanded execution system, device or device use or in connection.And at this In invention, computer-readable signal media may include in a base band or as carrier wave a part propagate data-signal, Wherein carry computer-readable program code.The data-signal of this propagation can take various forms, including but unlimited In electromagnetic signal, optical signal or above-mentioned any appropriate combination.Computer-readable signal media can also be that computer can Any computer-readable medium other than storage medium is read, which can send, propagates or transmit and be used for By the use of instruction execution system, device or device or program in connection.Include on computer-readable medium Program code can transmit with any suitable medium, including but not limited to: wireless, electric wire, optical cable, RF etc. are above-mentioned Any appropriate combination.
Flow chart and block diagram in attached drawing are illustrated according to the system of various embodiments of the invention, method and computer journey The architecture, function and operation in the cards of sequence product.In this regard, each box in flowchart or block diagram can generation A part of one module, program segment or code of table, a part of above-mentioned module, program segment or code include one or more Executable instruction for implementing the specified logical function.It should also be noted that in some implementations as replacements, institute in box The function of mark can also occur in a different order than that indicated in the drawings.For example, two boxes succeedingly indicated are practical On can be basically executed in parallel, they can also be executed in the opposite order sometimes, and this depends on the function involved.Also it wants It is noted that the combination of each box in block diagram or flow chart and the box in block diagram or flow chart, can use and execute rule The dedicated hardware based systems of fixed functions or operations is realized, or can use the group of specialized hardware and computer instruction It closes to realize.
Being described in module involved in the embodiment of the present invention can be realized by way of software, can also be by hard The mode of part is realized.Described module also can be set in the processor, for example, can be described as: a kind of processor packet It includes sending module, obtain module, determining module and first processing module.Wherein, the title of these modules is under certain conditions simultaneously The restriction to the module itself is not constituted, for example, sending module is also described as " sending picture to the server-side connected The module of acquisition request ".
As on the other hand, the present invention also provides a kind of computer-readable medium, which be can be Included in equipment described in above-described embodiment;It is also possible to individualism, and without in the supplying equipment.Above-mentioned calculating Machine readable medium carries one or more program, when said one or multiple programs are executed by the equipment, makes It obtains the method for equipment realization data check or the method for data injection is realized based on Java note or is based on Java note in fact The method of existing data transmission.
Above-mentioned specific embodiment, does not constitute a limitation on the scope of protection of the present invention.Those skilled in the art should be bright It is white, design requirement and other factors are depended on, various modifications, combination, sub-portfolio and substitution can occur.It is any Made modifications, equivalent substitutions and improvements etc. within the spirit and principles in the present invention, should be included in the scope of the present invention Within.

Claims (20)

1. a kind of explain the method for realizing data check based on Java characterized by comprising
The verification label explained based on Java is determined according to interface specification, includes multiple constraints in the interface specification;
The verification label is added in source file, file to be verified is generated;
The file to be verified is run using validator, realizes the verification to the source file.
2. the method as described in claim 1, which is characterized in that the verification label includes at least one of:
Common verification label, for describing the attribute and value range of each field in the source file;
Customized verification label, the constraint for describing not described with the common label in the interface specification;
Compound verification label, at least two constraints that must satisfy for describing either field in the source file.
3. method according to claim 1 or 2, which is characterized in that run the file to be verified using validator, comprising:
Each field of the file to be verified is traversed, if including the verification label in the field, obtains the field On verification label and the field attribute and value range;
Obtain the corresponding check information of the verification label;
If the attribute and value range of the field meet the check information, the attribute and value range of the field meet The interface specification.
4. the method as described in claim 1, which is characterized in that the validator includes at least one of: grammer validator, Semantic verification device.
5. a kind of explain the method for realizing data injection based on Java characterized by comprising
According to the attribute information of field each in source file, the injection label explained based on Java is determined;
The injection label is added in the source file, file to be implanted is generated;
The file to be implanted is run using annotation processor, realizes the injection to the source file.
6. method as claimed in claim 5, which is characterized in that the injection label includes at least one of:
Constant injects label, for describing the attribute information of the immutable field of attribute information in the source file;
Common injection label, the attribute information for describing not including in the source file and need to obtain from third party's interface;
Customized injection label, at least two attribute informations for including for describing either field in the source file.
7. such as method described in claim 5 or 6, which is characterized in that run the file to be implanted, packet using annotation processor It includes:
Each field of the file to be implanted is traversed, if including the injection label on the attribute of the field, obtains institute State the injection label on the attribute of field;
Obtain the corresponding attribute information of the injection label;
The attribute information is injected on the attribute of the corresponding field of the injection label.
8. the method for claim 7, which is characterized in that further comprise:
For each field of the file to be implanted, if the field is set class object, loop iteration goes out the set Each attribute in class object;The set class object includes at least two attributes.
9. explaining the method for realizing data transmission based on Java characterized by comprising
Source file is verified using the method as described in claim 1-4 is any;
The source file for meeting interface specification is injected using the method as described in claim 5-8 is any.
10. a kind of explain the device for realizing data check based on Java characterized by comprising
Tag generation module is verified, for determining the verification label explained based on Java, the interface specification according to interface specification In include multiple constraints;
It verifies file generating module and generates file to be verified for the verification label to be added in source file;
Execution module is verified, for running the file to be verified using validator, realizes the verification to the source file.
11. device as claimed in claim 10, which is characterized in that the verification label includes at least one of:
Common verification label, for describing the attribute and value range of each field in the source file;
Customized verification label, the constraint for describing not described with the common label in the interface specification;
Compound verification label, at least two constraints that must satisfy for describing either field in the source file.
12. device as described in claim 10 or 11, which is characterized in that the verification execution module runs institute using validator State file to be verified, comprising:
Each field of the file to be verified is traversed, if including the verification label in the field, obtains the field On verification label and the field attribute and value range;
Obtain the corresponding check information of the verification label;
If the attribute and value range of the field meet the check information, the attribute and value range of the field meet The interface specification.
13. device as claimed in claim 10, which is characterized in that the validator includes at least one of: grammer verifying Device, semantic verification device.
14. a kind of explain the device for realizing data injection based on Java characterized by comprising
Tag generation module is injected, for the attribute information according to field each in source file, determines the note explained based on Java Enter label;
It injects file generating module and generates file to be implanted for the injection label to be added in the source file;
Execution module is injected, for running the file to be implanted using annotation processor, realizes the injection to the source file.
15. device as claimed in claim 14, which is characterized in that the injection label includes at least one of:
Constant injects label, for describing the attribute information of the immutable field of attribute information in the source file;
Common injection label, the attribute information for describing not including in the source file and need to obtain from third party's interface;
Customized injection label, at least two attribute informations for including for describing either field in the source file.
16. the device as described in claims 14 or 15, which is characterized in that the injection execution module is transported using annotation processor The row file to be implanted, comprising:
Each field of the file to be implanted is traversed, if including the injection label on the attribute of the field, obtains institute State the injection label on the attribute of field;
Obtain the corresponding attribute information of the injection label;
The attribute information is injected on the attribute of the corresponding field of the injection label.
17. device as claimed in claim 16, which is characterized in that the injection execution module is further used for:
For each field of the file to be implanted, if the field is set class object, loop iteration goes out the set Each attribute in class object;The set class object includes at least two attributes.
18. explaining the system for realizing data transmission based on Java characterized by comprising
Source file is verified using the device as described in claim 10-13 is any;
The source file for meeting interface specification is injected using the device as described in claim 14-17 is any.
19. a kind of explain the terminal for realizing data transmission based on Java characterized by comprising
One or more processors;
Storage device, for storing one or more programs,
When one or more of programs are executed by one or more of processors, so that one or more of processors are real The now method as described in any in claim 1-9.
20. a kind of computer-readable medium, is stored thereon with computer program, which is characterized in that described program is held by processor The method as described in any in claim 1-9 is realized when row.
CN201710941311.1A 2017-10-11 2017-10-11 The method and apparatus for realizing data check and injection are explained based on Java Pending CN109656744A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710941311.1A CN109656744A (en) 2017-10-11 2017-10-11 The method and apparatus for realizing data check and injection are explained based on Java

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710941311.1A CN109656744A (en) 2017-10-11 2017-10-11 The method and apparatus for realizing data check and injection are explained based on Java

Publications (1)

Publication Number Publication Date
CN109656744A true CN109656744A (en) 2019-04-19

Family

ID=66109014

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710941311.1A Pending CN109656744A (en) 2017-10-11 2017-10-11 The method and apparatus for realizing data check and injection are explained based on Java

Country Status (1)

Country Link
CN (1) CN109656744A (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110673838A (en) * 2019-09-10 2020-01-10 四川新网银行股份有限公司 Input checking method
CN111191246A (en) * 2019-12-19 2020-05-22 杭州安恒信息技术股份有限公司 Spring annotation based security development verification method
CN111475331A (en) * 2020-03-24 2020-07-31 平安银行股份有限公司 Data verification method and device, computer equipment and storage medium
CN111897842A (en) * 2020-01-02 2020-11-06 北京京东尚科信息技术有限公司 Data checking method, device, computer system and medium
CN112631695A (en) * 2020-12-22 2021-04-09 北京达佳互联信息技术有限公司 Data verification method and device, electronic equipment and storage medium
CN113190539A (en) * 2021-04-20 2021-07-30 鼎蓝惠民信息技术(西安)有限公司 Method for standardized verification of affair elements based on national government affair service
CN113377361A (en) * 2021-06-28 2021-09-10 浙江孚临科技有限公司 Method for realizing timing verification of data source based on linux crontad and jar packets

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101075989A (en) * 2007-03-23 2007-11-21 腾讯科技(深圳)有限公司 Method and system for verifying field validity
CN101753605A (en) * 2008-12-02 2010-06-23 北大方正集团有限公司 Data validation method and server
CN105677326A (en) * 2015-12-28 2016-06-15 国云科技股份有限公司 Software interface parameter validation method
CN106991023A (en) * 2017-03-22 2017-07-28 深圳市彬讯科技有限公司 A kind of interface parameters method of calibration and component
CN107145437A (en) * 2016-03-01 2017-09-08 阿里巴巴集团控股有限公司 A kind of java explains method of testing and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101075989A (en) * 2007-03-23 2007-11-21 腾讯科技(深圳)有限公司 Method and system for verifying field validity
CN101753605A (en) * 2008-12-02 2010-06-23 北大方正集团有限公司 Data validation method and server
CN105677326A (en) * 2015-12-28 2016-06-15 国云科技股份有限公司 Software interface parameter validation method
CN107145437A (en) * 2016-03-01 2017-09-08 阿里巴巴集团控股有限公司 A kind of java explains method of testing and device
CN106991023A (en) * 2017-03-22 2017-07-28 深圳市彬讯科技有限公司 A kind of interface parameters method of calibration and component

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
LOC_THOMAS: "使用 validator-api来验证 spring-boot 的参数", 《简书》 *
大圣: "Spring注解注入", 《博客园》 *

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110673838A (en) * 2019-09-10 2020-01-10 四川新网银行股份有限公司 Input checking method
CN111191246A (en) * 2019-12-19 2020-05-22 杭州安恒信息技术股份有限公司 Spring annotation based security development verification method
CN111897842A (en) * 2020-01-02 2020-11-06 北京京东尚科信息技术有限公司 Data checking method, device, computer system and medium
CN111475331A (en) * 2020-03-24 2020-07-31 平安银行股份有限公司 Data verification method and device, computer equipment and storage medium
CN112631695A (en) * 2020-12-22 2021-04-09 北京达佳互联信息技术有限公司 Data verification method and device, electronic equipment and storage medium
CN112631695B (en) * 2020-12-22 2024-06-11 北京达佳互联信息技术有限公司 Data verification method and device, electronic equipment and storage medium
CN113190539A (en) * 2021-04-20 2021-07-30 鼎蓝惠民信息技术(西安)有限公司 Method for standardized verification of affair elements based on national government affair service
CN113377361A (en) * 2021-06-28 2021-09-10 浙江孚临科技有限公司 Method for realizing timing verification of data source based on linux crontad and jar packets

Similar Documents

Publication Publication Date Title
CN109656744A (en) The method and apparatus for realizing data check and injection are explained based on Java
CN109634598A (en) A kind of page display method, device, equipment and storage medium
CN109409119A (en) Data manipulation method and device
CN107491382B (en) Log output method and device
CN109189379A (en) code generating method and device
CN108768840A (en) A kind of method and apparatus of account management
CN109582691A (en) Method and apparatus for controlling data query
CN110196790A (en) The method and apparatus of abnormal monitoring
CN110472207A (en) List generation method and device
CN108197036A (en) For determining the method and apparatus of the coverage rate information of incremental code
CN107729106A (en) It is a kind of that the method and apparatus quickly redirected are realized between application component
CN109981322A (en) The method and apparatus of cloud resource management based on label
CN110019080A (en) Data access method and device
CN109981719A (en) Information processing method and its system, computer system and computer readable medium
CN110020358A (en) Method and apparatus for generating dynamic page
CN109284198A (en) A kind of method and apparatus verifying data
CN109271556A (en) Method and apparatus for output information
CN109815107A (en) The method and apparatus of automatic test
CN110019263A (en) Information storage means and device
CN109859006A (en) For determining method, system, electronic equipment and the computer-readable medium of user interest profile
CN113626223A (en) Interface calling method and device
CN113238740A (en) Code generation method, code generation device, storage medium, and electronic apparatus
CN108984197A (en) A kind of code update method and device
CN110083457A (en) A kind of data capture method, device and data analysing method, device
CN110109983A (en) A kind of method and apparatus operating Redis database

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20190419

RJ01 Rejection of invention patent application after publication