CN109032662A - Code file generation method, device, computer equipment and storage medium - Google Patents

Code file generation method, device, computer equipment and storage medium Download PDF

Info

Publication number
CN109032662A
CN109032662A CN201810629826.2A CN201810629826A CN109032662A CN 109032662 A CN109032662 A CN 109032662A CN 201810629826 A CN201810629826 A CN 201810629826A CN 109032662 A CN109032662 A CN 109032662A
Authority
CN
China
Prior art keywords
code
template
file
metadata
catalogue
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
CN201810629826.2A
Other languages
Chinese (zh)
Other versions
CN109032662B (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.)
Weikun Shanghai Technology Service Co Ltd
Original Assignee
Lujiazui Shanghai International Financial Assets Market Ltd By Share 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 Lujiazui Shanghai International Financial Assets Market Ltd By Share Ltd filed Critical Lujiazui Shanghai International Financial Assets Market Ltd By Share Ltd
Priority to CN201810629826.2A priority Critical patent/CN109032662B/en
Publication of CN109032662A publication Critical patent/CN109032662A/en
Application granted granted Critical
Publication of CN109032662B publication Critical patent/CN109032662B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/73Program documentation

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Library & Information Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

This application involves a kind of code file generation method, device, computer equipment and storage mediums.Method includes: the metadata obtained to operation object;At least one set of Code Template of load and the meta data match extracted, wherein every group of Code Template defines the setting operation logic to operation object;The Code Template of load and the metadata are combined, the code file described at least one operation to operation object is generated.A variety of operation logic source code flexible customizations can be realized using this method.

Description

