Beispiel #1
0
        public static string ConvertDefine(string in_renamed)
        {
            StringBuffer    out_renamed = new StringBuffer();
            StringTokenizer tk          = new StringTokenizer(in_renamed);

            while (tk.HasMoreElements())
            {
                string token = tk.NextToken();
                if (token.Equals("#define"))
                {
                    out_renamed.Append("\tpublic final static int ");
                    out_renamed.Append(tk.NextToken());
                    out_renamed.Append("= ");
                    out_renamed.Append(tk.NextToken());
                    out_renamed.Append(";\\t");
                    while (tk.HasMoreElements())
                    {
                        out_renamed.Append(tk.NextToken());
                        out_renamed.Append(" ");
                    }
                }
                else
                {
                    out_renamed.Append(token);
                    out_renamed.Append(" ");
                }
            }

            return(out_renamed.ToString());
        }
Beispiel #2
0
        public void test_hasMoreElements()
        {
            // Test for method boolean java.util.StringTokenizer.hasMoreElements()

            StringTokenizer st = new StringTokenizer("This is a test String");

            st.NextElement();
            Assertion.Assert("hasMoreElements returned incorrect value", st
                             .HasMoreElements());
            st.NextElement();
            st.NextElement();
            st.NextElement();
            st.NextElement();
            Assertion.Assert("hasMoreElements returned incorrect value", !st
                             .HasMoreElements());
        }
Beispiel #3
0
        private ICollection <Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse> ParseNameUses(string usesString, XmlElement
                                                                                                      element, XmlToModelResult xmlToModelResult)
        {
            ICollection <Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse> uses = CollUtils.SynchronizedSet(new LinkedSet <Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse
                                                                                                                                    >());

            if (StringUtils.IsNotBlank(usesString))
            {
                StringTokenizer tokenizer = new StringTokenizer(usesString);
                while (tokenizer.HasMoreElements())
                {
                    string token = tokenizer.NextToken();
                    Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse nameUse = CodeResolverRegistry.Lookup <Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse
                                                                                                                     >(token);
                    if (nameUse != null)
                    {
                        uses.Add(nameUse);
                    }
                    else
                    {
                        RecordError("Name use '" + token + "' not recognized.", element, xmlToModelResult);
                    }
                }
            }
            return(uses);
        }
Beispiel #4
0
        private ICollection <Ca.Infoway.Messagebuilder.Domainvalue.PostalAddressUse> ParseAddressUses(string nameUseAttribute, XmlNode
                                                                                                      node, XmlToModelResult xmlToModelResult)
        {
            ICollection <Ca.Infoway.Messagebuilder.Domainvalue.PostalAddressUse> uses = CollUtils.SynchronizedSet(new LinkedSet <Ca.Infoway.Messagebuilder.Domainvalue.PostalAddressUse
                                                                                                                                 >());

            if (nameUseAttribute != null)
            {
                StringTokenizer tokenizer = new StringTokenizer(nameUseAttribute);
                while (tokenizer.HasMoreElements())
                {
                    string token = tokenizer.NextToken();
                    Ca.Infoway.Messagebuilder.Domainvalue.PostalAddressUse postalAddressUse = CodeResolverRegistry.Lookup <Ca.Infoway.Messagebuilder.Domainvalue.PostalAddressUse
                                                                                                                           >(token);
                    if (postalAddressUse == null)
                    {
                        // error if a use is not found
                        RecordError("PostalAddressUse '" + token + "' is not valid", (XmlElement)node, xmlToModelResult);
                    }
                    else
                    {
                        uses.Add(postalAddressUse);
                    }
                }
            }
            return(uses);
        }
Beispiel #5
0
        private void ParseAddressUses(XmlNode node, TelecommunicationAddress result)
        {
            string addressUses = GetAttributeValue(node, "use");

            if (addressUses != null)
            {
                StringTokenizer tokenizer = new StringTokenizer(addressUses);
                while (tokenizer.HasMoreElements())
                {
                    result.AddAddressUse(CodeResolverRegistry.Lookup <Ca.Infoway.Messagebuilder.Domainvalue.TelecommunicationAddressUse>(tokenizer
                                                                                                                                         .NextToken()));
                }
            }
        }
