📄 ij.jj
字号:
}/** * Autocommit lets you control this aspect of the connection. * REMIND: should have a general way to set all connection attributes, * this is a shortcut for immediate needs. * <p> * Syntax: * AUTOCOMMIT [ ON | OFF ] ; */ijResultAutocommitStatement()throws SQLException:{ Token on=null;}{ <AUTOCOMMIT> ( on=<ON> | <OFF> ) { haveConnection(); // REMIND: want to warn if unchanged? theConnection.setAutoCommit((on==null?false:true)); return null; }}/** * By default, holdability is set to true for Connection objects. This syntax NOHOLDFORCONNECTION lets you set it to close cursors at commit. * Syntax: * NOHOLDFORCONNECTION ; */ijResultNoHoldForConnectionStatement()throws SQLException:{ Token on=null;}{ <NOHOLDFORCONNECTION> { haveConnection(); theConnection = utilInstance.setHoldability(theConnection, JDBC30Translation.CLOSE_CURSORS_AT_COMMIT); return null; }}/** * Localizeddisplay controls locale sensitive data representayion * <p> * Syntax: * LOCALIZEDDISPLAY [ ON | OFF ] ; */ijResult LocalizedDisplay():{ Token on=null;}{ <LOCALIZEDDISPLAY> ( on=<ON> | <OFF> ) { LocalizedResource.enableLocalization((on==null?false:true)); return null; }}/** * ReadOnly lets you control this aspect of the connection. * REMIND: should have a general way to set all connection attributes, * this is a shortcut for immediate needs. * <p> * Syntax: * READONLY [ ON | OFF ] ; */ijResultReadOnlyStatement()throws SQLException:{ Token on=null;}{ <READONLY> ( on=<ON> | <OFF> ) { haveConnection(); theConnection.setReadOnly((on==null?false:true)); return null; }}/** * Elapsedtime on causes ij to dump out the elapsed time it takes * to run a user statement at the end of that statement. * <p> * Syntax: * ELAPSEDTIME [ ON | OFF ] ; */ijResultElapsedTimeStatement() :{ Token on=null;}{ <ELAPSEDTIME> ( on=<ON> | <OFF> ) { elapsedTime = (on != null); return null; }}/** * MaximumDisplayWidth EXACT_NUMERIC changes the maximum display width for * java.lang.String to the specified EXACT_NUMERIC. * This is only used by the console view. * <p> * Syntax: * MAXIMUMDISPLAYWIDTH INTEGER ; */ijResultMaximumDisplayWidthStatement() :{ int maxWidth;}{ <MAXIMUMDISPLAYWIDTH> maxWidth=intValue() { JDBCDisplayUtil.setMaxDisplayWidth(maxWidth); return null; }}intintValue() :{ Token t;}{ t = <INTEGER> { return Integer.parseInt(t.image); }}/** * Bang lets you issue a system command using System.exec. * <p> * Syntax: * ! 'command to issue' ; */ijResultBang() :{ Token cmd=null;}{ <BANG> cmd=<STRING> { ijResult result = null; try { Process p = Runtime.getRuntime().exec(stringValue(cmd.image)); LocalizedInput in = new LocalizedInput(p.getInputStream()); int c; Vector v = new Vector(); StringBuffer output = new StringBuffer(); // echo output while ((c = in.read()) != -1) { output.append((char)c); } in.close(); // echo errors in = new LocalizedInput(p.getErrorStream()); // echo output while ((c = in.read()) != -1) { output.append((char)c); } in.close(); v.addElement(output); result = new ijVectorResult(v,null); // wait for completion try { p.waitFor(); } catch (InterruptedException e) { throw ijException.bangException(e); } } catch (IOException ioe) { throw ijException.bangException(ioe); } return result; }}/** ExpectStatement is EXPECT [ FAIL ] {'String'}* END EXPECT <p> Will eventually detect the lines that the strings are without special literals, but for now this is expedient (except for the doubling of quotes...) <p> Used to test the previous statement's output. Note that ij must be in "expect" mode to use this statement, otherwise it is just ignored. This is due to the overhead of tracking the prior statement's output. */ijResultExpectStatement() :{ Token f = null; Vector stringVector = new Vector();}{ <EXPECT> [ f = <FAIL> ] StringList(stringVector) <END> <EXPECT> { if (!getExpect()) return null; // don't bother processing. // FIXME // Do the comparison of the string list to the prior rows of // output, using a row-by-row perl-regex comparison. boolean result = true; // register the result and whether it should be true or false // FIXME: how to find the expecter?? noteExpect(result, f==null); return null; }}voidStringList(Vector v) :{}{ StringItem(v) ( StringItem(v) ) *}voidStringItem(Vector v) :{ Token s;}{ s = <STRING> { v.addElement(s); }}/** Haven't included: ASYNC, !, EXPECT Don't include: XA_* **/ijResultHelpStatement() :{}{ <HELP> { Vector v = new Vector(); StringTokenizer st = new StringTokenizer(LocalizedResource.getMessage("IJ_HelpText"), "\n"); while (st.hasMoreTokens()) { v.addElement(st.nextToken()); } return new ijVectorResult(v,null); }}Stringidentifier() :{ Token t;}{ t=<IDENTIFIER> { // identifiers are case insensitive, so we map them up. // ij doesn't recognize any use of delimited identifiers in its syntax. return (t.image.toUpperCase(Locale.ENGLISH)); }}intintLiteral() throws SQLException :{ String sign = ""; Token tok;}{ [ sign = sign() ] tok = <INTEGER> { /* ** The various java parse utilities can't handle leading +, ** so only concatenate leading -. */ String num = tok.image; if (sign.equals("-")) { num = sign.concat(num); } return Integer.parseInt(num); }}VectorstaticMethodName() throws SQLException :{ Vector list = new Vector();}{ methodLeg( list ) ( <PERIOD> methodLeg( list ) )+ { return list; }}voidmethodLeg( Vector list ) throws SQLException :{ Token id;}{ id = <IDENTIFIER> { list.addElement( id.image ); }}String[]staticMethodArgs() throws SQLException :{ Vector list = new Vector(); String[] args;}{ <LEFT_PAREN> [ oneStaticArg( list ) ( <COMMA> oneStaticArg( list ) )* ] <RIGHT_PAREN> { args = new String[ list.size() ]; list.copyInto( args ); return args; }}voidoneStaticArg( Vector list ) throws SQLException :{ Token tok;}{ tok = <STRING> { list.addElement( stringValue( tok.image ) ); }}/* * <A NAME="sign">sign</A> */Stringsign() throws SQLException :{ Token s;}{ s = <PLUS_SIGN> { return s.image; }| s = <MINUS_SIGN> { return s.image; }}/** Undocumented commands to help XA testing. This is the grammer for the XA commands <XA_DATASOURCE> 'dbname' ( <CREATE> | shutdown ) - get a XADataSource whose database name is dbname and make that XADataSource the current XADataSource <XA_CONNECT> [ <USER> 'user' ] [ <PASSWORD> 'password' ] [ <AS> xaconnid ] - make an XAConnection using the current XADataSource and make that XAConnection the current XAConnection. If xaconnid is given, then associate xaconnid with the XAConnection. (xaconnid not implemeneted) <XA_COMMIT> ( <XA_1PHASE> | <XA_2PHASE> ) xid - commit a global transaction xid <XA_DISCONNECT> [ xaconnid = identifier() ] - disconnect an XAConnection. If xaconnid is given, then disconnect the XAConnection with the given xaconnid. (xaconnid not implemeneted) <XA_END> ( <XA_SUSPEND> | <XA_SUCCESS> | <XA_FAIL> ) xid - dissociate a transaction from the current XAConnection or end an already suspened one <XA_FORGET> xid - forget about a global transaction <XA_GETCONNECTION> [ <AS> connid ] - get a Connection object from the current XAConnection. If connid is given, then associate connid with the connection. (connid not implemented) <XA_PREPARE> xid - prepare a global transaction <XA_RECOVER> ( <XA_NOFLAGS> | <XA_STARTRSCAN> | <XA_ENDRSCAN> ) - return the list of in-doubt transactions <XA_ROLLBACK> xid - rollback a global transaction <XA_START> ( <XA_NOFLAGS> | <XA_JOIN> | <XA_RESUME> ) xid - associate a transaction or start a new global transaction with the current XAConnection. The following is for testing other JDBC2.0 ext interface, DataSource and ConnectionPoolDataSource. Strictly speaking, these are not xa, but their functionality will be lumped into xaHelper because these are here only for testing purposes. <DATASOURCE> 'dbname' [ <PROTOCOL> 'protocol' ] [ <USER> 'user' ] [ <PASSWORD> 'password' ] [ <AS> n=identifier() ] - get a data source whose database name is dbname and make that DataSource the current DataSource. If <PROTOCOL> is specified, the DataSource may be remote. Get a connection from that dataSource and use the user/password if specified. <CP_DATASOURCE> 'dbname' [ <PROTOCOL> 'protocol' ] - get a connection pool data source whose database name is dbname and make that DataSource the current CPDataSource. If <PROTOCOL> is specified, the DataSource may be remote. <CP_CONNECT> [ <USER> 'user' ] [ <PASSWORD> 'password' ] [ <AS> cpconnid ] - make a PooledConnection using the current CPDataSource and make that PooledConnection the current PooledConnection. If cpconnid is given, then associate cpconnid with the PooledConnection. (cpconnid not implemented). <CP_GETCONNECTION> [ <AS> connid ] - get a Connection object from the current PooledConnection. If connid is given, the associate connid with the connection. (connid not implemented) <CP_DISCONNECT> [ cpconnid = identifier() ] - disconnect a PooledConnection. If cpconnid is given, then disconnect the PooledConnection with the given cpconnid. (cpconnid not implemented)*//** * XA_DataSourceStatement is XA_DataSource 'dbname' ( create | shutdown ) * We new'ed an instance of XADataSource as the current DataSource and set its * database name to dbname. */ijResultXA_DataSourceStatement()throws SQLException:{ Token dbname = null; Token shut = null; String create = null;}{ <XA_DATASOURCE> dbname=<STRING> [ ( shut = <SHUTDOWN> | create = identifier() ) ] { xahelper.XADataSourceStatement(this, dbname, shut, create); return null; }}/*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -