Skip to content

Commit 84756ad

Browse files
committed
NumberParser 1.0.8.5 & UnitParser 1.0.9.1.
1 parent bd7c92f commit 84756ad

74 files changed

Lines changed: 11265 additions & 1515 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

all_binaries/NumberParser.jar

190 KB
Binary file not shown.
127 KB
Binary file not shown.

all_binaries/UnitParser.jar

9.64 KB
Binary file not shown.
6.12 KB
Binary file not shown.

all_code/NumberParser/.classpath

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src_Public"/>
4+
<classpathentry kind="src" path="src_Internal"/>
5+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
6+
<classpathentry kind="lib" path="/home/alvaro/workspace/UnitParser.jar"/>
7+
<classpathentry kind="output" path="bin"/>
8+
</classpath>

all_code/NumberParser/.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>NumberParser</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=1.8
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.source=1.8
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Manifest-Version: 1.0
2+
Created-By: varocarbas
3+
Implementation-Title: NumberParser
4+
Implementation-Version: 1.0.8.5
5+
Implementation-Vendor: Custom Solvers 2.0
6+
Implementation-URL: https://customsolvers.com/number_parser_java/
7+
Specification-Title: NumberParser
8+
Specification-Version: 1.0.8.5
9+
Specification-Vendor: Custom Solvers 2.0

