view src/org/dancres/blitz/DiskView.java @ 0:3dc0c5604566

Initial checkin of blitz 2.0 fcs - no installer yet.
author Dan Creswell <dan.creswell@gmail.com>
date Sat, 21 Mar 2009 11:00:06 +0000
parents
children
line wrap: on
line source

package org.dancres.blitz;

import org.dancres.blitz.entry.SearchOffer;
import org.dancres.blitz.entry.SearchVisitor;
import org.dancres.blitz.mangler.MangledEntry;

/**
 * Responsible for sourcing matching Entry's from the EntryRepositories to
 * go into the UIDSet
 */
class DiskView implements SearchVisitor {
    private UIDSet theUIDs;
    private MangledEntry theTemplate;

    DiskView(MangledEntry aTemplate, UIDSet aSet) {
        theTemplate = aTemplate;
        theUIDs = aSet;
    }

    public int offer(SearchOffer anOffer) {
        MangledEntry myTarget = anOffer.getEntry();

        if (theTemplate.match(myTarget)) {
            // Need to record a globally unique id for later
            theUIDs.add(new SpaceEntryUID(anOffer.getEntry().getType(),
                                            anOffer.getInfo().getOID()));
        }

        if (theUIDs.isFull())
            return STOP;
        else
            return TRY_AGAIN;
    }

    /**
       @return <code>true</code> if this Visitor wishes to perform a take.
     */
    public boolean isDeleter() {
        return false;
    }
}