Expression processing methods, apparatus, electronic devices, and computer-readable storage media
By using the expression language AIEL to parse and operate on string expressions, the problem of limited scope and weak text parsing capabilities of existing expression engines is solved, achieving efficient text parsing and logical operations, and supporting JSON object generation.
Patent Information
- Application Number
- CN202210220948.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-08
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2042-03-08
AI Technical Summary
Current expression engines have a limited scope and weak text parsing capabilities, making them unable to effectively describe and process complex business logic.
The AIEL expression language is used to parse target string expression fragments, form a string parsing stack, perform calculations, and generate operation results that return object types. It supports method calls, data structure mapping, and text parsing.
It achieves efficient text parsing and logical operations on string expressions, can dynamically handle complex business logic, improves text parsing and computing capabilities, and supports the generation of JSON objects.
Smart Images

Figure CN114611500B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer data processing technology, and more specifically, to an expression processing method, apparatus, electronic device, and computer-readable storage medium. Background Technology
[0002] An expression is a combination of numbers, operators, number grouping symbols, free variables, and bound variables arranged in a meaningful way that yields a numerical value. Many program codes involve expression calculations, and currently, arithmetic operations on expressions in code are handled by expression engines. An expression engine is a third-party expression calculation tool that can perform arithmetic operations, ternary operations, function calls, and other processing on string expressions, parsing them into code that computers can understand.
[0003] Although the main functional types of currently popular expression engines include automatic conversion, variable access, arithmetic operations, logical operations, relational operations, conditional operations, regular expressions, method calls, user-defined functions, constructor calls, and simple templates, the inventors of this application have found in the implementation process that current expression engines mainly perform expression calculations, have a small scope of application, and weak text parsing capabilities. Summary of the Invention
[0004] This application provides an expression processing method, apparatus, electronic device, and computer storage medium, which can solve the problems of limited scope and weak text parsing capabilities of current expression languages. The technical solution is as follows:
[0005] According to one aspect of the embodiments of this application, an expression processing method is provided, the method comprising:
[0006] Get the input string expression, and identify the target string expression fragment to be processed and the return object type of the target string expression fragment from the string expression;
[0007] Using the expression language AIEL, the business processing logic in the target string expression fragment is parsed to form a corresponding string parsing stack, and the string parsing stack is processed to obtain the operation result of the return object type;
[0008] Replace a portion of the string in the target string expression fragment with the result of the operation that returns an object, or construct the result of the operation that returns an object as a JSON object and return it.
[0009] In one possible implementation, the business processing logic in the target string expression fragment is parsed using the expression language AIEL to form a corresponding string parsing stack, including:
[0010] AIEL is used to parse the business processing logic in the target string expression fragment to obtain at least one execution node, and a string parsing stack is formed based on at least one execution node;
[0011] The string parsing stack performs operations and processing, including:
[0012] Whenever an execution node is obtained, the string parsing stack is processed by calling the corresponding method on that execution node.
[0013] In one possible implementation, a corresponding method call is made to an execution node, including:
[0014] If an exception occurs during the method call or the method call returns an empty result, the original string expression of one execution node will be preserved unchanged.
[0015] If the method call returns a normal value, the return value is set on the return result object.
[0016] In one possible implementation, the returned object type includes a string, a JS object abbreviation JSON object, and a JS object abbreviation array JSONArray object.
[0017] Specifically, when the target string expression fragment is a JSON-formatted string, the returned object type is a JSON object; when the target string expression fragment is a JSONArray-formatted string, the returned object type is a JSONArray object; when the target string expression fragment is neither a JSON-formatted string nor a JSONArray-formatted string, the returned object type is a string.
[0018] In one possible implementation, AIEL's functionality includes at least one of the following:
[0019] Mixed syntax for method calls and variables; data structure mapping; converting JSON strings into JSON objects through operations.
[0020] In one possible implementation, AIEL includes a context section, a processing logic section, and a basic functionality section;
[0021] The context part is what AIEL can obtain from the runtime environment at runtime. The context part includes string expressions, data object sets, method object sets, and built-in method sets.
[0022] The processing logic part is the calculation process of AIEL, which is the calculation logic that transforms a string expression into a return object. The processing logic part includes the first method call, variable calculation and / or retrieval, expression evaluation, built-in method reference, data structure conversion, path data retrieval, built-in methods, extended expression evaluation, and extended methods.
[0023] The basic functionality section supports the processing logic section. The basic functionality section includes string parsing, variable path retrieval, data structure conversion, and second method invocation.
[0024] According to another aspect of the embodiments of this application, an expression processing apparatus is provided, the apparatus comprising:
[0025] The first processing module is used to obtain the input string expression and identify the target string expression fragment to be processed and the return object type of the target string expression fragment from the string expression.
[0026] The second processing module is used to parse the business processing logic in the target string expression fragment using the expression language AIEL and form a corresponding string parsing stack, and to perform operations on the string parsing stack to obtain the operation result of the return object type.
[0027] The third processing module is used to replace part of the string in the target string expression fragment with the operation result of the returned object type, or to construct the operation result of the returned object type into a JSON object and return it.
[0028] In one possible implementation, when the second processing module parses the business processing logic in the target string expression fragment using the expression language AIEL and forms the corresponding string parsing stack, it is used for:
[0029] AIEL is used to parse the business processing logic in the target string expression fragment to obtain at least one execution node, and a string parsing stack is formed based on at least one execution node;
[0030] The second processing module, when performing operations on the string parsing stack, is used for:
[0031] Whenever an execution node is obtained, the string parsing stack is processed by calling the corresponding method on that execution node.
[0032] In one possible implementation, when the second processing module makes a corresponding method call to an execution node, it is used to:
[0033] When an exception occurs during the method call process or the method call returns an empty result, the original string expression of one execution node remains unchanged;
[0034] If the method call returns a normal value, the return value is set on the return result object.
[0035] In one possible implementation, the returned object type includes a string, a JS object abbreviation JSON object, and a JS object abbreviation array JSONArray object.
[0036] Specifically, when the target string expression fragment is a JSON-formatted string, the returned object type is a JSON object; when the target string expression fragment is a JSONArray-formatted string, the returned object type is a JSONArray object; when the target string expression fragment is neither a JSON-formatted string nor a JSONArray-formatted string, the returned object type is a string.
[0037] In one possible implementation, AIEL's functionality includes at least one of the following:
[0038] Mixed syntax for method calls and variables; data structure mapping; converting JSON strings into JSON objects through operations.
[0039] In one possible implementation, AIEL includes a context section, a processing logic section, and a basic functionality section;
[0040] The context part is what AIEL can obtain from the runtime environment at runtime. The context part includes string expressions, data object sets, method object sets, and built-in method sets.
[0041] The processing logic part is the calculation process of AIEL, which is the calculation logic that transforms a string expression into a return object. The processing logic part includes the first method call, variable calculation and / or retrieval, expression evaluation, built-in method reference, data structure conversion, path data retrieval, built-in methods, extended expression evaluation, and extended methods.
[0042] The basic functionality section supports the processing logic section. The basic functionality section includes string parsing, variable path retrieval, data structure conversion, and second method invocation.
[0043] According to another aspect of the present application, an electronic device is provided, comprising: a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the expression processing method described above.
[0044] According to another aspect of the embodiments of this application, a computer-readable storage medium is provided, wherein a computer program, when executed by a processor, implements the steps of the expression processing method described above.
[0045] According to one aspect of the embodiments of this application, a computer program product is provided, which, when executed by a processor, implements the steps of the expression processing method described above.
[0046] This application embodiment utilizes AIEL, a text parsing language capable of representing business logic. It can not only describe a business processing logic but also dynamically implement application logic processing and text parsing functions, achieving efficient parsing and logical operations on text expressions, greatly improving text parsing capabilities and computational power. Simultaneously, this application embodiment uses AIEL to parse the business processing logic within a target string expression fragment and form a corresponding string parsing stack. Operations are then performed on the string parsing stack to obtain a result of type object return. This achieves efficient text parsing and computational processing capabilities for string expressions. It not only allows for immediate preparation of the return result after string expression parsing but also enables the parsing of a JSON object from a JSON string expression within a contextual environment. Attached Figure Description
[0047] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments of this application will be briefly introduced below.
[0048] Figure 1 A flowchart illustrating an expression processing method provided in an embodiment of this application;
[0049] Figure 2 A schematic diagram of the AIEL structure provided in the embodiments of this application;
[0050] Figure 3 The test comparison results provided for the embodiments of this application regarding the performance of testing access variables;
[0051] Figure 4 The test comparison results regarding arithmetic operations provided for the embodiments of this application;
[0052] Figure 5 The test comparison results regarding logical operations provided for the embodiments of this application;
[0053] Figure 6 Test comparison results regarding relational operations provided for embodiments of this application;
[0054] Figure 7 Test comparison results regarding conditional operations provided for embodiments of this application;
[0055] Figure 8 Test comparison results of regular expressions provided for embodiments of this application;
[0056] Figure 9 Test comparison results regarding method calls provided for embodiments of this application;
[0057] Figure 10 This is a schematic diagram of the structure of an expression processing device provided in an embodiment of this application;
[0058] Figure 11 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0059] The embodiments of this application are described below with reference to the accompanying drawings. It should be understood that the embodiments described below with reference to the accompanying drawings are exemplary descriptions for explaining the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions of the embodiments of this application.
[0060] Those skilled in the art will understand that, unless otherwise stated, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the terms “comprising” and “including” as used in embodiments of this application mean that the corresponding feature can be implemented as the presented feature, information, data, step, operation, element, and / or component, but do not exclude implementation as other features, information, data, step, operation, element, component, and / or combinations thereof supported by the art. It should be understood that when we say that an element is “connected” or “coupled” to another element, the one element can be directly connected or coupled to the other element, or it can mean that the one element and the other element establish a connection relationship through an intermediate element. Furthermore, “connected” or “coupled” as used herein can include wireless connection or wireless coupling. The term “and / or” as used herein indicates at least one of the items defined by the term; for example, “A and / or B” indicates implementation as “A,” or implementation as “A,” or implementation as “A and B.”
[0061] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0062] First, let me introduce and explain several terms and related content involved in this application:
[0063] EL (Expression Language) obtains the result by executing a text expression. It typically consists of two parts: a context and an executor. It is mainly used for variable retrieval, logical operations, and loosely coupled code dependencies. It is suitable for scenarios where business logic frequently changes and JAR package dependencies are loosely coupled.
[0064] The currently popular expression languages mainly include:
[0065] J2EE Specification's JSF-EL
[0066] Expression Language (EL) is a new feature introduced in JSP 2.0. EL simplifies object references in JSP development, thereby standardizing page code and increasing readability and maintainability. EL provides a new way for those unfamiliar with Java web application development to create Java web applications.
[0067] 1. Basic Syntax of JSF-EL
[0068] JSF-EL expression syntax is simple. It begins with "${" and ends with "}", with a valid expression in between. The specific syntax format is as follows: ${expression}. `expression`: Specifies the content to be output; it can be a string or an expression composed of EL operators.
[0069] The use cases for JSF-EL are as follows:
[0070] 1.1 Outputting strings via JSF-EL
[0071] To output a string in a JSF-EL expression, you can enclose the string in a pair of single or double quotes.
[0072] Example: Output the string content using EL expressions: ${'pan_junbiao's blog'}
[0073] 1.2 Accessing data via JSF-EL
[0074] Data can be accessed using the "[]" and "." operators provided by JSF-EL. Generally, the "[]" and "." operators are equivalent and can be used interchangeably.
[0075] Example: ${userInfo.id},${userInfo["id"]}
[0076] 2. Features of JSF-EL
[0077] In addition to its simple syntax and ease of use, JSF-EL also has the following features.
[0078] (1) JSF-EL can be used in conjunction with JSTL or with JavaScript statements.
[0079] (2) JSF-EL will automatically perform type conversion.
[0080] (3) JSF-EL can access not only general variables, but also properties in JavaBeans, as well as nested properties and collection objects.
[0081] (4) Arithmetic operations, logical operations, relational operations and conditional operations can be performed in JSF-EL.
[0082] (5) In JSF-EL, you can obtain the namespace (PageContext object, which is the largest scope of the integration object of all other built-in objects in the page, and you can access other built-in objects through it).
[0083] (6) When performing division using JSF-EL, if 0 is used as the divisor, it returns Infinity instead of an error.
[0084] (7) JSP scopes (request, session, application, and page) can be accessed in JSF-EL.
[0085] (8) Extension functions can be mapped to static methods of Java classes.
[0086] 3. Reserved keywords: and, eq, gt, instanceof, div, or, le, false, empty, not, lt, ge.
[0087] 4. JSF-EL Operators
[0088] Arithmetic operators: +, - (binary), *, / , div, %, mod, - (unary).
[0089] Character concatenation operator: +=
[0090] Logical operators: and, &&, or, ||, not, !.
[0091] Relational operators: ==, eq, !, =, ne, <, lt, >, gt, <=, ge, >=
[0092] Apache JEXL
[0093] JEXL is an abbreviation for Java Expression Language, a simple expression language initially inspired by the expression languages defined in Apache Velocity and the JavaServer Pages Standard Tag Library 1.1 (JSTL) and JavaServer Pages 2.0 (JSP). JEXL can be used in many scenarios:
[0094] 1) Script Functionality
[0095] Used in applications that require users to define some custom calculation expressions.
[0096] 2) Component Configuration
[0097] Users can customize configuration files to personalize functionality. These configuration files mainly involve system variables and expressions.
[0098] 3) Loose coupling between interface and implementation
[0099] When certain components do not need to be dependent on during the compilation phase, or when a strong dependency is not desired, the mapping between the interface and the implementation class can be configured.
[0100] 4) Simple template functionality
[0101] In scenarios where JSP or Velocity are not needed, it can implement the functionality of a simple module.
[0102] When evaluating an expression, JEXL combines the JexlExpression or JexlScript with the JexlContext. Expressions are created using JexlEngine#createExpression(), passing a string containing valid JEXL syntax.
[0103] Although JEXL is similar to the expression language defined in JSTL, it improves upon the syntax in several ways:
[0104] ■Supports calling any accessible method
[0105] ■Supports setting / retrieval of any accessible public field
[0106] ■ A generic new() method that allows object instantiation
[0107] ■ A general size() method, used for:
[0108] ■String—Returns length
[0109] ■ Number of back buttons
[0110] ■ Number of elements returned
[0111] ■ A general-purpose empty() method for collections and strings.
[0112] ■ Supports the ternary operator 'a? b:c' and its GNU-C / "Elvis" variant 'a? :c'
[0113] ■ Supports Perl-like regular expression matching operators '=~' and '!~'
[0114] ■ Supports CSS3-inspired 'startsWith' and 'endsWith' operators, '=^', and '=$'
[0115] ■ Supports user-defined functions.
[0116] ■ The '+' operator has been overloaded and is used as a string concatenation operator.
[0117] Spring EL
[0118] Spring Expression Language (SpEL) is a powerful expression language that supports runtime querying and manipulation of objects. Its syntax is similar to Unified EL, but it offers additional features, most notably method invocation and basic string template functionality. The features of Spring Expression Language include:
[0119] ■Textual Expression
[0120] Boolean and Relational Operators
[0121] ■ Regular Expressions
[0122] ■Class Expressions
[0123] ■ Accessing properties, arrays, lists, and maps
[0124] ■Method Call
[0125] ■ Relational Operators
[0126] ■Assignment
[0127] ■ Calling the constructor
[0128] ■Bean Reference
[0129] ■Array Structure
[0130] ■Inline List
[0131] ■Inline mapping
[0132] ■ Ternary operator
[0133] ■Variables
[0134] ■User-defined functions
[0135] ■Select Set
[0136] ■ Templated Expressions
[0137] Expression languages like JSF-EL in the J2EE specification, JEXL in Apache, and Spring EL are primarily used to evaluate text expressions and output a result. Their function is embodied in the "Expression" part of "ExpressionLanguage". JSF-EL in the J2EE specification is used within the J2EE JSTL specification, while Spring EL is used within the Spring framework itself. Essentially, they all serve a single framework, implementing its specific functionalities.
[0138] The main functionalities of JSF-EL, Apache JEXL, and Spring EL include: automatic type conversion, variable access, arithmetic operations, logical operations, relational operations, conditional operations, regular expressions, method calls, user-defined functions, constructor calls, and simple templates. Currently, the EL products being compared primarily focus on expression calculation, resulting in a limited scope and weak text parsing capabilities. We need a text parsing language capable of representing business logic, describing a business processing logic rather than just a computational expression.
[0139] To address the above issues, this application proposes an expression processing solution. The technical solutions and their effects are described below through several exemplary embodiments. It should be noted that the following embodiments can be referenced, borrowed from, or combined with each other. Identical terms, similar features, and similar implementation steps in different embodiments will not be repeated.
[0140] Figure 1 This is a flowchart illustrating the expression processing method provided in an embodiment of this application, as shown below. Figure 1As shown, the method includes: Step S110, obtaining the input string expression, and identifying the target string expression fragment to be processed and the return object type of the target string expression fragment from the string expression; Step S120: using the expression language AIEL, parsing the business processing logic in the target string expression fragment and forming a corresponding string parsing stack, and performing operations on the string parsing stack to obtain the operation result of the return object type; Step S130, replacing part of the string in the target string expression fragment with the operation result of the return object type, or constructing the operation result of the return object type into a JSON object and returning it.
[0141] AIEL, an expression language, has fixed syntax, semantics, and reserved words. It can describe an arithmetic expression, a mapping of data structures, a method call, data processing before and after a method call, data validation, call timeout, and express a complete business logic, etc. Because the complete processing logic is executed during the parsing of the expression, a new EL can be created as needed, and special specifications can be defined to embed the functionality of Apache JEXL and Spring EL, reducing the development of repetitive functions.
[0142] AIEL is a text-based logic operation language that dynamically parses XML configuration logic at runtime to process application logic. It belongs to the parsing-based development language category and serves the web application middleware (FlyingServer). The main purpose of AIEL is to implement a configurable processing "language" that processes a set of expressions with complete business meaning.
[0143] AIEL's main functions include, but are not limited to: automatic type conversion, variable access, arithmetic operations, logical operations, relational operations, conditional operations, method calls, user-defined functions, data mapping, data anonymization, and logical templates. A key advantage of AIEL is that it allows for the customization of expression elements, enabling the addition or modification of new ones as needed.
[0144] In the process of expression processing based on AIEL, the following processing procedure can be performed:
[0145] First, obtain the input string expression, and based on the input string expression, identify the string segment to be processed (i.e., the target string expression segment) and determine the return object format (i.e., the return object type) of the string segment, including nested expression processing.
[0146] Next, the string expression array in the string fragment is scanned using the expression language AIEL. This process parses out the characters representing methods, variables, logical operations, arithmetic operations, relational operations, and data mappings. In other words, the business processing logic within the target string expression fragment is parsed to obtain the corresponding business processing logic. Here, business processing logic refers to the aforementioned characters representing methods, variables, logical operations, arithmetic operations, relational operations, and data mappings. After obtaining the corresponding business processing logic, it is formed into a corresponding string parsing stack (also known as a method call tree or execution stack). To improve parsing efficiency, this embodiment only scans the string fragment to be processed once from beginning to end to parse the string into a method call tree.
[0147] Next, the string parsing stack performs operations to obtain a result that returns an object. That is, it performs operations from the inside out according to the method call tree to obtain a result that returns an object. After the operations, the result that returns an object can be used to replace part of the string in the target string expression fragment, or the result that returns an object can be used to construct a JSON object and return it.
[0148] It should be noted that once the string in the above string fragment is parsed, the return result (i.e., the result of the operation that returns an object type) is ready. In other words, once the business logic in the target string expression fragment is parsed, the method call tree is completed, and the return result (i.e., the result of the operation) is ready.
[0149] The above process of expression processing based on AIEL can also be described as follows: AIEL scans the char array of the string expression, parses out the characters containing methods, variables, logical operations, arithmetic operations, relational operations, and data mappings, forming an execution stack (i.e., string parsing stack). After performing operations on the execution stack, the calculation result is returned to the string or constructed into a JSON object and returned.
[0150] The method provided in this application, through the AIEL text parsing language capable of representing business logic, can not only describe a business processing logic but also dynamically implement application logic processing and text parsing functions. This achieves efficient parsing and logical operations on text expressions, greatly improving text parsing capabilities and computational power. Furthermore, this application, through the AIEL expression language, parses the business processing logic in a target string expression fragment and forms a corresponding string parsing stack. It then performs operations on the string parsing stack to obtain a result that returns an object type. This achieves efficient text parsing and computational processing capabilities for string expressions. It not only allows for immediate preparation of the return result after string expression parsing but also enables the parsing of a JSON object from a JSON string expression within a context.
[0151] In one possible implementation of this application, the process of parsing the business processing logic in the target string expression fragment and forming a corresponding string parsing stack using the expression language AIEL can be as follows: parsing the business processing logic in the target string expression fragment using AIEL to obtain at least one execution node, and forming a string parsing stack based on at least one execution node; wherein, the process of performing operations on the string parsing stack can be as follows: whenever an execution node is obtained, the string parsing stack is operated on by making a corresponding method call on the execution node.
[0152] During the process of calling a method on an execution node, if an exception occurs during the method call or the method call returns an empty result, the original string expression of the execution node is preserved unchanged; if the method call returns a normal value, the return result is set on the return result object.
[0153] The implementation principle of AIEL can be described as follows: By scanning the string expression char array (i.e., the target string expression fragment mentioned above), it parses out the characters containing methods, variables, logical operations, arithmetic operations, relational operations, and data mappings (i.e., parsing the business processing logic in the target string expression fragment), forming an execution stack (i.e., the string parsing stack mentioned above). After performing calculations on the execution stack (i.e., performing operations on the string parsing stack), the calculation result (i.e., the result of the operation that returns an object type) is returned to the string (i.e., the string in the string expression char array mentioned above) or constructed as a JSON object and returned. The purpose of AIEL is to serve parsed languages and can currently be used as a basic function of application containers.
[0154] The specific processing steps may include the following:
[0155] The first step involves identifying the string segment to be processed and the object format to be returned based on the input string expression (i.e., identifying the target string expression segment to be processed and the return object type of the target string expression segment), including cases of nested expressions. To improve parsing efficiency, the method in this embodiment only needs to scan the string segment to be processed once from beginning to end to parse the string into a method call tree (i.e., the string parsing stack mentioned above), and then perform operations from the inside out according to the method call tree. Once the string parsing is complete, the return result (i.e., the object format to be returned, or the result of the operation on the return object type) is ready.
[0156] The second step is to perform computational processing. During the parsing process in the first step, one or more execution nodes can be obtained. When an execution node is parsed in the first step, a corresponding method call is made for that execution node to perform computational processing on the string parsing stack. If an exception occurs during the execution of the computational processing or the method call returns an empty result, the original node expression of that execution node is retained, that is, the original string expression of that execution node remains unchanged. If there is a normal return value, the original node expression is replaced or set on the return result object according to the return result type. That is, when the method call returns a normal value, the return result type is set on the return result object.
[0157] The third step, after parsing and method call tree invocation are complete, is to format the returned object (i.e., the return result type) according to requirements. Further processing of the returned object can be performed based on configuration. For example, the result of an operation on the returned object type can be used to replace a portion of the string in the target string expression fragment, or the result of an operation on the returned object type can be constructed into a JSON object and returned.
[0158] In one possible implementation, AIEL comprises a context section, a processing logic section, and a basic functionality section. The context section contains the information AIEL can obtain from its runtime environment, including string expressions, data object sets, method object sets, and built-in method sets. The processing logic section represents AIEL's computation process, transforming a string expression into a returned object. This process includes first method calls, variable calculation and / or retrieval, expression evaluation, built-in method references, data structure conversion, path data retrieval, built-in methods, extended expression evaluation, and extended methods. The basic functionality section supports the processing logic section and includes string parsing, variable path retrieval, data structure conversion, and second method calls.
[0159] like Figure 2As shown, the AIEL in this application embodiment includes a context part, a processing logic part, and a basic function part. The specific descriptions of these three parts are as follows:
[0160] The context section refers to the content that the AIEL runtime can obtain from the runtime environment. This section includes:
[0161] (1) Expression: The expression that needs to be calculated by AIEL. The expression exists in the form of a string and is passed to AIEL as a parameter.
[0162] (2) Data object set: This is a collection of data objects loaded by the AIEL runtime environment settings to match variables in expressions.
[0163] (3) Method object set: This is a collection of Java objects loaded by the AIEL runtime environment to match methods in the expression. The expression needs to specify the name of the Java object to which the method belongs.
[0164] (4) Built-in method set: This is the collection of built-in methods of AIEL itself. There is no need to specify the object name to which the specific method belongs in the expression. It can be called directly by the built-in method name + parameter.
[0165] The processing logic part is the AIEL operation process, which is the operation logic that turns a string into a returned object. Figure 2 The area filled with black dots describes the logic of the computation. First, the string expression is parsed (interpreting the expression) in the basic function section, breaking it down into a string stack that AIEL can recognize. Then, each string in the string stack is matched to a parsing unit. Next, the matched string is processed using that parsing unit, and the processing result is returned to the corresponding string position in the string stack. Finally, the result set in the string stack is assembled into a return object. The parsing unit here includes:
[0166] (1) Method call @{}: The string "@{method name}.method name(parameters)" represents the method of the Java object to be called. Here, method call @{} is the first method call mentioned above.
[0167] (2) Variable calculation / retrieval ${}: Use “${variable name}” to calculate or directly retrieve the data object from the context.
[0168] (3) Expression operation #{}: Perform logical, arithmetic or relational operations using "#{ expression of logical operation / arithmetic operation / relational operation}".
[0169] (4) Built-in method reference(): You can call built-in methods using "(built-in method name)".
[0170] (5) Data structure conversion mapping: Defines the mapping format for data object conversion.
[0171] (6) Path data retrieval. / []: The path is represented by "." or " / ", and [] represents an array or collection. The basic function variable path retrieval returns the parsed object.
[0172] (6) Built-in methods: Includes time, case conversion, formatting, encoding, encryption and other methods.
[0173] (7) Extended Expression Evaluation: Currently, Spring Expression and Jexl are integrated for rich expression evaluation. "#sp{expression content}" represents Spring Expression evaluation, and "#jxel{expression content)" represents Jexl evaluation.
[0174] (8) Extension methods: Supports custom parsing units and extends string expression functionality.
[0175] (9) The basic functionalities provided support the upper-level processing logic. These functionalities are not easily added to or modified, and generally meet the needs of any additions or changes to the upper-level processing logic. They mainly include:
[0176] (10) String parsing: used to parse a string into a call stack.
[0177] (11) Variable path retrieval: used to calculate data from the context.
[0178] (12) Data structure conversion: used for conversion between data objects.
[0179] (13) Method call: Used to call object methods in the environment. Complex logic can be encapsulated in object methods to simplify the expression of strings. This method call is the second method call mentioned above.
[0180] In one example, the main method of the AIEL function is getValueFromExpress. The input parameters of the main method are shown in Table 1 below, and the return parameters of the main method are shown in Table 2 below. The reason why the name of the return parameter is empty is because the name of the return parameter is not fixed or unique.
[0181] Table 1 Input Parameters
[0182] name type Is it a set? Remark expression String No expression string evn Map No Contextual data obj java.lang.Object No Method Class Manager
[0183] Table 2 Returns Parameters
[0184]
[0185] As shown in Table 2, the returned object types include strings, JS object abbreviations in JSON format, and JS object abbreviation arrays in JSONArray format. Specifically, when the target string expression fragment is a JSON-formatted string, the returned object type is a JSON object; when the target string expression fragment is a JSONArray-formatted string, the returned object type is a JSONArray object; and when the target string expression fragment is neither a JSON-formatted string nor a JSONArray-formatted string, the returned object type is a string.
[0186] In one possible implementation, AIEL's functionality includes at least one of the following: a mixed syntax for method calls and variables; data structure mapping; and the ability to convert JSON strings into JSON objects through operations.
[0187] In one example, AIEL's unique features include at least the following:
[0188] (1) The mixed syntax of method calls and variables is not supported by JXEL and SPEL, for example: company.getStaffs()[0].getName(). The "mixed syntax of variables" is a combination of variables and method calls, the purpose of which is to return the required object through a concise string expression. Figure 2 The "variable path retrieval" function in the document has the feature of "variable mixed syntax".
[0189] (2) Replace the text containing the defined expression, for example: Veris_SecFrame_(env_code)_Entity_Template_V1.0.xlsx, and replace (env_code) with the corresponding environment number at runtime.
[0190] (3) Data structure mapping, where, Figure 2 The "Data Structure Transformation" in the document describes how to transform data structures using "Data Structure Mapping" information. Figure 2 The "Data Structure Transformation" in the code consists of "Data Structure Mapping" and transformation logic code. Here, "Data Structure Mapping" is a JSON-formatted description of the transformation relationship between the original and target data structures.
[0191] Data structure mappings can take the following forms, for example:
[0192]
[0193] Through the above processing steps, one or more data items can be converted into a data object with a predefined structure.
[0194] (4) JSON strings are processed and converted into JSON objects. An example of this data structure conversion is given below. Figure 2 The term "data structure transformation" corresponds to this.
[0195]
[0196]
[0197] After the above processing steps, a JSON string will eventually be converted into a JSON object and returned.
[0198] In the same test environment, comparative tests were conducted on the performance of AIEL, SpringEL, and JEXL in key functions such as variable access, arithmetic operations, logical operations, relational operations, conditional operations, regular expressions, and method calls. The results showed that AIEL in this embodiment significantly outperforms SpringEL and JEXL. For detailed comparisons, please refer to [link / reference needed]. Figures 3 to 9 .in, Figure 3 This is a comparison of test results regarding the performance of accessing variables. Figure 3 It can be seen that the total time spent by AIEL in this embodiment to execute test access variables is significantly less than that of SpringEL and JEXL; Figure 4 This is a comparison of test results regarding arithmetic operations, based on... Figure 4 It can be seen that the total time taken by AIEL to perform arithmetic operations in this embodiment is significantly less than that of SpringEL and JEXL; Figure 5 These are test comparison results regarding logical operations, based on... Figure 5 It can be seen that the total time consumed by AIEL in this embodiment to perform logical operations is significantly less than that of SpringEL and JEXL; Figure 6 These are test comparison results regarding relational operations, based on... Figure 6 It can be seen that the total time consumed by AIEL in this embodiment to perform relational operations is significantly less than that of SpringEL and JEXL; Figure 7 This is a comparison of test results regarding conditional operations, based on... Figure 7 It can be seen that the total time consumed by AIEL in this embodiment to perform conditional operations is significantly less than that of SpringEL and JEXL; Figure 8 This is a test comparison result regarding regular expressions, based on... Figure 8 It can be seen that the total time taken by AIEL to execute regular expressions in this embodiment of the application is significantly less than that of SpringEL and JEXL; Figure 9 These are test comparison results regarding method calls, based on... Figure 9 It can be seen that the total time spent executing method calls in the AIEL implementation of this application is significantly less than that of SpringEL and JEXL.
[0199] Through the above Figures 3 to 9 As can be seen from the embodiments of this application, AIEL's processing efficiency is significantly better than that of the currently used SpringEL and JEXL. AIEL can be used to parse a JSON object from a JSON string expression in combination with the context; it can also be used to instantiate a defined data structure in different contexts; and it can also be used for data object structure mapping and transformation, data pruning, data anonymization, and authorization control of certain fields in data. Therefore, the AIEL of this application embodiment is compatible with other EL engines, is powerful and has extremely high processing efficiency. It is a JSON expression parsing engine that can not only parse a single expression, but also serve as a basic function of parsed languages, handling the instantiation of data and parameters.
[0200] This application provides an expression processing device, such as... Figure 10 As shown, the network capacity prediction device 100 may include: a first processing module 1001, a second processing module 1002, and a third processing module 1003, wherein,
[0201] The first processing module 1001 is used to obtain the input string expression and identify the target string expression fragment to be processed and the return object type of the target string expression fragment from the string expression.
[0202] The second processing module 1002 is used to parse the business processing logic in the target string expression fragment using the expression language AIEL and form a corresponding string parsing stack, and to perform operations on the string parsing stack to obtain the operation result of the return object type.
[0203] The third processing module 1003 is used to replace part of the string in the target string expression fragment with the operation result of the returned object type, or to construct the operation result of the returned object type into a JSON object and return it.
[0204] In one possible implementation, when the second processing module parses the business processing logic in the target string expression fragment using the expression language AIEL and forms the corresponding string parsing stack, it is used for:
[0205] AIEL is used to parse the business processing logic in the target string expression fragment to obtain at least one execution node, and a string parsing stack is formed based on at least one execution node;
[0206] The second processing module, when performing operations on the string parsing stack, is used for:
[0207] Whenever an execution node is obtained, the string parsing stack is processed by calling the corresponding method on that execution node.
[0208] In one possible implementation, when the second processing module makes a corresponding method call to an execution node, it is used to:
[0209] When an exception occurs during the method call process or the method call returns an empty result, the original string expression of one execution node remains unchanged;
[0210] If the method call returns a normal value, the return value is set on the return result object.
[0211] In one possible implementation, the returned object type includes a string, a JS object abbreviation JSON object, and a JS object abbreviation array JSONArray object.
[0212] Specifically, when the target string expression fragment is a JSON-formatted string, the returned object type is a JSON object; when the target string expression fragment is a JSONArray-formatted string, the returned object type is a JSONArray object; when the target string expression fragment is neither a JSON-formatted string nor a JSONArray-formatted string, the returned object type is a string.
[0213] In one possible implementation, AIEL's functionality includes at least one of the following:
[0214] Mixed syntax for method calls and variables; data structure mapping; converting JSON strings into JSON objects through operations.
[0215] In one possible implementation, AIEL includes a context section, a processing logic section, and a basic functionality section;
[0216] The context part is what AIEL can obtain from the runtime environment at runtime. The context part includes string expressions, data object sets, method object sets, and built-in method sets.
[0217] The processing logic part is the calculation process of AIEL, which is the calculation logic that transforms a string expression into a return object. The processing logic part includes the first method call, variable calculation and / or retrieval, expression evaluation, built-in method reference, data structure conversion, path data retrieval, built-in methods, extended expression evaluation, and extended methods.
[0218] The basic functionality section supports the processing logic section. The basic functionality section includes string parsing, variable path retrieval, data structure conversion, and second method invocation.
[0219] This application embodiment utilizes AIEL, a text parsing language capable of representing business logic. It can not only describe a business processing logic but also dynamically implement application logic processing and text parsing functions, achieving efficient parsing and logical operations on text expressions, greatly improving text parsing capabilities and computational power. Simultaneously, this application embodiment uses AIEL to parse the business processing logic within a target string expression fragment and form a corresponding string parsing stack. Operations are then performed on the string parsing stack to obtain a result of type object return. This achieves efficient text parsing and computational processing capabilities for string expressions. It not only allows for immediate preparation of the return result after string expression parsing but also enables the parsing of a JSON object from a JSON string expression within a contextual environment.
[0220] The expression processing device of this application embodiment can execute the expression processing method shown in the above embodiments of this application. The implementation principle is similar. The actions performed by each module in the device of each embodiment of this application correspond to the steps in the method of each embodiment of this application. For detailed functional descriptions of each module of the device, please refer to the descriptions in the corresponding methods shown above, which will not be repeated here.
[0221] This application provides an electronic device including a memory, a processor, and a computer program stored in the memory. The processor executes the computer program to implement the steps of a method for determining network coverage. Compared with the prior art, this method can achieve the following: acquiring an input string expression and identifying the target string expression fragment to be processed and the return object type of the target string expression fragment from the string expression; then, parsing the business processing logic in the target string expression fragment using the expression language AIEL to form a corresponding string parsing stack, and performing operations on the string parsing stack to obtain the operation result of the return object type; then, replacing part of the string in the target string expression fragment with the operation result of the return object type, or constructing the operation result of the return object type into a JSON object and returning it.
[0222] In one alternative embodiment, an electronic device is provided, such as Figure 11 As shown, Figure 11The illustrated electronic device 4000 includes a processor 4001 and a memory 4003. The processor 4001 and the memory 4003 are connected, for example, via a bus 4002. Optionally, the electronic device 4000 may further include a transceiver 4004, which can be used for data interaction between the electronic device and other electronic devices, such as sending and / or receiving data. It should be noted that in practical applications, the transceiver 4004 is not limited to one type, and the structure of the electronic device 4000 does not constitute a limitation on the embodiments of this application.
[0223] Processor 4001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 4001 may also be a combination that implements computational functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.
[0224] Bus 4002 may include a pathway for transmitting information between the aforementioned components. Bus 4002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. Bus 4002 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 11 Only one thick line is used in the diagram, but this does not mean that there is only one bus or one type of bus.
[0225] The memory 4003 may be ROM (Read Only Memory) or other types of static storage devices capable of storing static information and instructions, RAM (Random Access Memory) or other types of dynamic storage devices capable of storing information and instructions, or EEPROM (Electrically Erasable Programmable Read Only Memory), CD-ROM (Compact Disc Read Only Memory) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium capable of carrying or storing computer programs and capable of being read by a computer, without limitation herein.
[0226] The memory 4003 stores computer programs that execute embodiments of this application, and its execution is controlled by the processor 4001. The processor 4001 executes the computer programs stored in the memory 4003 to implement the steps shown in the foregoing method embodiments.
[0227] This application provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it can implement the steps and corresponding content of the aforementioned method embodiments.
[0228] This application also provides a computer program product, including a computer program that, when executed by a processor, can implement the steps and corresponding content of the aforementioned method embodiments.
[0229] It should be understood that although arrows indicate various operation steps in the flowcharts of this application's embodiments, the order in which these steps are implemented is not limited to the order indicated by the arrows. Unless explicitly stated herein, in some implementation scenarios of this application's embodiments, the implementation steps in each flowchart can be executed in other orders as required. Furthermore, some or all steps in each flowchart, based on the actual implementation scenario, may include multiple sub-steps or multiple stages. Some or all of these sub-steps or stages can be executed at the same time, and each sub-step or stage can also be executed at different times. In scenarios where execution times differ, the execution order of these sub-steps or stages can be flexibly configured according to requirements, and this application's embodiments do not limit this.
[0230] The above description is only an optional implementation method for some implementation scenarios of this application. It should be noted that for those skilled in the art, other similar implementation methods based on the technical concept of this application without departing from the technical concept of this application also fall within the protection scope of the embodiments of this application.
Claims
1. An expression processing method, characterized in that, include: The system acquires the input string expression and identifies the target string expression fragment to be processed from it. Based on the data format of the target string expression fragment, it identifies the return object type of the target string expression fragment. The return object type includes a string, a JS object abbreviation JSON object, and a JS object abbreviation array JSONArray object. When the target string expression fragment is a JSON format string, the return object type is a JSON object. When the target string expression fragment is a JSONArray format string, the return object type is a JSONArray object. When the target string expression fragment is neither a JSON format string nor a JSONArray format string, the return object type is a string. The AIEL expression language is used to parse the business processing logic in the target string expression fragment and form a corresponding string parsing stack. The string parsing stack is then processed to obtain the result of the operation on the returned object type. The AIEL function includes at least one of the following: a mixed syntax for method calls and variables, and data structure mapping. The mixed syntax for method calls and variables is used to parse chained expressions containing method calls and variable references. The data structure mapping is used to transform the original data structure of variables or expressions into a target data structure based on predefined JSON format description information. If the returned object type is a string, the result of the operation on the returned object type is used to replace part of the string in the target string expression fragment. If the returned object type is a JSON object or a JSONArray object, the result of the operation on the returned object type is used to construct a JSON object and return it.
2. The method according to claim 1, characterized in that, The step of parsing the business processing logic in the target string expression fragment using the AIEL expression language and forming a corresponding string parsing stack includes: The AIEL parses the business processing logic in the target string expression fragment to obtain at least one execution node, and forms the string parsing stack based on the at least one execution node; The string parsing stack performs operations, including: Whenever an execution node is obtained, the string parsing stack is processed by calling the corresponding method on that execution node.
3. The method according to claim 2, characterized in that, The method call to the corresponding execution node includes: If an exception occurs during the method call or the method call returns an empty result, the original string expression of the execution node is retained unchanged. If the method call returns a normal value, then the return result is set on the return result object.
4. The method according to any one of claims 1-3, characterized in that, The AIEL includes a context section, a processing logic section, and a basic functionality section. The context portion refers to the content that the AIEL runtime can obtain from the runtime environment. The context portion includes string expressions, data object sets, method object sets, and built-in method sets. The processing logic part is the calculation process of AIEL, which is the calculation logic of turning a string expression into a return object. The processing logic part includes a first method call, variable calculation and / or acquisition, expression calculation, built-in method reference, data structure conversion, path data acquisition, built-in methods, extended expression calculation, and extended methods. The basic functional part is used to support the processing logic part, and the basic functional part includes string parsing, variable path acquisition, data structure conversion and second method invocation; The first method call is represented by the string "@{method name}.method name(parameters)" which indicates the method of the Java object to be called; The extension method is used to customize the parsing unit and extend string expressions; The second method invokes object methods in the environment.
5. An expression processing device, characterized in that, include: The first processing module is used to acquire the input string expression, identify the target string expression fragment to be processed from the string expression, and identify the return object type of the target string expression fragment according to the data format of the string expression; wherein, the return object type includes string, JS object abbreviation JSON object, JS object abbreviation array JSONArray object; when the target string expression fragment is a JSON format string, the return object type is JSON object; when the target string expression fragment is a JSONArray format string, the return object type is JSONArray object; when the target string expression fragment is neither a JSON format string nor a JSONArray format string, the return object type is string. The second processing module is used to parse the business processing logic in the target string expression fragment using the expression language AIEL and form a corresponding string parsing stack, and to perform operations on the string parsing stack to obtain the operation result of the returned object type; wherein, the functions of AIEL include at least one of the following: method call and variable mixed syntax and data structure mapping; the method call and variable mixed syntax is used to parse chained expressions containing method calls and variable references; the data structure mapping is used to transform the original data structure of variables or expressions into the target data structure according to predefined JSON format description information; The third processing module is used to replace part of the string in the target string expression fragment with the operation result of the returned object type if the returned object type is a string, or to construct a JSON object and return it if the returned object type is a JSON object or a JSONArray object.
6. An electronic device comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the steps of the method according to any one of claims 1-4.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method described in any one of claims 1-4.
8. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1-4.
Citation Information
Patent Citations
Method and device for carrying out logic processing on complex character strings on basis of logic templates
CN102446167A
Data filtering device and method
CN107038161A