Exemple #1
0
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private boolean Process(boolean toStringFlag) throws java.sql.SQLException, java.io.IOException
        private bool Process(bool toStringFlag)


        {
            if (!this.runFlag_)

            {
                return(false);
            }

            if (this.category_ == 0L)

            {
                if (this.promptFlag_ == true)

                {
                    GetPrompt();
                }

                string line = null;
                if (this.inReader_ == null)

                {
                    this.inReader_ = new System.IO.StreamReader(System.in, Encoding.UTF8);
                }

                line = this.inReader_.ReadLine();

                if ((string.ReferenceEquals(line, null)) || (this.quitStrList_.Contains(line)))

                {
                    return(false);
                }

                ProcessLine(line, toStringFlag);
                return(true);
            }

            string fs     = GlobalBehavior.GetInstance().GetFieldSeparator();
            string outStr = this.lexAccessApi_.GetResultStrByCategory(this.category_, this.showQuery_, this.query_,
                                                                      this.noOutputFlag_, this.noOutputMsg_, this.showTotalRecNum_, this.formatOpt_, fs);


            this.out_.Print(this.outWriter_, outStr, this.fileOutput_, toStringFlag);
            return(false);
        }
Exemple #2
0
        private string GetLexRecords(string inTerm)
        {
            string resultStr = "";
            string fs        = GlobalBehavior.GetInstance().GetFieldSeparator();


            if ((string.ReferenceEquals(inTerm, null)) || (inTerm.Length == 0))

            {
                return(resultStr);
            }

            try

            {
                if (this.baseOpt_ == 0)

                {
                    resultStr = this.lexAccessApi_.GetResultStrByTerm(inTerm, this.outCat_, this.showQuery_,
                                                                      this.query_, this.noOutputFlag_, this.noOutputMsg_, this.showTotalRecNum_, this.formatOpt_, fs);
                }
                else

                {
                    resultStr = this.lexAccessApi_.GetResultStrByBase(inTerm, this.baseOpt_, this.outCat_,
                                                                      this.showQuery_, this.query_, this.noOutputFlag_, this.noOutputMsg_, this.showTotalRecNum_,
                                                                      this.formatOpt_, fs);
                }
            }
            catch (Exception e)

            {
                Console.Error.WriteLine("** ERR: " + e.Message);
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
            }

            return(resultStr);
        }
