Exemplo n.º 1
0
    } // find()

    /*
    ****************************************************************************
    * mkdir()
    ****************************************************************************
    */ /**
    *  Creates an entry under this CacheNode for the given subsegments
    * @param oAuth - The authority to add
    * @param n - The index of the subsegment to start with
    * @param iTargetDepth - The index of the subsegment to stop at.
    * @return The final CacheNode created by this method
    */
    CacheNode mkdir(XRIAuthority oAuth, int n, int iTargetDepth)
    {
        XRISubSegment oSubSegment = oAuth.getSubSegmentAt(n);
        if (oSubSegment == null)
        {
            return this;
        }

        CacheNode oNode = mkdir(oSubSegment.toString());

        return ((n + 1) < iTargetDepth)
        ? oNode.mkdir(oAuth, n + 1, iTargetDepth) : oNode;

    } // mkdir()
Exemplo n.º 2
0
    } // removeSelf()

    /*
    ****************************************************************************
    * find()
    ****************************************************************************
    */ /**
    * Finds subsegments under this CacheNode.  Will popluate oCachedDescriptors
    * along the way.
    * @param oAuth - The authority to search for
    * @param nNextSubsegment - The index of the next subsegment to search for
    * @param bCompleteChain - Whether or not a descriptor is necessary for all
    * subsegments in oAuth
    * @param oCachedDescriptors - If not null, stores descriptors found in the
    * cache, in the order of the subsegments.
    */
    CacheResult find(
        XRIAuthority oAuth, int nNextSubsegment, bool bCompleteChain,
        Vector oCachedDescriptors)
    {
        // if there are no new subsegments to get, just return "this", we are done
        XRISubSegment oSubSegment = oAuth.getSubSegmentAt(nNextSubsegment);
        if (oSubSegment == null)
        {
            return new CacheResult(this, nNextSubsegment);
        }

        // also return if we can't find the next subsegment
        CacheNode oNode = find(oSubSegment.toString());
        if (oNode == null)
        {
            return new CacheResult(this, nNextSubsegment);
        }

        // if the found node doesn't have a cached value, potentially bail
        if (
            (oNode.moCacheValue == null) ||
            (oNode.moCacheValue.getDescriptor() == null))
        {
            if (bCompleteChain)
            {
                return new CacheResult(this, nNextSubsegment);
            }
        }
        else if (oCachedDescriptors != null)
        {
            oCachedDescriptors.add(oNode.moCacheValue.getDescriptor());
        }

        // N O T E: The direcory metaphore used here allows for directories
        //           to be "empty" (null moCacheValue) and still have subdirs.
        //	     
        // As we recurse up, if the returned CacheNode has an empty
        // moCacheValue, we'll return "this" unless they caller does not
        // allow partials.
        return oNode.find(
            oAuth, nNextSubsegment + 1, bCompleteChain, oCachedDescriptors);

    } // find()