Exemplo n.º 1
0
        /// <summary>
        /// Tests to see if this absolute path is a subsegment-wise prefix of
        /// the given <code>path</code>.
        /// </summary>
        /// <param name="path"></param>
        /// <returns>true if <code>path</code> is prefixed with or exactly the same as this XRIAbsolutePath obj.</returns>
        public bool isPrefixOf(XRIAbsolutePath path)
        {
            int n = this.getNumSegments();
            // first, if we have more segments than the given path, return false
            if (n > path.getNumSegments())
                return false;

            // compare segment by segment
            for (int i = 0; i < n; i++)
            {
                XRISegment seg = getSegmentAt(i);
                if (i == n - 1)
                {
                    // final segment, can be a suffix
                    if (!seg.isPrefixOf(path.getSegmentAt(i)))
                        return false;
                }
                else if (!seg.EqualsIgnoreCase(path.getSegmentAt(i)))
                    // not final segment, must be equal
                    return false;
            }
            return true;
        }
Exemplo n.º 2
0
        static XRIPath scanXRIPath(ParseStream oStream)
        {
            // check for a local path regardless of scanAuthority outcome
            XRIAbsolutePath oPath = new XRIAbsolutePath();
            if (oPath.scan(oStream))
            {
                return oPath;
            }
            else
            {
                XRINoSchemePath oRelativePath = new XRINoSchemePath();
                if (oRelativePath.scan(oStream))
                {
                    return oRelativePath;
                }
            }

            return null;
        }