You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.2 KiB
52 lines
1.2 KiB
package de.memtext.baseobjects; |
|
|
|
import java.util.Collection; |
|
import java.util.LinkedList; |
|
|
|
/** |
|
* |
|
* @author MB |
|
* List with different behaviour when setting items, |
|
* when index higher than count of elements doesn't throw |
|
* Exception, but adds as many nulls as necessary up to the |
|
* right count of elements and then sets the indicated position to |
|
* the new value |
|
* |
|
* * If for example a value for column 5 is to be stored, but the data List only |
|
* contains values for column 1 and 2, for column 3 and 4 null values are stored. |
|
|
|
* */ |
|
public class DataList extends LinkedList { |
|
private static final long serialVersionUID = 1; |
|
|
|
/** |
|
* |
|
*/ |
|
public DataList() { |
|
super(); |
|
} |
|
|
|
/** |
|
* @param c |
|
*/ |
|
public DataList(Collection c) { |
|
super(c); |
|
|
|
} |
|
|
|
/** |
|
* If for example a value for column 5 is to be stored, but the data List only |
|
* contains values for column 1 and 2, for column 3 and 4 null values are stored. |
|
|
|
*/ |
|
@Override |
|
public Object set(int index, Object o) { |
|
while (index > this.size() - 1) { |
|
this.add(null); |
|
} |
|
Object previous = this.get(index); |
|
super.set(index, o); |
|
return previous; |
|
} |
|
|
|
}
|
|
|