Search in sources :

Example 1 with CDOMReference

use of pcgen.cdom.base.CDOMReference in project pcgen by PCGen.

the class CoreUtils method getLoadID.

private static <T> String getLoadID(T obj) {
    if (obj instanceof Identified) {
        Identified l = (Identified) obj;
        String name = l.getDisplayName();
        String id = obj.getClass().getSimpleName() + ": " + name;
        if (!l.getKeyName().equals(name)) {
            id = id + " [" + l.getKeyName() + "]";
        }
        return id;
    } else if (obj instanceof QualifiedObject) {
        QualifiedObject<?> qo = (QualifiedObject<?>) obj;
        return getLoadID(qo.getRawObject());
    } else if (obj instanceof CDOMReference) {
        CDOMReference<?> ref = (CDOMReference<?>) obj;
        return ref.getReferenceClass().getSimpleName() + " Primitive: " + ref.getLSTformat(false);
    } else {
        return obj.getClass().getSimpleName() + ": " + obj.toString();
    }
}
Also used : Identified(pcgen.cdom.base.Identified) QualifiedObject(pcgen.core.QualifiedObject) CDOMReference(pcgen.cdom.base.CDOMReference)

Example 2 with CDOMReference

use of pcgen.cdom.base.CDOMReference in project pcgen by PCGen.

the class AbstractListContext method commit.

void commit() {
    ListCommitStrategy commit = getCommitStrategy();
    for (CDOMReference<? extends CDOMList<?>> list : edits.positiveMasterMap.getKeySet()) {
        //Note: Intentional Generics Violation due to Sun Compiler
        commitDirect((CDOMReference) list);
    }
    for (CDOMReference<? extends CDOMList<?>> list : edits.negativeMasterMap.getKeySet()) {
        //Note: Intentional Generics Violation due to Sun Compiler
        removeDirect((CDOMReference) list);
    }
    for (URI uri : edits.globalClearSet.getKeySet()) {
        for (CDOMObject owner : edits.globalClearSet.getSecondaryKeySet(uri)) {
            for (String tokenName : edits.globalClearSet.getTertiaryKeySet(uri, owner)) {
                for (CDOMReference<? extends CDOMList<?>> list : edits.globalClearSet.getListFor(uri, owner, tokenName)) {
                    commit.removeAllFromList(tokenName, owner, list);
                }
            }
        }
    }
    for (URI uri : edits.negativeMap.getKeySet()) {
        for (CDOMObject owner : edits.negativeMap.getSecondaryKeySet(uri)) {
            CDOMObject neg = edits.negativeMap.get(uri, owner);
            Collection<CDOMReference<? extends CDOMList<?>>> modifiedLists = neg.getModifiedLists();
            for (CDOMReference<? extends CDOMList<?>> list : modifiedLists) {
                //Note: Intentional Generics Violation due to Sun Compiler
                remove(owner, neg, (CDOMReference) list);
            }
        }
    }
    for (URI uri : edits.positiveMap.getKeySet()) {
        for (CDOMObject owner : edits.positiveMap.getSecondaryKeySet(uri)) {
            CDOMObject neg = edits.positiveMap.get(uri, owner);
            Collection<CDOMReference<? extends CDOMList<?>>> modifiedLists = neg.getModifiedLists();
            for (CDOMReference<? extends CDOMList<?>> list : modifiedLists) {
                //Note: Intentional Generics Violation due to Sun Compiler
                add(owner, neg, (CDOMReference) list);
            }
        }
    }
    for (String token : edits.masterAllClear.getKeySet()) {
        for (OwnerURI ou : edits.masterAllClear.getListFor(token)) {
            commit.clearAllMasterLists(token, ou.owner);
        }
    }
    rollback();
}
Also used : CDOMObject(pcgen.cdom.base.CDOMObject) CDOMList(pcgen.cdom.base.CDOMList) URI(java.net.URI) CDOMReference(pcgen.cdom.base.CDOMReference)

Example 3 with CDOMReference

use of pcgen.cdom.base.CDOMReference in project pcgen by PCGen.

the class ListChanges method getAdded.

