|
25 | 25 | import org.ugp.serialx.converters.DataParser; |
26 | 26 | import org.ugp.serialx.converters.DataParser.ParserRegistry; |
27 | 27 | import org.ugp.serialx.converters.ObjectConverter; |
28 | | -import org.ugp.serialx.converters.StringConverter; |
29 | 28 | import org.ugp.serialx.converters.imports.ImportConverter; |
30 | | -import org.ugp.serialx.converters.operators.ArithmeticOperators; |
31 | | -import org.ugp.serialx.converters.operators.ComparisonOperators; |
32 | | -import org.ugp.serialx.converters.operators.ConditionalAssignmentOperators; |
33 | | -import org.ugp.serialx.converters.operators.LogicalOperators; |
| 29 | +import org.ugp.serialx.converters.imports.ImportConverter.Imports; |
| 30 | +import org.ugp.serialx.converters.imports.ImportsProvider; |
34 | 31 | import org.ugp.serialx.protocols.SerializationProtocol.ProtocolRegistry; |
35 | 32 |
|
36 | | -import javafx.beans.binding.When; |
37 | | - |
38 | 33 | /** |
39 | 34 | * This is implementation of {@link Serializer} for serializing in default SerialX API implementation known as JUSS (Java universal serial script) which is Json like domain specific language that has extended functionality! |
40 | 35 | * It should generate and work with .juss or .srlx files! |
|
44 | 39 | * @since 1.3.2 |
45 | 40 | */ |
46 | 41 | @SuppressWarnings("serial") |
47 | | -public class JussSerializer extends Serializer |
| 42 | +public class JussSerializer extends Serializer implements ImportsProvider |
48 | 43 | { |
49 | | - public static final ParserRegistry JUSS_PARSERS = DataParser.REGISTRY.clone(), JUSS_PARSERS_AND_OPERATORS; |
| 44 | + /** |
| 45 | + * {@link ParserRegistry} with all parsers required to parse JUSS! |
| 46 | + * |
| 47 | + * @since 1.3.2 |
| 48 | + */ |
| 49 | + public static final ParserRegistry JUSS_PARSERS = DataParser.REGISTRY.clone(); |
| 50 | + |
| 51 | + /** |
| 52 | + * {@link ParserRegistry} with all parsers required to parse JUSS with additional operators. |
| 53 | + * <br> |
| 54 | + * Since 1.3.7 this requires "org.ugp.serialx.converters.Operators" from SerialX "operators" modules to be present on the classpath! |
| 55 | + * |
| 56 | + * @since 1.3.2 |
| 57 | + */ |
| 58 | + public static final ParserRegistry JUSS_PARSERS_AND_OPERATORS; |
50 | 59 |
|
51 | 60 | static |
52 | 61 | { |
53 | 62 | JUSS_PARSERS.add(0, new ImportConverter()); |
54 | 63 | JUSS_PARSERS_AND_OPERATORS = JUSS_PARSERS.clone(); |
55 | | - JUSS_PARSERS_AND_OPERATORS.addAllBefore(StringConverter.class, true, new ConditionalAssignmentOperators(), new LogicalOperators(), new ComparisonOperators(), new ArithmeticOperators()); |
| 64 | + |
| 65 | + try |
| 66 | + { |
| 67 | + InvokeStaticFunc(Class.forName("org.ugp.serialx.converters.Operators"), "install", JUSS_PARSERS_AND_OPERATORS); |
| 68 | + } |
| 69 | + catch (Exception e) |
| 70 | + {} |
56 | 71 | } |
57 | 72 |
|
| 73 | + protected Imports imports; |
| 74 | + |
58 | 75 | /** |
59 | 76 | * Set this on true and program will generate comments and report!<br> |
60 | 77 | * Note: Keep this on false to achieve the best performance! |
@@ -158,6 +175,14 @@ public ParserRegistry getParsers() |
158 | 175 | return parsers != null ? parsers : (parsers = JUSS_PARSERS.clone()); |
159 | 176 | } |
160 | 177 |
|
| 178 | + @Override |
| 179 | + public Imports getImports() |
| 180 | + { |
| 181 | + if (imports == null) |
| 182 | + imports = ImportConverter.IMPORTS.clone(); |
| 183 | + return imports; |
| 184 | + } |
| 185 | + |
161 | 186 | /** |
162 | 187 | * @param absoluteClone | If true this scope will be cloned using {@link Serializer#Clone(Object, Registry, Object[], Object...)}, if false {@link Scope#clone()}! |
163 | 188 | * |
@@ -785,7 +810,7 @@ <th>Obtained serializer content (return)</th> |
785 | 810 | </tr> |
786 | 811 | </table> |
787 | 812 | * |
788 | | - * @throws When something went wrong during deserialization! |
| 813 | + * @throws If something went wrong during deserialization! |
789 | 814 | * |
790 | 815 | * @since 1.3.5 |
791 | 816 | */ |
|
0 commit comments