Code file generation method, device, computer equipment and storage medium
Technical field
This application involves field of computer technology, set more particularly to a kind of code file generation method, device, computer Standby and storage medium.
Background technique
With the development of internet technology, whole people's Internet era has undoubtedly been come into instantly, and software systems conduct The soul of internet, to meet the growing computer software demand for services of people, software developer needs constantly to carry out The exploitation and innovation of computer program.
Computer program is formed by a series of code combination and can express specific mathematical logic.Generate an above-mentioned system The traditional approach of the code of column includes: that developer strikes manually and writes code and automatically generated by Code Generator.Wherein, it opens Hair personnel are that a large amount of codes repeat to write purely manual the shortcomings that striking the mode for writing code, time-consuming and laborious.And it is generated by tool The mode of code, since traditional Code Generator is mostly to be directed to some special scenes to carry out code building, a kind of code is raw It can be only generated a kind of code of special scenes (such as database manipulation) at tool.It is needed when generating the operation code under several scenes Using Multiple Code Core Generator, code building low efficiency, flexibility is poor.
Summary of the invention
Based on this, it is necessary to which in view of the above technical problems, providing one kind, to can be realized a variety of operation logic source code flexibles fixed System, code building more efficient code building document method, device, computer equipment and storage medium.
A kind of code file generation method, which comprises
Obtain the metadata to operation object;
At least one set of Code Template of load and the meta data match extracted, wherein every group of Code Template defines institute State the setting operation logic to operation object;
The Code Template of load and the metadata are combined, generated described at least one operation to operation object Code file.
In one embodiment, the metadata for obtaining the operation object, comprising:
Obtain the sound code file to operation object;
The sound code file is parsed, according to the corresponding pass between preconfigured sound code file type and data extraction strategy System determines that the corresponding data of the sound code file extract strategy;
It loads the data and extracts strategy, extract strategy by the data and extract metadata from the sound code file.
In one embodiment, at least one set of Code Template of the load and the meta data match extracted, comprising:
At least one template processor is called according to the type of the metadata, wherein the template processor is setting The loader of Code Template combination;
Corresponding Code Template combination is loaded by the template processor.
In one embodiment, the Code Template by load is combined with the metadata, is generated at least one The operation code file to operation object, comprising:
The metadata of extraction is converted into the set of key-value pair, the key-value pair includes variable and variate-value;
The Code Template catalogue is obtained, the catalogue subitem in the Code Template catalogue is extracted, by the catalogue subitem In variable replacement to the variate-value of dependent variable, generating packet according to the catalogue subitem after variable replacement in the metadata Name;
Code Template file is obtained according to the file subitem in the Code Template catalogue, it will be in the Code Template file Variable replacement to the variate-value of dependent variable, generating code file, wherein the code file of generation in the metadata State the packet name generated.
In one embodiment, it is combined by the Code Template of load and the metadata, generates at least one behaviour Make described after the code file of operation object, further includes:
Judge whether the code file generated has existed, if so, by the code file of generation and having Code file is converted into syntax tree, and the consolidation strategy that circulation executes configuration generates the syntax tree after merging, according to the institute after merging It states syntax tree and generates the code file after merging.
A kind of code file generating means, described device include:
Metadata extraction module, for obtaining the metadata to operation object;
Code Template loading module, at least one set of Code Template of the meta data match for loading and extracting, In, Code Template described in every group defines the setting operation logic to operation object;
Composite module generates at least one operation institute for the Code Template of load and the metadata to be combined State the code file to operation object.
In one embodiment, the Code Template loading module, be also used to be called according to the type of the metadata to A few template processor predetermined;It is in advance each described by the template processor loading code form assembly Template processor configures its Code Template combination that can be loaded.
In one embodiment, the composite module, further includes:
Format converting module, for the metadata extracted to be converted into the set of key-value pair, the key-value pair includes Variable and variate-value;
Packet name generation module extracts catalogue in the Code Template catalogue for obtaining the Code Template catalogue , by the variable replacement in the catalogue subitem in the metadata to the variate-value of dependent variable, after variable replacement The catalogue subitem generates packet name;
Code file generation module, for obtaining Code Template text according to the file subitem in the Code Template catalogue Part, by the variable replacement in the Code Template file to the variate-value of dependent variable, generating code file in the metadata, Wherein, the packet name that the code file statement of generation generates.
A kind of computer equipment, including memory and processor, the memory are stored with computer program, the processing The step of device realizes any one of claims 1 to 5 the method when executing the computer program.
A kind of computer readable storage medium, is stored thereon with computer program, and the computer program is held by processor The step of method described in any one of claims 1 to 5 is realized when row.
Above-mentioned code generating method, device, computer equipment and storage medium extract energy by scanning to operation object The metadata of enough description object attributes, load can be with one group or multiple groups Code Template of metadata composition, every group of code mould Plate can realize certain types of operation in the set scene for treat operation object, combine metadata and Code Template generates code text Part, the code file of generation includes treating the code file of a variety of operations of operation object implementation, different by flexibly loading Code Template, realizes the flexible customization for treating the operation code of operation object, and once-through operation produces under several scenes The code file of a variety of operation logics.
Detailed description of the invention
Fig. 1 is the application scenario diagram of code file generation method in one embodiment;
Fig. 2 is the flow diagram of code file generation method in one embodiment;
Fig. 3 is the schematic diagram that metadata is extracted in one embodiment;
Fig. 4 is that process involved at least one set of Code Template of the load with meta data match is illustrated in one embodiment Figure;
Fig. 5 is that metadata and Code Template are combined in one embodiment, is generated involved in the code file of operation object Flow diagram;
Fig. 6 is the schematic diagram that code file merges in one embodiment;
Fig. 7 is the structural block diagram of code file generating means in one embodiment;
Fig. 8 is the structural block diagram of composite module in one embodiment;
Fig. 9 is the structural block diagram of code file generating means in another embodiment;
Figure 10 is the internal structure chart of computer equipment in one embodiment.
Specific embodiment
It is with reference to the accompanying drawings and embodiments, right in order to which the objects, technical solutions and advantages of the application are more clearly understood The application is further elaborated.It should be appreciated that specific embodiment described herein is only used to explain the application, not For limiting the application.
Code generating method provided by the present application can be applied in application environment as shown in Figure 1.Wherein, terminal 102 It is communicated with server 104 by network by network.For terminal 102 for providing user interface, monitoring users are specified To operation object, monitoring users configuration operate etc., to server 104 send code building request etc..Server 104 extracts To the metadata of operation object, at least one set of Code Template of load and meta data match carries out metadata and Code Template Combination generates the code for treating at least one action type of operation object.Terminal 102 can be, but not limited to be various personal meters Calculation machine, laptop, smart phone, tablet computer, server 104 can use independent server either multiple servers The server cluster of composition is realized.
In one embodiment, as shown in Fig. 2, providing a kind of code file generation method, it is applied to Fig. 1 in this way In server for be illustrated, comprising the following steps:
Step S202: the metadata to operation object is obtained.
Can be a web page, interface or class etc. to operation object has opposite solidification attribute and can be further The program unit of operation.Metadata to operation object refers to the data for description object attribute.For example, a http interface Metadata may include interface path, interface input/output argument etc..The metadata of web page can be component id, group Part type etc..
The source code to operation object is scanned, metadata is extracted from the source code to operation object.Such as JAVA engineering, By loading the class file to operation object, the class method (method) and class variable (field) traversed in class file obtains class Generic metadata is described in file.
Step S204: at least one set of Code Template of load and the meta data match extracted, wherein every group of Code Template is fixed Setting operation logic of the justice to operation object.
It is abstract to be directed to various types of various types of operation logics that implement to operation object, it defines for operating The Code Template of various types object.Operation logic is the operating method frame abstracted, and a type of operation logic is real It is that can wait for same class that operation object implements the code of setting operation in matter.As operated to " http interface " implementation " calling " Operation code is " interface calling Code Template ".
Have for a type of operation that may implement to operation object multiple, in the present embodiment, needle will wait for this Operation object defines multiple Code Templates, and each Code Template realizes a kind of operation logic for treating operation object.Such as wait operate Object is interface, may be the generation of the Code Template of calling interface, package interface for the Code Template that " http interface " defines Code mask etc..The combination for being directed to multiple Code Templates of same target can be used for realizing a kind of operation logic.
In one embodiment, the label of matching object, the generation of load can be added in each Code Template of definition Code mask is the Code Template that band needs operation object label.In another embodiment, can calculate the metadata of extraction with The matching degree of replaceable content in Code Template determines whether Code Template adapts to wait for this operation object is implemented according to matching degree Corresponding operation.Can be in a manner of logical human configuration, user is selected currently to need Code Template to be loaded.
In the present embodiment, load may include a Code Template with the group Code Template of meta data match, can also be with Including multiple Code Templates, the combination of either a Code Template or multiple Code Templates, which can be realized, treats operation pair A kind of operation logic of elephant.It loads one group of Code Template and loads a kind of one group of Code Template that can be realized operation logic.This Embodiment stresses to load multiple groups Code Template, and multiple groups Code Template can realize that a plurality of types of operations for treating operation object are patrolled Volume.
Step S206: the Code Template of load is combined with metadata, generates at least one operation to operation object Code file.
Template engine uses the template content of each group of Code Template of the metadata replacement load to operation object, replacement Each group of Code Template afterwards can realize the operation logic for treating the setting type of operation object.
In the present embodiment, by scanning object to be operated, the metadata for capableing of description object attribute is extracted, load can With one group or multiple groups Code Template of metadata composition, every group of Code Template, which can be realized, treats the certain types of of operation object Operation combines metadata and Code Template, that is, produces the code for the various types operation logic to operation object.This reality Apply example can Mass production wait for operation object a variety of action types code, the code of generation can flexible customization as needed.With To the matched Code Template of operation object being customized combination, patrolled with deriving multiple operations for treating operation object Volume.
In addition, by, to operation object abstract code logic, reducing code in development process for a certain type It is a large amount of to repeat to strike to write.
In one embodiment, step S202: obtaining to operation object metadata includes: the source code obtained to operation object File;Sound code file is parsed, the corresponding relationship between strategy is extracted according to preconfigured sound code file type and data and determines The corresponding data of sound code file extract strategy;The determining data of load extract strategy, extract strategy from wait operate pair by data Metadata is extracted in the sound code file of elephant.
Further, can carry multiple marks to operation object in request, server by the way of multithreading simultaneously Corresponding extraction strategy is loaded to operation object for multiple, while extracting multiple metadata to operation object.
As shown in figure 3, server loads the two kinds of sound code file to operation object, such as java.class file (class file) and Html file, load are in advance java.class file configuration path strategy, Method strategy, param strategy, Load is the component strategy of Html file configuration in advance, extracts metadata and output to operation object by the strategy of load, The metadata of output with matched Code Template for being matched.
In the present embodiment, different extraction strategies is defined to operation object for different types of, is extracted to operation object Metadata when call directly extraction strategy and can be realized metadata is automatically extracted.The different types of member to operation object Data can improve data extraction efficiency by calling obstructed extraction strategy to extract simultaneously.
In one embodiment, as shown in figure 4, step S204: at least one set of Code Template of load and meta data match, Include the following steps:
Step S402: at least one template processor is called according to the type of metadata, wherein template processor is setting The loader of Code Template combination.
Step S404: corresponding Code Template is loaded by template processor and is combined.
Pre-defined multiple template processor, is specifically defined the Code Template group that each template processor can load It closes.The Code Template combination that as each template processor configuration can load, template processor is essentially setting Code Template Combined loader.The Code Template in Code Template combination and Code Template combination that can be loaded by template processor The metadata type adapted to establishes the incidence relation between template processor and metadata type.It is shown as when specific implementation Following steps: calling at least one template processor according to the type of metadata, and loading it by template processor can load Code Template combination.Multiple Code Templates of same template processor load may be implemented to treat a kind of operation of operation object A series of relevant operation logics for treating operation object also may be implemented in logic.
The present embodiment by definition template processor, can in advance to various objects to be processed matched all code moulds Plate is combined classification, and the template processor that server need to only match according to the type search of metadata can be according to pre- Loading code template is gone in the combination first defined, without in the combination for carrying out cumbersome Code Template.
It for example, to the matched Code Template of operation object include Code Template A, Code Template B with a certain type With Code Template C, wherein the combination and code A of Code Template B and Code Template C, Code Template B and Code Template C Combination is also able to achieve a type of operation for treating operation object, then, it can define 5 template processors, define this 5 moulds The Code Template that sheet processor can load is followed successively by Code Template A, Code Template B, Code Template C, Code Template B and code mould The combination of plate C, the combination of code A, Code Template B and Code Template C.Certainly, if there are also other combinations also may be implemented pair To the operation of operation object, then more template processors are defined.Corresponding metadata category is added for the template processor of definition Type label, one of template processor can correspond to multiple metadata type labels.
In one embodiment, as shown in figure 5, step S306: the Code Template of load is combined with metadata, it is raw Code file at least one operation to operation object, includes the following steps:
It should be noted that following step provided is logic that metadata is combined with one or one group of Code Template, Following step can be executed by circulation realizes that the combination of metadata and multiple groups Code Template or multithreading run following step, Realize the sync of metadata and multiple groups Code Template.
Metadata: being converted into the set of key-value pair by step S502, and key-value pair includes variable and variate-value.
Metadata is converted into (" key=value ") character string, key is variable, and value is variate-value.
Step S504: obtaining the catalogue of Code Template, by the variable replacement of catalogue subitem in catalogue at the change in metadata Magnitude.
All subitems in recursive traversal Code Template catalogue judge that the subitem that currently traverses is that there are also catalogues for file, if It is catalogue, whether have variable, if so, searching in metadata with the presence or absence of the variable of the variable in corresponding catalogue if searching in catalogue Value, if so, with the variable in corresponding variate-value replacement catalogue, until replacing the variable of every layer of catalogue subitem of Code Template.
As having $ { var } change character in template directory, the metadata being converted into is context.put (" var ", " Hello "), when directory traversal, by $ { var } character use " hello " replacement.
Step S506: packet name is generated according to the catalogue subitem of the Code Template catalogue after replacement variable.
Step S508: obtaining Code Template file, using the content in metadata alternate file, generates code file, raw At code file statement generate packet name.
Code Template catalogue includes catalogue subitem and file subitem, by the variable replacement in catalogue subitem at the change of metadata After magnitude, each layer catalogue subitem based on Code Template generates packet name according to setting rule.
File subitem appointment codes template file in Code Template catalogue, template engine will be in Code Template files Appearance is replaced with metadata, removes the null in template and note, generates code file.
In the present embodiment, packet name is generated according to the catalogue subitem of template directory, it is raw according to the file subitem in template directory At code file, the packet name of code file statement generation.When generating code, a packet is stated for the code file of generation Name creates new NameSpace using the class in the entitled code file of the packet, since packet creates new NameSpace (namespace), so naming conflict will not be generated with any name in other packets.Use machine contracting system, it is easier to realize and visit It asks control, and makes positioning associated class simpler, be made as the newly-generated code that obtains without using this chartered plane and state that packet name will There is Edit Error.
In one embodiment, it is extracting when the metadata of operation object, is being metadata configurations packet name prefix.It can be with It is to search the system banner name to system locating for operation object, configure the system banner name of locating system to operation object Metadata packet name prefix.The Bao Mingzhong of generation adds packet name prefix.
For example, the template directory of Code Template are as follows: templates/app/AppCaller.java, wherein/app/ For catalogue subitem, AppCaller.java is file subitem, if the packet name prefix of configuration is com.lufax, according to catalogue subitem The entitled com.lufax.app of the packet of generation.Template file is loaded based on file subitem, is generated after gang form file and metadata Code file, the corresponding packet name of the code file is com.lufax.app.
When in one group of Code Template of load including multiple Code Templates, multiple generations are generated according to step S502-S508 Code file, each code file is corresponding to generate a packet name.It includes its corresponding packet name that generation, which obtains the catalogue of code file,.
It should be understood that although each step in the flow chart of Fig. 2,4-5 is successively shown according to the instruction of arrow, It is these steps is not that the inevitable sequence according to arrow instruction successively executes.Unless expressly stating otherwise herein, these steps There is no stringent sequences to limit for rapid execution, these steps can execute in other order.Moreover, in Fig. 2,4-5 extremely Few a part of step may include that perhaps these sub-steps of multiple stages or stage are not necessarily same to multiple sub-steps Moment executes completion, but can execute at different times, and the execution sequence in these sub-steps or stage is also not necessarily It successively carries out, but in turn or can be handed over at least part of the sub-step or stage of other steps or other steps Alternately execute.
In one embodiment, in step S508: the file for stating institute's Code Template is obtained, using in metadata alternate file Content generate code file, wherein after the packet name that the code file statement of generation is generated according to Code Template catalogue, also wrap It includes: judging whether the code file generated has existed, if so, merging code file.
If Fig. 6 is the logical schematic that code merges.Existing code file and fresh code file are obtained first, are used Existing code and fresh code are converted into syntax tree by the library Eclipse JDT, are loaded the consolidation strategy of configuration and are recycled and execute merging Syntax tree after merging is converted into code text to generate the syntax tree after merging by strategy, and target generation is written in code text Code file.
It in one embodiment, further include the merging of catalogue and catalogue.Specifically: the type for judging merging source is catalogue The merging of merging or file and file with catalogue.If the merging of file and file, using merging method as shown in FIG. 6 It merges.If the merging of catalogue and catalogue, then, the listed files in source directory is read, each of these file is traversed, The relative path obtained between file and source directory path obtains the fullpath of file destination, judges mesh according to relative path Mark file whether there is, if it does not exist, by the Code copying in the code file currently traversed into object code file, if mesh It marks file to exist, then carries out the merging for carrying out source file and file destination according to method shown in fig. 6.Under traversing in source directory One source file, until having traversed all files in source directory listed files.
In the present embodiment, consolidation strategy shown in following table is pre-defined, consolidation strategy type, the title provided in table 1 With the description to consolidation strategy, with specific reference to following table.
Table 1
In the present embodiment, to avoid the code file generated from covering existing code, code file is caused to lose, the present embodiment In pre-define code consolidation strategy, search code file to be combined automatically, merging and catalogue including file and file With the merging of catalogue.In the present embodiment, the merging that code policies carry out code automatically is executed by circulation, without merging manually, The automatic management of code is realized on the basis of Mass production code.
A kind of code file generation method, including following content are provided in one embodiment:
The sound code file to operation object is obtained, the metadata to operation object is extracted from sound code file.It will be needed The metadata of operation object is stored in the form of meta data file.When getting the instruction of Mass production code, recurrence time Each meta data file is gone through, metadata is read from file, the metadata of reading is converted into recursive key-value pair format Map.Data capsule is created, using (Spring is the JavaSE/EE full-stack of a layering one-stop light from Spring Magnitude Open Framework) in load configuration various tool-class format is converted after metadata be added in data capsule, obtain Registration prefix is added in data capsule by the packet name prefix of configuration.
Template processor to be loaded is needed for the metadata configurations currently traversed, it can also be according to template predetermined Processor and the corresponding relationship to operation object, load corresponding template processor automatically.Pre-define each template processor The Code Template of load.All subitems for the Code Template catalogue that traversal template processor can load, what judgement currently traversed Subitem is file or catalogue, if catalogue, whether there is variable in lookup, and variable carries out the key-value pair in data capsule Matching combines current layer catalogue and upper one layer of catalogue to generate packet name by variable replacement at variate-value, after replacement, traverses next layer of mesh Record subitem, constantly update packet name, until traversal subitem be file, newest packet name is added into data capsule, packet name and Packet name prefix is combined into complete packet name.Template engine loads template code file, calls data capsule, is to call data first Content in Code Template is substituted for metadata by the metadata in container, secondly, being that generation is written in the packet name in data capsule The position that packet name is stated in code mask, finally replaces template content, goes the note in null and template caused by removing template, raw At and output code file, packet name in the code file claim data container of generation, judge that code file whether there is, if It is to merge code file.
Next Code Template catalogue that traversal template processor can load, traversing directories subitem generate packet name, will be current The packet name of generation is added and replaces existing packet name into data capsule, the corresponding Code Template text of load current code template directory Part generates code file, replaced packet name in the code file claim data container of generation.Until having traversed the metadata pair All Code Templates in all template processors answered.Next meta data file is obtained, based on next metadata text Part rebuilds data capsule, has traversed all meta data files.
In the present embodiment, a data capsule is generated to operation object based on one, numerous Code Templates of configuration are called The data be easy to carry out content replacement can Mass production code file, code file formation efficiency is higher.
In one embodiment, as shown in fig. 7, providing a kind of code file generating means, comprising: meta-data extraction mould Block 702, Code Template loading module 704 and composite module 706, in which:
Metadata extraction module 702 obtains the metadata to operation object.
Code Template loading module 704, at least one set of Code Template of the meta data match for loading and extracting, In, every group of Code Template defines the setting operation logic to operation object.
Composite module 706 generates at least one and operates wait grasp for the Code Template of load to be combined with metadata Make the code file of object.
In one embodiment, metadata extraction module 702 are also used to obtain the sound code file to operation object;Parsing Sound code file extracts the corresponding relationship between strategy according to preconfigured sound code file type and data and determines sound code file pair The data answered extract strategy;The determining data of load extract strategy, extract strategy by data and extract first number from sound code file According to.
In one embodiment, Code Template loading module 704 is also used to call at least one according to the type of metadata Template processor, wherein template processor is the loader for setting Code Template combination;It is loaded by template processor corresponding Code Template combination.
In one embodiment, as shown in figure 8, composite module 706, including format converting module 802, packet name generation module 804 and code file generation module 806, in which:
Format converting module 802, for metadata to be converted into the set of key-value pair, key-value pair includes variable and variable Value.
Packet name generation module 804 extracts the catalogue subitem in Code Template catalogue, incites somebody to action for obtaining Code Template catalogue Variable replacement in catalogue subitem is at, to the variate-value of dependent variable, generating packet according to the catalogue subitem after variable replacement in metadata Name.
Code file generation module 806, for obtaining Code Template file according to the file subitem in Code Template catalogue, By the variable replacement in Code Template file to the variate-value of dependent variable, generating code file, wherein generation in metadata The packet name that code file statement generates.
In one embodiment, it as shown in figure 9, code generating unit further includes file combination module 708, is given birth to for judging At code file whether have existed, if so, the code file of generation and existing code file are converted into syntax tree, follow The consolidation strategy that ring executes configuration generates the syntax tree after merging, and the code text after merging is generated according to the syntax tree after merging Part.
Specific about code generating unit limits the restriction that may refer to above for code generating method, herein not It repeats again.Modules in above-mentioned code generating unit can be realized fully or partially through software, hardware and combinations thereof.On Stating each module can be embedded in the form of hardware or independently of in the processor in computer equipment, can also store in a software form In memory in computer equipment, the corresponding operation of the above modules is executed in order to which processor calls.
In one embodiment, a kind of computer equipment is provided, which can be server, internal junction Composition can be as shown in Figure 10.The computer equipment include by system bus connect processor, memory, network interface and Database.Wherein, the processor of the computer equipment is for providing calculating and control ability.The memory packet of the computer equipment Include non-volatile memory medium, built-in storage.The non-volatile memory medium is stored with operating system, computer program and data Library.The built-in storage provides environment for the operation of operating system and computer program in non-volatile memory medium.The calculating The database of machine equipment is used to store the code file generated.The network interface of the computer equipment is used for logical with external terminal Cross network connection communication.To realize a kind of code file generation method when the computer program is executed by processor.
It will be understood by those skilled in the art that structure shown in Figure 10, only part relevant to application scheme The block diagram of structure, does not constitute the restriction for the computer equipment being applied thereon to application scheme, and specific computer is set Standby may include perhaps combining certain components or with different component layouts than more or fewer components as shown in the figure.
In one embodiment, a kind of computer equipment, including memory and processor are provided, which is stored with Computer program, the processor perform the steps of the metadata obtained to operation object when executing computer program;Load with At least one set of Code Template of the meta data match of extraction, wherein every group of Code Template defines the setting operation to operation object Logic;The Code Template of load is combined with metadata, generates code file of at least one operation to operation object.
In one embodiment, acquisition is also performed the steps of when processor executes computer program to operation object Sound code file;Sound code file is parsed, the corresponding relationship between strategy is extracted according to preconfigured sound code file type and data Determine that the corresponding data of sound code file extract strategy;It loads data and extracts strategy, extract strategy from sound code file by data Extract metadata.
In one embodiment, the type according to metadata is also performed the steps of when processor executes computer program Call at least one template processor, wherein template processor is the loader for setting Code Template combination;It is handled by template Device loads corresponding Code Template combination.
In one embodiment, it is also performed the steps of when processor executes computer program and turns the metadata of extraction Change the set of key-value pair into, key-value pair includes variable and variate-value;Code Template catalogue is obtained, is extracted in Code Template catalogue Catalogue subitem, by the variable replacement in catalogue subitem in metadata to the variate-value of dependent variable, according to the mesh after variable replacement It records subitem and generates packet name;Code Template file is obtained according to the file subitem in Code Template catalogue, it will be in Code Template file Variable replacement to the variate-value of dependent variable, generating code file in metadata, wherein the code file of generation is stated to generate Packet name.
In one embodiment, the code text that judgement generates also is performed the steps of when processor executes computer program Whether part has existed, if so, the code file of generation and existing code file are converted into syntax tree, circulation executes configuration Consolidation strategy generate merge after syntax tree, according to after merging syntax tree generate merge after code file.
In one embodiment, a kind of computer readable storage medium is provided, computer program is stored thereon with, is calculated Machine program performs the steps of the metadata obtained to operation object when being executed by processor;Load and the metadata extracted At least one set of Code Template matched, wherein every group of Code Template defines the setting operation logic to operation object;By the generation of load Code mask is combined with metadata, generates code file of at least one operation to operation object.
In one embodiment, acquisition is also performed the steps of when computer program is executed by processor to operation object Sound code file;Sound code file is parsed, according to the corresponding pass between preconfigured sound code file type and data extraction strategy It is to determine that the corresponding data of sound code file extract strategy;It loads data and extracts strategy, extract strategy from sound code file by data Middle extraction metadata.
In one embodiment, the class according to metadata is also performed the steps of when computer program is executed by processor Type calls at least one template processor, wherein template processor is the loader for setting Code Template combination;At template It manages device and loads corresponding Code Template combination.
In one embodiment, it is also performed the steps of when computer program is executed by processor by the metadata of extraction It is converted into the set of key-value pair, key-value pair includes variable and variate-value;Code Template catalogue is obtained, is extracted in Code Template catalogue Catalogue subitem, by the variable replacement in catalogue subitem in metadata to the variate-value of dependent variable, after variable replacement Catalogue subitem generates packet name;Code Template file is obtained according to the file subitem in Code Template catalogue, by Code Template file In variable replacement to the variate-value of dependent variable, generating code file in metadata, wherein the code file of generation states life At packet name.
In one embodiment, the code that judgement generates also is performed the steps of when computer program is executed by processor Whether file has existed, if so, the code file of generation and existing code file are converted into syntax tree, circulation, which executes, matches The consolidation strategy set generates the syntax tree after merging, and generates the code file after merging according to the syntax tree after merging.
Those of ordinary skill in the art will appreciate that realizing all or part of the process in above-described embodiment method, being can be with Relevant hardware is instructed to complete by computer program, computer program can be stored in a non-volatile computer and can be read In storage medium, the computer program is when being executed, it may include such as the process of the embodiment of above-mentioned each method.Wherein, the application To any reference of memory, storage, database or other media used in provided each embodiment, may each comprise non- Volatibility and/or volatile memory.Nonvolatile memory may include read-only memory (ROM), programming ROM (PROM), Electrically programmable ROM (EPROM), electrically erasable ROM (EEPROM) or flash memory.Volatile memory may include arbitrary access Memory (RAM) or external cache.By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic ram (DRAM), synchronous dram (SDRAM), double data rate sdram (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronization link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) directly RAM (RDRAM), straight Connect memory bus dynamic ram (DRDRAM) and memory bus dynamic ram (RDRAM) etc..
Each technical characteristic of above embodiments can be combined arbitrarily, for simplicity of description, not to above-described embodiment In each technical characteristic it is all possible combination be all described, as long as however, the combination of these technical characteristics be not present lance Shield all should be considered as described in this specification.
Above embodiments only express the several embodiments of the application, and the description thereof is more specific and detailed, but can not Therefore it is construed as limiting the scope of the patent.It should be pointed out that for those of ordinary skill in the art, Under the premise of not departing from the application design, various modifications and improvements can be made, these belong to the protection scope of the application. Therefore, the scope of protection shall be subject to the appended claims for the application patent.

