Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
public static class row1Struct implements
routines.system.IPersistableRow<row1Struct> {
final static byte[] commonByteArrayLock_LOCAL_PROJECT_Test = new byte;
static byte[] commonByteArray_LOCAL_PROJECT_Test = new byte;
public String newColumn;
public String getNewColumn() {
return this.newColumn;
}
public String newColumn1;
public String getNewColumn1() {
return this.newColumn1;
}
public String newColumn2;
public String getNewColumn2() {
return this.newColumn2;
}
public String newColumn3;
public String getNewColumn3() {
return this.newColumn3;
}
public String newColumn4;
public String getNewColumn4() {
return this.newColumn4;
}
private String readString(ObjectInputStream dis) throws IOException {
String strReturn = null;
int length = 0;
length = dis.readInt();
if (length == -1) {
strReturn = null;
} else {
if (length > commonByteArray_LOCAL_PROJECT_Test.length) {
if (length < 1024
&& commonByteArray_LOCAL_PROJECT_Test.length == 0) {
commonByteArray_LOCAL_PROJECT_Test = new byte;
} else {
commonByteArray_LOCAL_PROJECT_Test = new byte;
}
}
dis.readFully(commonByteArray_LOCAL_PROJECT_Test, 0, length);
strReturn = new String(commonByteArray_LOCAL_PROJECT_Test, 0,
length, utf8Charset);
}
return strReturn;
}
private void writeString(String str, ObjectOutputStream dos)
throws IOException {
if (str == null) {
dos.writeInt(-1);
} else {
byte[] byteArray = str.getBytes(utf8Charset);
dos.writeInt(byteArray.length);
dos.write(byteArray);
}
}
public void readData(ObjectInputStream dis) {
synchronized (commonByteArrayLock_LOCAL_PROJECT_Test) {
try {
int length = 0;
this.newColumn = readString(dis);
this.newColumn1 = readString(dis);
this.newColumn2 = readString(dis);
this.newColumn3 = readString(dis);
this.newColumn4 = readString(dis);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
public void writeData(ObjectOutputStream dos) {
try {
// String
writeString(this.newColumn, dos);
// String
writeString(this.newColumn1, dos);
// String
writeString(this.newColumn2, dos);
// String
writeString(this.newColumn3, dos);
// String
writeString(this.newColumn4, dos);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(super.toString());
sb.append("");
return sb.toString();
}
/**
* Compare keys
*/
public int compareTo(row1Struct other) {
int returnValue = -1;
return returnValue;
}
private int checkNullsAndCompare(Object object1, Object object2) {
int returnValue = 0;
if (object1 instanceof Comparable && object2 instanceof Comparable) {
returnValue = ((Comparable) object1).compareTo(object2);
} else if (object1 != null && object2 != null) {
returnValue = compareStrings(object1.toString(),
object2.toString());
} else if (object1 == null && object2 != null) {
returnValue = 1;
} else if (object1 != null && object2 == null) {
returnValue = -1;
} else {
returnValue = 0;
}
return returnValue;
}
private int compareStrings(String string1, String string2) {
return string1.compareTo(string2);
}
}
package routines;
import local_project.test_0_1.Test.row1Struct;
/*
* user specification: the function's comment should contain keys as follows: 1. write about the function's comment.but
* it must be before the "{talendTypes}" key.
*
* 2. {talendTypes} 's value must be talend Type, it is required . its value should be one of: String, char | Character,
* long | Long, int | Integer, boolean | Boolean, byte | Byte, Date, double | Double, float | Float, Object, short |
* Short
*
* 3. {Category} define a category for the Function. it is required. its value is user-defined .
*
* 4. {param} 's format is: {param} <type> <name>
*
* <type> 's value should be one of: string, int, list, double, object, boolean, long, char, date. <name>'s value is the
* Function's parameter name. the {param} is optional. so if you the Function without the parameters. the {param} don't
* added. you can have many parameters for the Function.
*
* 5. {example} gives a example for the Function. it is optional.
*/
public class TestRoutine {
public static void rowHandlingTest(row1Struct myRow) {
System.out.println("My Row = "+myRow.toString());
}
}
routines.TestRoutine.rowHandlingTest(row1);
My Row = local_project.test_0_1.Test$row1Struct@5cb27de5
My Row = local_project.test_0_1.Test$row1Struct@5cb27de5
My Row = local_project.test_0_1.Test$row1Struct@5cb27de5
My Row = local_project.test_0_1.Test$row1Struct@5cb27de5
My Row = local_project.test_0_1.Test$row1Struct@5cb27de5
public static class row1Struct implements
routines.system.IPersistableRow<row1Struct> {
final static byte[] commonByteArrayLock_LOCAL_PROJECT_Test = new byte;
static byte[] commonByteArray_LOCAL_PROJECT_Test = new byte;
public String newColumn;
public String getNewColumn() {
return this.newColumn;
}
public String newColumn1;
public String getNewColumn1() {
return this.newColumn1;
}
public String newColumn2;
public String getNewColumn2() {
return this.newColumn2;
}
public String newColumn3;
public String getNewColumn3() {
return this.newColumn3;
}
public String newColumn4;
public String getNewColumn4() {
return this.newColumn4;
}
private String readString(ObjectInputStream dis) throws IOException {
String strReturn = null;
int length = 0;
length = dis.readInt();
if (length == -1) {
strReturn = null;
} else {
if (length > commonByteArray_LOCAL_PROJECT_Test.length) {
if (length < 1024
&& commonByteArray_LOCAL_PROJECT_Test.length == 0) {
commonByteArray_LOCAL_PROJECT_Test = new byte;
} else {
commonByteArray_LOCAL_PROJECT_Test = new byte;
}
}
dis.readFully(commonByteArray_LOCAL_PROJECT_Test, 0, length);
strReturn = new String(commonByteArray_LOCAL_PROJECT_Test, 0,
length, utf8Charset);
}
return strReturn;
}
private void writeString(String str, ObjectOutputStream dos)
throws IOException {
if (str == null) {
dos.writeInt(-1);
} else {
byte[] byteArray = str.getBytes(utf8Charset);
dos.writeInt(byteArray.length);
dos.write(byteArray);
}
}
public void readData(ObjectInputStream dis) {
synchronized (commonByteArrayLock_LOCAL_PROJECT_Test) {
try {
int length = 0;
this.newColumn = readString(dis);
this.newColumn1 = readString(dis);
this.newColumn2 = readString(dis);
this.newColumn3 = readString(dis);
this.newColumn4 = readString(dis);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
public void writeData(ObjectOutputStream dos) {
try {
// String
writeString(this.newColumn, dos);
// String
writeString(this.newColumn1, dos);
// String
writeString(this.newColumn2, dos);
// String
writeString(this.newColumn3, dos);
// String
writeString(this.newColumn4, dos);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(super.toString());
sb.append("");
return sb.toString();
}
/**
* Compare keys
*/
public int compareTo(row1Struct other) {
int returnValue = -1;
return returnValue;
}
private int checkNullsAndCompare(Object object1, Object object2) {
int returnValue = 0;
if (object1 instanceof Comparable && object2 instanceof Comparable) {
returnValue = ((Comparable) object1).compareTo(object2);
} else if (object1 != null && object2 != null) {
returnValue = compareStrings(object1.toString(),
object2.toString());
} else if (object1 == null && object2 != null) {
returnValue = 1;
} else if (object1 != null && object2 == null) {
returnValue = -1;
} else {
returnValue = 0;
}
return returnValue;
}
private int compareStrings(String string1, String string2) {
return string1.compareTo(string2);
}
}
package routines;
import local_project.test_0_1.Test.row1Struct;
/*
* user specification: the function's comment should contain keys as follows: 1. write about the function's comment.but
* it must be before the "{talendTypes}" key.
*
* 2. {talendTypes} 's value must be talend Type, it is required . its value should be one of: String, char | Character,
* long | Long, int | Integer, boolean | Boolean, byte | Byte, Date, double | Double, float | Float, Object, short |
* Short
*
* 3. {Category} define a category for the Function. it is required. its value is user-defined .
*
* 4. {param} 's format is: {param} <type> <name>
*
* <type> 's value should be one of: string, int, list, double, object, boolean, long, char, date. <name>'s value is the
* Function's parameter name. the {param} is optional. so if you the Function without the parameters. the {param} don't
* added. you can have many parameters for the Function.
*
* 5. {example} gives a example for the Function. it is optional.
*/
public class TestRoutine {
public static void rowHandlingTest(row1Struct myRow) {
System.out.println("My Row = "+myRow.toString());
}
}
routines.TestRoutine.rowHandlingTest(row1);
My Row = local_project.test_0_1.Test$row1Struct@5cb27de5
My Row = local_project.test_0_1.Test$row1Struct@5cb27de5
My Row = local_project.test_0_1.Test$row1Struct@5cb27de5
My Row = local_project.test_0_1.Test$row1Struct@5cb27de5
My Row = local_project.test_0_1.Test$row1Struct@5cb27de5
@Richard Hall hello Rhall. I followed the steps .
But when i run the job I get an error as follows
Could not find or load main class user_test.comparetwononpublishfiles_0_1.CompareTwoNonPublishFiles
The following are the row classes corresponding the row link that i have imported in my custom routine.
import user_test.comparetwononpublishfiles_0_1.CompareTwoNonPublishFiles.inpStruct;
import user_test.comparetwononpublishfiles_0_1.CompareTwoNonPublishFiles.refStruct;
I am using talend 7.3
Hi @Jijo George,
This post is a few years old and it seems that the configuration of Studio has changed so that you cannot reference a Job as a library anymore. I am sure it can be hacked, but there is a simpler way.
If your row is called row1, then to get a String representation of the whole row you can simply use....
System.out.println(row1.toString());
Replace System.out.println() with whatever method you want to pass the values to. You can use some String manipulation to retrieve the values from there.