示例#1
0
        bool doScan(ParseStream oStream)
        {
            if (oStream.empty() || oStream.getData()[0] != '#')
                return false;

            oStream.consume(1);

            // read the characters, it is ok if they are empty
            int n = scanIFragmentChars(oStream.getData());
            oStream.consume(n);

            return true;
        }
示例#2
0
        /// <summary>
        /// Parses the input stream into the obj
        /// </summary>
        /// <param name="oStream">The input stream to scan from</param>
        /// <returns>True if part of the Stream was consumed into the obj</returns>
        bool doScan(ParseStream oStream)
        {
            if (oStream.getData()[0] == XRI.PDELIM)
            {
                this.mbPersistant = true;
                oStream.consume(1);
            }
            else if (oStream.getData()[0] == XRI.RDELIM)
            {
                oStream.consume(1);
            }
            else if (!mbAllowImpliedDelimiter)
            {
                return false;
            }

            // if there is a cross-reference, it has priority in scanning
            XRef oXRef = new XRef();
            if (oXRef.scan(oStream))
            {
                moXRef = oXRef;
                return true;
            }

            // read the characters, it is ok if they are empty
            int n = scanPChars(oStream.getData());
            oStream.consume(n);

            return true;
        }
示例#3
0
        /// <summary>
        /// Scans the Stream for a valid IRI-Authority
        /// </summary>
        /// <param name="oStream"></param>
        /// <returns></returns>
        bool doScan(ParseStream oStream)
        {
            bool bVal = false;
            int n = scanChars(oStream.getData());
            string sData = oStream.getData().Substring(0, n);
            try
            {
                moURI = new Uri("http", sData, null, null, null);
                String sHost = moURI.Host;
                if ((sHost != null) && (sHost.Length > 0))
                {
                    char cFirst = sHost[0];
                    bool bCheckIP = char.IsDigit(cFirst) ||
                        (cFirst == '[');
                    bVal = bCheckIP ? verifyIP(sHost) : verifyDNS(sHost);
                }
            }
            catch (UriFormatException e)
            { }

            // consume and return true if valid
            if (bVal)
            {
                oStream.consume(n);
                return true;
            }

            return false;
        }
示例#4
0
        /// <summary>
        /// Parses the input stream into the obj
        /// </summary>
        /// <param name="oStream">The input stream to scan from</param>
        /// <returns>True if part of the Stream was consumed into the obj</returns>
        bool doScan(ParseStream oStream)
        {
            // make sure we start with a slash
            if (oStream.empty() || (oStream.getData()[0] != '/'))
            {
                return false;
            }

            // consume the slash
            oStream.consume(1);

            // now scan the XRI segments as we are supposed to
            base.scanXRISegments(oStream);

            // return true no matter what, we got the slash
            return true;
        }
示例#5
0
文件: XRef.cs 项目: AArnott/dotnetxri
        /// <summary>
        /// Returns a non-null String if an IRI is consumed from the stream
        /// </summary>
        /// <param name="oStream"></param>
        /// <returns></returns>
        static string scanIRI(ParseStream oStream)
        {
            int n = scanIRIChars(oStream.getData());
            string data = oStream.getData().Substring(0, n);

            try
            {
                // try parsing to check validity, Java's URI parser may not be IRI compliant so
                // this is a TODO
                Uri u = new Uri(data);
                if (!u.IsAbsoluteUri)
                {
                    return null;
                }
            }
            catch (UriFormatException)
            {
                return null;
            }

            oStream.consume(n);
            return data;
        }
示例#6
0
        /// <summary>
        /// Parses the input stream into the GCS Character String
        /// </summary>
        /// <param name="oParseStream">The input stream to scan from</param>
        /// <returns>True if part of the Stream was consumed</returns>
        private bool scanGCSChar(ParseStream oParseStream)
        {
            if (oParseStream.empty())
            {
                return false;
            }

            switch (oParseStream.getData()[0])
            {
                case '+':
                case '=':
                case '@':
                case '$':
                case '!':
                    {
                        // this way provides a clean copy, whereas substring does not
                        msGCSRoot = char.ToString(oParseStream.getData()[0]);
                        oParseStream.consume(1);
                        return true;
                    }
            }

            return false;
        }