From 7db376da195d6926629995fee8e3e6fd6daff402 Mon Sep 17 00:00:00 2001 From: Rainer Prosi Date: Sat, 15 Jun 2024 18:27:05 +0200 Subject: [PATCH 1/4] updated generatorutil to 64 bit and thus many many versions --- .../cip4/jdflib/generator/GeneratorUtil.java | 39 ++++++------------- .../jdflib/generator/JavaCoreStringUtil.java | 7 ++++ .../jdflib/generator/GeneratorUtilTest.java | 17 ++++++++ 3 files changed, 35 insertions(+), 28 deletions(-) create mode 100644 src/test/java/org/cip4/jdflib/generator/GeneratorUtilTest.java diff --git a/src/main/java/org/cip4/jdflib/generator/GeneratorUtil.java b/src/main/java/org/cip4/jdflib/generator/GeneratorUtil.java index 7d2f0ea..20226c9 100755 --- a/src/main/java/org/cip4/jdflib/generator/GeneratorUtil.java +++ b/src/main/java/org/cip4/jdflib/generator/GeneratorUtil.java @@ -25,6 +25,7 @@ import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Vector; import org.cip4.jdflib.core.AttributeInfo; @@ -2340,20 +2341,12 @@ private static void mergeAttributeInfo(final SchemaAttribute newSchema, final Sc * @param String usage "optional" or "required" * @param String firstVersion i.e. "1.1" and lastVersion = "" * @param String lastVersion i.e. "1.2" and firstVersion = "" - * @return a String of form 44333311 + * @return a String of form 44333311l */ public static String getVersionInfoAttributes(final String usage, final String firstVersion, final String lastVersion) { // we need a vector the iterator can be random and we need a spezific order - final Vector version = new Vector(); - version.add(EnumVersion._1_7); - version.add(EnumVersion._1_6); - version.add(EnumVersion._1_5); - version.add(EnumVersion._1_4); - version.add(EnumVersion._1_3); - version.add(EnumVersion._1_2); - version.add(EnumVersion._1_1); - version.add(EnumVersion._1_0); + final List version = EnumVersion.getEnumList(); EnumVersion eFirstVer = EnumVersion.getEnum(firstVersion); EnumVersion eLastVer = EnumVersion.getEnum(lastVersion); @@ -2365,14 +2358,13 @@ public static String getVersionInfoAttributes(final String usage, final String f if (eLastVer == null) { - eLastVer = EnumVersion._1_7; + eLastVer = EnumVersion.getLastVersion(); } - final StringBuffer verBuffer = new StringBuffer(10); + final StringBuffer verBuffer = new StringBuffer(20); - for (int i = 0; i < version.size(); i++) + for (final EnumVersion processedVersion : version) { - final EnumVersion processedVersion = (EnumVersion) version.elementAt(i); if (processedVersion.getValue() > eLastVer.getValue()) { @@ -2394,6 +2386,7 @@ else if (processedVersion.getValue() >= eFirstVer.getValue()) verBuffer.append("1"); } } + verBuffer.append("l"); return verBuffer.toString(); } @@ -2418,15 +2411,7 @@ else if (processedVersion.getValue() >= eFirstVer.getValue()) public static String getVersionInfoElements(final boolean isOptional, final String firstVersion, final String lastVersion, final String maxOccurs) { // we need a vector the iterator can be random and we need a spezific order - final Vector version = new Vector(); - version.add(EnumVersion._1_7); - version.add(EnumVersion._1_6); - version.add(EnumVersion._1_5); - version.add(EnumVersion._1_4); - version.add(EnumVersion._1_3); - version.add(EnumVersion._1_2); - version.add(EnumVersion._1_1); - version.add(EnumVersion._1_0); + final List version = EnumVersion.getEnumList(); EnumVersion eLastVer = EnumVersion.getEnum(lastVersion); EnumVersion eFirstVer = EnumVersion.getEnum(firstVersion); @@ -2438,15 +2423,13 @@ public static String getVersionInfoElements(final boolean isOptional, final Stri if (eLastVer == null) { - eLastVer = EnumVersion._1_7; + eLastVer = EnumVersion.getLastVersion(); } final StringBuffer verBuffer = new StringBuffer(10); - for (int i = 0; i < version.size(); i++) + for (final EnumVersion processedVersion : version) { - final EnumVersion processedVersion = (EnumVersion) version.elementAt(i); - if (processedVersion.getValue() > eLastVer.getValue()) { // is deprecated if (maxOccurs.equals("1")) @@ -2488,7 +2471,7 @@ else if (processedVersion.getValue() >= eFirstVer.getValue()) verBuffer.append("1"); } } - + verBuffer.append("l"); return verBuffer.toString(); } diff --git a/src/main/java/org/cip4/jdflib/generator/JavaCoreStringUtil.java b/src/main/java/org/cip4/jdflib/generator/JavaCoreStringUtil.java index 45c3e7e..2fe691b 100755 --- a/src/main/java/org/cip4/jdflib/generator/JavaCoreStringUtil.java +++ b/src/main/java/org/cip4/jdflib/generator/JavaCoreStringUtil.java @@ -88,6 +88,11 @@ public static List getEnumList() return getEnumList(EnumVersion.class); } + public static EnumVersion getLastVersion() + { + return (EnumVersion) getEnumList().get(getEnumList().size() - 1); + } + public static Iterator iterator() { return iterator(EnumVersion.class); @@ -113,6 +118,8 @@ public static Vector getNamesVector() public static final EnumVersion _1_5 = new EnumVersion("1.5"); public static final EnumVersion _1_6 = new EnumVersion("1.6"); public static final EnumVersion _1_7 = new EnumVersion("1.7"); + public static final EnumVersion _1_8 = new EnumVersion("1.8"); + public static final EnumVersion _1_9 = new EnumVersion("1.9"); } public static String getStrJavaCoreFile(final SchemaComplexType schemaComplexType) diff --git a/src/test/java/org/cip4/jdflib/generator/GeneratorUtilTest.java b/src/test/java/org/cip4/jdflib/generator/GeneratorUtilTest.java new file mode 100644 index 0000000..f94a2c6 --- /dev/null +++ b/src/test/java/org/cip4/jdflib/generator/GeneratorUtilTest.java @@ -0,0 +1,17 @@ +package org.cip4.jdflib.generator; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +class GeneratorUtilTest +{ + + @Test + void testVersionAtts() + { + assertEquals("1122222222l", GeneratorUtil.getVersionInfoAttributes("required", "1.2", null)); + assertEquals("2222244444l", GeneratorUtil.getVersionInfoAttributes("required", null, "1.4")); + } + +} From 2b06585cfd060e9fce23a3f44e4a00c371f1871f Mon Sep 17 00:00:00 2001 From: Rainer Prosi Date: Mon, 17 Jun 2024 19:32:35 +0200 Subject: [PATCH 2/4] updated generator --- .../java/org/cip4/jdflib/generator/GeneratorUtil.java | 4 ++-- .../org/cip4/jdflib/generator/JavaCoreStringUtil.java | 9 +++++++++ .../org/cip4/jdflib/generator/GeneratorUtilTest.java | 4 ++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/cip4/jdflib/generator/GeneratorUtil.java b/src/main/java/org/cip4/jdflib/generator/GeneratorUtil.java index 20226c9..1a71b16 100755 --- a/src/main/java/org/cip4/jdflib/generator/GeneratorUtil.java +++ b/src/main/java/org/cip4/jdflib/generator/GeneratorUtil.java @@ -2346,7 +2346,7 @@ private static void mergeAttributeInfo(final SchemaAttribute newSchema, final Sc public static String getVersionInfoAttributes(final String usage, final String firstVersion, final String lastVersion) { // we need a vector the iterator can be random and we need a spezific order - final List version = EnumVersion.getEnumList(); + final List version = EnumVersion.getReverseList(); EnumVersion eFirstVer = EnumVersion.getEnum(firstVersion); EnumVersion eLastVer = EnumVersion.getEnum(lastVersion); @@ -2411,7 +2411,7 @@ else if (processedVersion.getValue() >= eFirstVer.getValue()) public static String getVersionInfoElements(final boolean isOptional, final String firstVersion, final String lastVersion, final String maxOccurs) { // we need a vector the iterator can be random and we need a spezific order - final List version = EnumVersion.getEnumList(); + final List version = EnumVersion.getReverseList(); EnumVersion eLastVer = EnumVersion.getEnum(lastVersion); EnumVersion eFirstVer = EnumVersion.getEnum(firstVersion); diff --git a/src/main/java/org/cip4/jdflib/generator/JavaCoreStringUtil.java b/src/main/java/org/cip4/jdflib/generator/JavaCoreStringUtil.java index 2fe691b..0c00ee1 100755 --- a/src/main/java/org/cip4/jdflib/generator/JavaCoreStringUtil.java +++ b/src/main/java/org/cip4/jdflib/generator/JavaCoreStringUtil.java @@ -30,6 +30,8 @@ // package package org.cip4.jdflib.generator; +import java.util.ArrayList; +import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -88,6 +90,13 @@ public static List getEnumList() return getEnumList(EnumVersion.class); } + public static List getReverseList() + { + final List enumList = new ArrayList<>(getEnumList(EnumVersion.class)); + Collections.reverse(enumList); + return enumList; + } + public static EnumVersion getLastVersion() { return (EnumVersion) getEnumList().get(getEnumList().size() - 1); diff --git a/src/test/java/org/cip4/jdflib/generator/GeneratorUtilTest.java b/src/test/java/org/cip4/jdflib/generator/GeneratorUtilTest.java index f94a2c6..15e132d 100644 --- a/src/test/java/org/cip4/jdflib/generator/GeneratorUtilTest.java +++ b/src/test/java/org/cip4/jdflib/generator/GeneratorUtilTest.java @@ -10,8 +10,8 @@ class GeneratorUtilTest @Test void testVersionAtts() { - assertEquals("1122222222l", GeneratorUtil.getVersionInfoAttributes("required", "1.2", null)); - assertEquals("2222244444l", GeneratorUtil.getVersionInfoAttributes("required", null, "1.4")); + assertEquals(GeneratorUtil.getVersionInfoAttributes("required", "1.2", null), "1122222222l"); + assertEquals(GeneratorUtil.getVersionInfoAttributes("required", null, "1.4"), "2222244444l"); } } From d0b5a13d3e376b74d966580e78ff2daf705a03f3 Mon Sep 17 00:00:00 2001 From: Rainer Prosi Date: Wed, 26 Jun 2024 11:00:18 +0200 Subject: [PATCH 3/4] update to jdflib 1.8 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 37aab49..89ff5d6 100644 --- a/build.gradle +++ b/build.gradle @@ -123,7 +123,7 @@ processResources { } dependencies { - implementation('org.cip4.lib.jdf:JDFLibJ:2.1.7.+') { + implementation('org.cip4.lib.jdf:JDFLibJ:2.1.8.+') { exclude group: 'xml-apis' } From 91b1947b609eff717cab2e7b898895f974c10242 Mon Sep 17 00:00:00 2001 From: Rainer Prosi Date: Wed, 26 Jun 2024 11:25:17 +0200 Subject: [PATCH 4/4] test fix --- .../java/org/cip4/jdflib/generator/GeneratorUtilTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/cip4/jdflib/generator/GeneratorUtilTest.java b/src/test/java/org/cip4/jdflib/generator/GeneratorUtilTest.java index 15e132d..ea6a08c 100644 --- a/src/test/java/org/cip4/jdflib/generator/GeneratorUtilTest.java +++ b/src/test/java/org/cip4/jdflib/generator/GeneratorUtilTest.java @@ -10,8 +10,8 @@ class GeneratorUtilTest @Test void testVersionAtts() { - assertEquals(GeneratorUtil.getVersionInfoAttributes("required", "1.2", null), "1122222222l"); - assertEquals(GeneratorUtil.getVersionInfoAttributes("required", null, "1.4"), "2222244444l"); + assertEquals(GeneratorUtil.getVersionInfoAttributes("required", "1.2", null), "2222222211l"); + assertEquals(GeneratorUtil.getVersionInfoAttributes("required", null, "1.4"), "4444422222l"); } }