Announcement

Collapse
No announcement yet.

Java Interfacae

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Java Interfacae

    Hi all,
    How can I call and use java interface class in javascript writer.

    For example,
    for(Column column : table.getColumns()){
    //Object value = row.get(column);
    System.out.println(column);

    while Column is interface class.
    Last edited by moon; 03-03-2020, 05:21 PM. Reason: Wrong spelling

  • #2
    Assuming tables.getcolumns() returns an object that implements Iterable,

    Code:
    for (var column in Iterator(table.getColumns())) {
        var value = row.get(column);
        logger.info(column);
    }
    Edit: FYI, the fact that Column is an interface has no bearing on this answer. The object referenced by the variable "column" will be seen as the actual object that implements the interface without doing any casting since javascript is not strictly typed. The Rhino function Iterator() will convert any Java Iterable or Iterator into a javascript iterator which can be used in a for..in loop.
    Last edited by agermano; 03-09-2020, 12:58 PM.

    Comment

    Working...
    X