Claims (10)

1. a kind of code file generation method, which comprises
Obtain the metadata to operation object;
At least one set of Code Template of load and the meta data match extracted, wherein the definition of every group of Code Template it is described to The setting operation logic of operation object;
The Code Template of load and the metadata are combined, the code described at least one operation to operation object is generated File.
2. the method according to claim 1, wherein the metadata for obtaining the operation object, comprising:
Obtain the sound code file to operation object;
The sound code file is parsed, the corresponding relationship extracted between strategy according to preconfigured sound code file type and data is true Determine the corresponding data of the sound code file and extracts strategy;
It loads the data and extracts strategy, extract strategy by the data and extract metadata from the sound code file.
3. the method according to claim 1, wherein the load and the meta data match extracted are at least One group of Code Template, comprising:
At least one template processor is called according to the type of the metadata, wherein the template processor is setting code The loader of form assembly;
Corresponding Code Template combination is loaded by the template processor.
4. method according to claim 1-3, which is characterized in that the Code Template by load and the member Data are combined, and generate the code file described at least one operation to operation object, comprising:
The metadata of extraction is converted into the set of key-value pair, the key-value pair includes variable and variate-value;
The Code Template catalogue is obtained, the catalogue subitem in the Code Template catalogue is extracted, it will be in the catalogue subitem Variable replacement is to the variate-value of dependent variable, generating packet name according to the catalogue subitem after variable replacement in the metadata;
Code Template file is obtained according to the file subitem in the Code Template catalogue, by the change in the Code Template file Amount is substituted for the variate-value in the metadata to dependent variable, generates code file, wherein the code file of generation is stated The packet name generated.
5. wanting the described in any item methods of 1-3 according to right, which is characterized in that in the Code Template and the metadata that will be loaded It is combined, generates described at least one operation after the code file of operation object, further includes:
Judge whether the code file generated has existed, if so, by the code file of generation and existing code File is converted into syntax tree, and the consolidation strategy that circulation executes configuration generates the syntax tree after merging, according to institute's predicate after merging Method tree generates the code file after merging.
6. a kind of code file generating means, which is characterized in that described device includes:
Metadata extraction module, for obtaining the metadata to operation object;
Code Template loading module, at least one set of Code Template of the meta data match for loading and extracting, wherein every The group Code Template defines the setting operation logic to operation object;
Composite module, for the Code Template of load and the metadata to be combined, generate at least one operation it is described to The code file of operation object.
7. device according to claim 6, which is characterized in that the Code Template loading module is also used to according to The type of metadata calls at least one template processor predetermined;Pass through the template processor loading code template group It closes, configures its Code Template combination that can be loaded in advance for each template processor.
8. device according to claim 6 or 7, which is characterized in that the composite module, further includes:
Format converting module, for the metadata extracted to be converted into the set of key-value pair, the key-value pair includes variable And variate-value;
Packet name generation module extracts the catalogue subitem in the Code Template catalogue, incites somebody to action for obtaining the Code Template catalogue Variable replacement in the catalogue subitem in the metadata to the variate-value of dependent variable, according to the mesh after variable replacement It records subitem and generates packet name;
Code file generation module will for obtaining Code Template file according to the file subitem in the Code Template catalogue Variable replacement in the Code Template file is at, to the variate-value of dependent variable, generating code file in the metadata, wherein The packet name that the code file statement generated generates.
9. a kind of computer equipment, including memory and processor, the memory are stored with computer program, feature exists In the step of processor realizes any one of claims 1 to 5 the method when executing the computer program.
10. a kind of computer readable storage medium, is stored thereon with computer program, which is characterized in that the computer program The step of method described in any one of claims 1 to 5 is realized when being executed by processor.
CN201810629826.2A 2018-06-19 2018-06-19 Code file generation method and device, computer equipment and storage medium Active CN109032662B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810629826.2A CN109032662B (en) 2018-06-19 2018-06-19 Code file generation method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810629826.2A CN109032662B (en) 2018-06-19 2018-06-19 Code file generation method and device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN109032662A true CN109032662A (en) 2018-12-18
CN109032662B CN109032662B (en) 2021-03-23