@Override
public Collection<CDOMReference<T>> getAdded() {
    TreeSet<CDOMReference<T>> set = new TreeSet<>(ReferenceUtilities.REFERENCE_SORTER);
    Collection<CDOMReference<T>> listMods = positive.getListMods(list);
    if (listMods != null) {
        for (CDOMReference<T> ref : listMods) {
            for (AssociatedPrereqObject assoc : positive.getListAssociations(list, ref)) {
                if (tokenName.equals(assoc.getAssociation(AssociationKey.TOKEN))) {
                    set.add(ref);
                }
            }
        }
    }
    return set;
}
Also used : TreeSet(java.util.TreeSet) CDOMReference(pcgen.cdom.base.CDOMReference) AssociatedPrereqObject(pcgen.cdom.base.AssociatedPrereqObject)

Example 4 with CDOMReference

use of pcgen.cdom.base.CDOMReference in project pcgen by PCGen.

the class ListChanges method getRemoved.

@Override
public Collection<CDOMReference<T>> getRemoved() {
    TreeSet<CDOMReference<T>> set = new TreeSet<>(ReferenceUtilities.REFERENCE_SORTER);
    if (negative == null) {
        return set;
    }
    Collection<CDOMReference<T>> listMods = negative.getListMods(list);
    if (listMods != null) {
        for (CDOMReference<T> ref : listMods) {
            for (AssociatedPrereqObject assoc : negative.getListAssociations(list, ref)) {
                if (tokenName.equals(assoc.getAssociation(AssociationKey.TOKEN))) {
                    set.add(ref);
                }
            }
        }
    }
    return set;
}
Also used : TreeSet(java.util.TreeSet) CDOMReference(pcgen.cdom.base.CDOMReference) AssociatedPrereqObject(pcgen.cdom.base.AssociatedPrereqObject)

Example 5 with CDOMReference

use of pcgen.cdom.base.CDOMReference in project pcgen by PCGen.

the class AbstractListContext method remove.

private <BT extends CDOMObject, L extends CDOMList<BT>> void remove(CDOMObject owner, CDOMObject neg, CDOMReference<L> list) {
    ListCommitStrategy commit = getCommitStrategy();
    Collection<CDOMReference<BT>> mods = neg.getListMods(list);
    for (CDOMReference<BT> ref : mods) {
        for (AssociatedPrereqObject assoc : neg.getListAssociations(list, ref)) {
            String token = assoc.getAssociation(AssociationKey.TOKEN);
            AssociatedPrereqObject edge = commit.removeFromList(token, owner, list, ref);
            Collection<AssociationKey<?>> associationKeys = assoc.getAssociationKeys();
            for (AssociationKey<?> ak : associationKeys) {
                setAssoc(assoc, edge, ak);
            }
            edge.addAllPrerequisites(assoc.getPrerequisiteList());
        }
    }
}
Also used : AssociationKey(pcgen.cdom.enumeration.AssociationKey) CDOMReference(pcgen.cdom.base.CDOMReference) AssociatedPrereqObject(pcgen.cdom.base.AssociatedPrereqObject)

Aggregations

CDOMReference (pcgen.cdom.base.CDOMReference)125 ArrayList (java.util.ArrayList)57 StringTokenizer (java.util.StringTokenizer)40 AssociatedPrereqObject (pcgen.cdom.base.AssociatedPrereqObject)35 ParseResult (pcgen.rules.persistence.token.ParseResult)30 Skill (pcgen.core.Skill)24 ChoiceSet (pcgen.cdom.base.ChoiceSet)22 ConcretePersistentTransitionChoice (pcgen.cdom.base.ConcretePersistentTransitionChoice)21 ReferenceChoiceSet (pcgen.cdom.choiceset.ReferenceChoiceSet)19 Prerequisite (pcgen.core.prereq.Prerequisite)18 Formula (pcgen.base.formula.Formula)16 CDOMObject (pcgen.cdom.base.CDOMObject)15 Spell (pcgen.core.spell.Spell)15 TreeSet (java.util.TreeSet)14 Test (org.junit.Test)14 ClassSkillChoiceActor (pcgen.cdom.helper.ClassSkillChoiceActor)12 CharID (pcgen.cdom.enumeration.CharID)11 ObjectMatchingReference (pcgen.cdom.reference.ObjectMatchingReference)11 ParsingSeparator (pcgen.base.text.ParsingSeparator)10 CDOMList (pcgen.cdom.base.CDOMList)10