Skip to Content
Script DeltaWalker ClassicScripting API Reference

Scripting API Reference

The Scripting API Reference lists every object, method, and constant that a script can use. It is generated from the code of DeltaWalker Classic, so it is complete and exact, but it is written for Java programmers: methods appear as Java signatures. This page shows how to read those signatures from JavaScript, and which types to look at first.

The scripting types are all in one package, com.deltawalker.script, and its page lists every type mentioned below.

Start here

These are the types most scripts use. Each name links to its page in the reference.

TypeWhat it is for
AppThe starting point, available in every script as App (and dw). It gives you getComparisons(), getSettings(), getWindow(), getVersion(), getEdition(), and getProperty(name).
ComparisonsCreates comparisons with create(...) and lists the open ones and the comparison history.
ComparisonWhat every comparison can do: compare(), hasDifferences(), print(), close(), and getSettings(). Its nested enum Comparison.Type (FOLDER, IMAGE, TEXT) says which kind of comparison to create.
FileComparisonA comparison of two or three files, with save(...) and saveAll(...). Text and image comparisons are file comparisons.
TextComparisonA text comparison: getAllDeltas(), getText(...), setText(...), merge(...), and report(...). It has no getDeltaCount(); count the deltas with getAllDeltas().length.
FolderComparisonA folder comparison: getAllDeltas(), getDeltaCount(), getRootDelta(), sort(...), sync(...), deleteResource(...), and report(...).
ImageComparisonAn image comparison. It adds nothing to a file comparison.
ScriptOperationWhat a long-running method hands back. You await it.
SettingsReads and changes settings with get(...) and set(...), saves and loads them with save(...) and load(...), and gives access to page and printer settings. App.getSettings() returns the application’s; comparison.getSettings() returns a comparison’s.
WindowThe main window: its bounds, and whether it is full screen, maximized, minimized, or visible.
FiltersThe filters of a kind of comparison, from settings.filters(Comparison.Type.FOLDER). Add filters with addPathFilter(...), addSizeFilter(...), and the other add...Filter methods.
ReportKindThe kind of report to write: HTML, JSON, or PATCH.
RoleWhich side of a comparison you mean: REF (the Reference), ONE (the first Modified side), or TWO (the second Modified side, in a three-way comparison).

Reading a Java signature from JavaScript

The reference shows each method the way Java declares it. In JavaScript you call it like this:

  • Interfaces are objects you get from App. Comparisons, Comparison, Settings, Window, and the others are not constructors. You never write new Comparison(). Start from App and follow the methods: App.getComparisons().create(...) gives you a comparison.
  • Getters are methods. The reference lists getAllDeltas(), so you write comparison.getAllDeltas(), with parentheses. There is no comparison.allDeltas. The same goes for isClosed() and hasDifferences(), and for setters such as setBounds(...).
  • Enums and constants come from Java.type. An enum such as Role or ReportKind is not predefined. Load it first: const Role = Java.type('com.deltawalker.script.Role');, and then use Role.REF. For an enum nested in an interface, load the interface and reach into it: Comparison.Type.TEXT and Comparison.Method.SIZE after Java.type('com.deltawalker.script.Comparison'). Constants used as setting names, such as SettingKey.D_COMP_METHOD, come from Java.type('com.deltopia.io.SettingKey'), as the sample workflows show.
  • Strings, numbers, and booleans are the JavaScript ones. A Java String is a JavaScript string, int, long, and double are numbers, and boolean is true or false.
  • Arrays are arrays. Where the reference shows String[], pass a JavaScript array such as ['/path/old.txt', '/path/new.txt']. A method that returns an array, such as getAllDeltas(), gives you something you can index and ask for .length.
  • null stands for an argument you don’t need. Many methods accept a listener or a format that is optional. create(Comparison.Type.TEXT, paths, null) makes a comparison without a listener, and report(path, ReportKind.HTML, null) on a text comparison writes an HTML report without a patch format.
  • Operations are awaited. A method that takes time, such as compare(), merge(...), sync(...), report(...), and print(), returns straight away with an operation. The reference shows its type as ScriptOperation, or as Object. Put await in front of the call to wait for it to finish. A failed operation throws at the await, so you can catch it with try/catch.
  • throws means a failure you can catch. A method declared with throws IOException or throws IllegalArgumentException raises an exception in your script when it fails. Wrap the call in try/catch if you want to handle it.

A short example puts these together:

const Comparison = Java.type('com.deltawalker.script.Comparison'); const ReportKind = Java.type('com.deltawalker.script.ReportKind'); const comparison = App.getComparisons().create( Comparison.Type.TEXT, ['/path/to/old.txt', '/path/to/new.txt'], null); await comparison.compare(); console.log('Deltas: ' + comparison.getAllDeltas().length); await comparison.report('/path/to/report.html', ReportKind.HTML, null);

See Also

Последна промяна на