Beispiel #6
0
        private TelecommunicationAddress ParseTelecommunicationAddress(XmlNode node, XmlToModelResult xmlToModelResult)
        {
            string value = GetAttributeValue(node, "value");

            if (StringUtils.IsBlank(value) && this.allowReference)
            {
                value = GetAttributeValue(node, "reference");
            }
            // remove the // that appear after the colon if necessary
            // e.g. file://monkey
            value = value == null ? null : System.Text.RegularExpressions.Regex.Replace(value, "://", ":");
            // anything before the FIRST colon is the URL scheme. Anything after it is the address.
            int    colonIndex = value == null ? -1 : value.IndexOf(':');
            string address    = null;

            Ca.Infoway.Messagebuilder.Domainvalue.URLScheme urlScheme = null;
            if (colonIndex == -1)
            {
                address = value;
            }
            else
            {
                address = Ca.Infoway.Messagebuilder.StringUtils.Substring(value, colonIndex + 1);
                string urlSchemeString = Ca.Infoway.Messagebuilder.StringUtils.Substring(value, 0, colonIndex);
                urlScheme = CodeResolverRegistry.Lookup <Ca.Infoway.Messagebuilder.Domainvalue.URLScheme>(urlSchemeString);
                if (urlScheme == null)
                {
                    string message = "Unrecognized URL scheme '" + urlSchemeString + "' in element " + XmlDescriber.DescribePath(node);
                    xmlToModelResult.AddHl7Error(new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, message, (XmlElement)node));
                }
            }
            TelecommunicationAddress result = new TelecommunicationAddress();

            result.Address   = address;
            result.UrlScheme = urlScheme;
            // handle address uses
            string addressUses = GetAttributeValue(node, "use");

            if (addressUses != null)
            {
                StringTokenizer tokenizer = new StringTokenizer(addressUses);
                while (tokenizer.HasMoreElements())
                {
                    result.AddAddressUse(CodeResolverRegistry.Lookup <Ca.Infoway.Messagebuilder.Domainvalue.TelecommunicationAddressUse>(tokenizer
                                                                                                                                         .NextToken()));
                }
            }
            return(result);
        }
        }       //	findSalesRep

        /**
         *  Find SalesRep/User based on Request Type and Question.
         *  @param request request
         *  @return SalesRep_ID user
         */
        private int FindSalesRep(MRequest request)
        {
            String QText = request.GetSummary();

            if (QText == null)
            {
                QText = "";
            }
            else
            {
                QText = QText.ToUpper();
            }
            //
            MRequestProcessorRoute[] routes = m_model.GetRoutes(false);
            for (int i = 0; i < routes.Length; i++)
            {
                MRequestProcessorRoute route = routes[i];

                //	Match first on Request Type
                if ((request.GetR_RequestType_ID() == route.GetR_RequestType_ID()) &&
                    (route.GetR_RequestType_ID() != 0))
                {
                    return(route.GetAD_User_ID());
                }

                //	Match on element of keyword
                String keyword = route.GetKeyword();
                if (keyword != null)
                {
                    StringTokenizer st = new StringTokenizer(keyword.ToUpper(), " ,;\t\n\r\f");
                    while (st.HasMoreElements())
                    {
                        if (QText.IndexOf(st.NextToken()) != -1)
                        {
                            return(route.GetAD_User_ID());
                        }
                    }
                }
            }   //	for all routes

            return(m_model.GetSupervisor_ID());
        }   //  findSalesRep
