[hibernate-commits] Hibernate SVN: r16364 - core/branches/antlr3/src/main/java/org/hibernate/sql/ast/common.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Mon Apr 20 17:34:30 EDT 2009


Author: steve.ebersole at jboss.com
Date: 2009-04-20 17:34:30 -0400 (Mon, 20 Apr 2009)
New Revision: 16364

Added:
   core/branches/antlr3/src/main/java/org/hibernate/sql/ast/common/HibernateToken.java
   core/branches/antlr3/src/main/java/org/hibernate/sql/ast/common/HibernateTree.java
Log:
token and tree types

Added: core/branches/antlr3/src/main/java/org/hibernate/sql/ast/common/HibernateToken.java
===================================================================
--- core/branches/antlr3/src/main/java/org/hibernate/sql/ast/common/HibernateToken.java	                        (rev 0)
+++ core/branches/antlr3/src/main/java/org/hibernate/sql/ast/common/HibernateToken.java	2009-04-20 21:34:30 UTC (rev 16364)
@@ -0,0 +1,70 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat Middleware LLC or third-party
+ * contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors.  All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software
+ * Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+ * License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA  02110-1301  USA
+ */
+
+package org.hibernate.sql.ast.common;
+
+import org.antlr.runtime.CommonToken;
+import org.antlr.runtime.Token;
+import org.antlr.runtime.CharStream;
+
+/**
+ * Models the token-type/text portion of an Antlr tree for a specific node in said tree.
+ *
+ * @author Steve Ebersole
+ */
+public class HibernateToken extends CommonToken {
+       public HibernateToken(int type) {
+               super(type);
+       }
+
+       public HibernateToken(CharStream input, int type, int channel, int start,
+                       int stop) {
+               super(input, type, channel, start, stop);
+       }
+
+       public HibernateToken(int type, String text) {
+               super(type, text);
+       }
+
+       /**
+        * Constructor that preserves the char offset
+        *
+        * @param oldToken
+        */
+       public HibernateToken(Token oldToken) {
+               super(oldToken);
+               if (null != oldToken
+                               && (oldToken.getClass().equals(CommonToken.class) || oldToken
+                                               .getClass().equals(HibernateToken.class))) {
+                       start = ((CommonToken) oldToken).getStartIndex();
+                       stop = ((CommonToken) oldToken).getStopIndex();
+               }
+       }
+
+}

Added: core/branches/antlr3/src/main/java/org/hibernate/sql/ast/common/HibernateTree.java
===================================================================
--- core/branches/antlr3/src/main/java/org/hibernate/sql/ast/common/HibernateTree.java	                        (rev 0)
+++ core/branches/antlr3/src/main/java/org/hibernate/sql/ast/common/HibernateTree.java	2009-04-20 21:34:30 UTC (rev 16364)
@@ -0,0 +1,103 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat Middleware LLC or third-party
+ * contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors.  All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software
+ * Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+ * License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA  02110-1301  USA
+ */
+package org.hibernate.sql.ast.common;
+
+import org.antlr.runtime.tree.CommonTree;
+import org.antlr.runtime.tree.Tree;
+import org.antlr.runtime.Token;
+
+/**
+ * todo : javadocs
+ *
+ * @author Steve Ebersole
+ */
+public class HibernateTree extends CommonTree {
+	/**
+	 * start char offset
+	 */
+	int startCharOffset = -1;
+
+	/**
+	 * end char offset
+	 */
+	int endCharOffset = -1;
+
+	public HibernateTree(HibernateTree node) {
+		super( node );
+		this.token = node.token;
+	}
+
+	public HibernateTree(Token token) {
+		super( token );
+	}
+
+	public HibernateTree(int type, String text) {
+		this( new HibernateToken( type, text ) );
+	}
+
+	public Tree dupNode() {
+		return new HibernateTree( this );
+	}
+
+	/**
+	 * getter for start char offset
+	 *
+	 * @return start char offset
+	 */
+	public int getStartCharOffset() {
+		return startCharOffset;
+	}
+
+	/**
+	 * setter for start char offset
+	 *
+	 * @param startCharOffset start char offset
+	 */
+	public void setStartCharOffset(int startCharOffset) {
+		this.startCharOffset = startCharOffset;
+	}
+
+	/**
+	 * getter of end char offset
+	 *
+	 * @return end char offset
+	 */
+	public int getEndCharOffset() {
+		return endCharOffset;
+	}
+
+	/**
+	 * setter of end char offset
+	 *
+	 * @param endCharOffset end char offset
+	 */
+	public void setEndCharOffset(int endCharOffset) {
+		this.endCharOffset = endCharOffset;
+	}
+}




More information about the hibernate-commits mailing list