A method and device for implementing client version rule determination compatibility
By defining enumeration variables and comparison functions, the different version numbers of the client are compared uniformly, which solves the problem that it is difficult to achieve compatibility in the prior art version number comparison, and achieves compatibility and efficiency improvement in version rule determination.
Patent Information
- Application Number
- CN202010696453.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-20
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2040-07-20
AI Technical Summary
The prior art is difficult to compare the version numbers of different rules uniformly, making it difficult to achieve compatibility in determining the client version rules.
The comparison results of the client's different version numbers are encapsulated by defining enumeration variables, and the version types of the client's first version number and the second version number are compared based on the comparison function. The specific steps include splitting the version number, getting the minimum length, polling and comparing, and continuing to compare or returning the result based on the comparison result.
The unified comparison of version numbers of different rules is achieved to ensure compatibility of client version rules judgments and improve judgment efficiency.
Smart Images

Figure CN113961176B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a method and device for implementing client version rule determination compatibility. Background Art
[0002] Currently, applications have multiple version numbers. The latest version is closer to the current time, and the older version is farther away from the current time. Versions that appear in different periods correspond to different version numbers. The version number is composed of a data or a group of numbers with a unified rule. Since the rules are unified and they are all composed of numbers, the version level can be determined by comparing the size of the numbers, thereby determining whether the application needs to be upgraded. However, in actual use, there is no unified rule logic for version numbers. Therefore, unified comparison of version numbers with different rules is a technical problem that needs to be solved urgently. Summary of the invention
[0003] In view of the above problems, the present invention is proposed to provide a method and device for implementing client version rule determination compatibility that overcomes the above problems or at least partially solves the above problems.
[0004] In a first aspect, the present invention provides a method for implementing client version rule determination compatibility, comprising:
[0005] A result set of comparison results of different version numbers of the client is encapsulated by defining an enumeration variable, a private variable is defined in the enumeration variable, the private variable is used to describe result information of the result set, and the enumeration variable of the result set is specifically any one of the following: equal to, greater than, and less than;
[0006] Based on a comparison function compareValue, comparing the version type of the first version number of the client with the version type of the second version number of the client, including:
[0007] The first version number and the second version number are split respectively by calling the split function to obtain a first array set and a second array set;
[0008] Obtain a first length value of an array set with a minimum length between the first array set and the second array set;
[0009] According to the first length value, obtain a first character group in the first array set with a length information equal to the first length value, and obtain a second character group in the second array set with a length information equal to the first length;
[0010] Perform polling comparison on characters at the same position in the first character group and the second character group, and return a first comparison result of the first array set and the second array set;
[0011] When the first comparison result is equal, obtaining an array set with the largest length between the first array set and the second array set as an array set to be continued to be compared;
[0012] Constructing a poll for the array set to be compared continuously, so that the starting position of the poll is the end position of the first length value, and the ending position of the poll is the end position of the maximum length;
[0013] Compare the array set to be compared with 0 respectively according to the polling, and return a second comparison result of the first array set and the second array set;
[0014] Based on the second comparison result, a comparison result of the version type of the first version number and the version type of the second version number is obtained.
[0015] Furthermore, after returning a first comparison result of the first array set and the second array set, the method further includes:
[0016] When the first comparison result is greater than or less than, based on the first comparison result, a comparison result of the version type of the first version number and the version type of the second version number is obtained.
[0017] Further, the polling and comparing characters at the same position in the first character group and the second character group includes:
[0018] Call the Integer.parseInt function to convert each character in the first character group into a number and assign the value to the first integer variable, and call the Integer.parseInt function to convert each character in the first character group into a number and assign the value to the second integer variable;
[0019] The loop function is called to perform polling comparison between the first integer variable and the integer variable at the same position in the second integer variable.
[0020] Furthermore, the calling of the split function to split the first version number and the second version number to obtain a first array set and a second array set includes:
[0021] String[]currentArray=curVersion.split("\\.");
[0022] String[]nextArray=nextVersion.split("\\.");
[0023] Among them, nextVersion is the first version number, curVersion is the second version number, \\. means splitting the first version number and the second version number according to ., currentArray is the first array set, and nextArray is the second array set.
[0024] Further, extracting a first length value of an array set with a minimum length between the first array set and the second array set includes:
[0025] The min function in Math is used to extract the first length value of the array set with the minimum length between the first array set and the second array set:
[0026] int minLength=Math.min(currentArray.length,nextArray.length)
[0027] Among them, minLength is the first length value.
[0028] Furthermore, the obtaining of an array set with the maximum length between the first array set and the second array set as an array set to be compared further includes:
[0029] The max function in Math is used to obtain the array set with the maximum length between the first array set and the second array set as the character group to be compared:
[0030] int maxLength=Math.max(currentArray.length,nextArray.length)
[0031] The maxLength is the maximum length.
[0032] Furthermore, the result set of the comparison results of different version numbers of the client is encapsulated by defining an enumeration variable, a private variable is defined in the enumeration variable, and the private variable is used to describe the result information of the result set. The enumeration variable of the result set is specifically any one of the following: equal to, greater than, and less than, including:
[0033] Encapsulate the result set by defining an enumeration variable:
[0034] public enum VersionResult{}
[0035] Wherein, VersionResult is the result set, and enum is the enumeration variable;
[0036] Define private variables within said enumeration:
[0037] private int result;
[0038] Define the get method of the private variable to get the value of the private variable result:
[0039] public int getResult(){
[0040] return result;
[0041] }
[0042] Define the set method of the private variable to assign a value to the private variable result:
[0043] public void setResult(int result){
[0044] this.result = result;
[0045] }.
[0046] In a second aspect, the present invention further provides a device for implementing client version rule determination compatibility, comprising:
[0047] A result set definition module is used to encapsulate the result set of the comparison results of different version numbers of the client by defining an enumeration variable, and a private variable is defined in the enumeration variable, and the private variable is used to describe the result information of the result set. The enumeration variable of the result set is specifically any one of the following: equal to, greater than, and less than;
[0048] The first comparison module is used to compare the version type of the first version number of the client with the version type of the second version number of the client based on the comparison function compareValue, including:
[0049] A splitting unit, used to split the first version number and the second version number respectively by calling a split function to obtain a first array set and a second array set;
[0050] A first acquiring unit, configured to acquire a first length value of an array set of minimum length between the first array set and the second array set;
[0051] A first obtaining unit is used to obtain, according to the first length value, a first character group in the first array set and a length information equal to the first length value, and obtain a second character group in the second array set and a length information equal to the first length value;
[0052] A first polling comparison unit, configured to perform polling comparison on the characters at the same position in the first character group and the second character group, and return a first comparison result of the first array set and the second array set;
[0053] A second acquisition unit, configured to acquire, when the first comparison result is equal, an array set of maximum length between the first array set and the second array set as an array set to be continued to be compared;
[0054] A polling construction unit is used to construct a polling for the array set to be compared continuously, so that the starting position of the polling is the end position of the first length value, and the end position of the polling is the end position of the maximum length;
[0055] A second polling comparison unit, configured to compare the continued comparison array set with 0 respectively according to the polling, and return a second comparison result of the first array set and the second array set;
[0056] The second obtaining unit is used to obtain a comparison result between the version type of the first version number and the version type of the second version number based on the second comparison result.
[0057] In a third aspect, the present invention further provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned method steps when executing the program.
[0058] In a fourth aspect, the present invention further provides a computer-readable storage medium, on which a computer program is stored, characterized in that the program implements the above-mentioned method steps when executed by a processor.
[0059] One or more technical solutions in the embodiments of the present invention have at least the following technical effects or advantages:
[0060] The method for realizing the compatibility of client version rules provided by the present invention comprises: encapsulating a result set of comparison results of different version numbers of the client by defining an enumeration variable, defining a private variable in the enumeration variable, the private variable being used to describe the result information of the result set, the enumeration variable of the result set being specifically any one of the following: equal to, greater than and less than; then defining a comparison function, and based on the comparison function, comparing the version types of the first version number and the second version number of the client, comprising: splitting the first version number and the second version number by calling a split function respectively, obtaining a first array set and a second array set, obtaining a first length value of an array set of the minimum length in the first array set and the second array set; obtaining, according to the first length value, a first character group in the length information equal to the first length value in the first array set, obtaining a first character group in the second array set equal to the first length value equal to the second character group in the length information, poll and compare the characters in the same position in the first character group and the second character group, and return a first comparison result of the first array set and the second array set; when the first comparison result is equal, obtain the array set with the maximum length in the first array set and the second array set as the array set to be continued to be compared; construct a poll for the array set to be continued to be compared, so that the starting position of the poll is the end position of the first length value, and the end position of the poll is the end position of the maximum length; compare the array set to be continued to be compared with 0 according to the poll, and return a second comparison result of the first array set and the second array set; based on the second comparison result, obtain the comparison result of the version type of the first version number and the version type of the second version number, so that the version numbers of different rules can be uniformly compared, thereby achieving the compatibility of client version rule determination. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Also, throughout the accompanying drawings, the same reference figures are used to represent the same components. In the drawings:
[0062] Figure 1 , Figure 2 A schematic diagram of the steps of implementing a method for determining compatibility based on client version rules in Embodiment 1 of the present invention is shown;
[0063] Figure 3 , Figure 4 A schematic diagram showing the structure of an apparatus for implementing client version rule determination compatibility in Embodiment 2 of the present invention;
[0064] Figure 5 A schematic diagram of the structure of an electronic device for implementing client version rule determination compatibility in Embodiment 3 of the present invention is shown. DETAILED DESCRIPTION
[0065] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0066] The general idea of the present invention is as follows:
[0067] The present invention provides a method for implementing client version rule compatibility determination, including: encapsulating a result set of comparison results of different version numbers of a client by defining an enumeration variable, wherein the enumeration result is specifically: equal to, greater than or less than, and a private variable is defined in the enumeration variable, and the private variable is used to describe the result information of the result set. Then, through a comparison function, the version type of the first version number of the client is compared with the version type of the second version number of the client, wherein the first version number and the second version number are firstly split by calling a split function, respectively, to obtain a first array set and a second array set, and then obtain the first length value of the array set with the minimum length in the first array set and the second array set; according to the first length value, the first character group in the length information equal to the first length value in the first array set is obtained, and the second character group in the length information equal to the first length in the second array set is obtained; the characters in the same position in the first character group and the second character group are polled and compared, and the comparison between the first array set and the second array set is returned. The first comparison result; when the first comparison result is equal, obtain the array set with the maximum length in the first array set and the second array set as the array set to be continued to be compared; construct a poll for the array set to be continued to be compared, so that the starting position of the poll is the end position of the first length value, and the end position of the poll is the end position of the maximum length, and finally, compare the array set to be continued to be compared with 0 according to the poll, and return the second comparison result of the first array set and the second array set; based on the second comparison result, obtain the comparison result of the version type of the first version number and the version type of the second version number, so as to uniformly compare the version numbers of different rules, thereby achieving the compatibility of the client version rule determination.
[0068] Embodiment 1
[0069] The present invention provides a method for implementing client version rule determination compatibility, such as Figure 1 , Figure 2 As shown, including:
[0070] S101, encapsulating a result set of comparison results of different version numbers of the client by defining an enumeration variable, defining a private variable in the enumeration variable, the private variable being used to describe result information of the result set, and the enumeration variable of the result set is specifically any one of the following: equal to, greater than, and less than;
[0071] S102, based on a comparison function compareValue, comparing the version type of the first version number of the client with the version type of the second version number of the client, including:
[0072] S201 calls the split function to split the first version number and the second version number respectively, to obtain a first array set and a second array set;
[0073] S202, obtaining a first length value of an array set with a minimum length between the first array set and the second array set;
[0074] S203, according to the first length value, obtaining a first character group in the length information equal to the first length value in the first array set, and obtaining a second character group in the length information equal to the first length in the second array set;
[0075] S204, performing polling comparison on the characters at the same position in the first character group and the second character group, and returning a first comparison result of the first array set and the second array set;
[0076] S205, when the first comparison result is equal, obtaining an array set with the maximum length between the first array set and the second array set as an array set to be compared further;
[0077] S206, continuing to compare the array set to construct a poll, so that the starting position of the poll is the end position of the first length value, and the end position of the poll is the end position of the maximum length;
[0078] S207, continue to compare the array set with 0 respectively according to the polling, and return a second comparison result of the first array set and the second array set;
[0079] S208: Based on the second comparison result, obtain a comparison result between the version type of the first version number and the version type of the second version number.
[0080] By using the above method, the version numbers of different rules are compared, so as to achieve the compatibility of the judgment of different versions of the client rules, thereby improving the judgment efficiency.
[0081] In a specific implementation, currently, the most common version rules for client version numbers are as follows:
[0082] One is marked with numbers, for example, 1, 2, 3, etc. Rule A.
[0083] One is to add a dot to the number to distinguish the minor version information, for example, 1.2, 1.5, etc. Rule B.
[0084] One is to have multiple points on the basis of numbers to distinguish multiple sub-dimensional information, for example, rule C, such as 1.10.11, 1.20.30, etc.
[0085] In actual use, when there are too many dimensions, letters such as a, b, c may appear, for example, 1.fa10, etc.
[0086] It can be seen that the above-mentioned multiple versions of rules are diverse and there is no unified rule logic.
[0087] Therefore, the present invention provides a method for implementing client version rule compatibility determination. First, a version comparison result set is designed.
[0088] The results obtained after comparing different versions include: equal, greater than, and less than. Therefore, a solution for a result set is designed: specifically, S101, encapsulating the result set of the comparison results of different version numbers of the client by defining an enumeration variable, defining a private variable in the enumeration variable, and the private variable is used to describe the result information of the result set. The enumeration variable of the result set is specifically any one of the following: equal, greater than, and less than.
[0089] In an optional implementation, an enumeration variable VersionResult is defined to abstractly encapsulate the result set of the comparison results of different version numbers of the client. The specific definition method is as follows:
[0090] public enum VersionResult{}
[0091] In this enumeration variable, a private variable result is defined. This private variable result is used to describe the result information of the result set. The definition method of this private variable result is as follows:
[0092] private int result
[0093] Next, define the get method and set method of the private variable. The get method is used to get the value of the private variable result, and the set method is used to assign a value to the private variable result.
[0094] The specific get method is as follows:
[0095] public int getResult(){
[0096] return result;
[0097] }
[0098] The specific set method is as follows:
[0099] public void setResult(int result){
[0100] this.result = result;
[0101] }
[0102] The existing solution does not define the private variable result. Therefore, in the existing solution, the enumeration constant value cannot be defined in the way of private variables during enumeration. Instead, the enumeration constant can only be defined by default, and the positive integer starting from 1 is the value information of the corresponding enumeration value. This method cannot realize the customized enumeration value situation. It can be seen that the private variable is used in the present invention to customize the enumeration value.
[0103] The present invention uses a private variable result to customize the enumeration information. Specifically, there are three enumeration results, greater than, equal to, and less than. The following enumeration information is used to describe these three situations:
[0104] Greater than: BIGGER(1), less than: SMALLER(-1), equal to: EQUALS(0);
[0105] Among them, 1, -1, and 0 in the enumeration variable are the values of the result variable, thereby constructing a mapping relationship from a private variable result to the enumeration variable, realizing the three enumeration results of the result set.
[0106] Next, S102 is executed to compare the version type of the first version number of the client with the version type of the second version number of the client based on a comparison function compareValue.
[0107] First, you need to define the comparison function compareValue. The specific comparison function is defined as follows:
[0108] public static VersionResult compareValue(String nextVersion,StringcurVersion){}
[0109] The function is a public and static function, and its return value is a result information of the enumeration type VersionResult. The function name of the comparison function is compareValue. Two comparison parameters are set, corresponding to the first version number of the client nextVersion and the second version number of the client curVersion.
[0110] If the version type of the first version number nextVersion is greater than the version type of the second version number curVersion, the return value is BIGGER (1); if the version type of the first version number nextVersion is less than the version type of the second version number curVersion, the return value is SMALLER (-1). Of course, if they are equal, the return value is EQUALS (0).
[0111] When comparing the version types of these two version numbers, the main method is to implement it by bit truncation. Specifically, the version number with the smaller number of digits in the two version numbers is obtained. For example, one version number is 2 digits and the other version number is 3 digits. Then, 2 digits are truncated from the 3-digit version number, and the truncated 2-digit version number is compared with the other 2-digit version number. If each digit is equal, the longer version number is compared with 0 starting from the 2nd digit. If there is a digit greater than 0, it means that the version number is greater than the version number with the smaller number of digits. Otherwise, it is less than or equal to.
[0112] Specifically, the same number of bits is compared first.
[0113] Execute S202 to split the first version number and the second version number respectively by calling the split function to obtain a first array set and a second array set.
[0114] The first version number is split by calling the split function, specifically according to ".". The specific splitting method is as follows:
[0115] String[]currentArray=curVersion.split("\\.");
[0116] The second version number is split by calling the split function, specifically according to ".". The specific splitting method is as follows:
[0117] String[]nextArray=nextVersion.split("\\.");
[0118] Among them, nextVersion is the first version number, curVersion is the second version number, \\. means splitting the first version number and the second version number according to ., currentArray is the first array set, and nextArray is the second array set.
[0119] Next, execute S202 to obtain the first length value of the array set with the minimum length between the first array set and the second array set. The method for obtaining is as follows:
[0120] int minLength=Math.min(currentArray.length,nextArray.length);
[0121] The min function in Math is used to extract the first length value of the array set with the minimum length between the first array set and the second array set, and minLength is the first length value.
[0122] Next, a bit-by-bit comparison is performed according to the minimum length value, that is, according to the first length value.
[0123] In an optional implementation, the arrays of the two version numbers are first intercepted and then polled and compared.
[0124] Specifically, execute S203 to obtain, according to the first length value, a first character group in the length information equal to the first length value in the first array set, and obtain a second character group in the length information equal to the first length in the second array set.
[0125] First, a for loop is used for polling, and then in each polling, the value at the same position is obtained by calling the Integer.parseInt function to obtain a character group of the same length.
[0126] int curValue=Integer.parseInt(currentArray[i]);
[0127] int nextValue=Integer.parseInt(nextArray[i]);
[0128] The character currentArray[i] corresponding to the position i in the first version number is converted into a number by calling the Integer.parseInt function and assigned to the integer variable curValue, and the character nextArray[i] corresponding to the position i in the second version number is assigned to the integer variable nextValue by calling the Integer.parseInt function. In this way, the first character group curValue and the second character group nextValue are obtained.
[0129] Next, a bit-by-bit comparison is performed, and S204 is executed to perform a polling comparison on the characters at the same position in the first character group and the second character group, and a first comparison result of the first array set and the second array set is returned.
[0130] If there is an inequality, the result set is returned directly.
[0131] Specifically, after S204, when the first comparison result is greater than or less than, based on the first comparison result, a comparison result of the version type of the first version number and the version type of the second version number is obtained.
[0132] The specific comparison method is as follows:
[0133] if(nextValue <curValue){
[0134] return VersionResult.SMALLER;
[0135] }
[0136] It can be seen that if the first character group curValue is greater than the second character group nextValue, the comparison result is directly returned as the result set return VersionResult.SMALLER.
[0137] if(nextValue>curValue){
[0138] return VersionResult.BIGGER;
[0139] }
[0140] It can be seen that if the first character group curValue is less than the second character group nextValue, the comparison result returns the result set return VersionResult.BIGGER.
[0141] For example, when the first comparison result is that the current position value in the first character group is greater than the same position value in the second character group, it is determined that the version type of the first version number is higher than the version type of the second version number.
[0142] In addition to the above-mentioned greater than and less than situations, there is also an equal situation. In this case, a redundant last digit comparison is performed.
[0143] Execute S205 , when the first comparison result is equal, obtain the array set with the maximum length from the first array set and the second array set as the array set to be continued to be compared.
[0144] In a specific implementation, it is determined whether the first array set or the second array set has a longer number of bits.
[0145] Specifically, the max function in Math is used to obtain the array set with the maximum length between the first array set and the second array set as the array set to be compared:
[0146] int maxLength=Math.max(currentArray.length,nextArray.length)
[0147] The maxLength is the maximum length.
[0148] Then, the length of the first array set is compared with the length of the second array set as follows:
[0149] if(currentArray.length>nextArray.length){}
[0150] If the length of the first array set currentArray is longer than the length of the second array set nextArray, the redundant last bits of the first array set currentArray need to be compared; otherwise, the redundant last bits of the second array set nextArray need to be compared.
[0151] Next, S206 is executed to construct a poll for the character group to be compared, so that the start position of the poll is the end position of the first length value, and the end position of the poll is the end position of the maximum length.
[0152] By constructing a poll for this group of characters that continue to be compared:
[0153] for(int i=minLength; i <maxLength;i++)
[0154] Then, each bit of data information is taken out in turn in the polling, wherein the taking out method is obtained by the following method:
[0155] Int restRes=Integer.parseInt(currentArray[i])
[0156] By calling the Integer.parseInt(currentArray[i]) method, each bit of data information is obtained and stored in restRes. Here, the array set to be compared is taken as the first array set as an example.
[0157] Next, S207 is executed to compare the array set to be compared with 0 respectively according to polling, and a second comparison result of the first array set and the second array set is returned.
[0158] Specifically, if restRes>0 appears in any sequential polling, it means that the version number of the array set to be compared is larger, that is, the latest, and the returned result is as follows:
[0159] return VersionResult.SMALLER;
[0160] Otherwise, the next round of polling comparison is performed. The reason why the comparison with 0 is judged here is because the short version number is padded with 0. Therefore, it is only necessary to compare the polling result with 0 to obtain the final comparison result.
[0161] Thus, S208 is executed to obtain a comparison result of the version type of the first version number and the version type of the second version number based on the second comparison result.
[0162] Similarly, when the array set to be compared is the second array set nextArray, the type method is used for judgment and comparison. The specific code description is as follows:
[0163]
[0164] Of course, it is also possible that the version types of the two version numbers are the same. Specifically, this is achieved through the following code:
[0165] return VersionResult.EQUALS.
[0166] Therefore, the version numbers of different rules are uniformly compared to obtain the comparison results.
[0167] One or more technical solutions in the embodiments of the present invention have at least the following technical effects or advantages:
[0168] The method for realizing the compatibility of client version rules provided by the present invention comprises: encapsulating a result set of comparison results of different version numbers of the client by defining an enumeration variable, defining a private variable in the enumeration variable, the private variable being used to describe the result information of the result set, the enumeration variable of the result set being specifically any one of the following: equal to, greater than and less than; then defining a comparison function, and based on the comparison function, comparing the version types of the first version number and the second version number of the client, comprising: splitting the first version number and the second version number by calling a split function respectively, obtaining a first array set and a second array set, obtaining a first length value of an array set of the minimum length in the first array set and the second array set; according to the first length value, obtaining a first character group in the length information equal to the first length value in the first array set, obtaining a first character group in the second array set equal to the first length value The second character group within the equal length information, polling and comparing the characters at the same position in the first character group and the second character group, and returning a first comparison result of the first array set and the second array set; when the first comparison result is equal, obtaining the array set with the maximum length in the first array set and the second array set as the array set to be continued to be compared; constructing a poll for the array set to be continued to be compared, so that the starting position of the poll is the end position of the first length value, and the end position of the poll is the end position of the maximum length; comparing the array to be continued to be compared with 0 according to the polling, and returning a second comparison result of the first array set and the second array set; based on the second comparison result, obtaining the comparison result of the version type of the first version number and the version type of the second version number, being able to uniformly compare the version numbers of different rules, thereby achieving the compatibility of client version rule determination.
[0169] Embodiment 2
[0170] Based on the same inventive concept, the present invention provides a device for implementing client version rule determination compatibility, such as Figure 3 , Figure 4 As shown, including:
[0171] A result set definition module 301 is used to encapsulate a result set of comparison results of different version numbers of the client by defining an enumeration variable, and a private variable is defined in the enumeration variable, and the private variable is used to describe the result information of the result set. The enumeration variable of the result set is specifically any one of the following: equal to, greater than, and less than;
[0172] The first comparison module 302 is used to compare the version type of the first version number of the client with the version type of the second version number of the client based on the comparison function compareValue, including:
[0173] A splitting unit 401 is used to split the first version number and the second version number respectively by calling a split function to obtain a first array set and a second array set;
[0174] A first acquiring unit 402 is configured to acquire a first length value of an array set with a minimum length between the first array set and the second array set;
[0175] A first obtaining unit 403 is used to obtain, according to the first length value, a first character group in the first array set and a length information equal to the first length value, and obtain a second character group in the second array set and a length information equal to the first length value;
[0176] A first polling comparison unit 404 is used to perform polling comparison on the characters at the same position in the first character group and the second character group, and return a first comparison result of the first array set and the second array set;
[0177] A second acquisition unit 405 is configured to acquire, when the first comparison result is equal, an array set with the largest length between the first array set and the second array set as an array set to be continued to be compared;
[0178] A polling construction unit 406 is used to construct a polling for the array set to be compared continuously, so that the starting position of the polling is the end position of the first length value, and the end position of the polling is the end position of the maximum length;
[0179] A second polling comparison unit 407, configured to compare the continued comparison array set with 0 respectively according to the polling, and return a second comparison result of the first array set and the second array set;
[0180] The second obtaining unit 408 is configured to obtain a comparison result between the version type of the first version number and the version type of the second version number based on the second comparison result.
[0181] In an optional implementation, the first comparison module 302 further includes:
[0182] The third obtaining unit 409 is configured to obtain a comparison result of the version type of the first version number and the version type of the second version number based on the first comparison result when the first comparison result is greater than or less than.
[0183] In an optional implementation, the first polling comparison unit 404 includes:
[0184] A first calling subunit is used to call the Integer.parseInt function to convert each character in the first character group into a number and assign the number to a first integer variable, and call the Integer.parseInt function to convert each character in the first character group into a number and assign the number to a second integer variable;
[0185] The second calling subunit is used to call the loop function to poll and compare the first integer variable with the integer variable at the same position in the second integer variable.
[0186] In an optional implementation, the splitting unit 401 is used to:
[0187] String[]currentArray=curVersion.split("\\.");
[0188] String[]nextArray=nextVersion.split("\\.");
[0189] Among them, nextVersion is the first version number, curVersion is the second version number, \\. means splitting the first version number and the second version number according to ., currentArray is the first array set, and nextArray is the second array set.
[0190] In an optional implementation, the first acquiring unit 402 is used to:
[0191] The min function in Math is used to extract the first length value of the array set with the minimum length between the first array set and the second array set:
[0192] int minLength=Math.min(currentArray.length,nextArray.length)
[0193] Among them, minLength is the first length value.
[0194] In an optional implementation manner, the second acquiring unit 405 is configured to:
[0195] The max function in Math is used to obtain the array set with the maximum length between the first array set and the second array set as the character group to be compared:
[0196] int maxLength=Math.max(currentArray.length,nextArray.length)
[0197] The maxLength is the maximum length.
[0198] In an optional implementation, the definition result set module 301 includes:
[0199] Define an enumeration variable unit, which is used to encapsulate the result set by defining an enumeration variable:
[0200] public enum VersionResult{}
[0201] Wherein, VersionResult is the result set, and enum is the enumeration variable;
[0202] Define a private variable unit, which is used to define private variables in the enumeration variable:
[0203] private int result;
[0204] Define the get method of private variables for:
[0205] Define the get method of the private variable to get the value of the private variable result:
[0206] public int getResult(){
[0207] return result;
[0208] }
[0209] Define the set method of private variables for:
[0210] Define the set method of the private variable to assign a value to the private variable result:
[0211] public void setResult(int result){
[0212] this.result = result;
[0213] }
[0214] Embodiment 3
[0215] Based on the same inventive concept, the third embodiment of the present invention further provides a computer device, such as Figure 5As shown, it includes a memory 504, a processor 502, and a computer program stored in the memory 504 and executable on the processor 502. When the processor 502 executes the program, the steps of any method in the method for determining compatibility based on client version rules are implemented.
[0216] Among them, Figure 5 In the embodiment of the present invention, a bus architecture (represented by bus 500) is shown, which may include any number of interconnected buses and bridges, and bus 500 links various circuits including one or more processors represented by processor 502 and memory represented by memory 504. Bus 500 may also link various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. Bus interface 506 provides an interface between bus 500 and receiver 501 and transmitter 503. Receiver 501 and transmitter 503 may be the same element, namely a transceiver, providing a unit for communicating with various other devices over a transmission medium. Processor 502 is responsible for managing bus 500 and general processing, while memory 504 may be used to store data used by processor 502 when performing operations.
[0217] Embodiment 4
[0218] Based on the same inventive concept, the fourth embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps of any method in the above-mentioned method for determining compatibility by client version rules are implemented.
[0219] The algorithm and display provided herein are not inherently related to any particular computer, virtual system or other device. Various general purpose systems can also be used together with the teachings based on this. According to the above description, it is obvious that the structure required for constructing such systems. In addition, the present invention is not directed to any specific programming language either. It should be understood that various programming languages can be utilized to realize the content of the present invention described herein, and the description of the above specific languages is for disclosing the best mode of the present invention.
[0220] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.
[0221] Similarly, it should be understood that in order to streamline the present disclosure and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the present invention, various features of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, this disclosed method should not be interpreted as reflecting the intention that the claimed invention requires more features than those explicitly recited in each claim. More specifically, as reflected in the claims below, inventive aspects lie in less than all the features of the individual embodiments disclosed above. Therefore, the claims that follow the specific embodiment are hereby expressly incorporated into the specific embodiment, with each claim itself serving as a separate embodiment of the present invention.
[0222] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and in addition they may be divided into a plurality of submodules or subunits or subcomponents. Except that at least some of such features and / or processes or units are mutually exclusive, all features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed in this manner may be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.
[0223] In addition, those skilled in the art will appreciate that, although some embodiments herein include certain features included in other embodiments but not other features, the combination of features of different embodiments is meant to be within the scope of the present invention and form different embodiments. For example, in the claims below, any one of the claimed embodiments may be used in any combination.
[0224] The various component embodiments of the present invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that a microprocessor or digital signal processor (DSP) may be used in practice to implement some or all functions of some or all components of a device or computer device for determining compatibility according to an embodiment of the present invention using client version rules. The present invention may also be implemented as a device or device program (e.g., a computer program and a computer program product) for executing part or all of the methods described herein. Such a program for implementing the present invention may be stored on a computer-readable medium, or may be in the form of one or more signals. Such a signal may be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.
[0225] It should be noted that the above embodiments illustrate the present invention rather than limit it, and that those skilled in the art may devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbol between brackets shall not be construed as a limitation on the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "one" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention may be implemented by means of hardware comprising a number of different elements and by means of a suitably programmed computer. In a unit claim enumerating a number of devices, several of these devices may be embodied by the same hardware item. The use of the words first, second, and third, etc., does not indicate any order. These words may be interpreted as names.
Claims
1. A method for implementing client version rule determination compatibility, characterized in that: include: A result set of comparison results of different version numbers of the client is encapsulated by defining an enumeration variable, a private variable is defined in the enumeration variable, the private variable is used to describe result information of the result set, and the enumeration variable of the result set is specifically any one of the following: equal to, greater than, and less than; Based on a comparison function compareValue, comparing the version type of the first version number of the client with the version type of the second version number of the client, including: The first version number and the second version number are split respectively by calling the split function to obtain a first array set and a second array set; Obtain a first length value of an array set with a minimum length between the first array set and the second array set; According to the first length value, obtain a first character group in the first array set with a length information equal to the first length value, and obtain a second character group in the second array set with a length information equal to the first length; Perform polling comparison on characters at the same position in the first character group and the second character group, and return a first comparison result of the first array set and the second array set; When the first comparison result is equal, obtaining an array set with the largest length between the first array set and the second array set as an array set to be continued to be compared; Constructing a poll for the array set to be compared continuously, so that the starting position of the poll is the end position of the first length value, and the ending position of the poll is the end position of the maximum length; Compare the array set to be compared with 0 respectively according to the polling, and return a second comparison result of the first array set and the second array set; Based on the second comparison result, a comparison result of the version type of the first version number and the version type of the second version number is obtained.
2. The method according to claim 1, characterized in that After returning a first comparison result of the first array set and the second array set, the method further includes: When the first comparison result is greater than or less than, based on the first comparison result, a comparison result of the version type of the first version number and the version type of the second version number is obtained.
3. The method according to claim 1, characterized in that The polling and comparing characters at the same position in the first character group and the second character group comprises: Call the Integer.parseInt function to convert each character in the first character group into a number and assign the value to the first integer variable, and call the Integer.parseInt function to convert each character in the first character group into a number and assign the value to the second integer variable; The loop function is called to perform polling comparison between the first integer variable and the integer variable at the same position in the second integer variable.
4. The method according to claim 1, characterized in that The first version number and the second version number are split respectively by calling the split function to obtain a first array set and a second array set, including: String[]currentArray=curVersion.split("\\."); String[]nextArray=nextVersion.split("\\."); Among them, nextVersion is the first version number, curVersion is the second version number, \\. means splitting the first version number and the second version number according to ., currentArray is the first array set, and nextArray is the second array set.
5. The method according to claim 1, characterized in that The extracting a first length value of an array set having a minimum length from the first array set and the second array set comprises: The min function in Math is used to extract the first length value of the array set with the minimum length between the first array set and the second array set: int minLength=Math.min(currentArray.length,nextArray.length) Among them, minLength is the first length value.
6. The method according to claim 1, characterized in that The step of obtaining an array set with the maximum length between the first array set and the second array set as an array set to be compared further includes: The max function in Math is used to obtain the array set with the maximum length between the first array set and the second array set as the character group to be compared: int maxLength=Math.max(currentArray.length,nextArray.length) The maxLength is the maximum length.
7. The method according to claim 1, characterized in that The result set of the comparison results of different version numbers of the client is encapsulated by defining an enumeration variable, a private variable is defined in the enumeration variable, and the private variable is used to describe the result information of the result set. The enumeration variable of the result set is specifically any one of the following: equal to, greater than, and less than, including: Encapsulate the result set by defining an enumeration variable: public enum VersionResult{} Wherein, VersionResult is the result set, and enum is the enumeration variable; Define private variables in said enumeration: private int result; Define the get method of the private variable to get the value of the private variable result: public int getResult(){ return result; } Define the set method of the private variable to assign a value to the private variable result: public void setResult(int result){ this.result = result; }。 8. A device for implementing client version rule determination compatibility, characterized in that: include: A result set definition module is used to encapsulate the result set of the comparison results of different version numbers of the client by defining an enumeration variable, and a private variable is defined in the enumeration variable, and the private variable is used to describe the result information of the result set. The enumeration variable of the result set is specifically any one of the following: equal to, greater than, and less than; The first comparison module is used to compare the version type of the first version number of the client with the version type of the second version number of the client based on the comparison function compareValue, including: A splitting unit, used to split the first version number and the second version number respectively by calling a split function to obtain a first array set and a second array set; A first acquiring unit, configured to acquire a first length value of an array set of minimum length between the first array set and the second array set; A first obtaining unit is used to obtain, according to the first length value, a first character group in the first array set and a length information equal to the first length value, and obtain a second character group in the second array set and a length information equal to the first length value; A first polling comparison unit, configured to perform polling comparison on the characters at the same position in the first character group and the second character group, and return a first comparison result of the first array set and the second array set; A second acquisition unit is used for acquiring, when the first comparison result is equal, an array set with the largest length between the first array set and the second array set as an array set to be continued to be compared; A polling construction unit is used to construct a polling for the array set to be compared continuously, so that the starting position of the polling is the end position of the first length value, and the end position of the polling is the end position of the maximum length; A second polling comparison unit, configured to compare the continued comparison array set with 0 respectively according to the polling, and return a second comparison result of the first array set and the second array set; The second obtaining unit is used to obtain a comparison result between the version type of the first version number and the version type of the second version number based on the second comparison result.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method steps according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method steps as claimed in any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Metadata version comparison method and device
CN110018845A
Method of comparing version strings
US20040024781A1