Beispiel #8
0
        /// <summary>
        /// Is it OK to Run process On IP of this box
        /// </summary>
        /// <returns></returns>
        public bool IsOKtoRunOnIP()
        {
            String ipOnly = GetRunOnlyOnIP();

            if (ipOnly == null || ipOnly.Length == 0)
            {
                return(true);
            }

            StringTokenizer st = new StringTokenizer(ipOnly, ";");

            while (st.HasMoreElements())
            {
                String ip = st.NextToken();
                if (CheckIP(ip))
                {
                    return(true);
                }
            }
            return(false);
        }       //	isOKtoRunOnIP
        }   //  parse

        public String ParseAndSaveLine(String line, int AD_Client_ID, int AD_Org_ID, int C_Element_ID, MTree tree)
        {
            log.Config(line);

            //  Fields with ',' are enclosed in "
            StringBuilder   newLine = new StringBuilder();
            StringTokenizer st      = new StringTokenizer(line, "\"", false);

            newLine.Append(st.NextToken());         //  first part
            while (st.HasMoreElements())
            {
                String s = st.NextToken();           //  enclosed part
                newLine.Append(s.Replace(',', ' ')); //  remove ',' with space
                if (st.HasMoreTokens())
                {
                    newLine.Append(st.NextToken()); //  unenclosed
                }
            }
            //  add space at the end        - tokenizer does not count empty fields
            newLine.Append(" ");

            //  Parse Line - replace ",," with ", ,"    - tokenizer does not count empty fields
            String pLine = Utility.Util.Replace(newLine.ToString(), ",,", ", ,");

            pLine = Utility.Util.Replace(pLine, ",,", ", ,");
            st    = new StringTokenizer(pLine, ",", false);
            //  All fields there ?
            if (st.CountTokens() == 1)
            {
                log.Log(Level.SEVERE, "Ignored: Require ',' as separator - " + pLine);
                return("");
            }
            if (st.CountTokens() < 9)
            {
                log.Log(Level.SEVERE, "Ignored: FieldNumber wrong: " + st.CountTokens() + " - " + pLine);
                return("");
            }

            //  Fill variables
            String Value = null, Name = null, Description = null,
                   AccountType = null, AccountSign = null, IsDocControlled = null,
                   IsSummary = null, Default_Account = null;
            int accountParent = -1;

            //
            for (int i = 0; i < 9 && st.HasMoreTokens(); i++)
            {
                String s = st.NextToken().Trim();
                //  Ignore, if is it header line
                if (s.StartsWith("[") && s.EndsWith("]"))
                {
                    return("");
                }
                if (s == null)
                {
                    s = "";
                }
                //
                if (i == 0)                     //	A - Value
                {
                    Value = s;
                }
                else if (i == 1)        //	B - Name
                {
                    Name = s;
                }
                else if (i == 2)        //	C - Description
                {
                    Description = s;
                }
                else if (i == 3)        //	D - Type
                {
                    AccountType = s.Length > 0 ? s[0].ToString() : "E";
                }
                else if (i == 4)        //	E - Sign
                {
                    AccountSign = s.Length > 0 ? s[0].ToString() : "N";
                }
                else if (i == 5)        //	F - DocControlled
                {
                    IsDocControlled = s.Length > 0 ? s[0].ToString() : "N";
                }
                else if (i == 6)        //	G - IsSummary
                {
                    IsSummary = s.Length > 0 ? s[0].ToString() : "N";
                }
                else if (i == 7)        //	H - Default_Account
                {
                    Default_Account = s;
                }
                else if (i == 8)
                {
                    accountParent = Util.GetValueOfInt(s);
                }
            }

            //	Ignore if Value & Name are empty (no error message)
            if ((Value == null || Value.Length == 0) && (Name == null || Name.Length == 0))
            {
                return("");
            }
            ////////////////////
            //Commented By Lakhwinder
            ////  Default Account may be blank
            //if (Default_Account == null || Default_Account.Length == 0)
            //    //	Default_Account = String.valueOf(s_keyNo++);
            //    return "";

            ////	No Summary Account
            //if (IsSummary == null || IsSummary.Length == 0)
            //    IsSummary = "N";
            //if (!IsSummary.Equals("N"))
            //    return "";

            ////  Validation
            //if (AccountType == null || AccountType.Length == 0)
            //    AccountType = "E";

            //if (AccountSign == null || AccountSign.Length == 0)
            //    AccountSign = "N";
            //if (IsDocControlled == null || IsDocControlled.Length == 0)
            //    IsDocControlled = "N";
            //////////////////////

            //	log.config( "Value=" + Value + ", AcctType=" + AccountType
            //		+ ", Sign=" + AccountSign + ", Doc=" + docControlled
            //		+ ", Summary=" + summary + " - " + Name + " - " + Description);

            try
            {
                //	Try to find - allows to use same natutal account for multiple default accounts
                MElementValue na = null;
                if (m_valueMap.ContainsKey(Value))
                {
                    na = (MElementValue)m_valueMap[Value];
                }
                if (na == null)
                {
                    //  Create Account - save later
                    na = new MElementValue(m_ctx, Value, Name, Description, AccountType, AccountSign, IsDocControlled.ToUpper().StartsWith("Y"), IsSummary.ToUpper().StartsWith("Y"), m_trx);
                    int refElementID = Util.GetValueOfInt(DB.ExecuteScalar(@"SELECT C_ElementValue_ID FROM C_ElementValue
                                                                                    WHERE IsActive='Y' AND AD_Client_ID=" + na.GetAD_Client_ID() + " AND Value='" + accountParent + @"'
                                                                                    AND C_Element_ID=" + C_Element_ID, null, m_trx));
                    na.SetRef_C_ElementValue_ID(refElementID);
                    m_valueMap[Value] = na;
                    na.SetAD_Client_ID(AD_Client_ID);
                    na.SetAD_Org_ID(AD_Org_ID);
                    na.SetC_Element_ID(C_Element_ID);
                    na.SetVIS_DefaultAccount(Default_Account);
                    if (!na.Save(m_trx))
                    {
                        return("Acct Element Values NOT inserted");
                        //m_info.Append(Msg.Translate(m_lang, "C_ElementValue_ID")).Append(" # ").Append(m_nap.Count).Append("\n");
                    }
                    VAdvantage.Model.MTreeNode mNode = VAdvantage.Model.MTreeNode.Get(tree, na.Get_ID());
                    if (mNode == null)
                    {
                        mNode = new VAdvantage.Model.MTreeNode(tree, na.Get_ID());
                    }
                    ((VAdvantage.Model.PO)mNode).Set_Value("Parent_ID", refElementID);
                    if (!mNode.Save(m_trx))
                    {
                        return("Acct Element Values NOT inserted");
                    }
                }

                if (!(Default_Account == null || Default_Account.Length == 0))
                {
                    //  Add to Cache
                    s_base.Add(Default_Account.ToUpper(), na);
                }
            }
            catch (Exception e)
            {
                return(e.Message);
            }

            return("");
        }   //
        /// <summary>
        /// Create Account Entry for Default Accounts only.
        /// </summary>
        /// <param name="line">line with info
        /// <para>
        /// Line format (9 fields)
        /// 1	A   [Account Value]
        /// 2	B   [Account Name]
        /// 3	C   [Description]
        /// 4	D   [Account Type]
        /// 5	E   [Account Sign]
        /// 6	F   [Document Controlled]
        /// 7	G   [Summary Account]
        /// 8	H   [Default_Account]
        /// 9	I   [Parent Value] - ignored
        /// </para>
        /// </param>
        /// <returns>error message or "" if OK</returns>
        public String ParseLine(String line)
        {
            log.Config(line);

            //  Fields with ',' are enclosed in "
            StringBuilder   newLine = new StringBuilder();
            StringTokenizer st      = new StringTokenizer(line, "\"", false);

            newLine.Append(st.NextToken());         //  first part
            while (st.HasMoreElements())
            {
                String s = st.NextToken();           //  enclosed part
                newLine.Append(s.Replace(',', ' ')); //  remove ',' with space
                if (st.HasMoreTokens())
                {
                    newLine.Append(st.NextToken()); //  unenclosed
                }
            }
            //  add space at the end        - tokenizer does not count empty fields
            newLine.Append(" ");

            //  Parse Line - replace ",," with ", ,"    - tokenizer does not count empty fields
            String pLine = Utility.Util.Replace(newLine.ToString(), ",,", ", ,");

            pLine = Utility.Util.Replace(pLine, ",,", ", ,");
            st    = new StringTokenizer(pLine, ",", false);
            //  All fields there ?
            if (st.CountTokens() == 1)
            {
                log.Log(Level.SEVERE, "Ignored: Require ',' as separator - " + pLine);
                return("");
            }
            if (st.CountTokens() < 9)
            {
                log.Log(Level.SEVERE, "Ignored: FieldNumber wrong: " + st.CountTokens() + " - " + pLine);
                return("");
            }

            //  Fill variables
            String Value = null, Name = null, Description = null,
                   AccountType = null, AccountSign = null, IsDocControlled = null,
                   IsSummary = null, Default_Account = null;

            //
            for (int i = 0; i < 8 && st.HasMoreTokens(); i++)
            {
                String s = st.NextToken().Trim();
                //  Ignore, if is it header line
                if (s.StartsWith("[") && s.EndsWith("]"))
                {
                    return("");
                }
                if (s == null)
                {
                    s = "";
                }
                //
                if (i == 0)                     //	A - Value
                {
                    Value = s;
                }
                else if (i == 1)        //	B - Name
                {
                    Name = s;
                }
                else if (i == 2)        //	C - Description
                {
                    Description = s;
                }
                else if (i == 3)        //	D - Type
                {
                    AccountType = s.Length > 0 ? s[0].ToString() : "E";
                }
                else if (i == 4)        //	E - Sign
                {
                    AccountSign = s.Length > 0 ? s[0].ToString() : "N";
                }
                else if (i == 5)        //	F - DocControlled
                {
                    IsDocControlled = s.Length > 0 ? s[0].ToString() : "N";
                }
                else if (i == 6)        //	G - IsSummary
                {
                    IsSummary = s.Length > 0 ? s[0].ToString() : "N";
                }
                else if (i == 7)        //	H - Default_Account
                {
                    Default_Account = s;
                }
            }

            //	Ignore if Value & Name are empty (no error message)
            if ((Value == null || Value.Length == 0) && (Name == null || Name.Length == 0))
            {
                return("");
            }

            //  Default Account may be blank
            if (Default_Account == null || Default_Account.Length == 0)
            {
                //	Default_Account = String.valueOf(s_keyNo++);
                return("");
            }

            //	No Summary Account
            if (IsSummary == null || IsSummary.Length == 0)
            {
                IsSummary = "N";
            }
            if (!IsSummary.Equals("N"))
            {
                return("");
            }

            //  Validation
            if (AccountType == null || AccountType.Length == 0)
            {
                AccountType = "E";
            }

            if (AccountSign == null || AccountSign.Length == 0)
            {
                AccountSign = "N";
            }
            if (IsDocControlled == null || IsDocControlled.Length == 0)
            {
                IsDocControlled = "N";
            }


            //	log.config( "Value=" + Value + ", AcctType=" + AccountType
            //		+ ", Sign=" + AccountSign + ", Doc=" + docControlled
            //		+ ", Summary=" + summary + " - " + Name + " - " + Description);

            try
            {
                //	Try to find - allows to use same natutal account for multiple default accounts
                MElementValue na = null;
                if (m_valueMap.ContainsKey(Value))
                {
                    na = (MElementValue)m_valueMap[Value];
                }
                if (na == null)
                {
                    //  Create Account - save later
                    na = new MElementValue(m_ctx, Value, Name, Description, AccountType, AccountSign, IsDocControlled.ToUpper().StartsWith("Y"), IsSummary.ToUpper().StartsWith("Y"), m_trx);
                    m_valueMap[Value] = na;
                }

                //  Add to Cache
                s_base.Add(Default_Account.ToUpper(), na);
            }
            catch (Exception e)
            {
                return(e.Message);
            }

            return("");
        }   //  parseLine
Beispiel #11
0
        /// <summary>
        ///Add table alias to identifier in where clause
        /// </summary>
        /// <param name="where">where</param>
        /// <param name="alias">alias</param>
        /// <returns>converted where clause</returns>
        private String AddAliasToIdentifier(String where, String alias)
        {
            String sqlkey = "AND,OR,FROM,WHERE,JOIN,BY,GROUP,IN,INTO,SELECT,NOT,SET,UPDATE,DELETE,HAVING,IS,NULL,EXISTS,BETWEEN,LIKE,INNER,OUTER";

            StringTokenizer st     = new StringTokenizer(where);
            String          result = "";
            String          token  = "";
            int             o      = -1;

            while (true)
            {
                token = st.NextToken();
                String test = token.StartsWith("(") ? token.Substring(1) : token;
                if (sqlkey.IndexOf(test) == -1)
                {
                    token = token.Trim();
                    //skip subquery, non identifier and fully qualified identifier
                    if (o != -1)
                    {
                        result = result + " " + token;
                    }
                    else
                    {
                        result = result + " ";
                        StringBuilder t = new StringBuilder();
                        for (int i = 0; i < token.Length; i++)
                        {
                            char c = token[i];
                            if (IsOperator(c))
                            {
                                if (t.Length > 0)
                                {
                                    if (c == '(')
                                    {
                                        result = result + t.ToString();
                                    }
                                    else if (IsIdentifier(t.ToString()) &&
                                             t.ToString().IndexOf('.') == -1)
                                    {
                                        result = result + alias + "." + t.ToString();
                                    }
                                    else
                                    {
                                        result = result + t.ToString();
                                    }
                                    t = new StringBuilder();
                                }
                                result = result + c;
                            }
                            else
                            {
                                t.Append(c);
                            }
                        }
                        if (t.Length > 0)
                        {
                            if ("SELECT".Equals(t.ToString().ToUpper()))
                            {
                                o      = 0;
                                result = result + t.ToString();
                            }
                            else if (IsIdentifier(t.ToString()) &&
                                     t.ToString().IndexOf('.') == -1)
                            {
                                result = result + alias + "." + t.ToString();
                            }
                            else
                            {
                                result = result + t.ToString();
                            }
                        }
                    }

                    if (o != -1)
                    {
                        for (int i = 0; i < token.Length; i++)
                        {
                            char c = token[i];
                            if (c == '(')
                            {
                                o++;
                            }
                            if (c == ')')
                            {
                                o--;
                            }
                        }
                    }
                }
                else
                {
                    result = result + " " + token;
                    if ("SELECT".Equals(test, StringComparison.OrdinalIgnoreCase))
                    {
                        o = 0;
                    }
                }
                if (!st.HasMoreElements())
                {
                    break;
                }
            }
            return(result);
        }
Beispiel #12
0
        }       //	report

        /// <summary>
        ///	Read Response
        /// </summary>
        /// <param name="inn">input stream</param>
        /// <returns>error message</returns>
        private String ReadResponse(StreamReader inn)
        {
            StringBuilder sb                = new StringBuilder();
            int           Record_ID         = 0;
            String        ResponseText      = null;
            String        RequestDocumentNo = null;

            try                 //	Get Answer
            {
                int c;
                while ((c = inn.Read()) != -1)
                {
                    sb.Append((char)c);
                }
                inn.Close();
                log.Fine(sb.ToString());
                String clear = HttpUtility.UrlEncode(sb.ToString(), UTF8Encoding.UTF8);      //  "UTF-8");
                log.Fine(clear);
                //	Interpret Data
                StringTokenizer st = new StringTokenizer(clear, DELIMITER);
                while (st.HasMoreElements())
                {
                    String pair = st.NextToken();
                    try
                    {
                        int index = pair.IndexOf("=");
                        if (pair.StartsWith("RECORDID="))
                        {
                            String info = pair.Substring(index + 1);
                            Record_ID = Utility.Util.GetValueOfInt(info);
                        }
                        else if (pair.StartsWith("RESPONSE="))
                        {
                            ResponseText = pair.Substring(index + 1);
                        }
                        else if (pair.StartsWith("DOCUMENTNO="))
                        {
                            RequestDocumentNo = pair.Substring(index + 1);
                        }
                    }
                    catch (Exception e)
                    {
                        log.Warning(pair + " - " + e.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Log(Level.FINE, "", ex);
                return("Reading-" + ex.Message);
            }

            if (Record_ID != 0)
            {
                SetRecord_ID(Record_ID);
            }
            if (ResponseText != null)
            {
                SetResponseText(ResponseText);
            }
            if (RequestDocumentNo != null)
            {
                SetRequestDocumentNo(RequestDocumentNo);
            }
            return(null);
        }       //	readResponse