Previous Topic

Next Topic

Book Contents

Book Index

Supporting Arrays and Collections

Collections are also supported. Their implementations can be supplied as arguments as options with or without a generic type.

Usually only the last parameter in the method can be array or collection.

Example 1:

@Command

public void command1(

@Argument() int number,

@Argument() LinkedList<Byte> data) {

}

If you run:

command1 10 20 30 40 50 0xf

you will get:

int number = 10

LinkedList<Byte> data = [ 20, 30, 40, 50, 0xf ]

Example 2:

@Command

public void command2(

@Argument() int number,

@Argument() byte[] data)

{ }

If you run:

command2 10 20 30 40 50 0xf

you will get:

int number = 10

byte[] data = [ 20, 30, 40, 50, 0xf ]

An exception of this rule is when a single command-line parameter is mapped to array or collection.

Here is an example:

@Command

public void command3(

@Argument() Bundle[] bundle

@Argument() int[] states){

}

----

command3 core.* 1 1 1 1

In that case:

Bundle[] bundles = [com.prosyst.mbs.core.api, com.prosyst.mbs.core.threads, ...]

int[] state = [ 1, 1, 1, 1 ]