Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 56 additions & 28 deletions common/src/main/java/com/genexus/GXBaseList.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,39 @@
import com.genexus.internet.IGxJSONAble;
import com.genexus.internet.IGxJSONSerializable;

public abstract class GXBaseList<T> extends Vector<T> implements Serializable, IGxJSONAble, IGxJSONSerializable, IGXAssigned
{
public abstract class GXBaseList<T> extends Vector<T> implements Serializable, IGxJSONAble, IGxJSONSerializable, IGXAssigned {
private boolean IsAssigned;

public GXBaseList()
{
public GXBaseList() {
IsAssigned = true;
}

public boolean getIsAssigned()
{
public boolean getIsAssigned() {
return this.IsAssigned;
}
public void setIsAssigned(boolean bAssigned)
{
public void setIsAssigned(boolean bAssigned) {
this.IsAssigned = bAssigned;
}
public void removeAllItems()
{
public void removeAllItems() {
super.clear();
IsAssigned = true;
}
public byte removeItem(int index)
{
public byte removeItem(int index) {
T item = null;
if(index > 0 && index <= size())
{
if(index > 0 && index <= size()) {
item = super.remove((int)index - 1);//Vector.remove(int)
IsAssigned = true;
return (byte)1;
}
return (byte)0;
}
public byte removeElement(double index)
{
if(index > 0 && index <= size())
{
public byte removeElement(double index) {
if(index > 0 && index <= size()) {
super.remove((int)index - 1);//Vector.remove(int)
IsAssigned = true;
return (byte)1;
}
else
{
else {
return (byte)0;
}
}
Expand All @@ -58,24 +48,62 @@ public void addObject(Object obj){
IsAssigned = true;
}
@SuppressWarnings("unchecked")
public void add(Object item, int index)
{
if(index < 1 || index > size())
{
public void add(Object item, int index) {
if(index < 1 || index > size()) {
add((T)item); //this.add, GXBCLevelCollection.add for example
}
else
{
else {
super.add(index - 1, (T)item); //Vector insert element
IsAssigned = true;
}
}
@SuppressWarnings("unchecked")
public void addBase( Object item)
{
public void addBase( Object item) {
super.add((T)item);
IsAssigned = true;
}

public boolean addRange( GXBaseList<T> baseList, Number index) {
if (baseList.size() == 0)
return true;

boolean result;
if (index == null) {
result = addAll(baseList);
}
else {
int nindex = index.intValue();
if(nindex != 1 && (nindex < 0 || nindex > size() +1))
return false;
if (nindex == 0)
nindex = 1;
result = addAll(nindex -1, baseList);
}
IsAssigned = true;
return result;
}

public boolean removeRange( int index, Number count) {
int colSize = size();
if(index <= 0 || index > colSize || (count != null && index + count.intValue() > colSize))
return false;
int toIndex;
if (count == null)
toIndex = colSize;
else
toIndex = count.intValue();
super.removeRange(index -1, toIndex);
IsAssigned = true;
return true;
}

public boolean setElement( int index, T element) {
if(index < 1 || index > size())
return false;
super.set(index -1, element);
IsAssigned = true;
return true;
}
}


Expand Down
12 changes: 12 additions & 0 deletions common/src/main/java/com/genexus/GXSimpleCollection.java
Original file line number Diff line number Diff line change
Expand Up @@ -1352,5 +1352,17 @@ public boolean update(){
return false;
}

public boolean addRange( GXSimpleCollection<T> baseList, Number index) {
return super.addRange(baseList, index);
}

public boolean removeRange( int index, Number count) {
return super.removeRange(index, count);
}

public boolean setElement( int index, T element) {
return super.setElement(index, element);
}


}