all_code/NumberParser/build.xml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<!-- WARNING: Eclipse auto-generated file.
3+
Any modifications will be overwritten.
4+
To include a user specific buildfile here, simply create one in the same
5+
directory with the processing instruction <?eclipse.ant.import?>
6+
as the first entry and export the buildfile again. --><project basedir="." default="build" name="NumberParser">
7+
<property environment="env"/>
8+
<property name="debuglevel" value="source,lines,vars"/>
9+
<property name="target" value="1.8"/>
10+
<property name="source" value="1.8"/>
11+
<path id="NumberParser.classpath">
12+
<pathelement location="bin"/>
13+
<pathelement location="../UnitParser.jar"/>
14+
</path>
15+
<target name="init">
16+
<mkdir dir="bin"/>
17+
<copy includeemptydirs="false" todir="bin">
18+
<fileset dir="src_Public">
19+
<exclude name="**/*.launch"/>
20+
<exclude name="**/*.java"/>
21+
</fileset>
22+
</copy>
23+
<copy includeemptydirs="false" todir="bin">
24+
<fileset dir="src_Internal">
25+
<exclude name="**/*.launch"/>
26+
<exclude name="**/*.java"/>
27+
</fileset>
28+
</copy>
29+
</target>
30+
<target name="clean">
31+
<delete dir="bin"/>
32+
</target>
33+
<target depends="clean" name="cleanall"/>
34+
<target depends="build-subprojects,build-project" name="build"/>
35+
<target name="build-subprojects"/>
36+
<target depends="init" name="build-project">
37+
<echo message="${ant.project.name}: ${ant.file}"/>
38+
<javac debug="true" debuglevel="${debuglevel}" destdir="bin" includeantruntime="false" source="${source}" target="${target}">
39+
<src path="src_Public"/>
40+
<src path="src_Internal"/>
41+
<classpath refid="NumberParser.classpath"/>
42+
</javac>
43+
</target>
44+
<target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
45+
<target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
46+
<copy todir="${ant.library.dir}">
47+
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
48+
</copy>
49+
<unzip dest="${ant.library.dir}">
50+
<patternset includes="jdtCompilerAdapter.jar"/>
51+
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
52+
</unzip>
53+
</target>
54+
<target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
55+
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
56+
<antcall target="build"/>
57+
</target>
58+
<target name="Test">
59+
<java classname="NumberParser.Test" failonerror="true" fork="yes">
60+
<classpath refid="NumberParser.classpath"/>
61+
</java>
62+
</target>
63+
</project>
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
package InternalNumberParser;
2+
3+
import InternalNumberParser.CSharpAdaptation.*;
4+
import NumberParser.*;
5+
import NumberParser.Number;
6+
7+
import java.util.ArrayList;
8+
import java.util.HashMap;
9+
10+
@SuppressWarnings({ "rawtypes", "unchecked", "serial" })
11+
public class Basic
12+
{
13+
//Positive min./max. values for all the supported numeric types to behave accurately.
14+
//This is useful when dealing with NumberX variables, to determine the points where BaseTenExponent
15+
//has to be brought into picture to complement Value.
16+
public static HashMap<NumericTypes, ArrayList<Object>> AllNumberMinMaxPositives =
17+
new HashMap<NumericTypes, ArrayList<Object>>()
18+
{
19+
{
20+
put(NumericTypes.Double, new ArrayList() {{ add(1e-308); add(Double.MAX_VALUE); }});
21+
put(NumericTypes.Float, new ArrayList() {{ add(1e-37); add(Float.MAX_VALUE); }});
22+
put(NumericTypes.Long, new ArrayList() {{ add(1); add(Long.MAX_VALUE); }});
23+
put(NumericTypes.Integer, new ArrayList() {{ add(1); add(Integer.MAX_VALUE); }});
24+
put(NumericTypes.Short, new ArrayList() {{ add(1); add(Short.MAX_VALUE); }});
25+
put(NumericTypes.Character, new ArrayList() {{ add(1); add(Character.MAX_VALUE); }});
26+
put(NumericTypes.Byte, new ArrayList() {{ add(1); add(Byte.MAX_VALUE); }});
27+
}
28+
};
29+
30+
//Min./max. values for all the supported numeric types.
31+
public static HashMap<NumericTypes, ArrayList<Object>> AllNumberMinMaxs =
32+
new HashMap<NumericTypes, ArrayList<Object>>()
33+
{
34+
{
35+
put(NumericTypes.Double, new ArrayList<Object>() {{ add(Double.MIN_VALUE); add(Double.MAX_VALUE); }});
36+
put(NumericTypes.Float, new ArrayList<Object>() {{ add(Float.MIN_VALUE); add(Float.MAX_VALUE); }});
37+
put(NumericTypes.Long, new ArrayList<Object>() {{ add(Long.MIN_VALUE); add(Long.MAX_VALUE); }});
38+
put(NumericTypes.Integer, new ArrayList<Object>() {{ add(Integer.MIN_VALUE); add(Integer.MAX_VALUE); }});
39+
put(NumericTypes.Short, new ArrayList<Object>() {{ add(Short.MIN_VALUE); add(Short.MAX_VALUE); }});
40+
put(NumericTypes.Character, new ArrayList<Object>() {{ add(Character.MIN_VALUE); add(Character.MAX_VALUE); }});
41+
put(NumericTypes.Byte, new ArrayList<Object>() {{ add(Byte.MIN_VALUE); add(Byte.MAX_VALUE); }});
42+
}
43+
};
44+
45+
public static ArrayList<NumericTypes> AllNumericTypes = new ArrayList<NumericTypes>()
46+
{{
47+
add(NumericTypes.Double); add(NumericTypes.Float); add(NumericTypes.Long); add(NumericTypes.Integer);
48+
add(NumericTypes.Short); add(NumericTypes.Character); add(NumericTypes.Byte);
49+
}};
50+
51+
public static ArrayList<NumericTypes> AllUnsignedTypes = new ArrayList<NumericTypes>()
52+
{{
53+
add(NumericTypes.Byte); add(NumericTypes.Character);
54+
}};
55+
56+
public static ArrayList<Class> AllNumberClassTypes = new ArrayList<Class>()
57+
{{
58+
add(Number.class); add(NumberD.class); add(NumberO.class); add(NumberP.class);
59+
}};
60+
61+
public static ArrayList<NumericTypes> AllDecimalTypes = new ArrayList<NumericTypes>()
62+
{{
63+
add(NumericTypes.Double); add(NumericTypes.Float);
64+
}};
65+
66+
//Returns all the types whose ranges are equal or smaller than int.
67+
public static ArrayList<NumericTypes> GetSmallIntegers()
68+
{
69+
return LinqNP.Where
70+
(
71+
AllNumericTypes,
72+
(
73+
x -> x != NumericTypes.Long &&
74+
!AllDecimalTypes.contains(x)
75+
)
76+
);
77+
}
78+
79+
//The purpose of this function is to easily create simple values for a given type.
80+
//It isn't prepared to deal with range incompatibilities between different types.
81+
//Sample inputs: 0, 1 or -1.
82+
public static Object GetNumberSpecificType(Object value, NumericTypes target)
83+
{
84+
NumericTypes type = ErrorInfoNumber.InputTypeIsValidNumeric(value);
85+
if (type.equals(NumericTypes.None) || type.equals(target)) return value;
86+
87+
return Conversions.CastDynamicToType(value, target);
88+
}
89+
90+
//This method assumes that input and type are valid numeric types.
91+
public static boolean InputInsideTypeRange(Object input, NumericTypes type)
92+
{
93+
double value = Conversions.ConvertToDoubleInternal
94+
(
95+
new NumberD(input).getValue()
96+
);
97+
98+
ArrayList<Double> minMax = new ArrayList<Double>()
99+
{{
100+
add
101+
(
102+
ConvertTo.ConverToDouble
103+
(
104+
Basic.AllNumberMinMaxPositives.get(type).get(0)
105+
)
106+
);
107+
add
108+
(
109+
ConvertTo.ConverToDouble
110+
(
111+
Basic.AllNumberMinMaxPositives.get(type).get(1)
112+
)
113+
);
114+
}};
115+
116+
return
117+
(
118+
value >= minMax.get(0) && value <= minMax.get(1)
119+
);
120+
}
121+
}

0 commit comments

Comments
 (0)