Family

ID=64609599

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810629826.2A Active CN109032662B (en) 2018-06-19 2018-06-19 Code file generation method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN109032662B (en)

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109947431A (en) * 2019-03-28 2019-06-28 北京字节跳动网络技术有限公司 A kind of code generating method, device, equipment and storage medium
CN111045685A (en) * 2019-11-05 2020-04-21 贝壳技术有限公司 Code conversion method, device, storage medium and electronic equipment
CN111061475A (en) * 2019-12-13 2020-04-24 中国南方电网有限责任公司 Software code generation method and device, computer equipment and storage medium
CN112286557A (en) * 2020-11-05 2021-01-29 苏州帝博信息技术有限公司 Method and device for updating code content in non-covering mode
CN112596706A (en) * 2020-12-15 2021-04-02 用友网络科技股份有限公司 Patterned code generation method, device and computer readable storage medium
CN112650529A (en) * 2020-12-31 2021-04-13 城云科技(中国)有限公司 System and method capable of configuring generation of mobile terminal APP code
CN112799718A (en) * 2021-01-15 2021-05-14 亿企赢网络科技有限公司 Enumerated document generation method and device, electronic equipment and storage medium
CN113608726A (en) * 2021-07-30 2021-11-05 三一专用汽车有限责任公司 Code generation method and device, electronic equipment and storage medium
CN113742008A (en) * 2021-09-13 2021-12-03 挂号网(杭州)科技有限公司 Interface calling method and device, electronic equipment and storage medium
CN113905277A (en) * 2021-12-09 2022-01-07 北京新片场传媒股份有限公司 Method and device for playing video by browser and electronic equipment
CN115048111A (en) * 2022-08-16 2022-09-13 深圳华锐分布式技术股份有限公司 Code generation method, device, equipment and medium based on metadata

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100299663A1 (en) * 2009-05-21 2010-11-25 Salesforce.Com, Inc. System, method and computer program product for versioning and deprecation of components of an application
CN102117202A (en) * 2009-12-30 2011-07-06 北大方正集团有限公司 J2EE architecture-based code generating device
US20120317504A1 (en) * 2011-06-13 2012-12-13 Microsoft Corporation Automated user interface object transformation and code generation
CN103412749A (en) * 2013-07-29 2013-11-27 福建联迪商用设备有限公司 Relational database based code generation method and code generator
US20130339841A1 (en) * 2012-06-14 2013-12-19 Open Text S.A. Systems and methods of a script generation engine
CN104267966A (en) * 2014-10-15 2015-01-07 北京国双科技有限公司 Method and device for generating program codes of software
CN104657140A (en) * 2015-02-10 2015-05-27 广州华多网络科技有限公司 Code generating method and device
CN106528165A (en) * 2016-11-11 2017-03-22 深圳中兴网信科技有限公司 Code generation method and code generation system
CN106843878A (en) * 2017-01-20 2017-06-13 武汉斗鱼网络科技有限公司 A kind of model generating method and system
CN106873949A (en) * 2015-12-11 2017-06-20 泰康保险集团股份有限公司 Code generating method and its device
WO2017112864A1 (en) * 2015-12-22 2017-06-29 Opera Solutions U.S.A., Llc System and method for rapid development and deployment of reusable analytic code for use in computerized data modeling and analysis
CN107291450A (en) * 2017-05-25 2017-10-24 深圳市彬讯科技有限公司 A kind of quick code automatic generation method for programming friendly

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100299663A1 (en) * 2009-05-21 2010-11-25 Salesforce.Com, Inc. System, method and computer program product for versioning and deprecation of components of an application
CN102117202A (en) * 2009-12-30 2011-07-06 北大方正集团有限公司 J2EE architecture-based code generating device
US20120317504A1 (en) * 2011-06-13 2012-12-13 Microsoft Corporation Automated user interface object transformation and code generation
US20130339841A1 (en) * 2012-06-14 2013-12-19 Open Text S.A. Systems and methods of a script generation engine
CN103412749A (en) * 2013-07-29 2013-11-27 福建联迪商用设备有限公司 Relational database based code generation method and code generator
CN104267966A (en) * 2014-10-15 2015-01-07 北京国双科技有限公司 Method and device for generating program codes of software
CN104657140A (en) * 2015-02-10 2015-05-27 广州华多网络科技有限公司 Code generating method and device
CN106873949A (en) * 2015-12-11 2017-06-20 泰康保险集团股份有限公司 Code generating method and its device
WO2017112864A1 (en) * 2015-12-22 2017-06-29 Opera Solutions U.S.A., Llc System and method for rapid development and deployment of reusable analytic code for use in computerized data modeling and analysis
CN106528165A (en) * 2016-11-11 2017-03-22 深圳中兴网信科技有限公司 Code generation method and code generation system
CN106843878A (en) * 2017-01-20 2017-06-13 武汉斗鱼网络科技有限公司 A kind of model generating method and system
CN107291450A (en) * 2017-05-25 2017-10-24 深圳市彬讯科技有限公司 A kind of quick code automatic generation method for programming friendly

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
MICHIAKI TATSUBORI等: ""HTML templates that fly: a template engine approach to automated offloading from server to client"", 《WWW "09: PROCEEDINGS OF THE 18TH INTERNATIONAL CONFERENCE ON WORLD WIDE WEB》 *
林钰杰 等: ""基于FreeMarker的企业Web应用代码生成器研究"", 《信息技术》 *

