package fr.inrialpes.exmo.ontosim.entity.model;

import java.lang.ref.Reference;
import java.lang.ref.SoftReference;
import java.util.List;
import java.util.Set;
import java.util.Vector;

import fr.inrialpes.exmo.ontowrap.HeavyLoadedOntology;

public class HLIndividualImpl<E> extends HLEntityImpl<E> implements HLIndividual<E> {

    protected HLIndividualImpl(HeavyLoadedOntology<E> ont, E e) {
	super(ont, e);
	// TODO Auto-generated constructor stub
    }

    private List<Reference<Set<HLClass<E>>>> classes;
    
    /* Individual methods */
    @SuppressWarnings("unchecked")
    public Set<HLClass<E>> getClasses(int local, int asserted, int named ) {
	if (classes==null) classes=new Vector<Reference<Set<HLClass<E>>>>();
	int idx = getIdx(local,asserted,named);
	while (classes.size()<=idx) classes.add(null);
	if (classes.get(idx)==null  || classes.get(idx).get()==null) 
	    classes.set(idx, new SoftReference<Set<HLClass<E>>>((Set<HLClass<E>>)fact.getFrom((Set<E>)onto.getClasses(getObject(), local, asserted, named))));
	return classes.get(idx).get();
    }
}
