Пример #1
0
		protected HqlTreeNode(int type, string text, IASTFactory factory, IEnumerable<HqlTreeNode> children)
		{
			Factory = factory;
			_node = factory.CreateNode(type, text);
			_children = new List<HqlTreeNode>();

			AddChildren(children);
		}
Пример #2
0
        protected HqlTreeNode(int type, string text, IASTFactory factory, IEnumerable <HqlTreeNode> children)
        {
            Factory   = factory;
            _node     = factory.CreateNode(type, text);
            _children = new List <HqlTreeNode>();

            AddChildren(children);
        }
Пример #3
0
        public IASTNode Append(int type, String text, bool appendIfEmpty)
        {
            if (text != null && (appendIfEmpty || text.Length > 0))
            {
                return(parent.AddChild(factory.CreateNode(type, text)));
            }

            return(null);
        }
Пример #4
0
        protected HqlTreeNode(int type, string text, IASTFactory factory, params HqlTreeNode[] children)
        {
            _node = factory.CreateNode(type, text);
            _children = new List<HqlTreeNode>();

            foreach (var child in children)
            {
                _children.Add(child);
                _node.AddChild(child.AstNode);
            }
        }
Пример #5
0
		/// <summary>
		/// Generates the scalar column AST nodes for a given array of SQL columns
		/// </summary>
		public static void GenerateScalarColumns(IASTFactory factory, IASTNode node, string[] sqlColumns, int i)
		{
			if (sqlColumns.Length == 1)
			{
				GenerateSingleScalarColumn(factory, node, i);
			}
			else
			{
				node.Text = sqlColumns[0]; // Use the DOT node to emit the first column name.

				// Create the column names, folled by the column aliases.
				for (int j = 0; j < sqlColumns.Length; j++)
				{
					if (j > 0)
					{
						node = node.AddSibling(factory.CreateNode(HqlSqlWalker.SQL_TOKEN, sqlColumns[j]));
					}

					node = node.AddSibling(factory.CreateNode(HqlSqlWalker.SELECT_COLUMNS, " as " + NameGenerator.ScalarName(i, j)));
				}
			}
		}
Пример #6
0
        /// <summary>
        /// Generates the scalar column AST nodes for a given array of SQL columns
        /// </summary>
        public static void GenerateScalarColumns(IASTFactory factory, IASTNode node, string[] sqlColumns, int i)
        {
            if (sqlColumns.Length == 1)
            {
                GenerateSingleScalarColumn(factory, node, i);
            }
            else
            {
                node.Text = sqlColumns[0];                 // Use the DOT node to emit the first column name.

                // Create the column names, folled by the column aliases.
                for (int j = 0; j < sqlColumns.Length; j++)
                {
                    if (j > 0)
                    {
                        node = node.AddSibling(factory.CreateNode(HqlSqlWalker.SQL_TOKEN, sqlColumns[j]));
                    }

                    node = node.AddSibling(factory.CreateNode(HqlSqlWalker.SELECT_COLUMNS, " as " + NameGenerator.ScalarName(i, j)));
                }
            }
        }
Пример #7
0
		/// <summary>
		/// Turns a path into an AST.
		/// </summary>
		/// <param name="path">The path.</param>
		/// <param name="factory">The AST factory to use.</param>
		/// <returns>An HQL AST representing the path.</returns>
		public static IASTNode ParsePath(string path, IASTFactory factory)
		{
			string[] identifiers = StringHelper.Split(".", path);
			IASTNode lhs = null;
			for (int i = 0; i < identifiers.Length; i++)
			{
				string identifier = identifiers[i];
				IASTNode child = factory.CreateNode(HqlSqlWalker.IDENT, identifier);
				if (i == 0)
				{
					lhs = child;
				}
				else
				{
					lhs = factory.CreateNode(HqlSqlWalker.DOT, ".", lhs, child);
				}
			}
			if (log.IsDebugEnabled)
			{
				log.Debug("parsePath() : " + path + " -> " + ASTUtil.GetDebugstring(lhs));
			}
			return lhs;
		}
Пример #8
0
        /// <summary>
        /// Turns a path into an AST.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="factory">The AST factory to use.</param>
        /// <returns>An HQL AST representing the path.</returns>
        public static IASTNode ParsePath(string path, IASTFactory factory)
        {
            string[] identifiers = StringHelper.Split(".", path);
            IASTNode lhs         = null;

            for (int i = 0; i < identifiers.Length; i++)
            {
                string   identifier = identifiers[i];
                IASTNode child      = factory.CreateNode(HqlSqlWalker.IDENT, identifier);
                if (i == 0)
                {
                    lhs = child;
                }
                else
                {
                    lhs = factory.CreateNode(HqlSqlWalker.DOT, ".", lhs, child);
                }
            }
            if (log.IsDebugEnabled())
            {
                log.Debug("parsePath() : {0} -> {1}", path, ASTUtil.GetDebugstring(lhs));
            }
            return(lhs);
        }
Пример #9
0
		public static void GenerateSingleScalarColumn(IASTFactory factory, IASTNode node, int i)
		{
			node.AddSibling(factory.CreateNode(HqlSqlWalker.SELECT_COLUMNS, " as " + NameGenerator.ScalarName(i, 0)));
		}
Пример #10
0
 public static void GenerateSingleScalarColumn(IASTFactory factory, IASTNode node, int i)
 {
     node.AddSibling(factory.CreateNode(HqlSqlWalker.SELECT_COLUMNS, " as " + NameGenerator.ScalarName(i, 0)));
 }