How to transfer a list of objects using BusMethod

asked 2015-06-01 04:29:02 -0700

julianbros gravatar image

updated 2015-06-01 04:32:06 -0700

Hey there!

let's assume we have a function to deliver/exchange information using AllJoyn and BusMethods. In another forum I've read that it isn't possible to exchange ArrayList<someobject> using the Bus, because there is no type signature for Lists. I don't want to send each single object using the bus...</someobject>

Any help?

Thank you!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-06-21 23:38:06 -0700

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

Ok. I've found the solution on my own. There are two available possibilities to send/receive a number of objects "a list of objects" due to use of BusMethod interfaces.

One solution is to use arrays.. unfortunately not a good way in my opinion, because they're static and changing/adding something in the list is a little bit difficult, because of copying the array, incrementing the index and adding the new object... My opinion, please leave me a message if I'm going to think to complicated ;-)

On the other hand you are able to provide a HashMap as a transfer object using BusMethods. Yes, indeed, an BusMethod returning an ArrayList would result in BAD_ANNOTATION when registering the BusObject to the Bus, but actually you can transfer a HashMap ... really funny.

* Copyright Julian Rossbach
* Replace "Node" with the type you wan't to transfer. I do not guarantee full functionality as this is just a thought/workaround based on my experience with AllJoyn!
* Make shure to have defined this type fully valid! 
* Send me a mail if you've got further improvements or any comments: jr@rossbach-systems.eu
public class DataTypeList{
//The List of items, each with a dedicated id (Integer)
public Map<Integer, Node> list;

//The current size of the list
public int size = 0;

public DataTypeList(){
    list = new HashMap<Integer, Node>();

public void add(Node n){
    this.list.put(size++, n);

public Node get(int index){
        Node result = this.list.get(String.valueOf(index));
        return result;
    }catch(Exception e){
        throw new NoSuchElementException();

public void remove(int index){
    if(index == 0)
        throw new IndexOutOfBoundsException();


private void rebuildList(int startIndex) {
    Node myTemp;
    for(int i = startIndex; i<=size; i++){
        int next = i+1;
        myTemp = get(next);
        list.put(startIndex, myTemp);

public void setSize(int size){
    if(size < 0) throw new IllegalArgumentException("List size must be positive or at least zero!");
    this.size = size;

public Integer getSize(){
    return this.size;

public Map<Integer, Node> getList(){
    return this.list;


edit flag offensive delete publish link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-06-01 04:29:02 -0700

Seen: 60 times

Last updated: Jun 21 '15