diff --git a/README.jrf b/README.jrf
index 6ef05281..972bcd4e 100644
--- a/README.jrf
+++ b/README.jrf
@@ -1,5 +1,5 @@
# This is a Jamal reference file containing serialized base64 encoded macros
-# Created: 2024-12-06 15:26:42 +0100
+# Created: 2024-12-10 17:58:05 +0100
# id|openStr|closeStr|verbatim|tailParameter|pure|content|parameters
# TOC
VE9D|eyU=|JX0=|0|0|0|Ci4gPDxJbnN0YWxsYXRpb24+PgouIDw8R1M+PgouIDw8Q29uZmlndXJhdGlvbj4+Ci4gPDxGZWF0dXJlcz4+Ci4gPDxDb250cmlidXRpbmc+PgouIDw8RG9jdW1lbnRhdGlvbj4+Ci4gPDxMaWNlbnNlPj4KLiA8PENoYW5nZWxvZz4+Ci4gPDxSb2FkbWFwPj4KLiA8PFN1cHBvcnQ+PgouIDw8RkFRPj4KLiA8PE1haW50ZW5hbmNlPj4=|
diff --git a/RELEASES.adoc b/RELEASES.adoc
index f9dcb48d..5e87ba1b 100644
--- a/RELEASES.adoc
+++ b/RELEASES.adoc
@@ -9,7 +9,7 @@
NOTE: The known bugs sections in the releases are updated after the release.
Plese consult the latest SNAPSHOT version available online at https://github.com/verhas/jamal/blob/master/RELEASES.adoc[GitHub Jamal RELEASES.adoc]
-== https://github.com/verhas/jamal/tree/2.8.1[2.8.1]
+== https://github.com/verhas/jamal/tree/2.8.2[2.8.2]
=== Known Bugs
@@ -17,6 +17,27 @@ __currently there are no known bugs in this release__
=== New Features
+* The installation kit installed command line version includes the debugger.
+
+* When starting the command line version using `-debug` without value it will start the HTTP debugger on the port `8080`.
+If you need to start it on a different port use the ``-debug=http:port`` option.
+Here `http:` is a literal string, and `port` is the port number.
+
+* There is a macro module to read a local GIT repository, which is experimental in this release.
+
+== https://github.com/verhas/jamal/tree/2.8.1[2.8.1]
+
+=== Known Bugs
+
+The command line version of the application does not include the debugger.
+It is not a bug, per se.
+You can start the debugger from the command line, but you have to start the application editing some shell scripts adding the dependency.
+Because the jbang version does include the debugger, it was not considered a bug.
+Starting with the release 2.8.1 there is an installation kit.
+When using the Jamal command line installed with the installation kit, the debugger is not available.
+
+=== New Features
+
* Functions depending on environment variables also read possible values from `.env` files.
This functionality can be achieved in prior versions using tools like `direnv`.
From this release Jamal itself reads the `.env` files.
diff --git a/RELEASES.adoc.jam b/RELEASES.adoc.jam
index ce610e73..eb5d17b4 100644
--- a/RELEASES.adoc.jam
+++ b/RELEASES.adoc.jam
@@ -9,7 +9,7 @@
NOTE: The known bugs sections in the releases are updated after the release.
Plese consult the latest SNAPSHOT version available online at https://github.com/verhas/jamal/blob/master/RELEASES.adoc[GitHub Jamal RELEASES.adoc]
-{%RELEASE KOMLO%}
+{%RELEASE HARKIV%}
=== Known Bugs
@@ -17,6 +17,27 @@ __currently there are no known bugs in this release__
=== New Features
+* The installation kit installed command line version includes the debugger.
+
+* When starting the command line version using `-debug` without value it will start the HTTP debugger on the port `8080`.
+If you need to start it on a different port use the ``-debug=http:port`` option.
+Here `http:` is a literal string, and `port` is the port number.
+
+* There is a macro module to read a local GIT repository, which is experimental in this release.
+
+{%RELEASE KOMLO%}
+
+=== Known Bugs
+
+The command line version of the application does not include the debugger.
+It is not a bug, per se.
+You can start the debugger from the command line, but you have to start the application editing some shell scripts adding the dependency.
+Because the jbang version does include the debugger, it was not considered a bug.
+Starting with the release {%RELEASE:KOMLO%} there is an installation kit.
+When using the Jamal command line installed with the installation kit, the debugger is not available.
+
+=== New Features
+
* Functions depending on environment variables also read possible values from `.env` files.
This functionality can be achieved in prior versions using tools like `direnv`.
From this release Jamal itself reads the `.env` files.
diff --git a/RELEASES.jim b/RELEASES.jim
index e113024f..f0e25c93 100644
--- a/RELEASES.jim
+++ b/RELEASES.jim
@@ -33,7 +33,7 @@ You can find some bare release numbers in the documentation even though the exis
my parents were there once
{@define ! RELEASE:ULANBATOR=1.12.3}
-The first "next" (non-retrospect) release is named after the city where I lived in most of the my life.
+The first "next" (non-retrospect) release is named after the city where I was born and where I lived in most of the my life.
{@define ! RELEASE:BUDAPEST=2.0.0}
@@ -65,4 +65,5 @@ a town very north in Russia
{@define ! RELEASE:PECSVARAD=2.7.0}
{@define ! RELEASE:PECS=2.8.0}
{@define ! RELEASE:KOMLO=2.8.1}
+{@define ! RELEASE:HARKIV=2.8.2} to remember the heroic effort of the Ukrainian people on the 1000-th day of the Russian war
diff --git a/documentation/macros/debug.adoc b/documentation/macros/debug.adoc
index 9b221635..0fef5753 100644
--- a/documentation/macros/debug.adoc
+++ b/documentation/macros/debug.adoc
@@ -51,4 +51,7 @@ When this option is on, the fact that a global and external debugger is defined
NOTE: The macro does not work inside the interactive embeddings like IntelliJ or AsciidocFx.
Starting up the debugger may cause several different issues in an environment like that.
-Insread the macro in those environments returns a constant string that gets into the document, so you can see while editing.
\ No newline at end of file
+Insread the macro in those environments returns a constant string that gets into the document, so you can see while editing.
+
+
+
diff --git a/documentation/macros/include.adoc.jam b/documentation/macros/include.adoc.jam
index fcd8acec..752f6ff0 100644
--- a/documentation/macros/include.adoc.jam
+++ b/documentation/macros/include.adoc.jam
@@ -1,6 +1,6 @@
{%@import macrodoc.jim%}
{%MACRO name="include" since={%RELEASE:ZURICH%}%}
-{%@snip:check file=../../jamal-core/src/main/java/javax0/jamal/builtins/Include.java hash=d09e14c9 %}
+{%@snip:check file=../../jamal-core/src/main/java/javax0/jamal/builtins/Include.java hash=826bb6cc %}
{%@import ../../environmentvariables.jim%}
== Syntax
diff --git a/jamal-api/src/main/java/javax0/jamal/api/Input.java b/jamal-api/src/main/java/javax0/jamal/api/Input.java
index af5617c1..c0ff827e 100644
--- a/jamal-api/src/main/java/javax0/jamal/api/Input.java
+++ b/jamal-api/src/main/java/javax0/jamal/api/Input.java
@@ -1,12 +1,11 @@
package javax0.jamal.api;
/**
- *
* The input Jamal is working with.
* This is essentially a stream of characters along with the position reference.
- * When a macro is processed many times the output is also the input of the surrounding macro.
+ * When a macro is processed many times, the output is also the input of the surrounding macro.
* Therefore, many times the class implementing this interface is also used as output.
- * The naming, therefore is a bit confusing.
+ * The naming, therefore, is a bit confusing.
*
* An input has a string builder and also a file name from where the input is coming from.
* The string builder is used to fetch the characters.
@@ -15,12 +14,20 @@
*/
public interface Input extends CharSequence {
/**
+ * Do not use this method in code using the implementations of this interface.
+ * The implementations should
+ *
+ * - either perform the operation as described here to support the default implementations, or
+ *
- implement the methods in a way that they do not use this method.
+ *
+ *
* Get the {@link StringBuilder} that contains the characters of the input. The processing many times works directly
* on the {@link StringBuilder} deleting characters from the start of it as the processing progresses, thus
* essentially modifying/mutating the {@code Input} object.
*
* @return the {@link StringBuilder} containing the characters of the input.
*/
+ @Deprecated()
StringBuilder getSB();
/**
@@ -118,6 +125,18 @@ default Input append(Object obj) {
return this;
}
+ /**
+ * replaces the current content of the input with the string representation of the {@code Object} argument.
+ *
+ * @param obj the object to be converted to string and replace the content of the input
+ * @return {@code this}
+ */
+ default Input replace(Object obj) {
+ this.reset();
+ this.append(obj);
+ return this;
+ }
+
/**
* Delete all character from the input. Invokes {@link StringBuilder#setLength(int) setLength(0)} on the underlying
* StringBuilder.
diff --git a/jamal-asciidoc/pom.xml b/jamal-asciidoc/pom.xml
index eb601357..33bf293c 100644
--- a/jamal-asciidoc/pom.xml
+++ b/jamal-asciidoc/pom.xml
@@ -180,7 +180,7 @@
org.jsoup
jsoup
- 1.18.1
+ 1.18.3
diff --git a/jamal-core/src/main/java/javax0/jamal/builtins/Defer.java b/jamal-core/src/main/java/javax0/jamal/builtins/Defer.java
index 4c26b15c..489d2823 100644
--- a/jamal-core/src/main/java/javax0/jamal/builtins/Defer.java
+++ b/jamal-core/src/main/java/javax0/jamal/builtins/Defer.java
@@ -67,9 +67,7 @@ public void close() throws Exception {
}
final var reader = MacroReader.macro(processor);
final String result = reader.readValue(outputName).orElse(out);
- final StringBuilder sb = output.getSB();
- sb.setLength(0);
- sb.append(result);
+ output.replace(result);
}
}
}
diff --git a/jamal-core/src/main/java/javax0/jamal/builtins/Escape.java b/jamal-core/src/main/java/javax0/jamal/builtins/Escape.java
index 95d6ebb0..de368cf2 100644
--- a/jamal-core/src/main/java/javax0/jamal/builtins/Escape.java
+++ b/jamal-core/src/main/java/javax0/jamal/builtins/Escape.java
@@ -205,8 +205,7 @@ public void close() throws Exception {
if (!processor.errors().isEmpty()) {
processor.throwUp();
}
- output.getSB().setLength(0);
- output.append(result);
+ output.replace(result);
}
}
}
diff --git a/jamal-core/src/main/java/javax0/jamal/builtins/Include.java b/jamal-core/src/main/java/javax0/jamal/builtins/Include.java
index 60c32cd5..3d79a41f 100644
--- a/jamal-core/src/main/java/javax0/jamal/builtins/Include.java
+++ b/jamal-core/src/main/java/javax0/jamal/builtins/Include.java
@@ -57,7 +57,9 @@ public String evaluate(Input input, Processor processor) throws BadSyntax {
final var weArePseudoDefault = processor.getRegister().open().equals("{") && processor.getRegister().close().equals("}");
final var useDefaultSeparators = in.length() > 1 && in.charAt(0) == IMPORT_SHEBANG1 && in.charAt(1) == IMPORT_SHEBANG2 && !weArePseudoDefault;
if (lines.isPresent()) {
- Range.Lines.filter(in.getSB(), lines.get());
+ final var sb = new StringBuilder(in);
+ Range.Lines.filter(sb, lines.get());
+ in.replace(sb);
}
if (verbatim.is()) {
result = in.toString();
diff --git a/jamal-engine/src/test/java/javax0/jamal/engine/TestProcessor.java b/jamal-engine/src/test/java/javax0/jamal/engine/TestProcessor.java
index 2617bc9b..fb504e89 100644
--- a/jamal-engine/src/test/java/javax0/jamal/engine/TestProcessor.java
+++ b/jamal-engine/src/test/java/javax0/jamal/engine/TestProcessor.java
@@ -308,10 +308,7 @@ public static class Postprocessor implements Macro, AutoCloseable, ProcessorAwar
@Override
public void close() {
- final var sb = output.getSB();
- final var text = sb.toString().toUpperCase(Locale.ENGLISH);
- sb.setLength(0);
- sb.append(text);
+ output.replace(output.toString().toUpperCase(Locale.ENGLISH));
}
@Override
diff --git a/jamal-extensions/src/main/java/javax0/jamal/extensions/UseComments.java b/jamal-extensions/src/main/java/javax0/jamal/extensions/UseComments.java
index fa6e74f2..7f2b599b 100644
--- a/jamal-extensions/src/main/java/javax0/jamal/extensions/UseComments.java
+++ b/jamal-extensions/src/main/java/javax0/jamal/extensions/UseComments.java
@@ -40,9 +40,7 @@ public String fetch(Processor processor, Input input) throws BadSyntaxAt {
}
lines[j++] = lines[i];
}
- final var sb = input.getSB();
- sb.delete(0, sb.length());
- sb.append(Arrays.stream(lines).limit(j).collect(Collectors.joining("\n")));
+ input.replace(Arrays.stream(lines).limit(j).collect(Collectors.joining("\n")));
return Macro.super.fetch(processor, input);
}
diff --git a/jamal-groovy/pom.xml b/jamal-groovy/pom.xml
index d24e1fcb..918f6d9b 100644
--- a/jamal-groovy/pom.xml
+++ b/jamal-groovy/pom.xml
@@ -77,7 +77,7 @@
org.codehaus.groovy
groovy-jsr223
- 3.0.22
+ 3.0.23
\ No newline at end of file
diff --git a/jamal-groovy/src/main/java/javax0/jamal/groovy/GroovyCloser.java b/jamal-groovy/src/main/java/javax0/jamal/groovy/GroovyCloser.java
index aa17212c..229ecd5a 100644
--- a/jamal-groovy/src/main/java/javax0/jamal/groovy/GroovyCloser.java
+++ b/jamal-groovy/src/main/java/javax0/jamal/groovy/GroovyCloser.java
@@ -16,12 +16,14 @@ private Closer(Shell shell, String closerScript) {
@Override
public void close() throws Exception {
- shell.property("result", result.getSB());
+ final var resultSB = new StringBuilder(result);
+ shell.property("result", resultSB);
try {
final var sb = shell.evaluate(closerScript, null);
- if (sb != null && sb != result.getSB()) {// NOT EQUALS, does it return the same object or not
- result.getSB().setLength(0);
- result.getSB().append(sb);
+ if (sb != null ) {
+ result.replace(sb);
+ }else{
+ result.replace(resultSB);
}
} catch (Exception e) {
throw new BadSyntax("There was an exception '"
diff --git a/jamal-groovy/src/main/java/javax0/jamal/groovy/GroovyImport.java b/jamal-groovy/src/main/java/javax0/jamal/groovy/GroovyImport.java
index 76a01537..611ec003 100644
--- a/jamal-groovy/src/main/java/javax0/jamal/groovy/GroovyImport.java
+++ b/jamal-groovy/src/main/java/javax0/jamal/groovy/GroovyImport.java
@@ -11,13 +11,13 @@ public String evaluate(Input in, Processor processor) throws BadSyntax {
final var shell = Shell.getShell(in, processor, this);
final var scriptName = InputHandler.fetch2EOL(in).trim();
final Input script;
- if (scriptName.length() > 0) {
+ if (!scriptName.isEmpty()) {
final var fileName = FileTools.absolute(in.getReference(), scriptName);
script = FileTools.getInput(fileName, processor);
} else {
script = in;
}
- script.getSB().append(";''");
+ script.append(";''");
try {
shell.evaluate(script.toString(), scriptName);
} catch (Exception e) {
diff --git a/jamal-groovy/src/main/java/javax0/jamal/groovy/Shell.java b/jamal-groovy/src/main/java/javax0/jamal/groovy/Shell.java
index 3217cd10..721fab8e 100644
--- a/jamal-groovy/src/main/java/javax0/jamal/groovy/Shell.java
+++ b/jamal-groovy/src/main/java/javax0/jamal/groovy/Shell.java
@@ -27,7 +27,7 @@ public Shell(String id) {
}
public Object evaluate(String script, String fileName) {
- if (fileName != null && fileName.length() > 0) {
+ if (fileName != null && !fileName.isEmpty()) {
return shell.evaluate(script, fileName);
} else {
return shell.evaluate(script, id + ".groovy");
diff --git a/jamal-java/src/main/java/javax0/jamal/java/Jdsl.java b/jamal-java/src/main/java/javax0/jamal/java/Jdsl.java
index d1143c51..d858a20d 100644
--- a/jamal-java/src/main/java/javax0/jamal/java/Jdsl.java
+++ b/jamal-java/src/main/java/javax0/jamal/java/Jdsl.java
@@ -24,9 +24,7 @@ private static class State implements AutoCloseable, Closer.OutputAware {
@Override
public void close() throws Exception {
- final var sb = output.getSB();
- sb.delete(0, sb.length());
- sb.append(result);
+ output.replace(result);
}
@Override
@@ -40,7 +38,7 @@ public String fetch(Processor processor, Input input) throws BadSyntaxAt {
final var original = Macro.super.fetch(processor, input);
processor.state(this, State::new).source = input.toString();
- input.getSB().delete(0, input.length());
+ input.reset();
return original;
}
diff --git a/jamal-ruby/pom.xml b/jamal-ruby/pom.xml
index 9f8b5f08..1215c066 100644
--- a/jamal-ruby/pom.xml
+++ b/jamal-ruby/pom.xml
@@ -82,7 +82,7 @@
org.jruby
jruby-complete
- 9.4.8.0
+ 9.4.9.0
\ No newline at end of file
diff --git a/jamal-ruby/src/main/java/javax0/jamal/ruby/RubyCloser.java b/jamal-ruby/src/main/java/javax0/jamal/ruby/RubyCloser.java
index 489867f4..a87c61ea 100644
--- a/jamal-ruby/src/main/java/javax0/jamal/ruby/RubyCloser.java
+++ b/jamal-ruby/src/main/java/javax0/jamal/ruby/RubyCloser.java
@@ -17,12 +17,11 @@ private Closer(Shell shell, String closerScript) {
@Override
public void close() throws Exception {
- shell.property("$result", RubyString.newString(shell.shell.getProvider().getRuntime(), result.getSB()));
+ shell.property("$result", RubyString.newString(shell.shell.getProvider().getRuntime(), result));
try {
final var sb = shell.evaluate(closerScript, null);
BadSyntax.when(sb == null, "Ruby closer script '%s' returned null", shell.getId());
- result.getSB().setLength(0);
- result.getSB().append(sb);
+ result.replace(sb);
} catch (Exception e) {
throw new BadSyntax(String.format("There was an exception '%s' executing the ruby closer script in the shell '%s'.",
e.getMessage(), shell.getId()), e);
diff --git a/jamal-ruby/src/main/java/javax0/jamal/ruby/RubyImport.java b/jamal-ruby/src/main/java/javax0/jamal/ruby/RubyImport.java
index 46030377..bfd3d547 100644
--- a/jamal-ruby/src/main/java/javax0/jamal/ruby/RubyImport.java
+++ b/jamal-ruby/src/main/java/javax0/jamal/ruby/RubyImport.java
@@ -17,7 +17,7 @@ public String evaluate(Input in, Processor processor) throws BadSyntax {
} else {
script = in;
}
- script.getSB().append("\n''");
+ script.append("\n''");
try {
shell.evaluate(script.toString(), scriptName);
} catch (Exception e) {
diff --git a/jamal-snippet/README.adoc b/jamal-snippet/README.adoc
index 08f641a9..b16a677c 100644
--- a/jamal-snippet/README.adoc
+++ b/jamal-snippet/README.adoc
@@ -596,7 +596,7 @@ When the XML content is in a file calling this macro is a bit more efficient.
This macro can modify an XML-formatted user defined macro inserting content into the XML document.
-XML-formatted user defined macros can be created using the `xml:define` and `snippet:xml` macros.
+XML-formatted user-defined macros can be created using the `xml:define` and `snippet:xml` macros.
This macro can also be used to insert an XML fragment into the XML document, which is the output of the whole processing.
This latter use is for the case when the Jamal file processed creates an XML file.
@@ -3477,9 +3477,9 @@ will result
- Sort.java: 8,606 bytes
- Decorate.java: 12,215 bytes
- Case.java: 2,439 bytes
-- NumberLines.java: 2,669 bytes
-- RangeMacro.java: 1,007 bytes
-- Untab.java: 2,205 bytes
+- NumberLines.java: 2,730 bytes
+- RangeMacro.java: 1,069 bytes
+- Untab.java: 2,216 bytes
- Plural.java: 2,136 bytes
- DateMacro.java: 681 bytes
- Format.java: 930 bytes
@@ -3491,7 +3491,7 @@ will result
- Def.java: 952 bytes
- Update.java: 829 bytes
- Eval.java: 1,827 bytes
-- SnipTransform.java: 16,939 bytes
+- SnipTransform.java: 16,950 bytes
- Base64.java: 3,606 bytes
- FilesMacro.java: 11,400 bytes
- Collect.java: 24,771 bytes
@@ -3499,9 +3499,9 @@ will result
- CounterFormatter.java: 4,599 bytes
- Repeat.java: 1,120 bytes
- HashCode.java: 462 bytes
-- TrimLines.java: 5,161 bytes
+- TrimLines.java: 5,172 bytes
- JavaSourceInsert.java: 8,813 bytes
-- ThinXml.java: 8,792 bytes
+- ThinXml.java: 8,777 bytes
- Decorator.java: 9,094 bytes
- Memoize.java: 8,760 bytes
- LineCount.java: 552 bytes
@@ -3524,30 +3524,30 @@ will result
- AbstractXmlDefine.java: 1,032 bytes
- Dictionary.java: 1,632 bytes
- Clear.java: 471 bytes
-- KillLines.java: 1,527 bytes
+- KillLines.java: 1,589 bytes
- SnipLoad.java: 3,298 bytes
- Rot13.java: 928 bytes
- SnippetStore.java: 11,145 bytes
- Download.java: 2,265 bytes
- ListDir.java: 5,236 bytes
-- XmlFormat.java: 3,745 bytes
+- XmlFormat.java: 3,693 bytes
- SnippetXmlReader.java: 6,515 bytes
-- XmlInsert.java: 5,954 bytes
+- XmlInsert.java: 5,902 bytes
- SnipProperties.java: 1,346 bytes
- Xml.java: 539 bytes
- CounterMacro.java: 4,186 bytes
- Variation.java: 6,370 bytes
- SnipList.java: 1,078 bytes
-- ShellVar.java: 5,290 bytes
+- ShellVar.java: 5,301 bytes
- Locate.java: 5,824 bytes
- XmlDocument.java: 5,928 bytes
- References.java: 9,142 bytes
- Java.java: 11,364 bytes
-- ReplaceLines.java: 3,258 bytes
-- SkipLines.java: 2,617 bytes
+- ReplaceLines.java: 3,320 bytes
+- SkipLines.java: 2,675 bytes
- SnipCheck.java: 7,556 bytes
- IdempotencyFailed.java: 1,816 bytes
-- Reflow.java: 1,910 bytes
+- Reflow.java: 1,973 bytes
- Pos.java: 5,016 bytes
- Snippet.java: 1,559 bytes
----
@@ -3816,7 +3816,7 @@ will result in the output
.output
[source]
----
-2024-12-06 15:26:42
+2024-12-10 17:58:06
----
diff --git a/jamal-snippet/README.adoc.jam b/jamal-snippet/README.adoc.jam
index f18f1046..88e4a018 100644
--- a/jamal-snippet/README.adoc.jam
+++ b/jamal-snippet/README.adoc.jam
@@ -657,7 +657,7 @@ If you want to change something in the XML file and edit some snippet code tempo
[[trimLines]]
=== {%chapter%}`trimLines`, `trim`
-{%#snip:check file={%JAVA_DIR%}TrimLines.java hash=df16a908%}
+{%#snip:check file={%JAVA_DIR%}TrimLines.java hash=8d8de139%}
This macro can cut off the unneeded spaces from the start and end of the lines.
{%parameterized%}
@@ -729,7 +729,7 @@ will result
[[untab]]
=== {%chapter%}`untab`
-{%#snip:check file={%JAVA_DIR%}Untab.java hash=341886c9%}
+{%#snip:check file={%JAVA_DIR%}Untab.java hash=d36e4064%}
The syntax of the macro is:
@@ -778,7 +778,7 @@ will be converted to
[[range]]
=== {%chapter%}`range`
-{%#snip:check file={%JAVA_DIR%}RangeMacro.java hash=fb31977a%}
+{%#snip:check file={%JAVA_DIR%}RangeMacro.java hash=7e738178%}
This macro can filter lines of its input by a range of numbers.
The syntax of the macro is:
@@ -1115,7 +1115,7 @@ If you write `semver` (case insensitive) instead of the fully qualified domain n
[[numberLines]]
=== {%chapter%}`numberLines`
-{%#snip:check file={%JAVA_DIR%}NumberLines.java hash=3a9613e0%}
+{%#snip:check file={%JAVA_DIR%}NumberLines.java hash=366ba1a6%}
This macro can put numbers in front of the lines, sequentially numbering them.
{%parameterized%}
@@ -1183,7 +1183,7 @@ Any illegal formatting will result in an error.
[[killLines]]
=== {%chapter%}`killLines`
-{%#snip:check file={%JAVA_DIR%}KillLines.java hash=f64d6845%}
+{%#snip:check file={%JAVA_DIR%}KillLines.java hash=0d0db731%}
This macro deletes, or keeps the selected lines from its input.
{%parameterized%}
@@ -1255,7 +1255,7 @@ In this case only the comment lines remained that start with `//` at the start o
[[skipLines]]
=== {%chapter%}`skipLines`
-{%#snip:check file={%JAVA_DIR%}SkipLines.java hash=5f1fcc03%}
+{%#snip:check file={%JAVA_DIR%}SkipLines.java hash=089a5797%}
You can use this macro to skip lines from the snippet.
{%parameterized%}
@@ -1366,7 +1366,7 @@ In that case you can switch it off using the option `(detectNoChange=false)` in
[[replaceLines]]
=== {%chapter%}`replaceLines`
-{%#snip:check file={%JAVA_DIR%}ReplaceLines.java hash=daba1439%}
+{%#snip:check file={%JAVA_DIR%}ReplaceLines.java hash=791bbd14%}
This macro replaces strings in the input.
{%parameterized%}
@@ -1671,7 +1671,7 @@ If you need a forward reference to a counter, you should define a user defined m
[[reflow]]
=== {%chapter%}`reflow`
-{%#snip:check file={%JAVA_DIR%}Reflow.java hash=ca41411b%}
+{%#snip:check file={%JAVA_DIR%}Reflow.java hash=02fd0303%}
This macro reflows the content.
{%parameterized%}
@@ -1842,7 +1842,7 @@ In that case yur `snip:eval` can reference the snippet by the name for the file
[[snipTransform]]
=== {%chapter%}`snip:transform`
-{%#snip:check file={%JAVA_DIR%}SnipTransform.java hash=592e82aa%}
+{%#snip:check file={%JAVA_DIR%}SnipTransform.java hash=da5129ea %}
The `snip:transform` macro integrates the functionality of the macros
@@ -2211,7 +2211,7 @@ will result
[[xmlFormat]]
=== {%chapter%}`xmlFormat`
-{%#snip:check file={%JAVA_DIR%}XmlFormat.java hash=9f366b64%}
+{%#snip:check file={%JAVA_DIR%}XmlFormat.java hash=ec91f3e3%}
The macro `xmlFormat` interprets the input as an XML document if there is any, resulting in the formatted document.
If the input is empty or contains only spaces, it registers a post-processor that runs after the Jamal processing and formats the final output as XML.
For example,
diff --git a/jamal-snippet/THINXML.adoc.jam b/jamal-snippet/THINXML.adoc.jam
index dd6e7aff..0f8a7b5b 100644
--- a/jamal-snippet/THINXML.adoc.jam
+++ b/jamal-snippet/THINXML.adoc.jam
@@ -1,5 +1,5 @@
== ThinXML Format
-{%@snip:check file=./src/main/java/javax0/jamal/snippet/ThinXml.java hash="e2b07658"%}
+{%@snip:check file=./src/main/java/javax0/jamal/snippet/ThinXml.java hash="73369c12"%}
{%@import res:jamal.jim%}\
{%@define sample(code)={%#define :lastCode={@xmlFormat (thin)}
code%}[source]
diff --git a/jamal-snippet/documentation/macros/xml_insert.adoc.jam b/jamal-snippet/documentation/macros/xml_insert.adoc.jam
index f9b94306..f2371db5 100644
--- a/jamal-snippet/documentation/macros/xml_insert.adoc.jam
+++ b/jamal-snippet/documentation/macros/xml_insert.adoc.jam
@@ -1,7 +1,7 @@
{%@import macrodoc.jim%}
-{%#snip:check file={%JAVA_DIR%}XmlInsert.java hash=d24f2421%}
+{%#snip:check file={%JAVA_DIR%}XmlInsert.java hash=c4f23837%}
This macro can modify an XML-formatted user defined macro inserting content into the XML document.
-XML-formatted user defined macros can be created using the `xml:define` and `snippet:xml` macros.
+XML-formatted user-defined macros can be created using the `xml:define` and `snippet:xml` macros.
This macro can also be used to insert an XML fragment into the XML document, which is the output of the whole processing.
This latter use is for the case when the Jamal file processed creates an XML file.
diff --git a/jamal-snippet/src/main/java/javax0/jamal/snippet/KillLines.java b/jamal-snippet/src/main/java/javax0/jamal/snippet/KillLines.java
index 2584b8a2..fb7c3938 100644
--- a/jamal-snippet/src/main/java/javax0/jamal/snippet/KillLines.java
+++ b/jamal-snippet/src/main/java/javax0/jamal/snippet/KillLines.java
@@ -15,7 +15,9 @@ public String evaluate(Input in, Processor processor) throws BadSyntax {
final var keep = scanner.bool("keep");
scanner.done();
- convertTextBlock(processor, in.getSB(), in.getPosition(), pattern.getParam(), keep.getParam());
+ final var sb = new StringBuilder(in);
+ convertTextBlock(processor, sb, in.getPosition(), pattern.getParam(), keep.getParam());
+ in.replace(sb);
return in.toString();
}
diff --git a/jamal-snippet/src/main/java/javax0/jamal/snippet/NumberLines.java b/jamal-snippet/src/main/java/javax0/jamal/snippet/NumberLines.java
index 6d7cda7b..a7cd5326 100644
--- a/jamal-snippet/src/main/java/javax0/jamal/snippet/NumberLines.java
+++ b/jamal-snippet/src/main/java/javax0/jamal/snippet/NumberLines.java
@@ -51,8 +51,9 @@ public String evaluate(Input in, Processor processor) throws BadSyntax {
final var start = scanner.number("start").defaultValue(1);
final var step = scanner.number("step").defaultValue(1);
scanner.done();
-
- convertTextBlock(processor, in.getSB(), in.getPosition(), format.getParam(), start.getParam(), step.getParam());
+ final var sb = new StringBuilder(in);
+ convertTextBlock(processor, sb, in.getPosition(), format.getParam(), start.getParam(), step.getParam());
+ in.replace(sb);
return in.toString();
}
diff --git a/jamal-snippet/src/main/java/javax0/jamal/snippet/RangeMacro.java b/jamal-snippet/src/main/java/javax0/jamal/snippet/RangeMacro.java
index eebd9ed5..eb4783b9 100644
--- a/jamal-snippet/src/main/java/javax0/jamal/snippet/RangeMacro.java
+++ b/jamal-snippet/src/main/java/javax0/jamal/snippet/RangeMacro.java
@@ -12,7 +12,9 @@ public String evaluate(Input in, Processor processor) throws BadSyntax {
final var ranges = scanner.str(null, "range", "ranges", "lines").optional();
scanner.done();
- convertTextBlock(processor, in.getSB(), in.getPosition(), ranges.getParam());
+ final var sb = new StringBuilder(in);
+ convertTextBlock(processor, sb, in.getPosition(), ranges.getParam());
+ in.replace(sb);
return in.toString();
}
diff --git a/jamal-snippet/src/main/java/javax0/jamal/snippet/Reflow.java b/jamal-snippet/src/main/java/javax0/jamal/snippet/Reflow.java
index ec2f8bba..c885fd0b 100644
--- a/jamal-snippet/src/main/java/javax0/jamal/snippet/Reflow.java
+++ b/jamal-snippet/src/main/java/javax0/jamal/snippet/Reflow.java
@@ -7,10 +7,12 @@
public class Reflow implements Macro, InnerScopeDependent, BlockConverter, Scanner.FirstLine {
@Override
public String evaluate(Input in, Processor processor) throws BadSyntax {
- final var scanner = newScanner(in,processor);
+ final var scanner = newScanner(in, processor);
final var width = scanner.number("width").defaultValue(0);
scanner.done();
- convertTextBlock(processor, in.getSB(), in.getPosition(), width.getParam());
+ final var sb = new StringBuilder(in);
+ convertTextBlock(processor, sb, in.getPosition(), width.getParam());
+ in.replace(sb);
return in.toString();
}
diff --git a/jamal-snippet/src/main/java/javax0/jamal/snippet/ReplaceLines.java b/jamal-snippet/src/main/java/javax0/jamal/snippet/ReplaceLines.java
index 5ef01838..9957cabe 100644
--- a/jamal-snippet/src/main/java/javax0/jamal/snippet/ReplaceLines.java
+++ b/jamal-snippet/src/main/java/javax0/jamal/snippet/ReplaceLines.java
@@ -17,7 +17,9 @@ public String evaluate(Input in, Processor processor) throws BadSyntax {
final var detectNoChange = scanner.bool("detectNoChange");
scanner.done();
- convertTextBlock(processor, in.getSB(), in.getPosition(), replace.getParam(), detectNoChange.getParam());
+ final var sb = new StringBuilder(in);
+ convertTextBlock(processor, sb, in.getPosition(), replace.getParam(), detectNoChange.getParam());
+ in.replace(sb);
return in.toString();
}
diff --git a/jamal-snippet/src/main/java/javax0/jamal/snippet/ShellVar.java b/jamal-snippet/src/main/java/javax0/jamal/snippet/ShellVar.java
index 01cb4d90..9c14f187 100644
--- a/jamal-snippet/src/main/java/javax0/jamal/snippet/ShellVar.java
+++ b/jamal-snippet/src/main/java/javax0/jamal/snippet/ShellVar.java
@@ -19,7 +19,7 @@ public String evaluate(Input in, Processor processor) throws BadSyntax {
// get the parameters without any key name constraint using the params handling tools
Params.using(processor).tillEnd().parse(javax0.jamal.tools.Input.makeInput(parameters.get()), values::put, s -> true);
- final var sb = in.getSB();
+ final var sb = new StringBuilder(in);
replace(processor, values, sb, 0);
unescape(sb);
return sb.toString();
diff --git a/jamal-snippet/src/main/java/javax0/jamal/snippet/SkipLines.java b/jamal-snippet/src/main/java/javax0/jamal/snippet/SkipLines.java
index 0871acc0..3be66ed5 100644
--- a/jamal-snippet/src/main/java/javax0/jamal/snippet/SkipLines.java
+++ b/jamal-snippet/src/main/java/javax0/jamal/snippet/SkipLines.java
@@ -16,7 +16,9 @@ public String evaluate(Input in, Processor processor) throws BadSyntax {
final var skipEnd = scanner.pattern("endSkip").defaultValue("end\\s+skip");
scanner.done();
- convertTextBlock(processor, in.getSB(), in.getPosition(), skipStart.getParam(), skipEnd.getParam());
+ final var sb = new StringBuilder(in);
+ convertTextBlock(processor, sb, in.getPosition(), skipStart.getParam(), skipEnd.getParam());
+ in.replace(sb);
return in.toString();
}
@@ -61,7 +63,7 @@ static void joinLines(final StringBuilder sb, final String[] lines, final int to
}
private static boolean needsNoExtraNl(String in, boolean lastLineCopied, String joined) {
- return joined.length() == 0 || joined.charAt(joined.length() - 1) == '\n' || (lastLineCopied && in.charAt(in.length() - 1) != '\n');
+ return joined.isEmpty() || joined.charAt(joined.length() - 1) == '\n' || (lastLineCopied && in.charAt(in.length() - 1) != '\n');
}
@Override
diff --git a/jamal-snippet/src/main/java/javax0/jamal/snippet/SnipTransform.java b/jamal-snippet/src/main/java/javax0/jamal/snippet/SnipTransform.java
index 0409435a..5c64e292 100644
--- a/jamal-snippet/src/main/java/javax0/jamal/snippet/SnipTransform.java
+++ b/jamal-snippet/src/main/java/javax0/jamal/snippet/SnipTransform.java
@@ -301,7 +301,7 @@ public String evaluate(final Input in, final Processor processor) throws BadSynt
public String evaluate(final Params.ExtraParams extraParams, final Input in, final Processor processor) throws BadSyntax {
final var params = new Parameters(extraParams, in, processor);
final var macros = new UnderlyingMacros(processor);
- final var sb = in.getSB();
+ final var sb = new StringBuilder(in);
final var pos = in.getPosition();
for (final String action : params.actionsSet) {
switch (action) {
diff --git a/jamal-snippet/src/main/java/javax0/jamal/snippet/ThinXml.java b/jamal-snippet/src/main/java/javax0/jamal/snippet/ThinXml.java
index 7138a805..621db6ac 100644
--- a/jamal-snippet/src/main/java/javax0/jamal/snippet/ThinXml.java
+++ b/jamal-snippet/src/main/java/javax0/jamal/snippet/ThinXml.java
@@ -137,7 +137,7 @@ private void convertText(StringBuilder xml, Input in, boolean tabText) {
} else {
if (tabText) {
skipWhiteSpaces(in);
- if (tags.size() > 0) {
+ if (!tags.isEmpty()) {
xml.append(spaces(tags.get(tags.size() - 1).outTab + tabSize));
}
}
@@ -147,7 +147,7 @@ private void convertText(StringBuilder xml, Input in, boolean tabText) {
}
tabClosed = tabText;
}
- in.getSB().setLength(0);
+ in.reset();
}
private boolean convertTag(StringBuilder xml, Input in, boolean tabText, int column) throws BadSyntax {
@@ -157,7 +157,7 @@ private boolean convertTag(StringBuilder xml, Input in, boolean tabText, int col
skipWhiteSpaces(in);
final var tag = fetchId(in);
final int outTab;
- if (tags.size() == 0) {
+ if (tags.isEmpty()) {
outTab = 0;
} else {
outTab = tags.get(tags.size() - 1).outTab + tabSize;
diff --git a/jamal-snippet/src/main/java/javax0/jamal/snippet/TrimLines.java b/jamal-snippet/src/main/java/javax0/jamal/snippet/TrimLines.java
index dd59b8f8..76ecff3a 100644
--- a/jamal-snippet/src/main/java/javax0/jamal/snippet/TrimLines.java
+++ b/jamal-snippet/src/main/java/javax0/jamal/snippet/TrimLines.java
@@ -24,7 +24,7 @@ public String evaluate(Input in, Processor processor) throws BadSyntax {
final var verticalTrimOnly = scanner.bool("verticalTrimOnly", "vtrimOnly");
scanner.done();
//end snippet
- final var sb = in.getSB();
+ final var sb = new StringBuilder(in);
convertTextBlock(processor, sb, in.getPosition(), margin.getParam(), trimVertical.getParam(), verticalTrimOnly.getParam());
return sb.toString();
}
diff --git a/jamal-snippet/src/main/java/javax0/jamal/snippet/Untab.java b/jamal-snippet/src/main/java/javax0/jamal/snippet/Untab.java
index 7e943ead..e77fec88 100644
--- a/jamal-snippet/src/main/java/javax0/jamal/snippet/Untab.java
+++ b/jamal-snippet/src/main/java/javax0/jamal/snippet/Untab.java
@@ -24,7 +24,7 @@ public String evaluate(Input in, Processor processor) throws BadSyntax {
final var scanner = newScanner(in, processor);
final var tabSize = scanner.number("tabSize", "tab", "size").defaultValue(8);
scanner.done();
- final var sb = in.getSB();
+ final var sb = new StringBuilder(in);
convertTextBlock(processor, sb, in.getPosition(), tabSize.getParam());
return sb.toString();
}
diff --git a/jamal-snippet/src/main/java/javax0/jamal/snippet/XmlFormat.java b/jamal-snippet/src/main/java/javax0/jamal/snippet/XmlFormat.java
index b83a8e4f..79bfa1ed 100644
--- a/jamal-snippet/src/main/java/javax0/jamal/snippet/XmlFormat.java
+++ b/jamal-snippet/src/main/java/javax0/jamal/snippet/XmlFormat.java
@@ -99,8 +99,7 @@ public void close() throws BadSyntax {
if (output != null) {
skipWhiteSpaces(output);
final var result = formatXml(output.toString(), tabsize, thin, wrong);
- output.getSB().setLength(0);
- output.getSB().append(result);
+ output.replace(result);
}
}
diff --git a/jamal-snippet/src/main/java/javax0/jamal/snippet/XmlInsert.java b/jamal-snippet/src/main/java/javax0/jamal/snippet/XmlInsert.java
index 598f7a88..d7503622 100644
--- a/jamal-snippet/src/main/java/javax0/jamal/snippet/XmlInsert.java
+++ b/jamal-snippet/src/main/java/javax0/jamal/snippet/XmlInsert.java
@@ -131,8 +131,7 @@ public void close() throws BadSyntax {
}
}
final var result = XmlDocument.formatDocument(doc, "" + tabsize);
- output.getSB().setLength(0);
- output.getSB().append(result);
+ output.replace(result);
} catch (ParserConfigurationException | SAXException | IOException | TransformerException e) {
throw new BadSyntax("Error while inserting XML nodes into the final document.", e);
}
diff --git a/jamal-sql/demodb.mv.db b/jamal-sql/demodb.mv.db
index 95702404..5e88ffee 100644
Binary files a/jamal-sql/demodb.mv.db and b/jamal-sql/demodb.mv.db differ
diff --git a/jamal-tools/src/main/java/javax0/jamal/tools/HexDumper.java b/jamal-tools/src/main/java/javax0/jamal/tools/HexDumper.java
index 959defd7..e62767c6 100644
--- a/jamal-tools/src/main/java/javax0/jamal/tools/HexDumper.java
+++ b/jamal-tools/src/main/java/javax0/jamal/tools/HexDumper.java
@@ -1,8 +1,32 @@
package javax0.jamal.tools;
+/**
+ * The {@code HexDumper} class provides a utility method to encode a byte array into a hexadecimal string representation.
+ * It is useful for converting binary data into a human-readable hexadecimal format, often needed in debugging,
+ * logging, or data serialization.
+ */
public class HexDumper {
- private static final char[] LOOKUP_TABLE = new char[]{0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66};
+ /**
+ * A lookup table for hexadecimal characters. The table contains the characters
+ * '0'-'9' and 'a'-'f', corresponding to the hexadecimal digits.
+ */
+ private static final char[] LOOKUP_TABLE = new char[]{
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
+ 0x61, 0x62, 0x63, 0x64, 0x65, 0x66
+ };
+
+ /**
+ * Encodes the given byte array into a hexadecimal string representation.
+ *
+ * Each byte in the input array is represented by two hexadecimal characters.
+ * The method processes each byte in the array, using the higher and lower 4 bits
+ * to index into the lookup table to determine the corresponding hexadecimal characters.
+ *
+ * @param byteArray the byte array to be encoded into hexadecimal format
+ * @return a string containing the hexadecimal representation of the input byte array
+ * @throws NullPointerException if the input byte array is {@code null}
+ */
public static String encode(byte[] byteArray) {
final char[] buffer = new char[byteArray.length * 2];
for (int i = 0; i < byteArray.length; i++) {
diff --git a/jamal-word/src/main/java/javax0/jamal/poi/word/XWPFAbstractInput.java b/jamal-word/src/main/java/javax0/jamal/poi/word/XWPFAbstractInput.java
new file mode 100644
index 00000000..20f9c791
--- /dev/null
+++ b/jamal-word/src/main/java/javax0/jamal/poi/word/XWPFAbstractInput.java
@@ -0,0 +1,183 @@
+package javax0.jamal.poi.word;
+
+import javax0.jamal.api.Position;
+
+public class XWPFAbstractInput implements javax0.jamal.api.Input {
+ protected final StringBuilder input;
+ private final Position pos;
+
+
+ /**
+ * Create an empty input, which may also serve as an output where the characters are collected.
+ */
+ public XWPFAbstractInput() {
+ this("");
+ }
+
+ /**
+ * Create an empty input with the specified parent.
+ *
+ * @param parent the parent of the new input
+ */
+ public XWPFAbstractInput(Position parent) {
+ this("", new Position(null, 1, 1, parent));
+ }
+
+ /**
+ * Create an input from the string builder with the given position.
+ * The string builder is directly used to create the input and will be consumed as the input is consumed.
+ *
+ * @param input the character of the input initially
+ * @param pos the position of the input initially
+ */
+ public XWPFAbstractInput(StringBuilder input, Position pos) {
+ this.input = input;
+ this.pos = new Position(pos);
+ }
+
+ /**
+ * Creates a new input from the characters of the string with the given position.
+ *
+ * @param input the character of the input
+ * @param pos the position of the input initially
+ */
+ public XWPFAbstractInput(String input, Position pos) {
+ this(new StringBuilder(input), pos);
+ }
+
+
+ /**
+ * Create new input from the characters of te string with null position.
+ *
+ * @param string the characters of the new input
+ */
+ public XWPFAbstractInput(String string) {
+ this(string, null);
+ }
+
+ /**
+ * Create an empty input, which may also serve as an output where the characters are collected.
+ *
+ * @return the new input
+ */
+ public static javax0.jamal.tools.Input makeInput() {
+ return new javax0.jamal.tools.Input();
+ }
+
+ /**
+ * Create an empty input with the specified parent.
+ *
+ * @param parent the parent of the new input
+ * @return the new input
+ */
+ public static javax0.jamal.tools.Input makeInput(Position parent) {
+ return new javax0.jamal.tools.Input(parent);
+ }
+
+ /**
+ * Create a new input from the characters of the string with null position information.
+ *
+ * @param string the characters of the new input
+ * @return the new input
+ */
+ public static javax0.jamal.tools.Input makeInput(String string) {
+ return new javax0.jamal.tools.Input(string);
+ }
+
+
+ /**
+ * Create an input from the string builder with the given position.
+ * The string builder is directly used to create the input and will be consumed as the input is consumed.
+ *
+ * @param input the character of the input initially
+ * @param pos the position of the input initially
+ * @return the new input
+ */
+ public static javax0.jamal.tools.Input makeInput(StringBuilder input, Position pos) {
+ return new javax0.jamal.tools.Input(input, pos);
+ }
+
+ /**
+ * Creates a new input from the characters of the string with the given position.
+ *
+ * @param input the character of the input
+ * @param pos the position of the input initially
+ * @return the new input
+ */
+ public static javax0.jamal.tools.Input makeInput(String input, Position pos) {
+ return new javax0.jamal.tools.Input(input, pos);
+ }
+
+ /**
+ * Make a new input from the characters of the input given as an argument. The new input inherits the position
+ * of the argument and clones it (any change in the created input will not alter the position of the original
+ * input).
+ *
+ * @param input the input from which the characters and the position are used
+ * @return the new input.
+ */
+ public static javax0.jamal.tools.Input makeInput(javax0.jamal.api.Input input) {
+ return new javax0.jamal.tools.Input(input.toString(), input.getPosition());
+ }
+
+
+ @Override
+ public int getLine() {
+ return pos.line;
+ }
+
+ @Override
+ public int getColumn() {
+ return pos.column;
+ }
+
+ @Override
+ public void stepLine() {
+ pos.line++;
+ pos.charpos++;
+ pos.column = 1;
+ }
+
+ @Override
+ public void stepColumn() {
+ pos.column++;
+ pos.charpos++;
+ }
+
+
+ @Override
+ public StringBuilder getSB() {
+ return input;
+ }
+
+ /**
+ * Return a clone of the position of the input.
+ *
+ * @return the position copy.
+ */
+ @Override
+ public Position getPosition() {
+ return pos.clone();
+ }
+
+ /**
+ * Get the file name of the position of the input. This is called {@code getReference()} because this file name is
+ * the reference file name to calculate the absolute path of a file specified as relative file name. The relative
+ * file names are always relative to the input in which they are specified.
+ *
+ * @return the file name of the position of the input
+ */
+ @Override
+ public String getReference() {
+ return pos.file;
+ }
+
+ @Override
+ public String toString() {
+ return (input == null ? "null" : input.toString());
+ }
+
+}
+
+
+
diff --git a/jamal-word/src/main/java/javax0/jamal/poi/word/XWPFInput.java b/jamal-word/src/main/java/javax0/jamal/poi/word/XWPFInput.java
index 3ec0410f..f85e0208 100644
--- a/jamal-word/src/main/java/javax0/jamal/poi/word/XWPFInput.java
+++ b/jamal-word/src/main/java/javax0/jamal/poi/word/XWPFInput.java
@@ -1,7 +1,6 @@
package javax0.jamal.poi.word;
import javax0.jamal.api.Position;
-import javax0.jamal.tools.Input;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFRun;
@@ -41,13 +40,11 @@
*
* It is also a limitation of this approach that you cannot use, at least as for now, deferred actions.
*/
-public class XWPFInput extends Input {
+public class XWPFInput extends XWPFAbstractInput {
final XWPFDocument document;
- final XWPFTableCell cell;
+ private final XWPFTableCell cell;
final List paragraphs;
- final Position pos;
- final StringBuilder sb;
/**
* Create a new input that will harvest the paragraphs so long as long it must. This input stops as soon as it can.
@@ -79,11 +76,9 @@ public class XWPFInput extends Input {
*/
public XWPFInput(XWPFDocument document, XWPFTableCell cell, List paragraphs, Position pos) {
super("", pos);
- this.sb = getSB();
this.document = document;
this.cell = cell;
this.paragraphs = paragraphs;
- this.pos = pos;
}
/**
@@ -135,7 +130,7 @@ public void setStart(int paragraphIndex, int runIndex) {
runEndIndex = runStartIndex;
if (paragraphStartIndex < paragraphs.size() && runStartIndex < paragraphs.get(paragraphStartIndex).getRuns().size()) {
final var text = paragraphs.get(paragraphStartIndex).getRuns().get(runStartIndex).getText(0);
- sb.append(text == null ? "" : text);
+ input.append(text == null ? "" : text);
}
}
@@ -191,7 +186,7 @@ private static boolean isEmpty(final XWPFParagraph paragraph) {
*/
@Override
public boolean isEmpty() {
- if (sb.length() > 0) {
+ if (input.length() > 0) {
return false;
}
return paragraphEndIndex == paragraphs.size() - 1 && runEndIndex == paragraphs.get(paragraphEndIndex).getRuns().size() - 1;
@@ -210,17 +205,17 @@ public boolean isEmpty() {
*/
@Override
public char charAt(int index) {
- if (index < sb.length()) {
- return sb.charAt(index);
+ if (index < input.length()) {
+ return input.charAt(index);
}
- while (index >= sb.length()) {
- final var l = sb.length();
+ while (index >= input.length()) {
+ final var l = input.length();
appendOneRun();
if (empty()) {// nothing was appended
throw new StringIndexOutOfBoundsException(index);
}
}
- return sb.charAt(index);
+ return input.charAt(index);
}
/**
@@ -285,10 +280,10 @@ public int indexOf(String s, int before) {
*/
@Override
public int indexOf(String str) {
- while (sb.length() < str.length() && thereAreMOreRuns() && str.startsWith(sb.toString())) {
+ while (input.length() < str.length() && thereAreMOreRuns() && str.startsWith(input.toString())) {
appendOneRun();
}
- return sb.indexOf(str);
+ return input.indexOf(str);
}
private boolean thereAreMOreRuns() {
@@ -302,7 +297,7 @@ private boolean thereAreMOreRuns() {
public boolean empty() {
return paragraphEndIndex >= paragraphs.size() - 1 &&
runEndIndex >= paragraphs.get(paragraphEndIndex).getRuns().size() - 1 &&
- sb.length() == 0;
+ input.length() == 0;
}
/**
@@ -315,15 +310,15 @@ private void appendOneRun() {
runEndIndex++;
}
if (runEndIndex < endRuns.size()) {
- sb.append(endRuns.get(runEndIndex).getText(0));
+ input.append(endRuns.get(runEndIndex).getText(0));
} else while (paragraphEndIndex + 1 < paragraphs.size()) {
paragraphEndIndex++;
runEndIndex = 0;
- sb.append("\n");
+ input.append("\n");
final var endRunsNext = paragraphs.get(paragraphEndIndex).getRuns();
if (!endRunsNext.isEmpty()) {
final var text = endRunsNext.get(0).getText(0);
- sb.append(text == null ? "" : text);
+ input.append(text == null ? "" : text);
break;
}
}
diff --git a/jamal-word/src/test/resources/demoConverted.docx b/jamal-word/src/test/resources/demoConverted.docx
index 800a55b9..b281023a 100644
Binary files a/jamal-word/src/test/resources/demoConverted.docx and b/jamal-word/src/test/resources/demoConverted.docx differ
diff --git a/jamal-word/src/test/resources/includetestConverted.docx b/jamal-word/src/test/resources/includetestConverted.docx
index c59a76ec..53f0a886 100644
Binary files a/jamal-word/src/test/resources/includetestConverted.docx and b/jamal-word/src/test/resources/includetestConverted.docx differ
diff --git a/jamal-word/src/test/resources/pictureConverted.docx b/jamal-word/src/test/resources/pictureConverted.docx
index 8629f649..aa73805c 100644
Binary files a/jamal-word/src/test/resources/pictureConverted.docx and b/jamal-word/src/test/resources/pictureConverted.docx differ
diff --git a/jamal-word/src/test/resources/sampleConverted.docx b/jamal-word/src/test/resources/sampleConverted.docx
index 97006172..a9d117f2 100644
Binary files a/jamal-word/src/test/resources/sampleConverted.docx and b/jamal-word/src/test/resources/sampleConverted.docx differ
diff --git a/jamal-xls/pom.xml b/jamal-xls/pom.xml
index 9dfbd9b1..7c2c0f09 100644
--- a/jamal-xls/pom.xml
+++ b/jamal-xls/pom.xml
@@ -108,7 +108,7 @@
org.apache.commons
commons-compress
- 1.26.2
+ 1.27.1
\ No newline at end of file
diff --git a/jamal-yaml/src/main/java/javax0/jamal/yaml/Output.java b/jamal-yaml/src/main/java/javax0/jamal/yaml/Output.java
index bee91713..55109dc4 100644
--- a/jamal-yaml/src/main/java/javax0/jamal/yaml/Output.java
+++ b/jamal-yaml/src/main/java/javax0/jamal/yaml/Output.java
@@ -23,8 +23,7 @@ public void close() throws Exception {
Resolver.resolve(yamlObject, processor, clone, copy);
final var out = new StringWriter();
yaml.dump(yamlObject.getObject(), out);
- output.reset();
- output.getSB().append(out);
+ output.replace(out);
}
@Override
diff --git a/jamal.sh b/jamal.sh
index 2f96689d..7b386274 100755
--- a/jamal.sh
+++ b/jamal.sh
@@ -122,8 +122,8 @@ download "org.apache.poi" "poi-ooxml" "5.3.0"
download "org.apache.poi" "poi-ooxml-lite" "5.3.0"
download "org.apache.xmlbeans" "xmlbeans" "5.2.1"
download "com.github.virtuald" "curvesapi" "1.08"
-download "org.apache.commons" "commons-compress" "1.26.2"
-download "org.apache.commons" "commons-lang3" "3.14.0"
+download "org.apache.commons" "commons-compress" "1.27.1"
+download "org.apache.commons" "commons-lang3" "3.16.0"
download "com.javax0.jamal" "jamal-rest" "2.8.2-SNAPSHOT"
download "com.javax0.jamal" "jamal-git" "2.8.2-SNAPSHOT"
download "com.javax0.jamal" "jamal-extensions" "2.8.2-SNAPSHOT"
diff --git a/pom.xml b/pom.xml
index be5d1381..012a5087 100644
--- a/pom.xml
+++ b/pom.xml
@@ -165,7 +165,7 @@
org.apache.maven.plugins
maven-surefire-plugin
- 3.5.1
+ 3.5.2
org.slf4j
diff --git a/version.jim b/version.jim
index 8c663ee2..eeb43e8f 100644
--- a/version.jim
+++ b/version.jim
@@ -69,7 +69,7 @@ MAVEN_PLUGIN_API=3.9.9 -- https://repo.maven.apache.org/mave
MAVEN_PLUGIN_ANNOTATIONS=3.13.1 -- https://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/maven-plugin-annotations/
MAVEN_PLUGIN_PLUGIN_VERSION=3.13.1 -- https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-plugin-plugin
SONATYPE_PLUGIN_VERSION=1.7.0 -- https://repo.maven.apache.org/maven2/org/sonatype/plugins/nexus-staging-maven-plugin
-SUREFIRE_PLUGIN_VERSION=3.5.1 -- https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-surefire-plugin
+SUREFIRE_PLUGIN_VERSION=3.5.2 -- https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-surefire-plugin
MAVEN_SOURCE_PLUGIN_VERSION=3.3.1 -- https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-source-plugin
APPASSEMBLER_PLUGIN_VERSION=2.1.0 -- https://repo.maven.apache.org/maven2/org/codehaus/mojo/appassembler-maven-plugin
MAVEN_DEPENDENCY_PLUGIN_VERSION=3.8.1 -- https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin
@@ -82,8 +82,8 @@ JUPITER_VERSION=5.11.3 -- https://repo.maven.apache.org/mave
MOCKITO_VERSION=5.14.2 -- https://repo.maven.apache.org/maven2/org/mockito/mockito-core/
-- dependencies needed for the Jamal libraries
-JRUBY_VERSION=9.4.8.0 -- https://repo.maven.apache.org/maven2/org/jruby/jruby-complete
-GROOVY_VERSION=3.0.22 -- https://repo.maven.apache.org/maven2/org/codehaus/groovy/groovy-jsr223
+JRUBY_VERSION=9.4.9.0 -- https://repo.maven.apache.org/maven2/org/jruby/jruby-complete
+GROOVY_VERSION=3.0.23 -- https://repo.maven.apache.org/maven2/org/codehaus/groovy/groovy-jsr223
OGNL_VERSION=3.4.3 -- https://repo.maven.apache.org/maven2/ognl/ognl
SNAKEYAML_VERSION=2.3 -- https://repo.maven.apache.org/maven2/org/yaml/snakeyaml
JSON_ORG_VERSION=20240303 -- https://repo.maven.apache.org/maven2/org/json/json/
@@ -104,6 +104,6 @@ JSQLPARSER_VERSION=5.0 -- https://repo.maven.apache.org/mave
-- dependencies needed for the Maven extension (not the plugin)
MAVEN_CORE_VERSION=3.9.8 -- https://repo.maven.apache.org/maven2/org/apache/maven/maven-core
PLEXUS_COMPONENT_METADATA_VERSION=2.2.0 -- https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-component-metadata
-COMMONS_COMPRESS_VERSION=1.26.2 -- https://repo.maven.apache.org/maven2/org/apache/commons/commons-compress
-JSOUP_VERSION=1.18.1 -- https://repo.maven.apache.org/maven2/org/jsoup/jsoup
+COMMONS_COMPRESS_VERSION=1.27.1 -- https://repo.maven.apache.org/maven2/org/apache/commons/commons-compress
+JSOUP_VERSION=1.18.3 -- https://repo.maven.apache.org/maven2/org/jsoup/jsoup
}
diff --git a/versions.adoc b/versions.adoc
index 7a5d70bb..a05d6f94 100644
--- a/versions.adoc
+++ b/versions.adoc
@@ -21,13 +21,13 @@ If all dependencies are up-to-date, then the output should not contain any `*[re
We do not upgrade to beta versions.
-* `OK` `MAVEN_JAVADOC_PLUGIN_VERSION` `3.10.1`
+* `*[red]#NO#*` `MAVEN_JAVADOC_PLUGIN_VERSION` `3.10.1` `*[red]#upgrade to 3.11.2#*`
* `OK` `MAVEN_GPG_PLUGIN_VERSION` `3.2.7`
* `OK` `MAVEN_ASSEMBLY_PLUGIN_VERSION` `3.7.1`
-* `*[red]#NO#*` `MAVEN_PLUGIN_API` `3.9.9` `*[red]#upgrade to 4.0.0-beta-5#*`
+* `*[red]#NO#*` `MAVEN_PLUGIN_API` `3.9.9` `*[red]#upgrade to 4.0.0-rc-1#*`
+
We do not upgrade to beta versions.
@@ -41,7 +41,7 @@ We do not upgrade to beta versions.
* `OK` `SONATYPE_PLUGIN_VERSION` `1.7.0`
-* `OK` `SUREFIRE_PLUGIN_VERSION` `3.5.1`
+* `OK` `SUREFIRE_PLUGIN_VERSION` `3.5.2`
* `*[red]#NO#*` `MAVEN_SOURCE_PLUGIN_VERSION` `3.3.1` `*[red]#upgrade to 4.0.0-beta-1#*`
+
@@ -55,9 +55,9 @@ We do not upgrade to beta versions.
* `OK` `MOCKITO_VERSION` `5.14.2`
-* `OK` `JRUBY_VERSION` `9.4.8.0`
+* `OK` `JRUBY_VERSION` `9.4.9.0`
-* `OK` `GROOVY_VERSION` `3.0.22`
+* `OK` `GROOVY_VERSION` `3.0.23`
* `OK` `OGNL_VERSION` `3.4.3`
@@ -76,13 +76,13 @@ We do not upgrade to beta versions.
When upgrading the newer version, check that the dependency on
-* `*[red]#NO#*` `COMMONS_COMPRESS_VERSION` `1.26.2` `*[red]#upgrade to 1.27.1#*`
+* `OK` `COMMONS_COMPRESS_VERSION` `1.27.1`
of the OOXML package is higher than 1.25.0
Version 1.25.0 has two vulnerabilities, CVE-2024-26308 and CVE-2024-25710.
The OOXML library version 5.2.5 depends on the vulnerable version.
-The version 1.26.2 of the compress library is explicitly added to the `jamal-xls` module as a dependency.
+The version 1.27.1 of the compress library is explicitly added to the `jamal-xls` module as a dependency.
It may not be needed when the poi-ooxml library also updates its dependency.
It has to be checked when stepping up from 5.2.5 to a newer version.
====
@@ -106,7 +106,7 @@ Version 2.5.2 changed the name of the module.
If we change the name of the module some tests that depend on prior versions of Jamal do not work.
To upgrade we have to remove the dependency from the snippet module and move the dependent macros to a different module.
-* `*[red]#NO#*` `MAVEN_CORE_VERSION` `3.9.8` `*[red]#upgrade to 4.0.0-beta-5#*`
+* `*[red]#NO#*` `MAVEN_CORE_VERSION` `3.9.8` `*[red]#upgrade to 4.0.0-rc-1#*`
+
We do not upgrade to beta versions.
@@ -122,4 +122,4 @@ We do not upgrade to beta versions.
* `OK` `JSQLPARSER_VERSION` `5.0`
-* `OK` `JSOUP_VERSION` `1.18.1`
\ No newline at end of file
+* `OK` `JSOUP_VERSION` `1.18.3`
\ No newline at end of file