Dovx4J: Enabling page numbers in ToC results in TocException - java

I am using Docx4j in an internship project and when I try to generate a ToC with page numbers it does not work.
Executing the code with
if (template.isGenerateToc()) {
Toc.setTocHeadingText("Inhaltsverzeichnis");
TocGenerator tocGenerator = new TocGenerator(wordPackage);
tocGenerator.generateToc(2, " TOC \\o \"1-3\" \\h \\z \\u ", true);
}
Works perfectly fine, but results in no page numbers in the .docx (when exporting to PDF via the Gotenberg API (https://gotenberg.dev), the page numbers are existant and correct).
When I try to pass "false" for the third parameter, the application crashes with the following exception/stacktrace:
org.docx4j.toc.TocException: Exception exporting package
at org.docx4j.toc.TocGenerator.getPageNumbersMapViaFOP(TocGenerator.java:871)
at org.docx4j.toc.TocGenerator.getPageNumbersMap(TocGenerator.java:694)
at org.docx4j.toc.TocGenerator.populateToc(TocGenerator.java:441)
at org.docx4j.toc.TocGenerator.generateToc(TocGenerator.java:306)
at org.docx4j.toc.TocGenerator.generateToc(TocGenerator.java:234)
at org.docx4j.toc.TocGenerator.generateToc(TocGenerator.java:194)
If usefull: This is my TocHeading:
private static String XML_TOCHeading_BasedOn_Nothing = "<w:style w:styleId=\"TOCHeading\" w:type=\"paragraph\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\">"
+ "<w:name w:val=\"TOC Heading\"/>"
// + "<w:basedOn w:val=\"Heading1\"/>" // would be ok if provided already present, since
+ "<w:next w:val=\"Normal\"/>"
+ "<w:uiPriority w:val=\"39\"/>"
+ "<w:semiHidden/>"
+ "<w:unhideWhenUsed/>"
+ "<w:qFormat/>"
+ "<w:pPr>"
+ "<w:keepNext/>"
+ "<w:keepLines/>"
+ "<w:spacing w:after=\"150\" w:before=\"480\"/>"
+ "<w:outlineLvl w:val=\"9\"/>"
+ "</w:pPr>"
+ "<w:rPr>"
+ "<w:rFonts w:ascii=\"Arial\" w:hAnsi=\"Arial\" w:cs=\"Arial\"/>"
+ "<w:b/>"
+ "<w:bCs/>"
+ "<w:sz w:val=\"36\"/>"
+ "<w:szCs w:val=\"36\"/>"
+ "</w:rPr>"
+ "</w:style>";
Any ideas on how to fix this exception and generate page numbers in my toc?
EDIT:
I updated the dependencies and now I am still getting the TocException but now with another cause:
Caused by: org.docx4j.openpackaging.exceptions.Docx4JException: Exception exporting package
at org.docx4j.convert.out.common.AbstractExporter.export(AbstractExporter.java:106)
at org.docx4j.Docx4J.toFO(Docx4J.java:734)
at org.docx4j.toc.TocGenerator.getPageNumbersMapViaFOP(TocGenerator.java:843)
... 97 more
Caused by: java.lang.NullPointerException
at org.docx4j.convert.out.common.preprocess.Containerization.borderChanged(Containerization.java:390)
at org.docx4j.convert.out.common.preprocess.Containerization.bordersChanged(Containerization.java:377)
at org.docx4j.convert.out.common.preprocess.Containerization.groupBodyContent(Containerization.java:204)
at org.docx4j.convert.out.common.preprocess.Containerization.groupAdjacentBorders(Containerization.java:129)
at org.docx4j.convert.out.common.preprocess.Containerization.process(Containerization.java:120)
at org.docx4j.convert.out.common.Preprocess.process(Preprocess.java:165)
at org.docx4j.convert.out.common.AbstractWmlExporter.preprocess(AbstractWmlExporter.java:51)
at org.docx4j.convert.out.common.AbstractWmlExporter.preprocess(AbstractWmlExporter.java:32)
at org.docx4j.convert.out.common.AbstractExporter.export(AbstractExporter.java:63)

Not sure which version of docx4j you are using, but generally, to update page numbers, you need FOP on your classpath.
We broke this in 8.3.3; it is fixed at https://github.com/plutext/docx4j/commit/50cfa5cabe08ab133f28c54b59f73d082d3e80a4#diff-29cfd63b63bfe585aa3468870ca54f1afb6e2246342c396155801b0d0aa9ae43L763
So you could try 8.3.2 with FOP on your classpath.
Alternatively, you could try the approach described at https://www.docx4java.org/blog/2020/03/documents4j-for-toc-update/
See further:
documents4j-local: https://github.com/plutext/docx4j/blob/master/docx4j-samples-documents4j-local/src/main/java/org/docx4j/samples/documents4j/local/TocOperations.java
documents4j-remote: https://github.com/plutext/docx4j/tree/master/docx4j-samples-documents4j-remote

Related

Face encodings/recognize using dlib in android

I am trying to use dlib in android. I integrated dlib in android app and able to get the face landmarks(Detection) but I need to get the encodings(128 points) signature of the face also, in order to (Recognize) the face.
but I couldn't find:
compute_face_descriptor()
or even
face_encodings()
that are used to encode the face.
Any possible solution how to encode detected faces on android?
face_encodings input -> An image that includes a human face and face landmarks (x,y) positions for each landmark:
return [{
"chin": points[0:17],
"left_eyebrow": points[17:22],
"right_eyebrow": points[22:27],
"nose_bridge": points[27:31],
"nose_tip": points[31:36],
"left_eye": points[36:42],
"right_eye": points[42:48],
"top_lip": points[48:55] + [points[64]] + [points[63]] + [points[62]] + [points[61]] + [points[60]],
"bottom_lip": points[54:60] + [points[48]] + [points[60]] + [points[67]] + [points[66]] + [points[65]] + [points[64]]
} for points in landmarks_as_tuples]
(face_encodings output):
return [np.array(face_encoder.compute_face_descriptor(face_image, raw_landmark_set, num_jitters)) for raw_landmark_set in raw_landmarks]
example:
array([-0.16420187, 0.1202074 , 0.04824107, 0.0310235 ,
-0.08204676,
0.01609662, -0.00988434, -0.1141774 , 0.13052855, -0.08573464,
0.12388597, -0.0552358 , -0.28384259, 0.02778015, 0.00979715,
0.07858013, -0.06921518, -0.10482424, -0.06367593, -0.09426223,
0.01720981, 0.02882373, 0.10169367, 0.07427052, -0.13133635,
-0.36511168, -0.12455334, -0.01808409, 0.05698581, -0.11716878,
-0.01069255, 0.02384903, -0.18379349, -0.01020074, -0.00822366,
0.09377331, -0.11172572, -0.09475195, 0.17303641, 0.05267501,
-0.09078838, -0.0462004 , 0.01025385, 0.34483802, 0.16765046,
0.08589408, 0.02387796, -0.10103907, 0.10045047, -0.22485517,
0.06756001, 0.15834026, 0.01401624, 0.04358319, 0.07435159,
-0.11184766, 0.07005014, 0.09503514, -0.18151978, 0.11087804,
0.11130056, -0.01948802, -0.02574608, -0.06022272, 0.17850368,
0.06385814, -0.08742134, -0.12314001, 0.09985813, -0.18121578,
0.01201929, 0.11202402, -0.11225995, -0.24819884, -0.23437411,
0.06914665, 0.42619887, 0.20492068, -0.05618291, -0.01572027,
-0.04358935, -0.03294446, 0.10202869, 0.06307103, -0.12709795,
-0.08882779, -0.14143534, 0.10135166, 0.20507583, 0.0193306 ,
-0.08980452, 0.20774253, 0.03527984, -0.00467462, 0.00076468,
0.06649322, -0.18126528, 0.03081046, -0.13404782, -0.05124934,
0.0402966 , -0.07325267, 0.00991299, 0.103517 , -0.16747224])
What I want, is to implement face_encodings function on android
(native c++).

Why does a variable of type com.ibm.jms.JMSTextMessage print truncated content and ellipses (...)?

I would like to understand why a variable of type com.ibm.jms.JMSTextMessage is printed with truncated content and ellipses (...) when converted to string.
I have this code in a JSR223 Sampler in JMeter:
import com.ibm.msg.client.jms.JmsConnectionFactory
import com.ibm.msg.client.jms.JmsFactoryFactory
import com.ibm.msg.client.wmq.WMQConstants
import javax.jms.Session
import javax.jms.TextMessage
def hostName = "127.0.0.1"
def hostPort = 1414
def channelName = "DEV.APP.SVRCONN"
def queueManagerName = "QM1"
def queueName = "DEV.QUEUE.1"
def ff = JmsFactoryFactory.getInstance(WMQConstants.WMQ_PROVIDER)
def cf = ff.createConnectionFactory()
cf.setStringProperty(WMQConstants.WMQ_HOST_NAME, hostName)
cf.setIntProperty(WMQConstants.WMQ_PORT, hostPort)
cf.setStringProperty(WMQConstants.WMQ_CHANNEL, channelName)
cf.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_CLIENT)
def connInboundQueue = cf.createConnection("user", "password")
def sessInboundQueue = connInboundQueue.createSession(false, Session.AUTO_ACKNOWLEDGE)
def payload = "AAA:+.? '\n" +
"ABC+ABCD:1+ABCDEFG:ZZ+ABCDEF:ZZ+123456:2042+12345678901++ABCD'\n" +
"DEF+ABCD+LH+FVKJUB+20000:2042+Y1234567+UN+D:21B'\n" +
"GHI+1+ABCD:D:11A:AA:ABCD+ABCD12345678901123ABC123456'\n" +
"JKL+745'\n" +
"HHH+TN:IIAA891011213531235BNM422244:::001'\n" +
"CCC+NT+++ABCDEFGHIJKLMNOPQRS'\n" +
"STU+00123456789012:UF+0000000000:GY'\n" +
"VXY+50+MI1234+++MI'\n" +
"AAA+235+ABC'\n" +
"BBB+200:3202062000:301'\n" +
"FFF+90+USA'\n" +
"BBB+232:2101051135:201'\n" +
"CCC+FF+++AaBaBa001:TEST1'\n" +
"DDD+3++G'\n" +
"EEE+329:711013'\n" +
"FFF+178+XXX'\n" +
"FFF+179+YYY'\n" +
"GGG+2+ZZZ'\n" +
"HHH+BXG:ABCDEF'\n" +
"HHH+ABC:12AB3E01234E8UD8'\n" +
"III+P:110:111+100000001'\n" +
"EEE+36:281105'\n" +
"FFF+91+ASD'\n" +
"VVV+50:2'\n" +
"XXX+0011+1'\n" +
"YYY+1+U0123456'\n" +
"ZZZ+1+U1234560002'\n"
TextMessage msg = sessInboundQueue.createTextMessage()
msg.setText(payload)
log.info(msg.toString())
log.info(msg.getClass().toString())
log.info(msg.getText())
I would like to understand why log.info(msg.toString()) does not print the whole text content and show ellipses after some point (...)
If I do log.info(msg.getText()), I can see the whole text message.
Here is the print outcome in jmeter's console:
2021-10-31 22:05:25,491 INFO o.a.j.p.j.s.J.JSR223 Sampler - Producer - Inbound Queue:
JMSMessage class: jms_text
JMSType: null
JMSDeliveryMode: 2
JMSDeliveryDelay: 0
JMSDeliveryTime: 1635710725481
JMSExpiration: 0
JMSPriority: 4
JMSMessageID: ID:414d5120514d312020202020202020201f537d6101c31040
JMSTimestamp: 1635710725481
JMSCorrelationID: 1757416553
JMSDestination: queue:///DEV.QUEUE.1
JMSReplyTo: null
JMSRedelivered: false
JMSXAppID: 4.1\bin\ApacheJMeter.jar
JMSXDeliveryCount: 0
JMSXUserID: mquser1
JMS_IBM_PutApplType: 28
JMS_IBM_PutDate: 20211031
JMS_IBM_PutTime: 20052548
AAA:+.? '
ABC+ABCD:1+ABCDEFG:ZZ+ABCDEF:ZZ+123456:2042+12345678901++ABCD'
DEF+ABCD+LH+FVKJUB+20000:20 ...
2021-10-31 22:05:25,491 INFO o.a.j.p.j.s.J.JSR223 Sampler - Producer - Inbound Queue: class com.ibm.jms.JMSTextMessage
2021-10-31 22:05:25,491 INFO o.a.j.p.j.s.J.JSR223 Sampler - Producer - Inbound Queue: AAA:+.? '
ABC+ABCD:1+ABCDEFG:ZZ+ABCDEF:ZZ+123456:2042+12345678901++ABCD'
DEF+ABCD+LH+FVKJUB+20000:2042+Y1234567+UN+D:21B'
GHI+1+ABCD:D:11A:AA:ABCD+ABCD12345678901123ABC123456'
JKL+745'
HHH+TN:IIAA891011213531235BNM422244:::001'
CCC+NT+++ABCDEFGHIJKLMNOPQRS'
STU+00123456789012:UF+0000000000:GY'
VXY+50+MI1234+++MI'
AAA+235+ABC'
BBB+200:3202062000:301'
FFF+90+USA'
BBB+232:2101051135:201'
CCC+FF+++AaBaBa001:TEST1'
DDD+3++G'
EEE+329:711013'
FFF+178+XXX'
FFF+179+YYY'
GGG+2+ZZZ'
HHH+BXG:ABCDEF'
HHH+ABC:12AB3E01234E8UD8'
III+P:110:111+100000001'
EEE+36:281105'
FFF+91+ASD'
VVV+50:2'
XXX+0011+1'
YYY+1+U0123456'
ZZZ+1+U1234560002'
According to the IBM documentation com.ibm.jms.JMSTextMessage inherits the toString() implementation from com.ibm.jms.JMSMessage and the JavaDoc for that method says:
Gets a String containing a formatted version of the message header.
My guess is that the body is cut off simply because toString() is really just meant to give you the header. However, only IBM would know for sure why it works that way. To be clear, there is no guarantee that toString() will (or should) return the entire body of the message.
If you really want to inspect the body of the text message you should invoke getText(). This method is required to return the body of the text-message according to the JMS JavaDoc as well as IBM's own JavaDoc. Both state:
Gets the String containing this message's data. The default value is null.

java.util.concurrent.TimeoutException during reading S3 bucket from SDK

I have written a piece of code in Java that connect to S3 and read list of files in the bucket. I tested the code and is working properly (in both local and EC2). However, when I run the code in EMR I face this error:
"java.util.concurrent.TimeoutException: Futures timed out after [100000 milliseconds]
I get suspected it can be because of ClientConfiguration and I increased all of the Timeout, RequestTimeout and SocketTimeOut to 5 minutes, but still not change and again I get the same error. What can be reason of this error? The content of bucket is big, but in client mode in EC2, I can read all of them in 3 minutes! something should be wrong!
and this is my code:
try {
ListVersionsRequest request = new ListVersionsRequest().withBucketName(bucketname).withPrefix(prefix)
.withMaxResults(999999);
VersionListing versionListing;
do {
versionListing = s3.listVersions(request);
for (S3VersionSummary versionSummary : versionListing.getVersionSummaries()) {
if (conditions.length != 0)
if (contain_str(versionSummary.getKey(), conditions))
collect.add("s3://" + bucketname + "/" + versionSummary.getKey());
else
continue;
else
collect.add("s3://" + bucketname + "/" + versionSummary.getKey());
}
request.setKeyMarker(versionListing.getNextKeyMarker());
request.setVersionIdMarker(versionListing.getNextVersionIdMarker());
} while (versionListing.isTruncated()); //check remaining pagination
}
catch (AmazonServiceException ase) {
System.out.println("Caught an AmazonServiceException, " +
"which means your request made it " +
"to Amazon S3, but was rejected with an error response " +
"for some reason.");
System.out.println("Error Message: " + ase.getMessage());
System.out.println("HTTP Status Code: " + ase.getStatusCode());
System.out.println("AWS Error Code: " + ase.getErrorCode());
System.out.println("Error Type: " + ase.getErrorType());
System.out.println("Request ID: " + ase.getRequestId());
} catch (AmazonClientException ace) {
System.out.println("Caught an AmazonClientException, " +
"which means the client encountered " +
"an internal error while trying to communicate" +
" with S3, " +
"such as not being able to access the network.");
System.out.println("Error Message: " + ace.getMessage());
}
finally {
Collections.shuffle(collect); //randomizing the file orders
if (collect.size() * percentage < 1) // if sample number is less than 1 take the whole data
percentage = 1;
collect2 = collect.subList(0, (int) (collect.size() * percentage)); //take the samples
return String.join(",", collect2);
}
And the error:
18/01/04 10:36:31 ERROR ApplicationMaster: Uncaught exception:
java.util.concurrent.TimeoutException: Futures timed out after [100000 milliseconds]
at scala.concurrent.impl.Promise$DefaultPromise.ready(Promise.scala:219)
at scala.concurrent.impl.Promise$DefaultPromise.result(Promise.scala:223)
at org.apache.spark.util.ThreadUtils$.awaitResult(ThreadUtils.scala:201)
at org.apache.spark.deploy.yarn.ApplicationMaster.runDriver(ApplicationMaster.scala:401)
at org.apache.spark.deploy.yarn.ApplicationMaster.run(ApplicationMaster.scala:254)
at org.apache.spark.deploy.yarn.ApplicationMaster$$anonfun$main$1.apply$mcV$sp(ApplicationMaster.scala:764)
at org.apache.spark.deploy.SparkHadoopUtil$$anon$2.run(SparkHadoopUtil.scala:67)
at org.apache.spark.deploy.SparkHadoopUtil$$anon$2.run(SparkHadoopUtil.scala:66)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:422)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1698)
at org.apache.spark.deploy.SparkHadoopUtil.runAsSparkUser(SparkHadoopUtil.scala:66)
at org.apache.spark.deploy.yarn.ApplicationMaster$.main(ApplicationMaster.scala:762)
at org.apache.spark.deploy.yarn.ApplicationMaster.main(ApplicationMaster.scala)
Thanks