Cited By (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109947431A (en) * 2019-03-28 2019-06-28 北京字节跳动网络技术有限公司 A kind of code generating method, device, equipment and storage medium
CN111045685A (en) * 2019-11-05 2020-04-21 贝壳技术有限公司 Code conversion method, device, storage medium and electronic equipment
CN111061475A (en) * 2019-12-13 2020-04-24 中国南方电网有限责任公司 Software code generation method and device, computer equipment and storage medium
CN111061475B (en) * 2019-12-13 2023-12-12 中国南方电网有限责任公司 Software code generating method, device, computer equipment and storage medium
CN112286557A (en) * 2020-11-05 2021-01-29 苏州帝博信息技术有限公司 Method and device for updating code content in non-covering mode
CN112286557B (en) * 2020-11-05 2024-03-22 苏州帝博信息技术有限公司 Method and device for updating code content in non-coverage mode
CN112596706A (en) * 2020-12-15 2021-04-02 用友网络科技股份有限公司 Patterned code generation method, device and computer readable storage medium
CN112650529A (en) * 2020-12-31 2021-04-13 城云科技(中国)有限公司 System and method capable of configuring generation of mobile terminal APP code
CN112799718A (en) * 2021-01-15 2021-05-14 亿企赢网络科技有限公司 Enumerated document generation method and device, electronic equipment and storage medium
CN113608726B (en) * 2021-07-30 2023-08-11 三一专用汽车有限责任公司 Code generation method, device, electronic equipment and storage medium
CN113608726A (en) * 2021-07-30 2021-11-05 三一专用汽车有限责任公司 Code generation method and device, electronic equipment and storage medium
CN113742008A (en) * 2021-09-13 2021-12-03 挂号网(杭州)科技有限公司 Interface calling method and device, electronic equipment and storage medium
CN113742008B (en) * 2021-09-13 2024-04-02 挂号网(杭州)科技有限公司 Interface calling method and device, electronic equipment and storage medium
CN113905277A (en) * 2021-12-09 2022-01-07 北京新片场传媒股份有限公司 Method and device for playing video by browser and electronic equipment
CN115048111A (en) * 2022-08-16 2022-09-13 深圳华锐分布式技术股份有限公司 Code generation method, device, equipment and medium based on metadata
CN115048111B (en) * 2022-08-16 2022-11-15 深圳华锐分布式技术股份有限公司 Code generation method, device, equipment and medium based on metadata

Also Published As

Publication number Publication date
CN109032662B (en) 2021-03-23

Similar Documents

Publication Publication Date Title
CN109032662A (en) Code file generation method, device, computer equipment and storage medium
CN103294475B (en) The business automatic creation system of graphic based business scenario and domain template and method
US10394925B2 (en) Automating web tasks based on web browsing histories and user actions
CN105989150B (en) A kind of data query method and device based on big data environment
US20140149882A1 (en) System, method, and apparatus for collaborative cax editing
CN108804618A (en) Configuration method for database, device, computer equipment and storage medium
CN111061475B (en) Software code generating method, device, computer equipment and storage medium
CN112434811A (en) Knowledge graph construction method and device, computing equipment and storage medium
CN112131837B (en) Service report configuration method, device, computer equipment and storage medium
CN113010476B (en) Metadata searching method, device, equipment and computer readable storage medium
CN112650529B (en) System and method for configurable generation of mobile terminal APP codes
CN109885299A (en) Template processing method, device, computer equipment and storage medium in model development
CN104765823A (en) Method and device for collecting website data
Kulasekaran et al. Metadata integration for an archaeology collection architecture
CN109542501A (en) Browser table compatibility method, device, computer equipment and storage medium
CN109213775A (en) Searching method, device, computer equipment and storage medium
CN116628066B (en) Data transmission method, device, computer equipment and storage medium
CN108153745B (en) Application data calling method and application development system
CN111176901B (en) HDFS deleted file recovery method, terminal device and storage medium
CN112765997A (en) Multi-language conversion method, device, computer equipment and storage medium
CN103559574A (en) Method and system for operating workflow
CN114153547A (en) Management page display method and device
CN109284429B (en) News data pushing method, device, system and storage medium
CN1828596A (en) File system represented inside a database
CN112052234A (en) Service data processing method and device, storage medium and electronic device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
TA01 Transfer of patent application right

Effective date of registration: 20200122

Address after: 200120 floor 15, 1333 Lujiazui Ring Road, China (Shanghai) pilot Free Trade Zone, Pudong New Area, Shanghai

Applicant after: Weikun (Shanghai) Technology Service Co., Ltd

Address before: 200120 13 floor, 1333 Lujiazui Road, Pudong New Area free trade pilot area, Shanghai.

Applicant before: Lujiazui Shanghai international financial assets market Limited by Share Ltd

TA01 Transfer of patent application right
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant