コード例 #1
0
        static void Main(string[] args)
        {
            Console.Write("\n This is TextQueryHandler!! ");
            TextQueryHandler      obj    = new TextQueryHandler();
            List <List <string> > inputs = new List <List <string> >();
            List <string>         dummy0 = new List <string>();
            List <string>         dummy  = new List <string>();
            List <string>         dummy1 = new List <string>();

            dummy0.Add("matchallqueries");
            inputs.Add(dummy0);
            dummy.Add("this");
            dummy.Add("that");
            inputs.Add(dummy);
            dummy1.Add("personal");
            dummy1.Add("office");
            inputs.Add(dummy1);
            obj.textQuery(List <List <string> > inputs);
        }
コード例 #2
0
        //initiates the QueryHandler for metadata query processing and text query processing
        protected override void ProcessMessages()
        {
            while (true)
            {
                ServiceMessage msg = bq.deQ();

                if (!msg.ResourceName.Equals("textquery"))
                {
                    QueryHandler          queryhandler = new QueryHandler();
                    List <List <string> > results      = queryhandler.MetaQuery(msg.nlist);

                    Console.Write("\n  {0} Recieved Message:\n", msg.TargetCommunicator);
                    msg.ShowMessage();
                    //Console.Write("\n  Query processing is an exercise for students\n");
                    if (msg.Contents == "quit")
                    {
                        break;
                    }
                    ServiceMessage reply = ServiceMessage.MakeQueryMessage("client-echo", "query", results, "reply from query");
                    reply.TargetUrl = msg.SourceUrl;
                    reply.SourceUrl = msg.TargetUrl;
                    AbstractMessageDispatcher dispatcher = AbstractMessageDispatcher.GetInstance();
                    dispatcher.PostMessage(reply);
                }

                else
                {
                    TextQueryHandler      textqueryhandler = new TextQueryHandler();
                    List <List <string> > results          = textqueryhandler.textQuery(msg.nlist);
                    if (msg.Contents == "quit")
                    {
                        break;
                    }
                    ServiceMessage reply = ServiceMessage.MakeQueryMessage("client-echo", "query", results, "reply from tquery");
                    reply.TargetUrl = msg.SourceUrl;
                    reply.SourceUrl = msg.TargetUrl;
                    AbstractMessageDispatcher dispatcher = AbstractMessageDispatcher.GetInstance();
                    dispatcher.PostMessage(reply);
                }
            }
        }