This is an automated email from the ASF dual-hosted git repository.
hansva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git
The following commit(s) were added to refs/heads/main by this push:
new 33c320c309 cleanup UDJC snippets, fixes #2718 (#7839)
33c320c309 is described below
commit 33c320c3091a42b618a2af08eed4893043d5f16f
Author: Hans Van Akelyen <[email protected]>
AuthorDate: Fri Aug 7 20:34:49 2026 +0200
cleanup UDJC snippets, fixes #2718 (#7839)
---
.../pipeline/transforms/userdefinedjavaclass.adoc | 6 +-
.../UserDefinedJavaClassCodeSnippets.java | 8 +-
.../UserDefinedJavaClassDialog.java | 36 +-
.../UserDefinedJavaClassMeta.java | 1 +
.../userdefinedjavaclass/codeSnippets.xml | 2100 +++-----------------
.../messages/messages_en_US.properties | 2 +-
...serDefinedJavaClassCodeSnippetsCompileTest.java | 143 ++
7 files changed, 416 insertions(+), 1880 deletions(-)
diff --git
a/docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/userdefinedjavaclass.adoc
b/docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/userdefinedjavaclass.adoc
index d7e153cd12..cd7b4b71d7 100644
---
a/docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/userdefinedjavaclass.adoc
+++
b/docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/userdefinedjavaclass.adoc
@@ -197,10 +197,10 @@ You can right-click on any item in this tree to either
Delete, Rename, or Show S
The Classes folder indicates what classes have corresponding code block tabs
in the Class Code panel.
-**Code Snippits**
+**Code Snippets**
-The Code Snippits folder shows the internal Hop code related to the User
Defined Java Class transform.
-These snippets are shown as reference for the code of your class.
+The Code Snippets folder contains ready to use fragments for the most common
User Defined Java Class operations, grouped by category.
+Click a snippet to insert it at the cursor position in the active class tab,
or right-click it and pick Show Sample to open it in a read-only tab for
reference.
**Input Fields**
diff --git
a/plugins/transforms/janino/src/main/java/org/apache/hop/pipeline/transforms/userdefinedjavaclass/UserDefinedJavaClassCodeSnippets.java
b/plugins/transforms/janino/src/main/java/org/apache/hop/pipeline/transforms/userdefinedjavaclass/UserDefinedJavaClassCodeSnippets.java
index 41a668d2f0..8c66f6590a 100644
---
a/plugins/transforms/janino/src/main/java/org/apache/hop/pipeline/transforms/userdefinedjavaclass/UserDefinedJavaClassCodeSnippets.java
+++
b/plugins/transforms/janino/src/main/java/org/apache/hop/pipeline/transforms/userdefinedjavaclass/UserDefinedJavaClassCodeSnippets.java
@@ -23,6 +23,7 @@ import java.util.List;
import java.util.Map;
import lombok.Getter;
import lombok.Setter;
+import org.apache.hop.core.Const;
import org.apache.hop.core.exception.HopXmlException;
import org.apache.hop.core.logging.LogChannel;
import org.apache.hop.core.xml.XmlHandler;
@@ -123,12 +124,15 @@ public class UserDefinedJavaClassCodeSnippets {
List<Node> nodes =
XmlHandler.getNodes(XmlHandler.getSubNode(doc, "codeSnippets"),
"codeSnippet");
for (Node node : nodes) {
+ String code = XmlHandler.getTagValue(node, "code");
+ // Most snippets are their own best sample, only specify <sample> when
it differs.
+ String sample = Const.NVL(XmlHandler.getTagValue(node, "sample"), code);
Snippet snippet =
new Snippet(
Category.valueOf(XmlHandler.getTagValue(node, "category")),
XmlHandler.getTagValue(node, "name"),
- XmlHandler.getTagValue(node, "sample"),
- XmlHandler.getTagValue(node, "code"));
+ sample,
+ code);
snippets.add(snippet);
Snippet oldSnippet = snippetsMap.put(snippet.name, snippet);
if (oldSnippet != null) {
diff --git
a/plugins/transforms/janino/src/main/java/org/apache/hop/pipeline/transforms/userdefinedjavaclass/UserDefinedJavaClassDialog.java
b/plugins/transforms/janino/src/main/java/org/apache/hop/pipeline/transforms/userdefinedjavaclass/UserDefinedJavaClassDialog.java
index 53b76714df..f61a4377b4 100644
---
a/plugins/transforms/janino/src/main/java/org/apache/hop/pipeline/transforms/userdefinedjavaclass/UserDefinedJavaClassDialog.java
+++
b/plugins/transforms/janino/src/main/java/org/apache/hop/pipeline/transforms/userdefinedjavaclass/UserDefinedJavaClassDialog.java
@@ -19,6 +19,7 @@ package
org.apache.hop.pipeline.transforms.userdefinedjavaclass;
import java.math.BigDecimal;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.EnumMap;
@@ -150,9 +151,13 @@ public class UserDefinedJavaClassDialog extends
BaseTransformDialog {
private enum TabAddActions {
ADD_COPY,
ADD_BLANK,
- ADD_DEFAULT
+ ADD_DEFAULT,
+ ADD_SAMPLE
}
+ /** Marks a tab that only shows a code snippet for reference, not a class of
this transform. */
+ private static final String SAMPLE_TAB = "sampleTab";
+
private String strActiveScript;
private UserDefinedJavaClassMeta input;
@@ -819,12 +824,12 @@ public class UserDefinedJavaClassDialog extends
BaseTransformDialog {
}
}
- private void addCtab(String tabName, String tabCode, TabAddActions tabType) {
+ private CTabItem addCtab(String tabName, String tabCode, TabAddActions
tabType) {
CTabItem item = new CTabItem(folder, SWT.CLOSE);
item.setFont(GuiResource.getInstance().getFontDefault());
switch (tabType) {
- case ADD_DEFAULT:
+ case ADD_DEFAULT, ADD_SAMPLE:
item.setText(tabName);
break;
default:
@@ -870,8 +875,20 @@ public class UserDefinedJavaClassDialog extends
BaseTransformDialog {
item.setImage(imageInactiveScript);
item.setControl(wScript);
- // Adding new Item to Tree
- modifyTabTree(item, TabActions.ADD_ITEM);
+ if (tabType == TabAddActions.ADD_SAMPLE) {
+ // A sample is shown for reference only. It is not a class of this
transform, so it doesn't
+ // belong in the classes tree and it must not end up in the definitions
to compile.
+ item.setData(SAMPLE_TAB, Boolean.TRUE);
+ wScript.setEditable(false);
+ } else {
+ // Adding new Item to Tree
+ modifyTabTree(item, TabActions.ADD_ITEM);
+ }
+ return item;
+ }
+
+ private boolean isSampleTab(CTabItem cTab) {
+ return Boolean.TRUE.equals(cTab.getData(SAMPLE_TAB));
}
private void modifyTabTree(CTabItem ctabitem, TabActions action) {
@@ -1167,7 +1184,10 @@ public class UserDefinedJavaClassDialog extends
BaseTransformDialog {
}
meta.replaceFields(newFields);
- CTabItem[] cTabs = folder.getItems();
+ CTabItem[] cTabs =
+ Arrays.stream(folder.getItems())
+ .filter(cTab -> !isSampleTab(cTab))
+ .toArray(CTabItem[]::new);
if (cTabs.length > 0) {
for (CTabItem cTab : cTabs) {
JaninoCheckerUtil janinoCheckerUtil = new JaninoCheckerUtil();
@@ -1706,9 +1726,7 @@ public class UserDefinedJavaClassDialog extends
BaseTransformDialog {
if (getCTabPosition(sampleTabName) == -1) {
addCtab(
- sampleTabName,
- snippitsHelper.getSample(snippitFullName),
- TabAddActions.ADD_DEFAULT);
+ sampleTabName, snippitsHelper.getSample(snippitFullName),
TabAddActions.ADD_SAMPLE);
}
if (getCTabPosition(sampleTabName) != -1) {
diff --git
a/plugins/transforms/janino/src/main/java/org/apache/hop/pipeline/transforms/userdefinedjavaclass/UserDefinedJavaClassMeta.java
b/plugins/transforms/janino/src/main/java/org/apache/hop/pipeline/transforms/userdefinedjavaclass/UserDefinedJavaClassMeta.java
index 4e10d11a8b..ab5e299fe9 100644
---
a/plugins/transforms/janino/src/main/java/org/apache/hop/pipeline/transforms/userdefinedjavaclass/UserDefinedJavaClassMeta.java
+++
b/plugins/transforms/janino/src/main/java/org/apache/hop/pipeline/transforms/userdefinedjavaclass/UserDefinedJavaClassMeta.java
@@ -272,6 +272,7 @@ public class UserDefinedJavaClassMeta
"org.apache.hop.core.*",
"org.apache.hop.core.exception.*",
"org.apache.hop.pipeline.*",
+ "org.apache.hop.pipeline.engine.*",
"org.apache.hop.workflow.*",
"org.apache.hop.workflow.action.*",
"org.apache.hop.core.plugins.*",
diff --git
a/plugins/transforms/janino/src/main/resources/org/apache/hop/pipeline/transforms/userdefinedjavaclass/codeSnippets.xml
b/plugins/transforms/janino/src/main/resources/org/apache/hop/pipeline/transforms/userdefinedjavaclass/codeSnippets.xml
index f825dd2c53..ff4cc19e06 100644
---
a/plugins/transforms/janino/src/main/resources/org/apache/hop/pipeline/transforms/userdefinedjavaclass/codeSnippets.xml
+++
b/plugins/transforms/janino/src/main/resources/org/apache/hop/pipeline/transforms/userdefinedjavaclass/codeSnippets.xml
@@ -17,2148 +17,518 @@
~
-->
-<codeSnippets language="us">
- <codeSnippet>
- <name>Main</name>
- <category>COMMON</category>
- <code><![CDATA[public boolean processRow() throws HopException {
- if (first) {
- first = false;
-
- /* TODO: Your code here. (Using info fields)
-
- FieldHelper infoField = get(Fields.Info, "info_field_name");
+<!--
+ Code snippets offered by the User Defined Java Class dialog.
- RowSet infoStream = findInfoRowSet("info_stream_tag");
+ Every snippet in this file is compiled by
+ UserDefinedJavaClassCodeSnippetsCompileTest against the real UDJC compiler
+ setup, so anything added here has to be valid Java against the current API.
- Object[] infoRow = null;
+ Snippets are either a complete class member (a method declaration) or a
+ statement fragment. Fragments may use these names, they are declared by the
+ test harness and are the names the surrounding examples use as well:
- int infoRowCount = 0;
+ Object[] r the current row
+ IRowSet rowSet a row set
+ String msg a log message
+ IRowListener rowListener a row listener
+-->
+<codeSnippets language="us">
- // Read all rows from info transform before calling getRow() method, which
returns first row from any
- // input rowset. As rowMeta for info and input transforms varies getRow()
can lead to errors.
- while((infoRow = getRowFrom(infoStream)) != null){
+ <!-- ==================== Common use ==================== -->
- // do something with info data
- infoRowCount++;
- }
- */
- }
+ <codeSnippet>
+ <name>Implement processRow</name>
+ <category>COMMON</category>
+ <code><![CDATA[//
+// Process one row: read a row from the input hop and write a row to the
output hop.
+// Called until it returns false, at which point the transform is done.
+//
+public boolean processRow() throws HopException {
+ // Get a row from the default input hop.
+ //
Object[] r = getRow();
+ // When the row is null there is no more input, so we're done.
+ //
if (r == null) {
setOutputDone();
return false;
}
- // It is always safest to call createOutputRow() to ensure that your output
row's Object[] is large
- // enough to handle any new fields you are creating in this transform.
- r = createOutputRow(r, data.outputRowMeta.size());
-
- /* TODO: Your code here. (See Sample)
+ if (first) {
+ first = false;
+ // TODO: one time initialisation, now that the input row layout is known.
+ }
- // Get the value from an input field
- String foobar = get(Fields.In, "a_fieldname").getString(r);
+ // Always call createOutputRow() so the output row is large enough to hold
+ // the fields this transform adds.
+ //
+ r = createOutputRow(r, data.outputRowMeta.size());
- foobar += "bar";
-
- // Set a value in a new output field
- get(Fields.Out, "output_fieldname").setValue(r, foobar);
+ // TODO: read input fields and calculate output fields, for example:
+ //
+ // String value = get(Fields.In, "input_field").getString(r);
+ // get(Fields.Out, "output_field").setValue(r, value + "!");
- */
- // Send the row on to the next transform.
+ // Send the row to the default output hop.
+ //
putRow(data.outputRowMeta, r);
return true;
}
]]></code>
- <sample><![CDATA[import java.math.*;
-import java.util.*;
-import java.util.Map.Entry;
-
-/* All this Manipulator/FieldsUpdater stuff is just some magic to let me show
you an example
- * when I have no idea what input or output fields you are going to connect to
the transform.
- * It looks for all the output fields and fiddles with them in some field type
appropriate way.
- * Hopefully your code will look a lot simpler and be more useful. ;) -Daniel
- */
-private interface Manipulator {
- public Object manipulate(Object in);
- public Object create();
-}
-public static final class FieldsUpdater {
- public static final FieldsUpdater NUMBER = new FieldsUpdater(new
Manipulator() {
- double numRecords = 0;
- long startTime = System.currentTimeMillis();
- public Object manipulate(Object in) {
- if (in == null) return create();
- return (Double)in + Math.random();
- }
- public Object create() {
- return numRecords++ / (System.currentTimeMillis() - startTime);
- }
- });
- public static final FieldsUpdater STRING = new FieldsUpdater(new
Manipulator() {
- public Object manipulate(Object in) {
- if (in == null) return create();
- return "Input was "+((String)in).length()+" characters.";
- }
- public Object create() { return "Hello World!"; }
- });
- public static final FieldsUpdater DATE = new FieldsUpdater(new Manipulator()
{
- Calendar cal = Calendar.getInstance();
- Date myBirthday = new Date(156517500000L);
- public Object manipulate(Object in) {
- if (in == null) return create();
- cal.setTime((Date)in);
- cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
- return cal.getTime();
- }
- public Object create() {
- return myBirthday;
- }
- });
- public static final FieldsUpdater BOOLEAN = new FieldsUpdater(new
Manipulator() {
- Boolean curBool = Boolean.FALSE;
- public Object manipulate(Object in) {
- if (in == null) return create();
- return (Boolean)in ? Boolean.TRUE : Boolean.FALSE;
- }
- public Object create() {
- curBool = curBool ? Boolean.FALSE : Boolean.TRUE;
- return curBool;
- }
- });
- public static final FieldsUpdater INTEGER = new FieldsUpdater(new
Manipulator() {
- int numRows = 0;
- public Object manipulate(Object in) {
- if (in == null) return create();
- return ((Long)in) * -1;
- }
- public Object create() {
- return numRows++;
- }
- });
- public static final FieldsUpdater BIGNUMBER = new FieldsUpdater(new
Manipulator() {
- final BigDecimal three = new BigDecimal(3);
- BigDecimal frac = new BigDecimal(Integer.MAX_VALUE,
MathContext.DECIMAL128);
- public Object manipulate(Object in) {
- if (in == null) return create();
- return ((BigDecimal)in).movePointLeft(1);
- }
- public Object create() {
- frac = frac.divide(three);
- return frac;
- }
- });
-
- private final Manipulator m;
- FieldsUpdater(Manipulator m) {
- this.m = m;
- }
- public Object manipulate(Object in) { return m.manipulate(in); }
- public static FieldsUpdater valueOf(String name) throws
HopTransformException {
- if ("Number".equals(name)) return NUMBER;
- else if ("String".equals(name)) return STRING;
- else if ("Date".equals(name)) return DATE;
- else if ("Boolean".equals(name)) return BOOLEAN;
- else if ("Integer".equals(name)) return INTEGER;
- else if ("BigNumber".equals(name)) return BIGNUMBER;
- else throw new HopTransformException("Unknown field data type "+name);
- }
-}
-private final HashMap fieldsToUpdate = new HashMap();
-private int rowsLeftForGenerateMode = -1;
-private int outputRowSize = 0;
-
-public boolean processRow() throws HopException {
- // If the global "first" flag is true, perform some initialization that
can only happen
- // once we have read the first row of input data
- if (first) {
- first = false;
-
- // Set up the list of fields that will be available after this
transform
- // Normally, this is simpler, but in the HelloWorld sample, I don't
know if
- // there is an input transform connected or not.
- if (r == null) {
- rowsLeftForGenerateMode = 100;
- }
- outputRowSize = data.outputRowMeta.size();
-
- // Again, an extra complicated block of code to make up for the fact that
I don't know
- // how you are connecting this sample to an existing transformation.
- for (int i = 0; i < outputRowSize; i++) {
- ValueMetaInterface valueMeta = data.outputRowMeta.getValueMeta(i);
-
- FieldsUpdater mapKey = FieldsUpdater.valueOf(valueMeta.getTypeDesc());
-
- List fieldsForType = (List)fieldsToUpdate.get(mapKey);
- if (fieldsForType == null) {
- fieldsForType = new ArrayList();
- fieldsToUpdate.put(mapKey, fieldsForType);
- }
- fieldsForType.add(valueMeta.getName());
- }
- }
-
- // First, get a row from the default input hop
- Object[] r = getRow();
-
- // If the row object is null, we are done processing.
- if (r == null && !first) {
- setOutputDone();
- return false;
- }
-
- // It is always safest to call createOutputRow() to ensure that your
output row's Object[] is large
- // enough to handle any new fields you are creating in this transform.
- r = createOutputRow(r, outputRowSize);
-
- /* Now for the last piece of HellowWorld magic. We will loop through all
the fields
- * that we will be outputing, and call the appropriate manipulate() for
that type of field.
- * In the real world, this is *much* simpler:
- *
- * FieldHelper fh = get(Field.Out, "myinputfield");
- * String oldFieldValue = fh.getString(r);
- * fh.setValue(r, "Adding to value: "+oldFieldValue);
- *
- * get(Field.Out, "mynewfield").setValue(r,"Hello World!");
- */
- Set entrySet = fieldsToUpdate.entrySet();
- for (Iterator entryIter = entrySet.iterator(); entryIter.hasNext();) {
- Entry entry = (Entry)entryIter.next();
- FieldsUpdater fieldsUpdater = (FieldsUpdater)entry.getKey();
- for (Iterator listIter = ((List)entry.getValue()).iterator();
listIter.hasNext();) {
- String fieldName = (String)listIter.next();
- FieldHelper fieldHelper = get(Fields.Out, fieldName);
- fieldHelper.setValue(r,
fieldsUpdater.manipulate(fieldHelper.getObject(r)));
- }
- }
-
- // putRow will send the row on to the default output hop.
- putRow(data.outputRowMeta, r);
-
- // This method will be continuously called until it returns false (i.e.
when all rows are processed).
- // Normally, you'd just return true if you are handling input rows or
you'd return false when you are done
- // generating new rows. In this case, we have the below fancy test to
figure out when to stop in either case.
- return (rowsLeftForGenerateMode == -1 || rowsLeftForGenerateMode-- > 0);
-}
-]]></sample>
</codeSnippet>
<codeSnippet>
<name>Implement init</name>
<category>COMMON</category>
- <code><![CDATA[public boolean init() {
- return parent.initImpl();
-}
-]]></code>
- <sample><![CDATA[/** Initialize and do work where other transforms
need to wait for... */
+ <code><![CDATA[//
+// Called once before the pipeline starts. Return false to make the transform
fail.
+//
public boolean init() {
+ // TODO: acquire resources, open connections, read lookup data, ...
return parent.initImpl();
}
-]]></sample>
+]]></code>
</codeSnippet>
<codeSnippet>
<name>Implement dispose</name>
<category>COMMON</category>
- <code><![CDATA[public void dispose() {
- parent.disposeImpl();
-}
-]]></code>
- <sample><![CDATA[/** Dispose of this transform: close files, empty
logs, etc. */
+ <code><![CDATA[//
+// Called once after the pipeline finished. Close files, release resources, ...
+//
public void dispose() {
+ // TODO: release the resources acquired in init()
parent.disposeImpl();
}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Implement processRow</name>
- <category>COMMON</category>
- <code><![CDATA[
-//
-// Perform the equivalent of processing one row. Typically this means reading
a row from input
-// (getRow()) and passing a row to output (putRow)).
-//
-// @return false if no more rows can be processed or an error occurred.
-// @throws HopException
-//
-public boolean processRow() throws HopException {
-
- return true;
-}
]]></code>
- <sample><![CDATA[//
-// Perform the equivalent of processing one row. Typically this means reading
a row from input
-// (getRow()) and passing a row to output (putRow)).
-//
-// @return false if no more rows can be processed or an error occurred.
-// @throws HopException
-//
-public boolean processRow() throws HopException {
- // If the row object is null, we are done processing.
- if (r == null && !first) {
- setOutputDone();
- return false;
- }
-
- // If the global "first" flag is true, perform some initialization that
can only happen
- // once we have read the first row of input data
- if (first) {
- first = false;
- }
-
- // It is always safest to call createOutputRow() to ensure that your
output row's Object[] is large
- // enough to handle any new fields you are creating in this transform.
- r = createOutputRow(r, outputRowSize);
-
- // putRow will send the row on to the default output hop.
- putRow(data.outputRowMeta, r);
-
- return true;
-}
-]]></sample>
</codeSnippet>
<codeSnippet>
<name>getRow</name>
<category>COMMON</category>
<code><![CDATA[Object[] r = getRow();
]]></code>
- <sample><![CDATA[Object[] r = getRow();
-]]></sample>
</codeSnippet>
<codeSnippet>
<name>getRowFrom</name>
<category>COMMON</category>
<code><![CDATA[Object[] row = getRowFrom(rowSet);
]]></code>
- <sample><![CDATA[Object[] row = getRowFrom(rowSet);
-]]></sample>
</codeSnippet>
<codeSnippet>
<name>putRow</name>
<category>COMMON</category>
- <code><![CDATA[putRow(row, data);
+ <code><![CDATA[putRow(data.outputRowMeta, r);
]]></code>
- <sample><![CDATA[putRow(row, data);
-]]></sample>
</codeSnippet>
<codeSnippet>
<name>putRowTo</name>
<category>COMMON</category>
- <code><![CDATA[putRowTo(rowMeta, row, rowSet);
+ <code><![CDATA[putRowTo(data.outputRowMeta, r, rowSet);
]]></code>
- <sample><![CDATA[putRowTo(rowMeta, row, rowSet);
-]]></sample>
</codeSnippet>
<codeSnippet>
<name>putError</name>
<category>COMMON</category>
- <code><![CDATA[putError(rowMeta, row, nrErrors, errorDescriptions,
fieldNames, errorCodes);
+ <code><![CDATA[putError(getInputRowMeta(), r, 1L, "error description",
"field name", "ERROR-CODE");
]]></code>
- <sample><![CDATA[putError(rowMeta, row, nrErrors, errorDescriptions,
fieldNames, errorCodes);
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>setErrors</name>
+ <name>setOutputDone</name>
<category>COMMON</category>
- <code><![CDATA[setErrors(1);
+ <code><![CDATA[setOutputDone();
]]></code>
- <sample><![CDATA[setErrors(1);
-]]></sample>
</codeSnippet>
<codeSnippet>
<name>stopAll</name>
<category>COMMON</category>
<code><![CDATA[stopAll();
]]></code>
- <sample><![CDATA[stopAll();
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>setOutputDone</name>
+ <name>isStopped</name>
<category>COMMON</category>
- <code><![CDATA[setOutputDone();
+ <code><![CDATA[if (isStopped()) {
+ return false;
+}
]]></code>
- <sample><![CDATA[setOutputDone();
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>getVariable</name>
+ <name>setErrors</name>
<category>COMMON</category>
- <code><![CDATA[String getVariable = getVariable(variableName,
defaultValue);
+ <code><![CDATA[setErrors(1);
]]></code>
- <sample><![CDATA[String getVariable = getVariable(variableName,
defaultValue);
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>checkFeedback</name>
+ <name>getParameter</name>
<category>COMMON</category>
- <code><![CDATA[boolean checkFeedback = checkFeedback(lines);
+ <code><![CDATA[String parameterValue = getParameter("PARAMETER_NAME");
]]></code>
- <sample><![CDATA[boolean checkFeedback = checkFeedback(lines);
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>addResultFile</name>
+ <name>getVariable</name>
<category>COMMON</category>
- <code><![CDATA[addResultFile(resultFile);
+ <code><![CDATA[String variableValue = getVariable("VARIABLE_NAME",
"default value");
]]></code>
- <sample><![CDATA[addResultFile(resultFile);
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>getResultFiles</name>
+ <name>setVariable</name>
<category>COMMON</category>
- <code><![CDATA[Map getResultFiles = getResultFiles();
+ <code><![CDATA[setVariable("VARIABLE_NAME", "value");
]]></code>
- <sample><![CDATA[Map getResultFiles = getResultFiles();
-]]></sample>
</codeSnippet>
-
<codeSnippet>
- <name>logBasic</name>
- <category>LOGGING</category>
- <code><![CDATA[logBasic(msg);
+ <name>checkFeedback</name>
+ <category>COMMON</category>
+ <code><![CDATA[if (checkFeedback(getLinesRead())) {
+ logBasic("Read " + getLinesRead() + " rows");
+}
]]></code>
- <sample><![CDATA[logBasic(msg);
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>logDebug</name>
- <category>LOGGING</category>
- <code><![CDATA[logDebug(msg);
+ <name>addResultFile</name>
+ <category>COMMON</category>
+ <code><![CDATA[ResultFile resultFile =
+ new ResultFile(
+ ResultFile.FILE_TYPE_GENERAL,
+
org.apache.hop.core.vfs.HopVfs.getFileObject("${java.io.tmpdir}/example.txt",
parent),
+ getPipelineMeta().getName(),
+ getTransformName());
+addResultFile(resultFile);
]]></code>
- <sample><![CDATA[logDebug(msg);
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>logDetailed</name>
- <category>LOGGING</category>
- <code><![CDATA[logDetailed(msg);
+ <name>getResultFiles</name>
+ <category>COMMON</category>
+ <code><![CDATA[Map<String, ResultFile> resultFiles = getResultFiles();
]]></code>
- <sample><![CDATA[logDetailed(msg);
-]]></sample>
</codeSnippet>
+
+ <!-- ==================== Row manipulation ==================== -->
+
<codeSnippet>
- <name>logError(msg)</name>
- <category>LOGGING</category>
- <code><![CDATA[logError(msg);
+ <name>createOutputRow</name>
+ <category>ROW</category>
+ <code><![CDATA[r = createOutputRow(r, data.outputRowMeta.size());
]]></code>
- <sample><![CDATA[logError(msg);
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>logError(msg,e)</name>
- <category>LOGGING</category>
- <code><![CDATA[logError(msg, e);
+ <name>Read an input field</name>
+ <category>ROW</category>
+ <code><![CDATA[// A FieldHelper has a getter per data type:
getString(), getLong(), getDate(),
+// getBoolean(), getDouble(), getBigDecimal(), getBinary(), getTimestamp(), ...
+//
+String stringValue = get(Fields.In, "field_name").getString(r);
+Long integerValue = get(Fields.In, "field_name").getLong(r);
]]></code>
- <sample><![CDATA[logError(msg, e);
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>logMinimal</name>
- <category>LOGGING</category>
- <code><![CDATA[logMinimal(msg);
+ <name>Write an output field</name>
+ <category>ROW</category>
+ <code><![CDATA[get(Fields.Out, "field_name").setValue(r, "value");
]]></code>
- <sample><![CDATA[logMinimal(msg);
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>logRowlevel</name>
- <category>LOGGING</category>
- <code><![CDATA[logRowlevel(msg);
+ <name>Read an info field</name>
+ <category>ROW</category>
+ <code><![CDATA[String infoValue = get(Fields.Info,
"field_name").getString(r);
]]></code>
- <sample><![CDATA[logRowlevel(msg);
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>logSummary</name>
- <category>LOGGING</category>
- <code><![CDATA[logSummary();
+ <name>findInfoRowSet</name>
+ <category>ROW</category>
+ <code><![CDATA[// Read all rows of an info stream before calling
getRow() on the main stream:
+// the row layouts differ, so mixing both leads to errors.
+//
+IRowSet infoRowSet = findInfoRowSet("info stream tag");
+Object[] infoRow = null;
+while ((infoRow = getRowFrom(infoRowSet)) != null) {
+ // TODO: do something with the info row
+}
]]></code>
- <sample><![CDATA[logSummary();
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>incrementLinesInput</name>
- <category>STATUS</category>
- <code><![CDATA[long incrementLinesInput = incrementLinesInput();
+ <name>findTargetRowSet</name>
+ <category>ROW</category>
+ <code><![CDATA[IRowSet targetRowSet = findTargetRowSet("target stream
tag");
+putRowTo(data.outputRowMeta, r, targetRowSet);
]]></code>
- <sample><![CDATA[long incrementLinesInput = incrementLinesInput();
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>incrementLinesOutput</name>
- <category>STATUS</category>
- <code><![CDATA[long incrementLinesOutput = incrementLinesOutput();
+ <name>getInputRowMeta</name>
+ <category>ROW</category>
+ <code><![CDATA[IRowMeta inputRowMeta = getInputRowMeta();
]]></code>
- <sample><![CDATA[long incrementLinesOutput = incrementLinesOutput();
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>incrementLinesRead</name>
- <category>STATUS</category>
- <code><![CDATA[long incrementLinesRead = incrementLinesRead();
+ <name>getErrorRowMeta</name>
+ <category>ROW</category>
+ <code><![CDATA[IRowMeta errorRowMeta = getErrorRowMeta();
]]></code>
- <sample><![CDATA[long incrementLinesRead = incrementLinesRead();
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>incrementLinesRejected</name>
- <category>STATUS</category>
- <code><![CDATA[long incrementLinesRejected = incrementLinesRejected();
+ <name>getInputRowSets</name>
+ <category>ROW</category>
+ <code><![CDATA[List<IRowSet> inputRowSets = getInputRowSets();
]]></code>
- <sample><![CDATA[long incrementLinesRejected =
incrementLinesRejected();
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>incrementLinesSkipped</name>
- <category>STATUS</category>
- <code><![CDATA[long incrementLinesSkipped = incrementLinesSkipped();
+ <name>getOutputRowSets</name>
+ <category>ROW</category>
+ <code><![CDATA[List<IRowSet> outputRowSets = getOutputRowSets();
]]></code>
- <sample><![CDATA[long incrementLinesSkipped = incrementLinesSkipped();
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>incrementLinesUpdated</name>
- <category>STATUS</category>
- <code><![CDATA[long incrementLinesUpdated = incrementLinesUpdated();
+ <name>findInputRowSet</name>
+ <category>ROW</category>
+ <code><![CDATA[IRowSet inputRowSet = findInputRowSet("source transform
name");
]]></code>
- <sample><![CDATA[long incrementLinesUpdated = incrementLinesUpdated();
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>incrementLinesWritten</name>
- <category>STATUS</category>
- <code><![CDATA[long incrementLinesWritten = incrementLinesWritten();
+ <name>findOutputRowSet</name>
+ <category>ROW</category>
+ <code><![CDATA[IRowSet outputRowSet = findOutputRowSet("target
transform name");
]]></code>
- <sample><![CDATA[long incrementLinesWritten = incrementLinesWritten();
-]]></sample>
</codeSnippet>
+
+ <!-- ==================== Logging ==================== -->
+
<codeSnippet>
- <name>getLinesInput</name>
- <category>STATUS</category>
- <code><![CDATA[long getLinesInput = getLinesInput();
+ <name>logMinimal</name>
+ <category>LOGGING</category>
+ <code><![CDATA[logMinimal(msg);
]]></code>
- <sample><![CDATA[long getLinesInput = getLinesInput();
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>getLinesOutput</name>
- <category>STATUS</category>
- <code><![CDATA[long getLinesOutput = getLinesOutput();
+ <name>logBasic</name>
+ <category>LOGGING</category>
+ <code><![CDATA[logBasic(msg);
]]></code>
- <sample><![CDATA[long getLinesOutput = getLinesOutput();
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>getLinesRead</name>
- <category>STATUS</category>
- <code><![CDATA[long getLinesRead = getLinesRead();
+ <name>logDetailed</name>
+ <category>LOGGING</category>
+ <code><![CDATA[logDetailed(msg);
]]></code>
- <sample><![CDATA[long getLinesRead = getLinesRead();
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>getLinesRejected</name>
- <category>STATUS</category>
- <code><![CDATA[long getLinesRejected = getLinesRejected();
+ <name>logDebug</name>
+ <category>LOGGING</category>
+ <code><![CDATA[logDebug(msg);
]]></code>
- <sample><![CDATA[long getLinesRejected = getLinesRejected();
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>getLinesSkipped</name>
- <category>STATUS</category>
- <code><![CDATA[long getLinesSkipped = getLinesSkipped();
+ <name>logRowlevel</name>
+ <category>LOGGING</category>
+ <code><![CDATA[logRowlevel(msg);
]]></code>
- <sample><![CDATA[long getLinesSkipped = getLinesSkipped();
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>getLinesUpdated</name>
- <category>STATUS</category>
- <code><![CDATA[long getLinesUpdated = getLinesUpdated();
+ <name>logError(msg)</name>
+ <category>LOGGING</category>
+ <code><![CDATA[logError(msg);
]]></code>
- <sample><![CDATA[long getLinesUpdated = getLinesUpdated();
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>getLinesWritten</name>
- <category>STATUS</category>
- <code><![CDATA[long getLinesWritten = getLinesWritten();
+ <name>logError(msg, e)</name>
+ <category>LOGGING</category>
+ <code><![CDATA[try {
+ // TODO: your code here
+} catch (Exception e) {
+ logError("Unexpected error", e);
+ setErrors(1);
+ stopAll();
+}
]]></code>
- <sample><![CDATA[long getLinesWritten = getLinesWritten();
-]]></sample>
</codeSnippet>
+
+ <!-- ==================== Transform status ==================== -->
+
<codeSnippet>
- <name>getProcessed</name>
+ <name>getLinesInput</name>
<category>STATUS</category>
- <code><![CDATA[long getProcessed = getProcessed();
+ <code><![CDATA[long linesInput = getLinesInput();
]]></code>
- <sample><![CDATA[long getProcessed = getProcessed();
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>getStatus</name>
+ <name>getLinesOutput</name>
<category>STATUS</category>
- <code><![CDATA[TransformExecutionStatus getStatus = getStatus();
+ <code><![CDATA[long linesOutput = getLinesOutput();
]]></code>
- <sample><![CDATA[TransformExecutionStatus getStatus = getStatus();
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>getStatusDescription</name>
+ <name>getLinesRead</name>
<category>STATUS</category>
- <code><![CDATA[String getStatusDescription = getStatusDescription();
+ <code><![CDATA[long linesRead = getLinesRead();
]]></code>
- <sample><![CDATA[String getStatusDescription = getStatusDescription();
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>decrementLinesRead</name>
+ <name>getLinesWritten</name>
<category>STATUS</category>
- <code><![CDATA[long decrementLinesRead = decrementLinesRead();
+ <code><![CDATA[long linesWritten = getLinesWritten();
]]></code>
- <sample><![CDATA[long decrementLinesRead = decrementLinesRead();
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>decrementLinesWritten</name>
+ <name>getLinesRejected</name>
<category>STATUS</category>
- <code><![CDATA[long decrementLinesWritten = decrementLinesWritten();
+ <code><![CDATA[long linesRejected = getLinesRejected();
]]></code>
- <sample><![CDATA[long decrementLinesWritten = decrementLinesWritten();
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>setLinesInput</name>
+ <name>getLinesSkipped</name>
<category>STATUS</category>
- <code><![CDATA[setLinesInput(newLinesInputValue);
+ <code><![CDATA[long linesSkipped = getLinesSkipped();
]]></code>
- <sample><![CDATA[setLinesInput(newLinesInputValue);
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>setLinesOutput</name>
+ <name>getLinesUpdated</name>
<category>STATUS</category>
- <code><![CDATA[setLinesOutput(newLinesOutputValue);
+ <code><![CDATA[long linesUpdated = getLinesUpdated();
]]></code>
- <sample><![CDATA[setLinesOutput(newLinesOutputValue);
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>setLinesRead</name>
+ <name>incrementLinesInput</name>
<category>STATUS</category>
- <code><![CDATA[setLinesRead(newLinesReadValue);
+ <code><![CDATA[incrementLinesInput();
]]></code>
- <sample><![CDATA[setLinesRead(newLinesReadValue);
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>setLinesRejected</name>
+ <name>incrementLinesOutput</name>
<category>STATUS</category>
- <code><![CDATA[setLinesRejected(linesRejected);
+ <code><![CDATA[incrementLinesOutput();
]]></code>
- <sample><![CDATA[setLinesRejected(linesRejected);
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>setLinesSkipped</name>
+ <name>incrementLinesRead</name>
<category>STATUS</category>
- <code><![CDATA[setLinesSkipped(newLinesSkippedValue);
+ <code><![CDATA[incrementLinesRead();
]]></code>
- <sample><![CDATA[setLinesSkipped(newLinesSkippedValue);
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>setLinesUpdated</name>
+ <name>incrementLinesWritten</name>
<category>STATUS</category>
- <code><![CDATA[setLinesUpdated(newLinesUpdatedValue);
+ <code><![CDATA[incrementLinesWritten();
]]></code>
- <sample><![CDATA[setLinesUpdated(newLinesUpdatedValue);
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>setLinesWritten</name>
+ <name>incrementLinesRejected</name>
<category>STATUS</category>
- <code><![CDATA[setLinesWritten(newLinesWrittenValue);
-]]></code>
- <sample><![CDATA[setLinesWritten(newLinesWrittenValue);
-]]></sample>
- </codeSnippet>
-
- <codeSnippet>
- <name>getInputRowMeta</name>
- <category>ROW</category>
- <code><![CDATA[RowMetaInterface getInputRowMeta = getInputRowMeta();
-]]></code>
- <sample><![CDATA[RowMetaInterface getInputRowMeta = getInputRowMeta();
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>getErrorRowMeta</name>
- <category>ROW</category>
- <code><![CDATA[RowMetaInterface getErrorRowMeta = getErrorRowMeta();
+ <code><![CDATA[incrementLinesRejected();
]]></code>
- <sample><![CDATA[RowMetaInterface getErrorRowMeta = getErrorRowMeta();
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>getInputRowSets</name>
- <category>ROW</category>
- <code><![CDATA[List getInputRowSets = getInputRowSets();
+ <name>incrementLinesSkipped</name>
+ <category>STATUS</category>
+ <code><![CDATA[incrementLinesSkipped();
]]></code>
- <sample><![CDATA[List getInputRowSets = getInputRowSets();
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>getOutputRowSets</name>
- <category>ROW</category>
- <code><![CDATA[List getOutputRowSets = getOutputRowSets();
+ <name>incrementLinesUpdated</name>
+ <category>STATUS</category>
+ <code><![CDATA[incrementLinesUpdated();
]]></code>
- <sample><![CDATA[List getOutputRowSets = getOutputRowSets();
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>findInputRowSet(sourceTransform)</name>
- <category>ROW</category>
- <code><![CDATA[RowSet findInputRowSet =
findInputRowSet(sourceTransform);
+ <name>getProcessed</name>
+ <category>STATUS</category>
+ <code><![CDATA[long processed = getProcessed();
]]></code>
- <sample><![CDATA[RowSet findInputRowSet =
findInputRowSet(sourceTransform);
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>findInputRowSet(from, fromcopy, to tocopy)</name>
- <category>ROW</category>
- <code><![CDATA[RowSet findInputRowSet = findInputRowSet(from,
fromcopy, to, tocopy);
+ <name>getErrors</name>
+ <category>STATUS</category>
+ <code><![CDATA[long errors = getErrors();
]]></code>
- <sample><![CDATA[RowSet findInputRowSet = findInputRowSet(from,
fromcopy, to, tocopy);
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>findOutputRowSet(targetTransform)</name>
- <category>ROW</category>
- <code><![CDATA[RowSet findOutputRowSet =
findOutputRowSet(targetTransform);
+ <name>getStatus</name>
+ <category>STATUS</category>
+ <code><![CDATA[EngineComponent.ComponentExecutionStatus status =
getStatus();
]]></code>
- <sample><![CDATA[RowSet findOutputRowSet =
findOutputRowSet(targetTransform);
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>findOutputRowSet(from, fromcopy, to tocopy)</name>
- <category>ROW</category>
- <code><![CDATA[RowSet findOutputRowSet = findOutputRowSet(from,
fromcopy, to, tocopy);
+ <name>getStatusDescription</name>
+ <category>STATUS</category>
+ <code><![CDATA[String statusDescription = getStatusDescription();
]]></code>
- <sample><![CDATA[RowSet findOutputRowSet = findOutputRowSet(from,
fromcopy, to, tocopy);
-]]></sample>
</codeSnippet>
+
+ <!-- ==================== Row listeners ==================== -->
+
<codeSnippet>
<name>addRowListener</name>
<category>LISTENERS</category>
<code><![CDATA[addRowListener(rowListener);
]]></code>
- <sample><![CDATA[addRowListener(rowListener);
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>addTransformListener</name>
+ <name>removeRowListener</name>
<category>LISTENERS</category>
- <code><![CDATA[addTransformListener(transformListener);
+ <code><![CDATA[removeRowListener(rowListener);
]]></code>
- <sample><![CDATA[addTransformListener(transformListener);
-]]></sample>
</codeSnippet>
<codeSnippet>
<name>getRowListeners</name>
<category>LISTENERS</category>
- <code><![CDATA[List getRowListeners = getRowListeners();
-]]></code>
- <sample><![CDATA[List getRowListeners = getRowListeners();
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>getTransformListeners</name>
- <category>LISTENERS</category>
- <code><![CDATA[List getTransformListeners = getTransformListeners();
-]]></code>
- <sample><![CDATA[List getTransformListeners = getTransformListeners();
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>removeRowListener</name>
- <category>LISTENERS</category>
- <code><![CDATA[removeRowListener(rowListener);
+ <code><![CDATA[List<IRowListener> rowListeners = getRowListeners();
]]></code>
- <sample><![CDATA[removeRowListener(rowListener);
-]]></sample>
</codeSnippet>
+ <!-- ==================== Uncommon use ==================== -->
+
<codeSnippet>
- <name>getTransformMeta</name>
+ <name>getTransformName</name>
<category>OTHER</category>
- <code><![CDATA[TransformMeta getTransformMeta = getTransformMeta();
+ <code><![CDATA[String transformName = getTransformName();
]]></code>
- <sample><![CDATA[TransformMeta getTransformMeta = getTransformMeta();
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>getPipeline</name>
+ <name>getTransformPluginId</name>
<category>OTHER</category>
- <code><![CDATA[Pipeline getPipeline = getPipeline();
+ <code><![CDATA[String transformPluginId = getTransformPluginId();
]]></code>
- <sample><![CDATA[Pipeline getPipeline = getPipeline();
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>getPipelineMeta</name>
+ <name>getTransformMeta</name>
<category>OTHER</category>
- <code><![CDATA[PipelineMeta getPipelineMeta = getPipelineMeta();
+ <code><![CDATA[TransformMeta transformMeta = getTransformMeta();
]]></code>
- <sample><![CDATA[PipelineMeta getPipelineMeta = getPipelineMeta();
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>getTransformDataInterface</name>
+ <name>getPipeline</name>
<category>OTHER</category>
- <code><![CDATA[TransformDataInterface getTransformDataInterface =
getTransformDataInterface();
+ <code><![CDATA[IPipelineEngine pipeline = getPipeline();
]]></code>
- <sample><![CDATA[TransformDataInterface getTransformDataInterface =
getTransformDataInterface();
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>getPartitionID</name>
+ <name>getPipelineMeta</name>
<category>OTHER</category>
- <code><![CDATA[String getPartitionID = getPartitionID();
+ <code><![CDATA[PipelineMeta pipelineMeta = getPipelineMeta();
]]></code>
- <sample><![CDATA[String getPartitionID = getPartitionID();
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>getPartitionTargets</name>
+ <name>getCopy</name>
<category>OTHER</category>
- <code><![CDATA[Map getPartitionTargets = getPartitionTargets();
+ <code><![CDATA[int copyNr = getCopy();
]]></code>
- <sample><![CDATA[Map getPartitionTargets = getPartitionTargets();
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>getRepartitioning</name>
+ <name>isDistributed</name>
<category>OTHER</category>
- <code><![CDATA[int getRepartitioning = getRepartitioning();
+ <code><![CDATA[boolean distributed = isDistributed();
]]></code>
- <sample><![CDATA[int getRepartitioning = getRepartitioning();
-]]></sample>
</codeSnippet>
<codeSnippet>
<name>isPartitioned</name>
<category>OTHER</category>
- <code><![CDATA[boolean isPartitioned = isPartitioned();
+ <code><![CDATA[boolean partitioned = isPartitioned();
]]></code>
- <sample><![CDATA[boolean isPartitioned = isPartitioned();
-]]></sample>
</codeSnippet>
<codeSnippet>
- <name>getClusterSize</name>
+ <name>getPartitionId</name>
<category>OTHER</category>
- <code><![CDATA[int getClusterSize = getClusterSize();
+ <code><![CDATA[String partitionId = getPartitionId();
]]></code>
- <sample><![CDATA[int getClusterSize = getClusterSize();
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>getCopy</name>
- <category>OTHER</category>
- <code><![CDATA[int getCopy = getCopy();
-]]></code>
- <sample><![CDATA[int getCopy = getCopy();
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>getErrors</name>
- <category>OTHER</category>
- <code><![CDATA[long getErrors = getErrors();
-]]></code>
- <sample><![CDATA[long getErrors = getErrors();
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>getRuntime</name>
- <category>OTHER</category>
- <code><![CDATA[long getRuntime = getRuntime();
-]]></code>
- <sample><![CDATA[long getRuntime = getRuntime();
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>getSlaveNr</name>
- <category>OTHER</category>
- <code><![CDATA[int getSlaveNr = getSlaveNr();
-]]></code>
- <sample><![CDATA[int getSlaveNr = getSlaveNr();
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>getSocketRepository</name>
- <category>OTHER</category>
- <code><![CDATA[SocketRepository getSocketRepository =
getSocketRepository();
-]]></code>
- <sample><![CDATA[SocketRepository getSocketRepository =
getSocketRepository();
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>getTransformName</name>
- <category>OTHER</category>
- <code><![CDATA[String getTransformName = getTransformName();
-]]></code>
- <sample><![CDATA[String getTransformName = getTransformName();
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>getTypeId</name>
- <category>OTHER</category>
- <code><![CDATA[String getTypeId = getTypeId();
-]]></code>
- <sample><![CDATA[String getTypeId = getTypeId();
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>getUniqueTransformCountAcrossSlaves</name>
- <category>OTHER</category>
- <code><![CDATA[int getUniqueTransformCountAcrossSlaves =
getUniqueTransformCountAcrossSlaves();
-]]></code>
- <sample><![CDATA[int getUniqueTransformCountAcrossSlaves =
getUniqueTransformCountAcrossSlaves();
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>getUniqueTransformNrAcrossSlaves</name>
- <category>OTHER</category>
- <code><![CDATA[int getUniqueTransformNrAcrossSlaves =
getUniqueTransformNrAcrossSlaves();
-]]></code>
- <sample><![CDATA[int getUniqueTransformNrAcrossSlaves =
getUniqueTransformNrAcrossSlaves();
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>isDistributed</name>
- <category>OTHER</category>
- <code><![CDATA[boolean isDistributed = isDistributed();
-]]></code>
- <sample><![CDATA[boolean isDistributed = isDistributed();
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>setVariable</name>
- <category>OTHER</category>
- <code><![CDATA[setVariable(variableName, variableValue);
-]]></code>
- <sample><![CDATA[setVariable(variableName, variableValue);
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override addResultFile</name>
- <category>OTHER</category>
- <code><![CDATA[public void addResultFile(ResultFile resultFile) {
- parent.addResultFileImpl(resultFile);
-}
-]]></code>
- <sample><![CDATA[public void addResultFile(ResultFile resultFile) {
- parent.addResultFileImpl(resultFile);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override addRowListener</name>
- <category>OTHER</category>
- <code><![CDATA[public void addRowListener(RowListener rowListener) {
- parent.addRowListenerImpl(rowListener);
-}
-]]></code>
- <sample><![CDATA[public void addRowListener(RowListener rowListener) {
- parent.addRowListenerImpl(rowListener);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override addTransformListener</name>
- <category>OTHER</category>
- <code><![CDATA[public void addTransformListener(TransformListener
transformListener) {
- parent.addTransformListenerImpl(transformListener);
-}
-]]></code>
- <sample><![CDATA[public void addTransformListener(TransformListener
transformListener) {
- parent.addTransformListenerImpl(transformListener);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override checkFeedback</name>
- <category>OTHER</category>
- <code><![CDATA[public boolean checkFeedback(long lines) {
- return parent.checkFeedbackImpl(lines);
-}
-]]></code>
- <sample><![CDATA[public boolean checkFeedback(long lines) {
- return parent.checkFeedbackImpl(lines);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override cleanup</name>
- <category>OTHER</category>
- <code><![CDATA[public void cleanup() {
- parent.cleanupImpl();
-}
-]]></code>
- <sample><![CDATA[public void cleanup() {
- parent.cleanupImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override decrementLinesRead</name>
- <category>OTHER</category>
- <code><![CDATA[public long decrementLinesRead() {
- return parent.decrementLinesReadImpl();
-}
-]]></code>
- <sample><![CDATA[public long decrementLinesRead() {
- return parent.decrementLinesReadImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override decrementLinesWritten</name>
- <category>OTHER</category>
- <code><![CDATA[public long decrementLinesWritten() {
- return parent.decrementLinesWrittenImpl();
-}
-]]></code>
- <sample><![CDATA[public long decrementLinesWritten() {
- return parent.decrementLinesWrittenImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override findInputRowSet(sourceTransform)</name>
- <category>OTHER</category>
- <code><![CDATA[public RowSet findInputRowSet(String sourceTransform)
throws HopTransformException {
- return parent.findInputRowSetImpl(sourceTransform);
-}
-]]></code>
- <sample><![CDATA[public RowSet findInputRowSet(String sourceTransform)
throws HopTransformException {
- return parent.findInputRowSetImpl(sourceTransform);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override findInputRowSet(from, fromcopy, to tocopy)</name>
- <category>OTHER</category>
- <code><![CDATA[public RowSet findInputRowSet(String from, int
fromcopy, String to, int tocopy) {
- return parent.findInputRowSetImpl(from, fromcopy, to, tocopy);
-}
-]]></code>
- <sample><![CDATA[public RowSet findInputRowSet(String from, int
fromcopy, String to, int tocopy) {
- return parent.findInputRowSetImpl(from, fromcopy, to, tocopy);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override findOutputRowSet(targetTransform)</name>
- <category>OTHER</category>
- <code><![CDATA[public RowSet findOutputRowSet(String targetTransform)
throws HopTransformException {
- return parent.findOutputRowSetImpl(targetTransform);
-}
-]]></code>
- <sample><![CDATA[public RowSet findOutputRowSet(String
targetTransform) throws HopTransformException {
- return parent.findOutputRowSetImpl(targetTransform);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override findOutputRowSet(from, fromcopy, to tocopy)</name>
- <category>OTHER</category>
- <code><![CDATA[public RowSet findOutputRowSet(String from, int
fromcopy, String to, int tocopy) {
- return parent.findOutputRowSetImpl(from, fromcopy, to, tocopy);
-}
-]]></code>
- <sample><![CDATA[public RowSet findOutputRowSet(String from, int
fromcopy, String to, int tocopy) {
- return parent.findOutputRowSetImpl(from, fromcopy, to, tocopy);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getClusterSize</name>
- <category>OTHER</category>
- <code><![CDATA[public int getClusterSize() {
- return parent.getClusterSizeImpl();
-}
-]]></code>
- <sample><![CDATA[public int getClusterSize() {
- return parent.getClusterSizeImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getCopy</name>
- <category>OTHER</category>
- <code><![CDATA[public int getCopy() {
- return parent.getCopyImpl();
-}
-]]></code>
- <sample><![CDATA[public int getCopy() {
- return parent.getCopyImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getErrorRowMeta</name>
- <category>OTHER</category>
- <code><![CDATA[public RowMetaInterface getErrorRowMeta() {
- return parent.getErrorRowMetaImpl();
-}
-]]></code>
- <sample><![CDATA[public RowMetaInterface getErrorRowMeta() {
- return parent.getErrorRowMetaImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getErrors</name>
- <category>OTHER</category>
- <code><![CDATA[public long getErrors() {
- return parent.getErrorsImpl();
-}
-]]></code>
- <sample><![CDATA[public long getErrors() {
- return parent.getErrorsImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getInputRowMeta</name>
- <category>OTHER</category>
- <code><![CDATA[public RowMetaInterface getInputRowMeta() {
- return parent.getInputRowMetaImpl();
-}
-]]></code>
- <sample><![CDATA[public RowMetaInterface getInputRowMeta() {
- return parent.getInputRowMetaImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getInputRowSets</name>
- <category>OTHER</category>
- <code><![CDATA[public List getInputRowSets() {
- return parent.getInputRowSetsImpl();
-}
-]]></code>
- <sample><![CDATA[public List getInputRowSets() {
- return parent.getInputRowSetsImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getLinesInput</name>
- <category>OTHER</category>
- <code><![CDATA[public long getLinesInput() {
- return parent.getLinesInputImpl();
-}
-]]></code>
- <sample><![CDATA[public long getLinesInput() {
- return parent.getLinesInputImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getLinesOutput</name>
- <category>OTHER</category>
- <code><![CDATA[public long getLinesOutput() {
- return parent.getLinesOutputImpl();
-}
-]]></code>
- <sample><![CDATA[public long getLinesOutput() {
- return parent.getLinesOutputImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getLinesRead</name>
- <category>OTHER</category>
- <code><![CDATA[public long getLinesRead() {
- return parent.getLinesReadImpl();
-}
-]]></code>
- <sample><![CDATA[public long getLinesRead() {
- return parent.getLinesReadImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getLinesRejected</name>
- <category>OTHER</category>
- <code><![CDATA[public long getLinesRejected() {
- return parent.getLinesRejectedImpl();
-}
-]]></code>
- <sample><![CDATA[public long getLinesRejected() {
- return parent.getLinesRejectedImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getLinesSkipped</name>
- <category>OTHER</category>
- <code><![CDATA[public long getLinesSkipped() {
- return parent.getLinesSkippedImpl();
-}
-]]></code>
- <sample><![CDATA[public long getLinesSkipped() {
- return parent.getLinesSkippedImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getLinesUpdated</name>
- <category>OTHER</category>
- <code><![CDATA[public long getLinesUpdated() {
- return parent.getLinesUpdatedImpl();
-}
-]]></code>
- <sample><![CDATA[public long getLinesUpdated() {
- return parent.getLinesUpdatedImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getLinesWritten</name>
- <category>OTHER</category>
- <code><![CDATA[public long getLinesWritten() {
- return parent.getLinesWrittenImpl();
-}
-]]></code>
- <sample><![CDATA[public long getLinesWritten() {
- return parent.getLinesWrittenImpl();
-}
-]]></sample>
- </codeSnippet>
-
- public List getOutputRowSets()
- {
- return parent.getOutputRowSetsImpl();
- }
-
- public String getPartitionID()
- {
- return parent.getPartitionIDImpl();
- }
-
- public Map getPartitionTargets()
- {
- return parent.getPartitionTargetsImpl();
- }
-
- <codeSnippet>
- <name>Override getProcessed</name>
- <category>OTHER</category>
- <code><![CDATA[public long getProcessed() {
- return parent.getProcessedImpl();
-}
-]]></code>
- <sample><![CDATA[public long getProcessed() {
- return parent.getProcessedImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getRepartitioning</name>
- <category>OTHER</category>
- <code><![CDATA[public int getRepartitioning() {
- return parent.getRepartitioningImpl();
-}
-]]></code>
- <sample><![CDATA[public int getRepartitioning() {
- return parent.getRepartitioningImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getResultFiles</name>
- <category>OTHER</category>
- <code><![CDATA[public Map getResultFiles() {
- return parent.getResultFilesImpl();
-}
-]]></code>
- <sample><![CDATA[public Map getResultFiles() {
- return parent.getResultFilesImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getRow</name>
- <category>OTHER</category>
- <code><![CDATA[public Object[] getRow() throws HopException {
- return parent.getRowImpl();
-}
-]]></code>
- <sample><![CDATA[public Object[] getRow() throws HopException {
- return parent.getRowImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getRowFrom</name>
- <category>OTHER</category>
- <code><![CDATA[public Object[] getRowFrom(RowSet rowSet) throws
HopTransformException {
- return parent.getRowFromImpl(rowSet);
-}
-]]></code>
- <sample><![CDATA[public Object[] getRowFrom(RowSet rowSet) throws
HopTransformException {
- return parent.getRowFromImpl(rowSet);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getRowListeners</name>
- <category>OTHER</category>
- <code><![CDATA[public List getRowListeners() {
- return parent.getRowListenersImpl();
-}
-]]></code>
- <sample><![CDATA[public List getRowListeners() {
- return parent.getRowListenersImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getRuntime</name>
- <category>OTHER</category>
- <code><![CDATA[public long getRuntime() {
- return parent.getRuntimeImpl();
-}
-]]></code>
- <sample><![CDATA[public long getRuntime() {
- return parent.getRuntimeImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getSlaveNr</name>
- <category>OTHER</category>
- <code><![CDATA[public int getSlaveNr() {
- return parent.getSlaveNrImpl();
-}
-]]></code>
- <sample><![CDATA[public int getSlaveNr() {
- return parent.getSlaveNrImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getSocketRepository</name>
- <category>OTHER</category>
- <code><![CDATA[public SocketRepository getSocketRepository() {
- return parent.getSocketRepositoryImpl();
-}
-]]></code>
- <sample><![CDATA[public SocketRepository getSocketRepository() {
- return parent.getSocketRepositoryImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getStatus</name>
- <category>OTHER</category>
- <code><![CDATA[public TransformExecutionStatus getStatus() {
- return parent.getStatusImpl();
-}
-]]></code>
- <sample><![CDATA[public TransformExecutionStatus getStatus() {
- return parent.getStatusImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getStatusDescription</name>
- <category>OTHER</category>
- <code><![CDATA[public String getStatusDescription() {
- return parent.getStatusDescriptionImpl();
-}
-]]></code>
- <sample><![CDATA[public String getStatusDescription() {
- return parent.getStatusDescriptionImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getTransformDataInterface</name>
- <category>OTHER</category>
- <code><![CDATA[public TransformDataInterface
getTransformDataInterface() {
- return parent.getTransformDataInterfaceImpl();
-}
-]]></code>
- <sample><![CDATA[public TransformDataInterface
getTransformDataInterface() {
- return parent.getTransformDataInterfaceImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getTransformID</name>
- <category>OTHER</category>
- <code><![CDATA[public String getTransformID() {
- return parent.getTransformIDImpl();
-}
-]]></code>
- <sample><![CDATA[public String getTransformID() {
- return parent.getTransformIDImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getTransformListeners</name>
- <category>OTHER</category>
- <code><![CDATA[public List getTransformListeners() {
- return parent.getTransformListenersImpl();
-}
-]]></code>
- <sample><![CDATA[public List getTransformListeners() {
- return parent.getTransformListenersImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getTransformMeta</name>
- <category>OTHER</category>
- <code><![CDATA[public TransformMeta getTransformMeta() {
- return parent.getTransformMetaImpl();
-}
-]]></code>
- <sample><![CDATA[public TransformMeta getTransformMeta() {
- return parent.getTransformMetaImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getTransformMetaInterface</name>
- <category>OTHER</category>
- <code><![CDATA[public TransformMetaInterface
getTransformMetaInterface() {
- return parent.getTransformMetaInterfaceImpl();
-}
-]]></code>
- <sample><![CDATA[public TransformMetaInterface
getTransformMetaInterface() {
- return parent.getTransformMetaInterfaceImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getTransformName</name>
- <category>OTHER</category>
- <code><![CDATA[public String getTransformName() {
- return parent.getTransformNameImpl();
-}
-]]></code>
- <sample><![CDATA[public String getTransformName() {
- return parent.getTransformNameImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getPipeline</name>
- <category>OTHER</category>
- <code><![CDATA[public Pipeline getPipeline() {
- return parent.getPipelineImpl();
-}
-]]></code>
- <sample><![CDATA[public Pipeline getPipeline() {
- return parent.getPipelineImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getPipelineMeta</name>
- <category>OTHER</category>
- <code><![CDATA[public PipelineMeta getPipelineMeta() {
- return parent.getPipelineMetaImpl();
-}
-]]></code>
- <sample><![CDATA[public PipelineMeta getPipelineMeta() {
- return parent.getPipelineMetaImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getTypeId</name>
- <category>OTHER</category>
- <code><![CDATA[public String getTypeId() {
- return parent.getTypeIdImpl();
-}
-]]></code>
- <sample><![CDATA[public String getTypeId() {
- return parent.getTypeIdImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getUniqueTransformCountAcrossSlaves</name>
- <category>OTHER</category>
- <code><![CDATA[public int getUniqueTransformCountAcrossSlaves() {
- return parent.getUniqueTransformCountAcrossSlavesImpl();
-}
-]]></code>
- <sample><![CDATA[public int getUniqueTransformCountAcrossSlaves() {
- return parent.getUniqueTransformCountAcrossSlavesImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getUniqueTransformNrAcrossSlaves</name>
- <category>OTHER</category>
- <code><![CDATA[public int getUniqueTransformNrAcrossSlaves() {
- return parent.getUniqueTransformNrAcrossSlavesImpl();
-}
-]]></code>
- <sample><![CDATA[public int getUniqueTransformNrAcrossSlaves() {
- return parent.getUniqueTransformNrAcrossSlavesImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getVariable(name)</name>
- <category>OTHER</category>
- <code><![CDATA[public String getVariable(String variableName) {
- return parent.getVariableImpl(variableName);
-}
-]]></code>
- <sample><![CDATA[public String getVariable(String variableName) {
- return parent.getVariableImpl(variableName);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override getVariable(name, default)</name>
- <category>OTHER</category>
- <code><![CDATA[public String getVariable(String variableName, String
defaultValue) {
- return parent.getVariableImpl(variableName, defaultValue);
-}
-]]></code>
- <sample><![CDATA[public String getVariable(String variableName, String
defaultValue) {
- return parent.getVariableImpl(variableName, defaultValue);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override incrementLinesInput</name>
- <category>OTHER</category>
- <code><![CDATA[public long incrementLinesInput() {
- return parent.incrementLinesInputImpl();
-}
-]]></code>
- <sample><![CDATA[public long incrementLinesInput() {
- return parent.incrementLinesInputImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override incrementLinesOutput</name>
- <category>OTHER</category>
- <code><![CDATA[public long incrementLinesOutput() {
- return parent.incrementLinesOutputImpl();
-}
-]]></code>
- <sample><![CDATA[public long incrementLinesOutput() {
- return parent.incrementLinesOutputImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override incrementLinesRead</name>
- <category>OTHER</category>
- <code><![CDATA[public long incrementLinesRead() {
- return parent.incrementLinesReadImpl();
-}
-]]></code>
- <sample><![CDATA[public long incrementLinesRead() {
- return parent.incrementLinesReadImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override incrementLinesRejected</name>
- <category>OTHER</category>
- <code><![CDATA[public long incrementLinesRejected() {
- return parent.incrementLinesRejectedImpl();
-}
-]]></code>
- <sample><![CDATA[public long incrementLinesRejected() {
- return parent.incrementLinesRejectedImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override incrementLinesSkipped</name>
- <category>OTHER</category>
- <code><![CDATA[public long incrementLinesSkipped() {
- return parent.incrementLinesSkippedImpl();
-}
-]]></code>
- <sample><![CDATA[public long incrementLinesSkipped() {
- return parent.incrementLinesSkippedImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override incrementLinesUpdated</name>
- <category>OTHER</category>
- <code><![CDATA[public long incrementLinesUpdated() {
- return parent.incrementLinesUpdatedImpl();
-}
-]]></code>
- <sample><![CDATA[public long incrementLinesUpdated() {
- return parent.incrementLinesUpdatedImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override incrementLinesWritten</name>
- <category>OTHER</category>
- <code><![CDATA[public long incrementLinesWritten() {
- return parent.incrementLinesWrittenImpl();
-}
-]]></code>
- <sample><![CDATA[public long incrementLinesWritten() {
- return parent.incrementLinesWrittenImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override initBeforeStart</name>
- <category>OTHER</category>
- <code><![CDATA[public void initBeforeStart() throws
HopTransformException {
- parent.initBeforeStartImpl();
-}
-]]></code>
- <sample><![CDATA[public void initBeforeStart() throws
HopTransformException {
- parent.initBeforeStartImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override isDistributed</name>
- <category>OTHER</category>
- <code><![CDATA[public boolean isDistributed() {
- return parent.isDistributedImpl();
-}
-]]></code>
- <sample><![CDATA[public boolean isDistributed() {
- return parent.isDistributedImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override isInitialising</name>
- <category>OTHER</category>
- <code><![CDATA[public boolean isInitialising() {
- return parent.isInitialisingImpl();
-}
-]]></code>
- <sample><![CDATA[public boolean isInitialising() {
- return parent.isInitialisingImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override isPartitioned</name>
- <category>OTHER</category>
- <code><![CDATA[public boolean isPartitioned() {
- return parent.isPartitionedImpl();
-}
-]]></code>
- <sample><![CDATA[public boolean isPartitioned() {
- return parent.isPartitionedImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override isSafeModeEnabled</name>
- <category>OTHER</category>
- <code><![CDATA[public boolean isSafeModeEnabled() {
- return parent.isSafeModeEnabledImpl();
-}
-]]></code>
- <sample><![CDATA[public boolean isSafeModeEnabled() {
- return parent.isSafeModeEnabledImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override isStopped</name>
- <category>OTHER</category>
- <code><![CDATA[public boolean isStopped() {
- return parent.isStoppedImpl();
-}
-]]></code>
- <sample><![CDATA[public boolean isStopped() {
- return parent.isStoppedImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override isUsingThreadPriorityManagment</name>
- <category>OTHER</category>
- <code><![CDATA[public boolean isUsingThreadPriorityManagment() {
- return parent.isUsingThreadPriorityManagmentImpl();
-}
-]]></code>
- <sample><![CDATA[public boolean isUsingThreadPriorityManagment() {
- return parent.isUsingThreadPriorityManagmentImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override logBasic</name>
- <category>OTHER</category>
- <code><![CDATA[public void logBasic(String s) {
- parent.logBasicImpl(s);
-}
-]]></code>
- <sample><![CDATA[public void logBasic(String s) {
- parent.logBasicImpl(s);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override logDebug</name>
- <category>OTHER</category>
- <code><![CDATA[public void logDebug(String s) {
- parent.logDebugImpl(s);
-}
-]]></code>
- <sample><![CDATA[public void logDebug(String s) {
- parent.logDebugImpl(s);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override logDetailed</name>
- <category>OTHER</category>
- <code><![CDATA[public void logDetailed(String s) {
- parent.logDetailedImpl(s);
-}
-]]></code>
- <sample><![CDATA[public void logDetailed(String s) {
- parent.logDetailedImpl(s);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override logError(msg)</name>
- <category>OTHER</category>
- <code><![CDATA[public void logError(String s) {
- parent.logErrorImpl(s);
-}
-]]></code>
- <sample><![CDATA[public void logError(String s) {
- parent.logErrorImpl(s);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override logError(msg, e)</name>
- <category>OTHER</category>
- <code><![CDATA[public void logError(String s, Throwable e) {
- parent.logErrorImpl(s, e);
-}
-]]></code>
- <sample><![CDATA[public void logError(String s, Throwable e) {
- parent.logErrorImpl(s, e);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override logMinimal</name>
- <category>OTHER</category>
- <code><![CDATA[public void logMinimal(String s) {
- parent.logMinimalImpl(s);
-}
-]]></code>
- <sample><![CDATA[public void logMinimal(String s) {
- parent.logMinimalImpl(s);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override logRowlevel</name>
- <category>OTHER</category>
- <code><![CDATA[public void logRowlevel(String s) {
- parent.logRowlevelImpl(s);
-}
-]]></code>
- <sample><![CDATA[public void logRowlevel(String s) {
- parent.logRowlevelImpl(s);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override logSummary</name>
- <category>OTHER</category>
- <code><![CDATA[public void logSummary() {
- parent.logSummaryImpl();
-}
-]]></code>
- <sample><![CDATA[public void logSummary() {
- parent.logSummaryImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override markStart</name>
- <category>OTHER</category>
- <code><![CDATA[public void markStart() {
- parent.markStartImpl();
-}
-]]></code>
- <sample><![CDATA[public void markStart() {
- parent.markStartImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override markStop</name>
- <category>OTHER</category>
- <code><![CDATA[public void markStop() {
- parent.markStopImpl();
-}
-]]></code>
- <sample><![CDATA[public void markStop() {
- parent.markStopImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override openRemoteInputTransformSocketsOnce</name>
- <category>OTHER</category>
- <code><![CDATA[public void openRemoteInputTransformSocketsOnce()
throws HopTransformException {
- parent.openRemoteInputTransformSocketsOnceImpl();
-}
-]]></code>
- <sample><![CDATA[public void openRemoteInputTransformSocketsOnce()
throws HopTransformException {
- parent.openRemoteInputTransformSocketsOnceImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override openRemoteOutputTransformSocketsOnce</name>
- <category>OTHER</category>
- <code><![CDATA[public void openRemoteOutputTransformSocketsOnce()
throws HopTransformException {
- parent.openRemoteOutputTransformSocketsOnceImpl();
-}
-]]></code>
- <sample><![CDATA[public void openRemoteOutputTransformSocketsOnce()
throws HopTransformException {
- parent.openRemoteOutputTransformSocketsOnceImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override outputIsDone</name>
- <category>OTHER</category>
- <code><![CDATA[public boolean outputIsDone() {
- return parent.outputIsDoneImpl();
-}
-]]></code>
- <sample><![CDATA[public boolean outputIsDone() {
- return parent.outputIsDoneImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override putError</name>
- <category>OTHER</category>
- <code><![CDATA[public void putError(RowMetaInterface rowMeta, Object[]
row, long nrErrors, String errorDescriptions, String fieldNames, String
errorCodes)
- throws HopTransformException
-]]></code>
- <sample><![CDATA[public void putError(RowMetaInterface rowMeta,
Object[] row, long nrErrors, String errorDescriptions, String fieldNames,
String errorCodes)
- throws HopTransformException
-]]></sample>
- </codeSnippet>
- {
- parent.putErrorImpl(rowMeta, row, nrErrors, errorDescriptions, fieldNames,
errorCodes);
- }
-
- <codeSnippet>
- <name>Override putRow</name>
- <category>OTHER</category>
- <code><![CDATA[public void putRow(RowMetaInterface row, Object[] data)
throws HopTransformException {
- parent.putRowImpl(row, data);
-}
-]]></code>
- <sample><![CDATA[public void putRow(RowMetaInterface row, Object[]
data) throws HopTransformException {
- parent.putRowImpl(row, data);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override putRowTo</name>
- <category>OTHER</category>
- <code><![CDATA[public void putRowTo(RowMetaInterface rowMeta, Object[]
row, RowSet rowSet) throws HopTransformException {
- parent.putRowToImpl(rowMeta, row, rowSet);
-}
-]]></code>
- <sample><![CDATA[public void putRowTo(RowMetaInterface rowMeta,
Object[] row, RowSet rowSet) throws HopTransformException {
- parent.putRowToImpl(rowMeta, row, rowSet);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override removeRowListener</name>
- <category>OTHER</category>
- <code><![CDATA[public void removeRowListener(RowListener rowListener) {
- parent.removeRowListenerImpl(rowListener);
-}
-]]></code>
- <sample><![CDATA[public void removeRowListener(RowListener
rowListener) {
- parent.removeRowListenerImpl(rowListener);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override rowsetInputSize</name>
- <category>OTHER</category>
- <code><![CDATA[public int rowsetInputSize() {
- return parent.rowsetInputSizeImpl();
-}
-]]></code>
- <sample><![CDATA[public int rowsetInputSize() {
- return parent.rowsetInputSizeImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override rowsetOutputSize</name>
- <category>OTHER</category>
- <code><![CDATA[public int rowsetOutputSize() {
- return parent.rowsetOutputSizeImpl();
-}
-]]></code>
- <sample><![CDATA[public int rowsetOutputSize() {
- return parent.rowsetOutputSizeImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override safeModeChecking</name>
- <category>OTHER</category>
- <code><![CDATA[public void safeModeChecking(RowMetaInterface row)
throws HopRowException {
- parent.safeModeCheckingImpl(row);
-}
-]]></code>
- <sample><![CDATA[public void safeModeChecking(RowMetaInterface row)
throws HopRowException {
- parent.safeModeCheckingImpl(row);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override setErrors</name>
- <category>OTHER</category>
- <code><![CDATA[public void setErrors(long errors) {
- parent.setErrorsImpl(errors);
-}
-]]></code>
- <sample><![CDATA[public void setErrors(long errors) {
- parent.setErrorsImpl(errors);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override setInputRowMeta</name>
- <category>OTHER</category>
- <code><![CDATA[public void setInputRowMeta(RowMetaInterface rowMeta) {
- parent.setInputRowMetaImpl(rowMeta);
-}
-]]></code>
- <sample><![CDATA[public void setInputRowMeta(RowMetaInterface rowMeta)
{
- parent.setInputRowMetaImpl(rowMeta);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override setInputRowSets</name>
- <category>OTHER</category>
- <code><![CDATA[public void setInputRowSets(List inputRowSets) {
- parent.setInputRowSetsImpl(inputRowSets);
-}
-]]></code>
- <sample><![CDATA[public void setInputRowSets(List inputRowSets) {
- parent.setInputRowSetsImpl(inputRowSets);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override setLinesInput</name>
- <category>OTHER</category>
- <code><![CDATA[public void setLinesInput(long newLinesInputValue) {
- parent.setLinesInputImpl(newLinesInputValue);
-}
-]]></code>
- <sample><![CDATA[public void setLinesInput(long newLinesInputValue) {
- parent.setLinesInputImpl(newLinesInputValue);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override setLinesOutput</name>
- <category>OTHER</category>
- <code><![CDATA[public void setLinesOutput(long newLinesOutputValue) {
- parent.setLinesOutputImpl(newLinesOutputValue);
-}
-]]></code>
- <sample><![CDATA[public void setLinesOutput(long newLinesOutputValue) {
- parent.setLinesOutputImpl(newLinesOutputValue);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override setLinesRead</name>
- <category>OTHER</category>
- <code><![CDATA[public void setLinesRead(long newLinesReadValue) {
- parent.setLinesReadImpl(newLinesReadValue);
-}
-]]></code>
- <sample><![CDATA[public void setLinesRead(long newLinesReadValue) {
- parent.setLinesReadImpl(newLinesReadValue);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override setLinesRejected</name>
- <category>OTHER</category>
- <code><![CDATA[public void setLinesRejected(long linesRejected) {
- parent.setLinesRejectedImpl(linesRejected);
-}
-]]></code>
- <sample><![CDATA[public void setLinesRejected(long linesRejected) {
- parent.setLinesRejectedImpl(linesRejected);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override setLinesSkipped</name>
- <category>OTHER</category>
- <code><![CDATA[public void setLinesSkipped(long newLinesSkippedValue) {
- parent.setLinesSkippedImpl(newLinesSkippedValue);
-}
-]]></code>
- <sample><![CDATA[public void setLinesSkipped(long
newLinesSkippedValue) {
- parent.setLinesSkippedImpl(newLinesSkippedValue);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override setLinesUpdated</name>
- <category>OTHER</category>
- <code><![CDATA[public void setLinesUpdated(long newLinesUpdatedValue) {
- parent.setLinesUpdatedImpl(newLinesUpdatedValue);
-}
-]]></code>
- <sample><![CDATA[public void setLinesUpdated(long newLinesUpdatedValue)
-{
- parent.setLinesUpdatedImpl(newLinesUpdatedValue);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override setLinesWritten</name>
- <category>OTHER</category>
- <code><![CDATA[public void setLinesWritten(long newLinesWrittenValue) {
- parent.setLinesWrittenImpl(newLinesWrittenValue);
-}
-]]></code>
- <sample><![CDATA[public void setLinesWritten(long
newLinesWrittenValue) {
- parent.setLinesWrittenImpl(newLinesWrittenValue);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override setOutputDone</name>
- <category>OTHER</category>
- <code><![CDATA[public void setOutputDone() {
- parent.setOutputDoneImpl();
-}
-]]></code>
- <sample><![CDATA[public void setOutputDone() {
- parent.setOutputDoneImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override setOutputRowSets</name>
- <category>OTHER</category>
- <code><![CDATA[public void setOutputRowSets(List outputRowSets) {
- parent.setOutputRowSetsImpl(outputRowSets);
-}
-]]></code>
- <sample><![CDATA[public void setOutputRowSets(List outputRowSets) {
- parent.setOutputRowSetsImpl(outputRowSets);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override setTransformListeners</name>
- <category>OTHER</category>
- <code><![CDATA[public void setTransformListeners(List
transformListeners) {
- parent.setTransformListenersImpl(transformListeners);
-}
-]]></code>
- <sample><![CDATA[public void setTransformListeners(List
transformListeners) {
- parent.setTransformListenersImpl(transformListeners);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override setVariable</name>
- <category>OTHER</category>
- <code><![CDATA[public void setVariable(String variableName, String
variableValue) {
- parent.setVariableImpl(variableName, variableValue);
-}
-]]></code>
- <sample><![CDATA[public void setVariable(String variableName, String
variableValue) {
- parent.setVariableImpl(variableName, variableValue);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override stopAll</name>
- <category>OTHER</category>
- <code><![CDATA[public void stopAll() {
- parent.stopAllImpl();
-}
-]]></code>
- <sample><![CDATA[public void stopAll() {
- parent.stopAllImpl();
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override stopRunning</name>
- <category>OTHER</category>
- <code><![CDATA[public void stopRunning(TransformMetaInterface
transformMetaInterface, TransformDataInterface transformDataInterface) throws
HopException {
- parent.stopRunningImpl(transformMetaInterface, transformDataInterface);
-}
-]]></code>
- <sample><![CDATA[public void stopRunning(TransformMetaInterface
transformMetaInterface, TransformDataInterface transformDataInterface) throws
HopException {
- parent.stopRunningImpl(transformMetaInterface, transformDataInterface);
-}
-]]></sample>
- </codeSnippet>
- <codeSnippet>
- <name>Override toString</name>
- <category>OTHER</category>
- <code><![CDATA[public String toString() {
- return parent.toStringImpl();
-}
-]]></code>
- <sample><![CDATA[public String toString() {
- return parent.toStringImpl();
-}
-]]></sample>
</codeSnippet>
</codeSnippets>
-
diff --git
a/plugins/transforms/janino/src/main/resources/org/apache/hop/pipeline/transforms/userdefinedjavaclass/messages/messages_en_US.properties
b/plugins/transforms/janino/src/main/resources/org/apache/hop/pipeline/transforms/userdefinedjavaclass/messages/messages_en_US.properties
index 85b1dcd911..e5c4058dd8 100644
---
a/plugins/transforms/janino/src/main/resources/org/apache/hop/pipeline/transforms/userdefinedjavaclass/messages/messages_en_US.properties
+++
b/plugins/transforms/janino/src/main/resources/org/apache/hop/pipeline/transforms/userdefinedjavaclass/messages/messages_en_US.properties
@@ -94,7 +94,7 @@ UserDefinedJavaClassDialog.Rename.Label=Rename
UserDefinedJavaClassDialog.Sample.Label=Show Sample
UserDefinedJavaClassDialog.SetTransformClass=Set as transform Class
UserDefinedJavaClassDialog.Shell.Title=User defined Java class
-UserDefinedJavaClassDialog.Snippits.Label=Code Snippits
+UserDefinedJavaClassDialog.Snippits.Label=Code Snippets
UserDefinedJavaClassDialog.Tabs.Fields.Title=Fields
UserDefinedJavaClassDialog.Tabs.Fields.TooltipText=Use this tab to specify the
output fields of this transform
UserDefinedJavaClassDialog.Tabs.Info.Title=Info transforms
diff --git
a/plugins/transforms/janino/src/test/java/org/apache/hop/pipeline/transforms/userdefinedjavaclass/UserDefinedJavaClassCodeSnippetsCompileTest.java
b/plugins/transforms/janino/src/test/java/org/apache/hop/pipeline/transforms/userdefinedjavaclass/UserDefinedJavaClassCodeSnippetsCompileTest.java
new file mode 100644
index 0000000000..3e2e68d539
--- /dev/null
+++
b/plugins/transforms/janino/src/test/java/org/apache/hop/pipeline/transforms/userdefinedjavaclass/UserDefinedJavaClassCodeSnippetsCompileTest.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hop.pipeline.transforms.userdefinedjavaclass;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
+
+import java.util.List;
+import java.util.stream.Stream;
+import org.apache.hop.core.logging.HopLogStore;
+import
org.apache.hop.pipeline.transforms.userdefinedjavaclass.UserDefinedJavaClassCodeSnippets.Snippet;
+import
org.apache.hop.pipeline.transforms.userdefinedjavaclass.UserDefinedJavaClassDef.ClassType;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
+/**
+ * Compiles every snippet offered by the User Defined Java Class dialog with
the very same Janino
+ * setup the transform itself uses, so the snippets can no longer rot away
from the API unnoticed
+ * (issue #2718).
+ *
+ * <p>Snippets come in two shapes. A snippet that declares a class member is
compiled as is. A
+ * snippet that is a statement fragment is compiled inside a harness method
which also declares the
+ * placeholder names the fragments are written against.
+ */
+class UserDefinedJavaClassCodeSnippetsCompileTest {
+
+ /**
+ * Placeholder fields the statement fragments are written against. A
fragment declaring a local
+ * variable with the same name simply shadows the field.
+ */
+ private static final String PLACEHOLDERS =
+ """
+ Object[] r;
+ IRowSet rowSet;
+ String msg;
+ IRowListener rowListener;
+ """;
+
+ private static final String PROCESS_ROW_STUB =
+ "public boolean processRow() throws HopException { return false; }\n";
+
+ @BeforeAll
+ static void initLogStore() {
+ HopLogStore.init();
+ }
+
+ static Stream<Arguments> codeBlocks() throws Exception {
+ return blocks(false);
+ }
+
+ static Stream<Arguments> sampleBlocks() throws Exception {
+ return blocks(true);
+ }
+
+ private static Stream<Arguments> blocks(boolean samples) throws Exception {
+ List<Snippet> snippets =
UserDefinedJavaClassCodeSnippets.getSnippetsHelper().getSnippets();
+ if (snippets.isEmpty()) {
+ fail("No code snippets were loaded from codeSnippets.xml");
+ }
+ return snippets.stream()
+ .map(
+ snippet ->
+ Arguments.of(snippet.getName(), samples ? snippet.getSample()
: snippet.getCode()));
+ }
+
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("codeBlocks")
+ void snippetCodeCompiles(String name, String code) {
+ assertNotNull(code, "Snippet '" + name + "' has no code");
+ compile(name, code);
+ }
+
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("sampleBlocks")
+ void snippetSampleCompiles(String name, String sample) {
+ assertNotNull(sample, "Snippet '" + name + "' has no sample");
+ compile(name, sample);
+ }
+
+ private void compile(String name, String code) {
+ String source = isClassMember(code) ? asClassMember(code) :
asStatementFragment(code);
+ UserDefinedJavaClassDef def =
+ new UserDefinedJavaClassDef(ClassType.TRANSFORM_CLASS,
className(name), source);
+ try {
+ assertNotNull(
+ new UserDefinedJavaClassMeta()
+ .cookClass(def, UserDefinedJavaClass.class.getClassLoader()));
+ } catch (Exception e) {
+ fail("Snippet '" + name + "' does not compile: " + e.getMessage() +
"\n\n" + source, e);
+ }
+ }
+
+ private String asClassMember(String code) {
+ return code.contains("boolean processRow()") ? code : code + "\n" +
PROCESS_ROW_STUB;
+ }
+
+ private String asStatementFragment(String code) {
+ return PLACEHOLDERS
+ + "\npublic boolean snippetHarness() throws Exception {\n"
+ + code
+ + "\nreturn true;\n}\n"
+ + PROCESS_ROW_STUB;
+ }
+
+ /**
+ * A snippet declares a class member when its first line of actual code
starts with a modifier.
+ */
+ private boolean isClassMember(String code) {
+ for (String line : code.split("\n")) {
+ String trimmed = line.trim();
+ if (trimmed.isEmpty()
+ || trimmed.startsWith("//")
+ || trimmed.startsWith("/*")
+ || trimmed.startsWith("*")) {
+ continue;
+ }
+ return trimmed.startsWith("public ")
+ || trimmed.startsWith("private ")
+ || trimmed.startsWith("protected ");
+ }
+ return false;
+ }
+
+ private String className(String snippetName) {
+ return "Snippet" + snippetName.replaceAll("[^A-Za-z0-9]", "");
+ }
+}