org.openprovenance.prov.xml.AttributeList Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of prov-xml Show documentation
Show all versions of prov-xml Show documentation
Java Objects representing the PROV model and an XML serialiser/deserialiser for them. Classes were initially generated by JAXB, from the XML schema for PROV, and over time edited by hand.
package org.openprovenance.prov.xml;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.openprovenance.prov.model.Attribute;
import org.openprovenance.prov.model.Identifiable;
public class AttributeList extends AbstractList {
private final ArrayList ll=new ArrayList();
private Identifiable obj;
public AttributeList(Identifiable obj) {
//System.out.println("*** Constructor called");
this.obj=obj;
}
public AttributeList(Identifiable obj, Collection col) {
this(obj);
ll.addAll(col);
}
@Override
public TYPE get(int index) {
return ll.get(index);
}
@Override
public TYPE set(int index, TYPE element) {
//System.out.println("*** AttributeList set " + index);
TYPE oldValue = ll.get(index);
ll.set(index,element);
return oldValue;
}
@Override
public int size() {
return ll.size();
}
@Override
public Object[] toArray() {
return (Object[]) ll.toArray();
}
public void add(int index,TYPE element){
//System.out.println("*** AttributeList add " + index + " " + element);
ll.add(index,element);
HasAllAttributes obj2=(HasAllAttributes)obj;
obj2.getAllAttributes().add((org.openprovenance.prov.model.Attribute)element);
}
final static public AttributeList populateKnownAttributes(Identifiable object,
List all,
Class cl) {
List some = new ArrayList();
if (all != null) {
for (Attribute attr : all) {
if (cl.isInstance(attr)) {
some.add((TYPE) attr);
}
}
}
return new AttributeList(object, some);
}
}