getSubSegmentAt() public method

Returns the subsegment at the given index
public getSubSegmentAt ( int nIndex ) : XRISubSegment
nIndex int The index of the subsegment to return
return XRISubSegment
Ejemplo n.º 1
0
        /*
        ****************************************************************************
        * 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
         */
        internal 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;
        }
Ejemplo n.º 2
0
        /*
        ****************************************************************************
        * 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.
         */
        internal CacheResult find(
            XRIAuthority oAuth, int nNextSubsegment, bool bCompleteChain,
            ArrayList 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);
        }