Exemple #3
0
        protected internal virtual void ExecuteCommand(OptionItem optionItem, Option systemOption, Out @out)

        {
            OptionItem nameItem = OptionUtility.GetItemByName(optionItem, systemOption, false);

            if (CheckOption(nameItem, "-b:b") == true)

            {
                this.baseOpt_ = 1;
            }
            else if (CheckOption(nameItem, "-b:c") == true)

            {
                this.baseOpt_ = 2;
            }
            else if (CheckOption(nameItem, "-b:e") == true)

            {
                this.baseOpt_ = 3;
            }
            else if (CheckOption(nameItem, "-b:ex") == true)

            {
                this.baseOpt_ = 4;
            }
            else if (CheckOption(nameItem, "-c:a") == true)

            {
                this.category_ |= Category.ToValue("adj");
            }
            else if (CheckOption(nameItem, "-c:all") == true)

            {
                this.category_ |= 0x7FF;
            }
            else if (CheckOption(nameItem, "-c:b") == true)

            {
                this.category_ |= Category.ToValue("adv");
            }
            else if (CheckOption(nameItem, "-c:c") == true)

            {
                this.category_ |= Category.ToValue("compl");
            }
            else if (CheckOption(nameItem, "-c:d") == true)

            {
                this.category_ |= Category.ToValue("det");
            }
            else if (CheckOption(nameItem, "-c:h") == true)

            {
                LexAccessHelp.CategoryHelp(this.outWriter_, this.fileOutput_, @out);
                this.runFlag_ = false;
            }
            else if (CheckOption(nameItem, "-c:j") == true)

            {
                this.category_ |= Category.ToValue("conj");
            }
            else if (CheckOption(nameItem, "-c:m") == true)

            {
                this.category_ |= Category.ToValue("modal");
            }
            else if (CheckOption(nameItem, "-c:n") == true)

            {
                this.category_ |= Category.ToValue("noun");
            }
            else if (CheckOption(nameItem, "-c:p") == true)

            {
                this.category_ |= Category.ToValue("prep");
            }
            else if (CheckOption(nameItem, "-c:r") == true)

            {
                this.category_ |= Category.ToValue("pron");
            }
            else if (CheckOption(nameItem, "-c:v") == true)

            {
                this.category_ |= Category.ToValue("verb");
            }
            else if (CheckOption(nameItem, "-c:x") == true)

            {
                this.category_ |= Category.ToValue("aux");
            }
            else if (CheckOption(nameItem, "-ci") == true)

            {
                try

                {
                    bool   useClassPath = false;
                    string configFile   = this.configFile_;
                    if (string.ReferenceEquals(configFile, null))

                    {
                        useClassPath = true;
                        configFile   = "data.config.lexAccess";
                    }

                    Configuration conf = new Configuration(configFile, useClassPath);


                    if (this.properties_ != null)

                    {
                        conf.OverwriteProperties(this.properties_);
                    }

                    @out.Println(this.outWriter_, conf.GetInformation(), this.fileOutput_, false);
                }
                catch (IOException)
                {
                }

                this.runFlag_ = false;
            }
            else if (CheckOption(nameItem, "-cn:LONG") == true)

            {
                long cat = long.Parse(nameItem.GetOptionArgument());
                if ((cat <= 0L) || (cat > 2047L))

                {
                    string temp = "*** Error: Illegal value for category (" + cat + ").";

                    try

                    {
                        @out.Println(this.outWriter_, temp, this.fileOutput_, false);
                    }
                    catch (IOException)
                    {
                    }

                    this.runFlag_ = false;
                }
                else

                {
                    this.category_ = long.Parse(nameItem.GetOptionArgument());
                }
            }
            else if (CheckOption(nameItem, "-cnf:LONG") == true)

            {
                this.outCat_ = long.Parse(nameItem.GetOptionArgument());
            }
            else if (CheckOption(nameItem, "-f:b") == true)

            {
                this.formatOpt_ = 3;
            }
            else if (CheckOption(nameItem, "-f:bd") == true)

            {
                this.formatOpt_ = 4;
            }
            else if (CheckOption(nameItem, "-f:h") == true)

            {
                LexAccessHelp.FormatHelp(this.outWriter_, this.fileOutput_, @out);
                this.runFlag_ = false;
            }
            else if (CheckOption(nameItem, "-f:i") == true)

            {
                this.formatOpt_ = 7;
            }
            else if (CheckOption(nameItem, "-f:id") == true)

            {
                this.formatOpt_ = 8;
            }
            else if (CheckOption(nameItem, "-f:s") == true)

            {
                this.formatOpt_ = 5;
            }
            else if (CheckOption(nameItem, "-f:sd") == true)

            {
                this.formatOpt_ = 6;
            }
            else if (CheckOption(nameItem, "-f:t") == true)

            {
                this.formatOpt_ = 0;
            }
            else if (CheckOption(nameItem, "-f:tx") == true)

            {
                this.formatOpt_ = 2;
            }
            else if (CheckOption(nameItem, "-f:x") == true)

            {
                this.formatOpt_ = 1;
            }
            else if (CheckOption(nameItem, "-h") == true)

            {
                LexAccessHelp.LexAccessHelp(this.outWriter_, this.fileOutput_, @out);
                this.runFlag_ = false;
            }
            else if (CheckOption(nameItem, "-hs") == true)

            {
                systemOption.PrintOptionHierachy();
                this.runFlag_ = false;
            }
            else if (CheckOption(nameItem, "-i:STR") == true)

            {
                string inFile = nameItem.GetOptionArgument();
                if (!string.ReferenceEquals(inFile, null))

                {
                    try

                    {
                        this.inReader_ = new System.IO.StreamReader(
                            new System.IO.FileStream(inFile, System.IO.FileMode.Open, System.IO.FileAccess.Read),
                            Encoding.UTF8);
                    }
                    catch (IOException)

                    {
                        this.runFlag_ = false;
                        Console.Error.WriteLine("**Error: problem of opening/reading file " + inFile);
                    }
                }
            }
            else if (CheckOption(nameItem, "-n") == true)

            {
                this.noOutputFlag_ = true;
            }
            else if (CheckOption(nameItem, "-o:STR") == true)

            {
                string outFile = nameItem.GetOptionArgument();
                if (!string.ReferenceEquals(outFile, null))

                {
                    try

                    {
                        this.outWriter_ = new System.IO.StreamWriter(
                            new System.IO.FileStream(outFile, System.IO.FileMode.Create, System.IO.FileAccess.Write),
                            Encoding.UTF8);

                        this.fileOutput_ = true;
                    }
                    catch (IOException)

                    {
                        this.runFlag_ = false;
                        Console.Error.WriteLine("**Error: problem of opening/writing file " + outFile);
                    }
                }
            }
            else if (CheckOption(nameItem, "-p") == true)

            {
                this.promptFlag_ = true;
            }
            else if (CheckOption(nameItem, "-q") == true)

            {
                this.query_     = this.option_.GetOptionStr();
                this.showQuery_ = true;
            }
            else if (CheckOption(nameItem, "-rv:STR") == true)

            {
                this.version_ = nameItem.GetOptionArgument();
                if (!SetVersionInConfig(this.version_))

                {
                    Console.Error.WriteLine("**Err@LexAccessCmdApi(): Illegal version setting (" + this.version_ + ")");


                    this.runFlag_ = false;
                }
            }
            else if (CheckOption(nameItem, "-s:STR") == true)

            {
                string separator = nameItem.GetOptionArgument();

                if (separator.Equals("\\t"))

                {
                    separator = (new char?('\t')).ToString();
                }

                GlobalBehavior.GetInstance().SetFieldSeparator(separator);
            }
            else if (CheckOption(nameItem, "-t") == true)

            {
                this.showTotalRecNum_ = true;
            }
            else if (CheckOption(nameItem, "-v") == true)

            {
                try

                {
                    string releaseStr = "lexAccess.2016";
                    @out.Println(this.outWriter_, releaseStr, this.fileOutput_, false);
                }
                catch (IOException)
                {
                }

                this.runFlag_ = false;
            }
            else if (CheckOption(nameItem, "-x:STR") == true)

            {
                this.configFile_ = nameItem.GetOptionArgument();
            }
        }