Ejemplo n.º 1
0
        public void readColumn(Table tab)
        {
            Attribute att = tab.addAttribute(trimQuotes(token));
            att.setComment(getComment());
            current = getNextToken(current, ref token);
            string type = token;
            if (token.ToUpper() == "CHARACTER") {
                current = getNextToken(current, ref token);
                if (token.ToUpper() == "VARYING") {
                    type = type + " " + token; // Varying
                } else {
                    current = goBackToken(current, token);
                }
            }
            if ( token.ToUpper() == "TIMESTAMP") {
                current = getNextToken(current, ref token);
                if ( token.ToUpper() == "WITH" || token.ToUpper() == "WITHOUT") {
                    type = type + " " + token;
                    current = getNextToken(current, ref token);
                    if (token.ToUpper() == "TIME") {
                        type = type + " " + token;
                        current = getNextToken(current, ref token);
                        if (token.ToUpper() == "ZONE") {
                            type = type + " " + token;
                        }
                    }
                } else {
                    current = goBackToken(current, token);
                }

            }

            att.setType(type);

            current = getNextToken(current, ref token);
            // parameter of type
            if (token == "(") {
                List<string> typeParam = readList(false);
                att.setType (typeParam);
                current = getNextToken(current, ref token);
            }

            if (token.ToUpper() == "UNSIGNED") {
                current = getNextToken(current, ref token);
            }

            readColumnNULL(att);

            if (token.ToUpper() == "DEFAULT") {
                string default_token;
                current = getNextToken(current, ref token);
                default_token = "";
                do {
                    default_token += token;
                    if (token == "(") {
                        while (token != ")") {
                            current = getNextToken(current, ref token);
                            default_token += token;
                        }
                        current = getNextToken(current, ref token);
                    }
                    else {
                        current = getNextToken(current, ref token);
                        if (token == "(") {
                            default_token += token;
                            while (token != ")") {
                                current = getNextToken(current, ref token);
                                default_token += token;
                            }
                            current = getNextToken(current, ref token);
                        }
                    }
                } while (token[0] == ':');
                if ( (token.ToUpper() == "WITH") || (token.ToUpper() == "WITHOUT")) {
                    default_token = default_token + " " + token;
                    current = getNextToken(current, ref token);
                    if (token.ToUpper() == "TIME") {
                        default_token = default_token + " " + token;
                        current = getNextToken(current, ref token);
                        if (token.ToUpper() == "ZONE") {
                            default_token = default_token + " " + token;
                            current = getNextToken(current, ref token);
                        }
                    }
                }
                if (token.ToUpper() == "VARYING") {
                    default_token = default_token + " " + token; // Varying
                    current = getNextToken(current, ref token);
                }
                att.setDefault(default_token);
            }

            readColumnNULL(att);

            if (token.ToUpper() == "CHECK") {
                current = getNextToken(current, ref token);
                if (token == "(") {
                    string check = string.Empty;
                    current = getNextToken(current, ref token);
                    int openBrackets = 1;
                    while (openBrackets > 0 && current.Length != 0 && !hFile.EndOfStream) {
                        check += " " + token;
                        current = getNextToken(current, ref token);
                        if (token == ")") {
                            openBrackets --;
                        }
                        if (token == "(") {
                            openBrackets ++;
                        }
                    }
                    att.setCheck(check);
                    current = getNextToken(current, ref token);
                }

            }
            while ( token != ","
                && token != ")"
                && current.Length != 0 && !hFile.EndOfStream) {
                current = getNextToken(current, ref token);
            }
            if ( current.Trim().Length >= 2 && current.Trim().Substring(0, 2) == "--") {
                att.setComment(current.Trim().Substring(2));
                current = goToNextLine(current);
            }
        }