View Javadoc

1   /*
2    * ModeShape (http://www.modeshape.org)
3    * See the COPYRIGHT.txt file distributed with this work for information
4    * regarding copyright ownership.  Some portions may be licensed
5    * to Red Hat, Inc. under one or more contributor license agreements.
6    * See the AUTHORS.txt file in the distribution for a full listing of 
7    * individual contributors.
8    *
9    * ModeShape is free software. Unless otherwise indicated, all code in ModeShape
10   * is licensed to you under the terms of the GNU Lesser General Public License as
11   * published by the Free Software Foundation; either version 2.1 of
12   * the License, or (at your option) any later version.
13   * 
14   * ModeShape is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17   * Lesser General Public License for more details.
18   *
19   * You should have received a copy of the GNU Lesser General Public
20   * License along with this software; if not, write to the Free
21   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
23   */
24  package org.modeshape.sequencer.ddl.dialect.derby;
25  
26  import java.util.Arrays;
27  import java.util.List;
28  
29  import org.modeshape.graph.property.Name;
30  import org.modeshape.sequencer.ddl.DdlConstants;
31  import org.modeshape.sequencer.ddl.StandardDdlLexicon;
32  
33  /**
34   * @author blafond
35   *
36   */
37  public interface DerbyDdlConstants extends DdlConstants {
38  	public static final String[] CUSTOM_KEYWORDS = {
39  		"TRIGGER", "SYNOMYM", "LOCK", "ISOLATION", "SQLID", INDEX, "RENAME", "DECLARE", "RESTART", "LOCKSIZE",
40  		"INCREMENT", "GENERATED", "ALWAYS", "BIGINT", "CLOB", "BLOB", "EXCLUSIVE", "REFERENCING" 
41  	};
42  	
43  	interface DerbyStatementStartPhrases {
44  		
45  	    static final String[][] ALTER_PHRASES = { 
46  		};
47  	    
48  		static final String[] STMT_CREATE_FUNCTION = {CREATE, "FUNCTION"};
49  		static final String[] STMT_CREATE_INDEX = {CREATE, "INDEX"};
50  		static final String[] STMT_CREATE_UNIQUE_INDEX = {CREATE, "UNIQUE", INDEX};
51  		static final String[] STMT_CREATE_PROCEDURE = {CREATE, "PROCEDURE"};
52  		static final String[] STMT_CREATE_ROLE = {CREATE, "ROLE"};
53  		static final String[] STMT_CREATE_SYNONYM = {CREATE, "SYNONYM"};
54  		static final String[] STMT_CREATE_TRIGGER = {CREATE, "TRIGGER"};
55  		
56  	    static final String[][] CREATE_PHRASES = { 
57  	    	STMT_CREATE_FUNCTION, STMT_CREATE_INDEX, STMT_CREATE_UNIQUE_INDEX, STMT_CREATE_PROCEDURE, 
58  	    	STMT_CREATE_ROLE, STMT_CREATE_SYNONYM, STMT_CREATE_TRIGGER
59  		};
60  	    
61  	    static final String[] STMT_DECLARE_GLOBAL_TEMP_TABLE = {"DECLARE", "GLOBAL", "TEMPORARY", "TABLE"};
62  		static final String[] STMT_DROP_FUNCTION = {DROP, "FUNCTION"};
63  		static final String[] STMT_DROP_INDEX = {DROP, "INDEX"};
64  		static final String[] STMT_DROP_PROCEDURE = {DROP, "PROCEDURE"};
65  		static final String[] STMT_DROP_ROLE = {DROP, "ROLE"};
66  		static final String[] STMT_DROP_SYNONYM = {DROP, "SYNONYM"};
67  		static final String[] STMT_DROP_TRIGGER = {DROP, "TRIGGER"};
68  		
69  	    static final String[][] DROP_PHRASES = { 
70  	    	STMT_DROP_FUNCTION, STMT_DROP_INDEX, STMT_DROP_PROCEDURE, STMT_DROP_ROLE, STMT_DROP_SYNONYM, STMT_DROP_TRIGGER 
71  		};
72  
73  		static final String[] STMT_LOCK_TABLE = {"LOCK", TABLE};
74  		static final String[] STMT_RENAME_TABLE = {"RENAME", TABLE};
75  		static final String[] STMT_RENAME_INDEX = {"RENAME", INDEX};
76  
77  	    
78  		static final String[] STMT_SET_ISOLATION = {SET, "ISOLATION"};
79  		static final String[] STMT_SET_CURRENT_ISOLATION = {SET, "CURRENT", "ISOLATION"};
80  		static final String[] STMT_SET_ROLE = {SET, "ROLE"};
81  		static final String[] STMT_SET_SCHEMA = {SET, "SCHEMA"};
82  		static final String[] STMT_SET_CURRENT_SCHEMA = {SET, "CURRENT", SCHEMA};
83  		static final String[] STMT_SET_CURRENT_SQLID = {SET, "CURRENT", "SQLID"};
84  		
85  	    static final String[][] SET_PHRASES = { 
86  	    	STMT_SET_ISOLATION, STMT_SET_CURRENT_ISOLATION, STMT_SET_ROLE, STMT_SET_SCHEMA, STMT_SET_CURRENT_SCHEMA,
87  	    	STMT_SET_CURRENT_SQLID
88  		};
89  	    
90  	    static final String[][] MISC_PHRASES = { STMT_LOCK_TABLE, STMT_RENAME_TABLE, STMT_RENAME_INDEX,
91  	    	STMT_DECLARE_GLOBAL_TEMP_TABLE
92  		};
93  	    
94  	    // COULD NOT FIND ACTUAL REFERENCE... assuming the following....
95  	    
96  	    public final static Name[] VALID_SCHEMA_CHILD_STMTS = {
97  	    	StandardDdlLexicon.TYPE_CREATE_TABLE_STATEMENT, 
98  	    	StandardDdlLexicon.TYPE_CREATE_VIEW_STATEMENT,
99  	    	StandardDdlLexicon.TYPE_GRANT_ON_TABLE_STATEMENT
100 	  	};
101 	}
102 	interface DerbyDataTypes {
103 		static final String[] DTYPE_BIGINT = {"BIGINT"};
104 		static final String[] DTYPE_LONG_VARCHAR = {"LONG", "VARCHAR"};
105 		static final String[] DTYPE_LONG_VARCHAR_FBD = {"LONG", "VARCHAR", "FOR", "BIT", "DATA"};
106 		
107 		static final String[] DTYPE_DOUBLE = {"DOUBLE"};
108 		static final String[] DTYPE_XML = {"XML"};
109 		static final String[] DTYPE_CLOB = {"CLOB"}; // CLOB [ ( length [{K |M |G }] ) ]
110 		static final String[] DTYPE_CHARACTER_LARGE_OBJECT = {"CHARACTER", "LARGE", "OBJECT"}; // [ ( length [{K |M |G }] ) ]
111 		static final String[] DTYPE_BLOB = {"BLOB"}; // BLOB [ ( length [{K |M |G }] ) ]
112 		static final String[] DTYPE_BINARY_LARGE_OBJECT = {"BINARY", "LARGE", "OBJECT"}; // [ ( length [{K |M |G }] ) ]
113 	
114 		static final List<String[]> CUSTOM_DATATYPE_START_PHRASES = 
115 	  		Arrays.asList(new String[][] {
116 	  				DTYPE_BIGINT, DTYPE_LONG_VARCHAR, DTYPE_LONG_VARCHAR_FBD, DTYPE_DOUBLE, DTYPE_XML,
117 	  				DTYPE_CLOB, DTYPE_CHARACTER_LARGE_OBJECT, DTYPE_BLOB, DTYPE_BINARY_LARGE_OBJECT
118 	  	  	});
119 		
120 	  	static final List<String> CUSTOM_DATATYPE_START_WORDS = 
121 	  		Arrays.asList(new String[] {"BIGINT", "LONG", "DOUBLE",
122 	  	  		"XML", "CLOB", "CHARACTER", "BLOB", "BINARY"
123 	  	  	});
124 	}
125 }