Java with OpenCV failed to read PNG image

SOLVED & WHY:
Path to image contains Unicode character, I have to say it's a bug.
ORIGINAL POST:
I am new to OpenCV and just use java with OpenCV 3.2.0, 3.1.0, and 2.4.3 to read this image without any success, namely, no width or height can be read, though my aim is to find the harris corners, and use other image is without this problem.
code:
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.highgui.Highgui;
public class Test
{
public static void main (String []args)
{
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
Mat img_object = Highgui.imread("E:/ℤIMAGEℂ/ℤtestℂ.png");
System.out.println(
"img_object.width() = " + img_object.width()
+ ",\n img_object.height() = " + img_object.height()
+ ",\n img_object.depth() = " + img_object.depth()
+ ",\n img_object.channels() = " + img_object.channels()
+ ",\n img_object.total() = " + img_object.total()
+ ",\n img_object.type() = " + img_object.type()
);
}
}
Image:
error:
img_object.width() = 0,
img_object.height() = 0,
img_object.depth() = 0,
img_object.channels() = 1,
img_object.total() = 0,
img_object.type() = 0
libpng warning: Image width is zero in IHDR
libpng warning: Image height is zero in IHDR
libpng error: Invalid IHDR data
OpenCV Error: Assertion failed (code) in cv::imencode, file ..\..\..\..\opencv\modules\highgui\src\loadsave.cpp, line 430
Exception in thread "main" CvException [org.opencv.core.CvException: cv::Exception: ..\..\..\..\opencv\modules\highgui\src\loadsave.cpp:430: error: (-215) code in function cv::imencode
]
at org.opencv.highgui.Highgui.imencode_1(Native Method)
at org.opencv.highgui.Highgui.imencode(Highgui.java:243)
at Imshow.imshow(Imshow.java:29)
at test.main(Test.java:21)
SOLVED & WHY:
Path to image contains Unicode character.
As someone suggests if you solve your problem, delete it or answer it.
If you try to read image from Unicode path, errors occur, and I didn't see related solution, so you can read this.
OpenCV is bugged with Unicode file path, sadly. That's the problem of OpenCV but mine.

