Esempio n. 1
0
        /// <summary>
        /// Parses the input stream into XRISegmentVals
        /// </summary>
        /// <param name="oPathStream">The input stream to scan from</param>
        protected void scanXRISegments(ParseStream oPathStream)
        {
            // sets whether colons are allowed
            bool bAllowColon = mbAllowColon;

            // loop through the XRI segments as long as we are consuming something
            bool bConsumed = true;
            while (!oPathStream.empty() && bConsumed)
            {
                bConsumed = false;
                ParseStream oStream = oPathStream.begin();
                bool bStartsWithSlash = (oStream.getData()[0] == '/');

                // if this is the first segment, it must not start with slash
                if ((bStartsWithSlash) && (moSegments.Count == 0))
                {
                    break;
                }

                // if this is not the first segment, we expect a slash
                if ((!bStartsWithSlash) && (moSegments.Count > 0))
                {
                    break;
                }

                // consume the slash if necessary
                if (bStartsWithSlash)
                {
                    bConsumed = true;
                    oStream.consume(1);
                }

                // if there is actually a segment, add it to the list
                XRISegment oSegment = new XRISegment(true, bAllowColon, true);
                if (oSegment.scan(oStream))
                {
                    bConsumed = true;
                    moSegments.Add(oSegment);
                }

                // consume whatever we used (even if the segment was empty)
                oPathStream.end(oStream);

                // after the first segment, colons are allowed
                bAllowColon = true;
            }
        }
Esempio n. 2
0
        bool doScan(ParseStream oStream)
        {
            if (oStream.empty())
            {
                return false;
            }

            ParseStream oTempStream = oStream.begin();

            // make sure we have a valid XRI Value
            XRef oXRef = new XRef();
            if (!oXRef.scan(oTempStream))
            {
                return false;
            }

            // at this point, we know we have enough for a valid xref
            oStream.end(oTempStream);
            moXRoot = oXRef;

            // the cross-reference MAY be followed by an XRI Segment
            // where the star cannot be assumed
            XRISegment oSegment = new XRISegment(false, true, true);
            if (oSegment.scan(oStream))
            {
                moSegment = oSegment;
            }

            return true;
        }
Esempio n. 3
0
        bool doScan(ParseStream oStream)
        {
            if (oStream.empty())
            {
                return false;
            }

            if (oStream.getData()[0] != '(')
            {
                return false;
            }

            ParseStream oTempStream = oStream.begin();
            oTempStream.consume(1);

            String sIRI = null;
            // make sure we have a valid XRI reference
            XRIReference oRef = scanXRIReference(oTempStream);
            if (oRef == null || oTempStream.empty() || (oTempStream.getData()[0] != ')'))
            {
                // if we got a reference, but the resulting temp stream is empty or does not begin with ')'
                // it got parsed wrongly (happens if the XRef is an IRI). Retry parsing with an IRI
                if (oRef != null)
                {
                    oTempStream = oStream.begin();
                    oTempStream.consume(1);
                }
                // if there is no XRI Reference, see if it is an IRI
                sIRI = scanIRI(oTempStream);
                if (sIRI == null)
                {
                    return false;
                }
            }

            // make sure we have the trailing ')'
            if (oTempStream.empty() || (oTempStream.getData()[0] != ')'))
            {
                return false;
            }

            // at this point, complete consumption and return true
            oTempStream.consume(1);
            oStream.end(oTempStream);
            moXRIRef = oRef;
            msIRI = sIRI;

            return true;
        }
Esempio n. 4
0
        /// <summary>
        /// Scans the stream for parts that can be parsed into the obj
        /// </summary>
        /// <param name="oParseStream">The input stream to read from</param>
        /// <returns>Returns true if all or part of the stream could be
        /// parsed into the obj</returns>
        public bool scan(ParseStream oParseStream)
        {
            if (oParseStream == null)
            {
                return false;
            }

            ParseStream oStream = oParseStream.begin();

            if (doScan(oStream))
            {
                setParsedValue(oParseStream.getConsumed(oStream));
                oParseStream.end(oStream);
                return true;
            }

            return false;
        }