You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**NOTE:** this is the conversion to Java of the original C# code stored in the [FlexibleParser repository](https://github.com/varocarbas/FlexibleParser).
6
6
7
-
## Introduction
8
-
The main class is called ```UnitP``` (```UnitParser``` package). It can be instantiated in many different ways.
7
+
FlexibleParser is a multi-purpose parsing library based upon the following ideas:
9
8
10
-
```Java
11
-
//1 N.
12
-
UnitP unitP =newUnitP("1 N");
9
+
- Intuitive, adaptable and easy to use.
10
+
- Pragmatic, but aiming for the maximum accuracy and correctness.
11
+
- Overall compatible and easily automatable.
12
+
- Formed by independent JARs managing specific situations.
13
13
14
-
//1 N.
15
-
unitP =newUnitP(1.0, UnitSymbols.Newton);
14
+
## Parts
16
15
17
-
//1 N.
18
-
unitP =newUnitP(1.0, "nEwTon");
16
+
At the moment, FlexibleParser is formed by the following independent parts:
It allows to easily deal with a wide variety of situations involving units of measurement.
20
+
Among its most salient features are: user-defined exception triggering and gracefully managing numeric values of any size.
23
21
24
-
```UnitP``` can be seen as an abstract concept including many specific types ([full list](https://github.com/varocarbas/FlexibleParser_Java/blob/master/all_code/UnitParser/src_Public/UnitParser/UnitTypes.java)). Same-type variables can be added/subtracted. Different-type variables can be multiplied/divided, but only in case of generating a valid-type output.
```UnitParts``` - Defining parts of the given unit.<br>
52
-
```UnitPrefix``` - [Supported prefix](https://github.com/varocarbas/FlexibleParser_Java/blob/master/all_code/UnitParser/src_Public/UnitParser/Prefix.java) affecting all the unit parts.<br>
53
-
```BaseTenExponent``` - Base-ten exponent used when dealing with too small/big values.<br>
54
-
```Error``` - Variable storing all the error- and exception-related information.
55
-
56
-
## General Rules
57
-
58
-
All the functionalities are based upon the following ideas:
59
-
- In case of incompatibility, the first element is always preferred.
60
-
- By default, the formally-correct alternative is preferred. Some required modifications might be performed.
61
-
- By default, all the errors are managed internally.
//The parser expects "km" or a full-name-based version like "KiLom".
69
-
unitP =newUnitP("1 Km");
70
-
71
-
//999999.9999999001*10^19 YSt.
72
-
unitP =UnitP.Multiplication
73
-
(
74
-
999999999999999999999999999999999999.9,
75
-
newUnitP("9999999999999 St")
76
-
);
77
-
```
78
-
79
-
## Unit String Parsing Format
80
-
81
-
The unit string parsing part is quite flexible, but there are some basic rules.
82
-
- String multi-part units are expected to be exclusively formed by units, multiplication/division signs and integer exponents.
83
-
- Only one division sign is expected. The parser understands that all what lies before/after it is the numerator/denominator.
84
-
85
-
```Java
86
-
//1 W.
87
-
unitP =newUnitP("1 J*J/s*J2*J-1*s*s-1");
88
-
89
-
//Error not triggering an exception.
90
-
//The parser understands "J*J/(s*J2*s*J*s)", what doesn't represent a supported type.
91
-
unitP =newUnitP("1 J*J/(s*J2*s)*J*s");
92
-
```
93
-
94
-
## Numeric Support
95
-
Formally, only the ```double``` type is supported. Practically, ```UnitP``` variables implement a mixed system delivering beyond-```double```-range support.
The [test application](https://github.com/varocarbas/FlexibleParser_Java/blob/master/all_code/Test/src/Parts/UnitParser.java) includes a relevant number of descriptive code samples.
126
22
127
23
## Authorship & Copyright
128
24
@@ -131,4 +27,5 @@ I, Alvaro Carballo Garcia (varocarbas), am the sole author of each single bit of
131
27
Equivalently to what happens with all my other online contributions, this code can be considered public domain. For more information about my copyright/authorship attribution ideas, visit the corresponding pages of my sites:
0 commit comments