Java ScriptEngine cannot find module referenced by Javascript file

I am using Java 7, and I have the following code that uses the jsondiffpatch Javascript library:
logger.debug("CURRENT PATH=" + Paths.get("").toAbsolutePath());
ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript");
reader = new FileReader("webclient/common/js/jsondiffpatch.min.js");
engine.eval(reader);
If you look at line 48 of jsondiffpatch.js (the uncompressed version of jsondiffpatch.min.js), you can see it references another module:
var packageInfoModuleName = '../package.json';
When executing the Java code, the engine.eval(reader) line can't find package.json and throws the following exception:
javax.script.ScriptException: Error: Cannot find module '../package.json' in <Unknown source> at line number 1
at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:224) ~[na:1.7.0_51]
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:249) ~[na:1.7.0_51]
at nms.server.domain.AuditManager$ConfigAuditProcessor.run(AuditManager.java:465) ~[nms.jar:na]
Caused by: sun.org.mozilla.javascript.internal.JavaScriptException: Error: Cannot find module '../package.json' (<Unknown source>#1)
at sun.org.mozilla.javascript.internal.Interpreter.interpretLoop(Interpreter.java:1066) ~[na:1.7.0_51]
at sun.org.mozilla.javascript.internal.Interpreter.interpret(Interpreter.java:849) ~[na:1.7.0_51]
at sun.org.mozilla.javascript.internal.InterpretedFunction.call(InterpretedFunction.java:162) ~[na:1.7.0_51]
at sun.org.mozilla.javascript.internal.ContextFactory.doTopCall(ContextFactory.java:430) ~[na:1.7.0_51]
at com.sun.script.javascript.RhinoScriptEngine$1.superDoTopCall(RhinoScriptEngine.java:116) ~[na:1.7.0_51]
at com.sun.script.javascript.RhinoScriptEngine$1.doTopCall(RhinoScriptEngine.java:109) ~[na:1.7.0_51]
at sun.org.mozilla.javascript.internal.ScriptRuntime.doTopCall(ScriptRuntime.java:3160) ~[na:1.7.0_51]
at sun.org.mozilla.javascript.internal.InterpretedFunction.exec(InterpretedFunction.java:173) ~[na:1.7.0_51]
at sun.org.mozilla.javascript.internal.Context.evaluateReader(Context.java:1169) ~[na:1.7.0_51]
at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:214) ~[na:1.7.0_51]
The jsondiffpatch.min.js file is located in the webclient/common/js directory, and the package.json file is located in the webclient/common directory.
The logger.debug line printed out the following for the current working directory:
CURRENT PATH=/usr/local/project/version/Software
So I tried copying the package.json file to the /usr/local/project/version directory, and I still got the same exception.
Why can't the ScriptEngine find the package.json file?
the jsondiffpatch.js file found in /public/build is a bundle (created with browserify) intended only for using it in a browser (the require function called there is defined at the top of the file, it doesn't read files from disc).
I'm not familiar with Java ScriptEngine, but it looks it's not allowing a redefine of the require function. if it supports CommonJS, you shouldn't use the bundled version, you should require ./src/main.js (the library main module, as pointed in package.json)
(Disclaimer: I'm jsondiffpatch author)
Attempt to try the full path of the module you want to include.
I used Java 8, Nashorn, nashorn-commonjs-modules, jsondiffpatch.js.
I deleted chalk external module and package.json from the file main.js because it's outside the scope of my Nashorn base folder.
It's work now :)
public String diff() throws ScriptException {
NashornScriptEngine engine = (NashornScriptEngine) new ScriptEngineManager().getEngineByName("nashorn");
FilesystemFolder rootFolder = FilesystemFolder.create(new File("C:\\Users\\Maxime\\Documents\\writecontrol\\default\\gateway\\src\\main\\resources\\static\\bower_components\\jsondiffpatch\\src"), "UTF-8");
Module module = Require.enable(engine, rootFolder);
try {
ScriptObjectMirror result = (ScriptObjectMirror) engine.eval("var jsondiffpatch = require('./main.js');" +
" var country = {\n" +
" name: \"Argentina\",\n" +
" capital: \"Buenos Aires\",\n" +
" independence: new Date(1816, 6, 9),\n" +
" unasur: true\n" +
" };" +
"var country2 = JSON.parse(JSON.stringify(country), jsondiffpatch.dateReviver);" +
" country2.name = \"Republica Argentina\";\n" +
" country2.population = 41324992;\n" +
" delete country2.capital;\n" +
" var delta = jsondiffpatch.diff(country, country2);" +
"print(delta.name);" +
"print('Nashorn Hello World!');" +
"data=JSON.stringify(delta);" +
"var result = {delta : data};" +
"result");
delta = (String) result.getMember("delta");
System.out.println(delta);
} catch (final ScriptException se) {
se.printStackTrace();
}
return delta;
}

Categories

Resources