提交 3954b942 authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 27cf2c8d
...@@ -21,6 +21,10 @@ import org.h2.util.Resources; ...@@ -21,6 +21,10 @@ import org.h2.util.Resources;
import org.h2.util.StringCache; import org.h2.util.StringCache;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
/**
* This class can read a file that is similar to BNF (Backus–Naur form).
* It is made specially to support SQL grammar.
*/
public class Bnf { public class Bnf {
static final boolean COMBINE_KEYWORDS = false; static final boolean COMBINE_KEYWORDS = false;
...@@ -77,11 +81,7 @@ public class Bnf { ...@@ -77,11 +81,7 @@ public class Bnf {
return random; return random;
} }
public HashMap getRuleMap() { private void parse(Reader csv) throws Exception {
return ruleMap;
}
public void parse(Reader csv) throws Exception {
csv = new BufferedReader(csv); csv = new BufferedReader(csv);
Rule functions = null; Rule functions = null;
statements = new ArrayList(); statements = new ArrayList();
...@@ -286,7 +286,6 @@ public class Bnf { ...@@ -286,7 +286,6 @@ public class Bnf {
} }
public void linkStatements() { public void linkStatements() {
HashMap ruleMap = getRuleMap();
for (Iterator it = ruleMap.values().iterator(); it.hasNext();) { for (Iterator it = ruleMap.values().iterator(); it.hasNext();) {
RuleHead r = (RuleHead) it.next(); RuleHead r = (RuleHead) it.next();
r.getRule().setLinks(ruleMap); r.getRule().setLinks(ruleMap);
...@@ -305,23 +304,6 @@ public class Bnf { ...@@ -305,23 +304,6 @@ public class Bnf {
} }
} }
public void updateTopic(String topic, String[] array) {
topic = StringUtils.toLowerEnglish(topic);
ArrayList list = new ArrayList();
for (int i = 0; i < array.length; i++) {
list.add(new RuleElement(array[i], true, topic));
}
RuleList rule = new RuleList(list, true);
RuleHead head = (RuleHead) ruleMap.get(topic);
if (head == null) {
head = new RuleHead(0, "db", topic, rule);
ruleMap.put(topic, head);
statements.add(head);
} else {
head.rule = rule;
}
}
public ArrayList getStatements() { public ArrayList getStatements() {
return statements; return statements;
} }
......
...@@ -6,15 +6,56 @@ package org.h2.bnf; ...@@ -6,15 +6,56 @@ package org.h2.bnf;
import java.util.HashMap; import java.util.HashMap;
/**
* Represents a BNF rule.
*/
public interface Rule { public interface Rule {
/**
* Get the name of the rule.
*
* @return the name
*/
String name(); String name();
/**
* Get a random entry.
*
* @param config
* @param level
* @return the entry
*/
String random(Bnf config, int level); String random(Bnf config, int level);
/**
* Get the last entry.
*
* @return the last entry
*/
Rule last(); Rule last();
/**
* Update cross references.
*
* @param ruleMap the reference map
*/
void setLinks(HashMap ruleMap); void setLinks(HashMap ruleMap);
/**
* Add the next possible token for a query.
* Used for autocomplete support.
*
* @param query the query
* @param sentence the sentence context
*/
void addNextTokenList(String query, Sentence sentence); void addNextTokenList(String query, Sentence sentence);
/** /**
* Remove a token from a sentence.
* Used for autocomplete support.
* *
* @param query the query
* @param sentence the sentence context
* @return null if not a match or a partial match, query.substring... if a full match * @return null if not a match or a partial match, query.substring... if a full match
*/ */
String matchRemove(String query, Sentence sentence); String matchRemove(String query, Sentence sentence);
......
...@@ -8,6 +8,9 @@ import java.util.HashMap; ...@@ -8,6 +8,9 @@ import java.util.HashMap;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
/**
* A single terminal rule in a BNF object.
*/
public class RuleElement implements Rule { public class RuleElement implements Rule {
private boolean keyword; private boolean keyword;
...@@ -16,14 +19,7 @@ public class RuleElement implements Rule { ...@@ -16,14 +19,7 @@ public class RuleElement implements Rule {
private int type; private int type;
private String topic; private String topic;
public RuleElement(String name, boolean keyword, String topic) { RuleElement(String name, String topic) {
this.name = name;
this.topic = topic;
this.keyword = keyword;
this.type = Sentence.CONTEXT;
}
public RuleElement(String name, String topic) {
this.name = name; this.name = name;
this.topic = topic; this.topic = topic;
if (name.length() == 1 || name.equals(StringUtils.toUpperEnglish(name))) { if (name.length() == 1 || name.equals(StringUtils.toUpperEnglish(name))) {
...@@ -33,7 +29,7 @@ public class RuleElement implements Rule { ...@@ -33,7 +29,7 @@ public class RuleElement implements Rule {
this.type = topic.startsWith("function") ? Sentence.FUNCTION : Sentence.KEYWORD; this.type = topic.startsWith("function") ? Sentence.FUNCTION : Sentence.KEYWORD;
} }
public RuleElement merge(RuleElement rule) { RuleElement merge(RuleElement rule) {
return new RuleElement(name + " " + rule.name, topic); return new RuleElement(name + " " + rule.name, topic);
} }
...@@ -66,7 +62,7 @@ public class RuleElement implements Rule { ...@@ -66,7 +62,7 @@ public class RuleElement implements Rule {
String test = StringUtils.toLowerEnglish(name.substring(i)); String test = StringUtils.toLowerEnglish(name.substring(i));
RuleHead r = (RuleHead) ruleMap.get(test); RuleHead r = (RuleHead) ruleMap.get(test);
if (r != null) { if (r != null) {
link = r.rule; link = r.getRule();
return; return;
} }
} }
...@@ -120,7 +116,7 @@ public class RuleElement implements Rule { ...@@ -120,7 +116,7 @@ public class RuleElement implements Rule {
link.addNextTokenList(query, sentence); link.addNextTokenList(query, sentence);
} }
public boolean isKeyword() { boolean isKeyword() {
return keyword; return keyword;
} }
......
...@@ -9,18 +9,21 @@ import java.util.Random; ...@@ -9,18 +9,21 @@ import java.util.Random;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
/**
* Represents a hard coded terminal rule in a BNF object.
*/
public class RuleFixed implements Rule { public class RuleFixed implements Rule {
public static final int YMD = 0, HMS = 1, NANOS = 2; static final int YMD = 0, HMS = 1, NANOS = 2;
public static final int ANY_EXCEPT_SINGLE_QUOTE = 3; static final int ANY_EXCEPT_SINGLE_QUOTE = 3;
public static final int ANY_EXCEPT_DOUBLE_QUOTE = 4; static final int ANY_EXCEPT_DOUBLE_QUOTE = 4;
public static final int ANY_UNTIL_EOL = 5; static final int ANY_UNTIL_EOL = 5;
public static final int ANY_UNTIL_END = 6; static final int ANY_UNTIL_END = 6;
public static final int ANY_WORD = 7; static final int ANY_WORD = 7;
public static final int HEX_START = 10, CONCAT = 11, AZ_UNDERLINE = 12, AF = 13, DIGIT = 14; static final int HEX_START = 10, CONCAT = 11, AZ_UNDERLINE = 12, AF = 13, DIGIT = 14;
private final int type; private final int type;
public RuleFixed(int type) { RuleFixed(int type) {
this.type = type; this.type = type;
} }
......
...@@ -4,12 +4,14 @@ ...@@ -4,12 +4,14 @@
*/ */
package org.h2.bnf; package org.h2.bnf;
/**
* Represents the head of a BNF rule.
*/
public class RuleHead { public class RuleHead {
int id; int id;
String section; String section;
String topic;
Rule rule; Rule rule;
private String topic;
RuleHead(int id, String section, String topic, Rule rule) { RuleHead(int id, String section, String topic, Rule rule) {
this.id = id; this.id = id;
......
...@@ -7,17 +7,15 @@ package org.h2.bnf; ...@@ -7,17 +7,15 @@ package org.h2.bnf;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
/**
* Represents a sequence of BNF rules, or a list of alternative rules.
*/
public class RuleList implements Rule { public class RuleList implements Rule {
private boolean or; private boolean or;
private ArrayList list; private ArrayList list;
private boolean mapSet; private boolean mapSet;
RuleList(ArrayList list, boolean or) {
this.or = or;
this.list = list;
}
RuleList(Rule first, Rule next, boolean or) { RuleList(Rule first, Rule next, boolean or) {
list = new ArrayList(); list = new ArrayList();
if (first instanceof RuleList && ((RuleList) first).or == or) { if (first instanceof RuleList && ((RuleList) first).or == or) {
......
...@@ -6,6 +6,9 @@ package org.h2.bnf; ...@@ -6,6 +6,9 @@ package org.h2.bnf;
import java.util.HashMap; import java.util.HashMap;
/**
* Represents an optional BNF rule.
*/
public class RuleOptional implements Rule { public class RuleOptional implements Rule {
private Rule rule; private Rule rule;
private boolean mapSet; private boolean mapSet;
......
...@@ -6,9 +6,12 @@ package org.h2.bnf; ...@@ -6,9 +6,12 @@ package org.h2.bnf;
import java.util.HashMap; import java.util.HashMap;
/**
* Represents a loop in a BNF object.
*/
public class RuleRepeat implements Rule { public class RuleRepeat implements Rule {
Rule rule; private Rule rule;
RuleRepeat(Rule rule) { RuleRepeat(Rule rule) {
this.rule = rule; this.rule = rule;
...@@ -23,7 +26,7 @@ public class RuleRepeat implements Rule { ...@@ -23,7 +26,7 @@ public class RuleRepeat implements Rule {
} }
public void setLinks(HashMap ruleMap) { public void setLinks(HashMap ruleMap) {
// rule.setLinks(ruleMap); // rule.setLinks(ruleMap);
} }
public String random(Bnf config, int level) { public String random(Bnf config, int level) {
......
...@@ -9,17 +9,22 @@ import java.util.HashSet; ...@@ -9,17 +9,22 @@ import java.util.HashSet;
import org.h2.server.web.DbTableOrView; import org.h2.server.web.DbTableOrView;
/**
* A query context object. It contains the list of table and alias objects.
* Used for autocomplete.
*/
public class Sentence { public class Sentence {
public static final int CONTEXT = 0, KEYWORD = 1; public static final int CONTEXT = 0;
public static final int FUNCTION = 2; static final int KEYWORD = 1;
static final int FUNCTION = 2;
public String text; public String text;
HashMap next; HashMap next;
long max; long max;
DbTableOrView lastTable; private DbTableOrView lastTable;
private HashSet tables; private HashSet tables;
private HashMap aliases; private HashMap aliases;
public boolean stop() { boolean stop() {
return System.currentTimeMillis() > max; return System.currentTimeMillis() > max;
} }
......
...@@ -12,12 +12,13 @@ import org.h2.engine.Database; ...@@ -12,12 +12,13 @@ import org.h2.engine.Database;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.message.Message; import org.h2.message.Message;
import org.h2.message.Trace; import org.h2.message.Trace;
import org.h2.message.TraceObject;
import org.h2.result.LocalResult; import org.h2.result.LocalResult;
import org.h2.result.ResultInterface; import org.h2.result.ResultInterface;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
/** /**
* @author Thomas * Represents a SQL statement. This object is only used on the server side.
*/ */
public abstract class Command implements CommandInterface { public abstract class Command implements CommandInterface {
private final String sql; private final String sql;
...@@ -140,6 +141,6 @@ public abstract class Command implements CommandInterface { ...@@ -140,6 +141,6 @@ public abstract class Command implements CommandInterface {
} }
public String toString() { public String toString() {
return sql; return TraceObject.toString(sql, getParameters());
} }
} }
...@@ -12,6 +12,10 @@ import org.h2.result.LocalResult; ...@@ -12,6 +12,10 @@ import org.h2.result.LocalResult;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
import org.h2.value.Value; import org.h2.value.Value;
/**
* Represents a single SQL statements.
* It wraps a prepared statement.
*/
public class CommandContainer extends Command { public class CommandContainer extends Command {
private Prepared prepared; private Prepared prepared;
......
...@@ -9,6 +9,9 @@ import java.sql.SQLException; ...@@ -9,6 +9,9 @@ import java.sql.SQLException;
import org.h2.result.ResultInterface; import org.h2.result.ResultInterface;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
/**
* Represents a SQL statement.
*/
public interface CommandInterface { public interface CommandInterface {
boolean isQuery(); boolean isQuery();
ObjectArray getParameters(); ObjectArray getParameters();
......
...@@ -9,6 +9,9 @@ import java.sql.SQLException; ...@@ -9,6 +9,9 @@ import java.sql.SQLException;
import org.h2.result.LocalResult; import org.h2.result.LocalResult;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
/**
* Represents a list of SQL statements.
*/
public class CommandList extends Command { public class CommandList extends Command {
private final Command command; private final Command command;
......
...@@ -12,11 +12,16 @@ import org.h2.engine.SessionRemote; ...@@ -12,11 +12,16 @@ import org.h2.engine.SessionRemote;
import org.h2.expression.ParameterInterface; import org.h2.expression.ParameterInterface;
import org.h2.expression.ParameterRemote; import org.h2.expression.ParameterRemote;
import org.h2.message.Trace; import org.h2.message.Trace;
import org.h2.message.TraceObject;
import org.h2.result.ResultInterface; import org.h2.result.ResultInterface;
import org.h2.result.ResultRemote; import org.h2.result.ResultRemote;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
import org.h2.value.Transfer; import org.h2.value.Transfer;
/**
* Represents the client-side part of a SQL statement.
* This class is not used in embedded mode.
*/
public class CommandRemote implements CommandInterface { public class CommandRemote implements CommandInterface {
private final ObjectArray transferList; private final ObjectArray transferList;
...@@ -215,4 +220,8 @@ public class CommandRemote implements CommandInterface { ...@@ -215,4 +220,8 @@ public class CommandRemote implements CommandInterface {
// TODO server: support cancel // TODO server: support cancel
} }
public String toString() {
return TraceObject.toString(sql, getParameters());
}
} }
...@@ -16,6 +16,9 @@ import org.h2.message.Message; ...@@ -16,6 +16,9 @@ import org.h2.message.Message;
import org.h2.result.LocalResult; import org.h2.result.LocalResult;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
/**
* A prepared statement.
*/
public abstract class Prepared { public abstract class Prepared {
protected Session session; protected Session session;
......
...@@ -13,6 +13,10 @@ import org.h2.index.Index; ...@@ -13,6 +13,10 @@ import org.h2.index.Index;
import org.h2.message.Message; import org.h2.message.Message;
import org.h2.schema.Schema; import org.h2.schema.Schema;
/**
* This class represents the statement
* ALTER INDEX RENAME
*/
public class AlterIndexRename extends DefineCommand { public class AlterIndexRename extends DefineCommand {
private Index oldIndex; private Index oldIndex;
......
...@@ -12,6 +12,10 @@ import org.h2.engine.Session; ...@@ -12,6 +12,10 @@ import org.h2.engine.Session;
import org.h2.message.Message; import org.h2.message.Message;
import org.h2.schema.Sequence; import org.h2.schema.Sequence;
/**
* This class represents the statement
* ALTER SEQUENCE
*/
public class AlterSequence extends DefineCommand { public class AlterSequence extends DefineCommand {
private Sequence sequence; private Sequence sequence;
......
...@@ -28,9 +28,9 @@ import org.h2.table.TableFilter; ...@@ -28,9 +28,9 @@ import org.h2.table.TableFilter;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
/** /**
* @author Thomas * This class represents the statement
* ALTER TABLE ADD CONSTRAINT
*/ */
public class AlterTableAddConstraint extends SchemaCommand { public class AlterTableAddConstraint extends SchemaCommand {
public static final int CHECK = 0, UNIQUE = 1, REFERENTIAL = 2, PRIMARY_KEY = 3; public static final int CHECK = 0, UNIQUE = 1, REFERENTIAL = 2, PRIMARY_KEY = 3;
......
...@@ -26,6 +26,17 @@ import org.h2.table.Table; ...@@ -26,6 +26,17 @@ import org.h2.table.Table;
import org.h2.table.TableData; import org.h2.table.TableData;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
/**
* This class represents the statements
* ALTER TABLE ADD,
* ALTER TABLE ALTER COLUMN,
* ALTER TABLE ALTER COLUMN RESTART,
* ALTER TABLE ALTER COLUMN SELECTIVITY,
* ALTER TABLE ALTER COLUMN SET DEFAULT,
* ALTER TABLE ALTER COLUMN SET NOT NULL,
* ALTER TABLE ALTER COLUMN SET NULL,
* ALTER TABLE DROP COLUMN
*/
public class AlterTableAlterColumn extends SchemaCommand { public class AlterTableAlterColumn extends SchemaCommand {
public static final int NOT_NULL = 0, NULL = 1, DEFAULT = 2, RESTART = 3, CHANGE_TYPE = 4; public static final int NOT_NULL = 0, NULL = 1, DEFAULT = 2, RESTART = 3, CHANGE_TYPE = 4;
......
...@@ -12,7 +12,8 @@ import org.h2.engine.Session; ...@@ -12,7 +12,8 @@ import org.h2.engine.Session;
import org.h2.schema.Schema; import org.h2.schema.Schema;
/** /**
* @author Thomas * This class represents the statement
* ALTER TABLE DROP CONSTRAINT
*/ */
public class AlterTableDropConstraint extends SchemaCommand { public class AlterTableDropConstraint extends SchemaCommand {
......
...@@ -15,7 +15,8 @@ import org.h2.schema.Schema; ...@@ -15,7 +15,8 @@ import org.h2.schema.Schema;
import org.h2.table.Table; import org.h2.table.Table;
/** /**
* @author Thomas * This class represents the statement
* ALTER TABLE RENAME
*/ */
public class AlterTableRename extends SchemaCommand { public class AlterTableRename extends SchemaCommand {
......
...@@ -13,6 +13,10 @@ import org.h2.table.Column; ...@@ -13,6 +13,10 @@ import org.h2.table.Column;
import org.h2.table.Table; import org.h2.table.Table;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
/**
* This class represents the statement
* ALTER TABLE ALTER COLUMN RENAME
*/
public class AlterTableRenameColumn extends DefineCommand { public class AlterTableRenameColumn extends DefineCommand {
private Table table; private Table table;
......
...@@ -15,9 +15,11 @@ import org.h2.security.SHA256; ...@@ -15,9 +15,11 @@ import org.h2.security.SHA256;
import org.h2.util.ByteUtils; import org.h2.util.ByteUtils;
/** /**
* @author Thomas * This class represents the statements
* ALTER USER ADMIN,
* ALTER USER RENAME,
* ALTER USER SET PASSWORD
*/ */
public class AlterUser extends DefineCommand { public class AlterUser extends DefineCommand {
public static final int SET_PASSWORD = 0, RENAME = 1, ADMIN = 2; public static final int SET_PASSWORD = 0, RENAME = 1, ADMIN = 2;
......
...@@ -10,6 +10,10 @@ import org.h2.engine.Right; ...@@ -10,6 +10,10 @@ import org.h2.engine.Right;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.table.TableView; import org.h2.table.TableView;
/**
* This class represents the statement
* ALTER VIEW
*/
public class AlterView extends DefineCommand { public class AlterView extends DefineCommand {
private TableView view; private TableView view;
......
...@@ -17,6 +17,10 @@ import org.h2.table.Table; ...@@ -17,6 +17,10 @@ import org.h2.table.Table;
import org.h2.table.TableData; import org.h2.table.TableData;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
/**
* This class represents the statement
* ANALYZE
*/
public class Analyze extends DefineCommand { public class Analyze extends DefineCommand {
private int sampleRows = Constants.SELECTIVITY_ANALYZE_SAMPLE_ROWS; private int sampleRows = Constants.SELECTIVITY_ANALYZE_SAMPLE_ROWS;
......
...@@ -12,6 +12,10 @@ import org.h2.engine.Database; ...@@ -12,6 +12,10 @@ import org.h2.engine.Database;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.message.Message; import org.h2.message.Message;
/**
* This class represents the statement
* CREATE AGGREGATE
*/
public class CreateAggregate extends DefineCommand { public class CreateAggregate extends DefineCommand {
private String name; private String name;
......
...@@ -15,6 +15,10 @@ import org.h2.schema.Constant; ...@@ -15,6 +15,10 @@ import org.h2.schema.Constant;
import org.h2.schema.Schema; import org.h2.schema.Schema;
import org.h2.value.Value; import org.h2.value.Value;
/**
* This class represents the statement
* CREATE CONSTANT
*/
public class CreateConstant extends SchemaCommand { public class CreateConstant extends SchemaCommand {
private String constantName; private String constantName;
......
...@@ -12,6 +12,10 @@ import org.h2.engine.FunctionAlias; ...@@ -12,6 +12,10 @@ import org.h2.engine.FunctionAlias;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.message.Message; import org.h2.message.Message;
/**
* This class represents the statement
* CREATE ALIAS
*/
public class CreateFunctionAlias extends DefineCommand { public class CreateFunctionAlias extends DefineCommand {
private String aliasName; private String aliasName;
......
...@@ -17,7 +17,8 @@ import org.h2.table.IndexColumn; ...@@ -17,7 +17,8 @@ import org.h2.table.IndexColumn;
import org.h2.table.Table; import org.h2.table.Table;
/** /**
* @author Thomas * This class represents the statement
* CREATE INDEX
*/ */
public class CreateIndex extends SchemaCommand { public class CreateIndex extends SchemaCommand {
......
...@@ -13,11 +13,10 @@ import org.h2.message.Message; ...@@ -13,11 +13,10 @@ import org.h2.message.Message;
import org.h2.schema.Schema; import org.h2.schema.Schema;
import org.h2.table.TableLink; import org.h2.table.TableLink;
/** /**
* @author Thomas * This class represents the statement
* CREATE LINKED TABLE
*/ */
public class CreateLinkedTable extends SchemaCommand { public class CreateLinkedTable extends SchemaCommand {
private String tableName; private String tableName;
......
...@@ -12,6 +12,10 @@ import org.h2.engine.Role; ...@@ -12,6 +12,10 @@ import org.h2.engine.Role;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.message.Message; import org.h2.message.Message;
/**
* This class represents the statement
* CREATE ROLE
*/
public class CreateRole extends DefineCommand { public class CreateRole extends DefineCommand {
private String roleName; private String roleName;
......
...@@ -13,6 +13,10 @@ import org.h2.engine.User; ...@@ -13,6 +13,10 @@ import org.h2.engine.User;
import org.h2.message.Message; import org.h2.message.Message;
import org.h2.schema.Schema; import org.h2.schema.Schema;
/**
* This class represents the statement
* CREATE SCHEMA
*/
public class CreateSchema extends DefineCommand { public class CreateSchema extends DefineCommand {
private String schemaName; private String schemaName;
......
...@@ -13,6 +13,10 @@ import org.h2.message.Message; ...@@ -13,6 +13,10 @@ import org.h2.message.Message;
import org.h2.schema.Schema; import org.h2.schema.Schema;
import org.h2.schema.Sequence; import org.h2.schema.Sequence;
/**
* This class represents the statement
* CREATE SEQUENCE
*/
public class CreateSequence extends SchemaCommand { public class CreateSequence extends SchemaCommand {
private String sequenceName; private String sequenceName;
......
...@@ -25,7 +25,8 @@ import org.h2.util.ObjectArray; ...@@ -25,7 +25,8 @@ import org.h2.util.ObjectArray;
import org.h2.value.DataType; import org.h2.value.DataType;
/** /**
* @author Thomas * This class represents the statement
* CREATE TABLE
*/ */
public class CreateTable extends SchemaCommand { public class CreateTable extends SchemaCommand {
......
...@@ -15,11 +15,10 @@ import org.h2.schema.TriggerObject; ...@@ -15,11 +15,10 @@ import org.h2.schema.TriggerObject;
import org.h2.table.Table; import org.h2.table.Table;
/** /**
* @author Thomas * This class represents the statement
* CREATE TRIGGER
*/ */
public class CreateTrigger extends SchemaCommand { public class CreateTrigger extends SchemaCommand {
// TODO implement drop trigger
private String triggerName; private String triggerName;
private boolean ifNotExists; private boolean ifNotExists;
......
...@@ -14,6 +14,10 @@ import org.h2.message.Message; ...@@ -14,6 +14,10 @@ import org.h2.message.Message;
import org.h2.security.SHA256; import org.h2.security.SHA256;
import org.h2.util.ByteUtils; import org.h2.util.ByteUtils;
/**
* This class represents the statement
* CREATE USER
*/
public class CreateUser extends DefineCommand { public class CreateUser extends DefineCommand {
private String userName; private String userName;
......
...@@ -13,6 +13,10 @@ import org.h2.engine.UserDataType; ...@@ -13,6 +13,10 @@ import org.h2.engine.UserDataType;
import org.h2.message.Message; import org.h2.message.Message;
import org.h2.table.Column; import org.h2.table.Column;
/**
* This class represents the statement
* CREATE DOMAIN
*/
public class CreateUserDataType extends DefineCommand { public class CreateUserDataType extends DefineCommand {
private String typeName; private String typeName;
......
...@@ -14,6 +14,10 @@ import org.h2.message.Message; ...@@ -14,6 +14,10 @@ import org.h2.message.Message;
import org.h2.schema.Schema; import org.h2.schema.Schema;
import org.h2.table.TableView; import org.h2.table.TableView;
/**
* This class represents the statement
* CREATE VIEW
*/
public class CreateView extends SchemaCommand { public class CreateView extends SchemaCommand {
private Query select; private Query select;
......
...@@ -8,6 +8,10 @@ import java.sql.SQLException; ...@@ -8,6 +8,10 @@ import java.sql.SQLException;
import org.h2.engine.Session; import org.h2.engine.Session;
/**
* This class represents the statement
* DEALLOCATE
*/
public class DeallocateProcedure extends DefineCommand { public class DeallocateProcedure extends DefineCommand {
private String procedureName; private String procedureName;
......
...@@ -8,6 +8,9 @@ import org.h2.command.Prepared; ...@@ -8,6 +8,9 @@ import org.h2.command.Prepared;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.result.LocalResult; import org.h2.result.LocalResult;
/**
* This class represents a non-transaction statement, for example a CREATE or DROP.
*/
public abstract class DefineCommand extends Prepared { public abstract class DefineCommand extends Prepared {
public DefineCommand(Session session) { public DefineCommand(Session session) {
......
...@@ -12,6 +12,10 @@ import org.h2.engine.Database; ...@@ -12,6 +12,10 @@ import org.h2.engine.Database;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.message.Message; import org.h2.message.Message;
/**
* This class represents the statement
* DROP AGGREGATE
*/
public class DropAggregate extends DefineCommand { public class DropAggregate extends DefineCommand {
private String name; private String name;
......
...@@ -13,6 +13,10 @@ import org.h2.message.Message; ...@@ -13,6 +13,10 @@ import org.h2.message.Message;
import org.h2.schema.Constant; import org.h2.schema.Constant;
import org.h2.schema.Schema; import org.h2.schema.Schema;
/**
* This class represents the statement
* DROP CONSTANT
*/
public class DropConstant extends SchemaCommand { public class DropConstant extends SchemaCommand {
private String constantName; private String constantName;
......
...@@ -15,6 +15,10 @@ import org.h2.schema.SchemaObject; ...@@ -15,6 +15,10 @@ import org.h2.schema.SchemaObject;
import org.h2.table.Table; import org.h2.table.Table;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
/**
* This class represents the statement
* DROP ALL OBJECTS
*/
public class DropDatabase extends DefineCommand { public class DropDatabase extends DefineCommand {
private boolean dropAllObjects; private boolean dropAllObjects;
......
...@@ -12,6 +12,10 @@ import org.h2.engine.FunctionAlias; ...@@ -12,6 +12,10 @@ import org.h2.engine.FunctionAlias;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.message.Message; import org.h2.message.Message;
/**
* This class represents the statement
* DROP ALIAS
*/
public class DropFunctionAlias extends DefineCommand { public class DropFunctionAlias extends DefineCommand {
private String aliasName; private String aliasName;
......
...@@ -17,7 +17,8 @@ import org.h2.table.Table; ...@@ -17,7 +17,8 @@ import org.h2.table.Table;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
/** /**
* @author Thomas * This class represents the statement
* DROP INDEX
*/ */
public class DropIndex extends SchemaCommand { public class DropIndex extends SchemaCommand {
......
...@@ -13,6 +13,10 @@ import org.h2.engine.Role; ...@@ -13,6 +13,10 @@ import org.h2.engine.Role;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.message.Message; import org.h2.message.Message;
/**
* This class represents the statement
* DROP ROLE
*/
public class DropRole extends DefineCommand { public class DropRole extends DefineCommand {
private String roleName; private String roleName;
......
...@@ -12,6 +12,10 @@ import org.h2.engine.Session; ...@@ -12,6 +12,10 @@ import org.h2.engine.Session;
import org.h2.message.Message; import org.h2.message.Message;
import org.h2.schema.Schema; import org.h2.schema.Schema;
/**
* This class represents the statement
* DROP SCHEMA
*/
public class DropSchema extends DefineCommand { public class DropSchema extends DefineCommand {
private String schemaName; private String schemaName;
......
...@@ -13,6 +13,10 @@ import org.h2.message.Message; ...@@ -13,6 +13,10 @@ import org.h2.message.Message;
import org.h2.schema.Schema; import org.h2.schema.Schema;
import org.h2.schema.Sequence; import org.h2.schema.Sequence;
/**
* This class represents the statement
* DROP SEQUENCE
*/
public class DropSequence extends SchemaCommand { public class DropSequence extends SchemaCommand {
private String sequenceName; private String sequenceName;
......
...@@ -15,7 +15,8 @@ import org.h2.schema.Schema; ...@@ -15,7 +15,8 @@ import org.h2.schema.Schema;
import org.h2.table.Table; import org.h2.table.Table;
/** /**
* @author Thomas * This class represents the statement
* DROP TABLE
*/ */
public class DropTable extends SchemaCommand { public class DropTable extends SchemaCommand {
......
...@@ -15,6 +15,10 @@ import org.h2.schema.Schema; ...@@ -15,6 +15,10 @@ import org.h2.schema.Schema;
import org.h2.schema.TriggerObject; import org.h2.schema.TriggerObject;
import org.h2.table.Table; import org.h2.table.Table;
/**
* This class represents the statement
* DROP TRIGGER
*/
public class DropTrigger extends SchemaCommand { public class DropTrigger extends SchemaCommand {
private String triggerName; private String triggerName;
......
...@@ -12,6 +12,10 @@ import org.h2.engine.Session; ...@@ -12,6 +12,10 @@ import org.h2.engine.Session;
import org.h2.engine.User; import org.h2.engine.User;
import org.h2.message.Message; import org.h2.message.Message;
/**
* This class represents the statement
* DROP USER
*/
public class DropUser extends DefineCommand { public class DropUser extends DefineCommand {
private boolean ifExists; private boolean ifExists;
......
...@@ -12,6 +12,10 @@ import org.h2.engine.Session; ...@@ -12,6 +12,10 @@ import org.h2.engine.Session;
import org.h2.engine.UserDataType; import org.h2.engine.UserDataType;
import org.h2.message.Message; import org.h2.message.Message;
/**
* This class represents the statement
* DROP DOMAIN
*/
public class DropUserDataType extends DefineCommand { public class DropUserDataType extends DefineCommand {
private String typeName; private String typeName;
......
...@@ -13,6 +13,10 @@ import org.h2.message.Message; ...@@ -13,6 +13,10 @@ import org.h2.message.Message;
import org.h2.schema.Schema; import org.h2.schema.Schema;
import org.h2.table.Table; import org.h2.table.Table;
/**
* This class represents the statement
* DROP VIEW
*/
public class DropView extends SchemaCommand { public class DropView extends SchemaCommand {
private String viewName; private String viewName;
......
...@@ -17,6 +17,13 @@ import org.h2.message.Message; ...@@ -17,6 +17,13 @@ import org.h2.message.Message;
import org.h2.table.Table; import org.h2.table.Table;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
/**
* This class represents the statements
* GRANT RIGHT,
* GRANT ROLE,
* REVOKE RIGHT,
* REVOKE ROLE
*/
public class GrantRevoke extends DefineCommand { public class GrantRevoke extends DefineCommand {
public static final int GRANT = 0, REVOKE = 1; public static final int GRANT = 0, REVOKE = 1;
......
...@@ -10,6 +10,10 @@ import org.h2.command.Prepared; ...@@ -10,6 +10,10 @@ import org.h2.command.Prepared;
import org.h2.engine.Procedure; import org.h2.engine.Procedure;
import org.h2.engine.Session; import org.h2.engine.Session;
/**
* This class represents the statement
* PREPARE
*/
public class PrepareProcedure extends DefineCommand { public class PrepareProcedure extends DefineCommand {
private String procedureName; private String procedureName;
......
...@@ -9,6 +9,9 @@ import java.sql.SQLException; ...@@ -9,6 +9,9 @@ import java.sql.SQLException;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.schema.Schema; import org.h2.schema.Schema;
/**
* This class represents a non-transaction statement that involves a schema.
*/
public abstract class SchemaCommand extends DefineCommand { public abstract class SchemaCommand extends DefineCommand {
private final Schema schema; private final Schema schema;
......
...@@ -14,6 +14,10 @@ import org.h2.expression.Expression; ...@@ -14,6 +14,10 @@ import org.h2.expression.Expression;
import org.h2.message.Message; import org.h2.message.Message;
import org.h2.table.Table; import org.h2.table.Table;
/**
* This class represents the statement
* COMMENT
*/
public class SetComment extends DefineCommand { public class SetComment extends DefineCommand {
private String schemaName; private String schemaName;
......
...@@ -12,6 +12,10 @@ import org.h2.engine.Session; ...@@ -12,6 +12,10 @@ import org.h2.engine.Session;
import org.h2.message.Message; import org.h2.message.Message;
import org.h2.table.Table; import org.h2.table.Table;
/**
* This class represents the statement
* TRUNCATE TABLE
*/
public class TruncateTable extends DefineCommand { public class TruncateTable extends DefineCommand {
private Table table; private Table table;
......
...@@ -14,7 +14,8 @@ import org.h2.schema.Schema; ...@@ -14,7 +14,8 @@ import org.h2.schema.Schema;
import org.h2.table.Table; import org.h2.table.Table;
/** /**
* Represents a ALTER TABLE statement. * This class represents the statement
* ALTER TABLE SET
*/ */
public class AlterTableSet extends SchemaCommand { public class AlterTableSet extends SchemaCommand {
......
...@@ -28,6 +28,10 @@ import org.h2.util.FileUtils; ...@@ -28,6 +28,10 @@ import org.h2.util.FileUtils;
import org.h2.util.IOUtils; import org.h2.util.IOUtils;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
/**
* This class represents the statement
* BACKUP
*/
public class BackupCommand extends Prepared { public class BackupCommand extends Prepared {
private String fileName; private String fileName;
......
...@@ -20,7 +20,8 @@ import org.h2.value.ValueArray; ...@@ -20,7 +20,8 @@ import org.h2.value.ValueArray;
import org.h2.value.ValueResultSet; import org.h2.value.ValueResultSet;
/** /**
* Represents a CALL statement. * This class represents the statement
* CALL
*/ */
public class Call extends Prepared { public class Call extends Prepared {
private Expression value; private Expression value;
......
...@@ -20,7 +20,8 @@ import org.h2.table.TableFilter; ...@@ -20,7 +20,8 @@ import org.h2.table.TableFilter;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
/** /**
* Represents a DELETE statement. * This class represents the statement
* DELETE
*/ */
public class Delete extends Prepared { public class Delete extends Prepared {
......
...@@ -15,7 +15,8 @@ import org.h2.result.LocalResult; ...@@ -15,7 +15,8 @@ import org.h2.result.LocalResult;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
/** /**
* Represents an EXECUTE statement. * This class represents the statement
* EXECUTE
*/ */
public class ExecuteProcedure extends Prepared { public class ExecuteProcedure extends Prepared {
......
...@@ -16,7 +16,8 @@ import org.h2.value.Value; ...@@ -16,7 +16,8 @@ import org.h2.value.Value;
import org.h2.value.ValueString; import org.h2.value.ValueString;
/** /**
* Represents an EXPLAIN statement. * This class represents the statement
* EXPLAIN
*/ */
public class ExplainPlan extends Prepared { public class ExplainPlan extends Prepared {
......
...@@ -22,7 +22,8 @@ import org.h2.util.ObjectArray; ...@@ -22,7 +22,8 @@ import org.h2.util.ObjectArray;
import org.h2.value.Value; import org.h2.value.Value;
/** /**
* Represents an INSERT statement. * This class represents the statement
* INSERT
*/ */
public class Insert extends Prepared { public class Insert extends Prepared {
......
...@@ -24,7 +24,8 @@ import org.h2.util.ObjectArray; ...@@ -24,7 +24,8 @@ import org.h2.util.ObjectArray;
import org.h2.value.Value; import org.h2.value.Value;
/** /**
* Represents a MERGE statement. * This class represents the statement
* MERGE
*/ */
public class Merge extends Prepared { public class Merge extends Prepared {
......
...@@ -18,7 +18,8 @@ import org.h2.util.ScriptReader; ...@@ -18,7 +18,8 @@ import org.h2.util.ScriptReader;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
/** /**
* Represents a RUNSCRIPT statement. * This class represents the statement
* RUNSCRIPT
*/ */
public class RunScriptCommand extends ScriptBase { public class RunScriptCommand extends ScriptBase {
......
...@@ -17,6 +17,7 @@ import java.sql.Statement; ...@@ -17,6 +17,7 @@ import java.sql.Statement;
import java.util.Comparator; import java.util.Comparator;
import org.h2.command.Parser; import org.h2.command.Parser;
import org.h2.constant.SysProperties;
import org.h2.constraint.Constraint; import org.h2.constraint.Constraint;
import org.h2.engine.Comment; import org.h2.engine.Comment;
import org.h2.engine.Constants; import org.h2.engine.Constants;
...@@ -54,7 +55,8 @@ import org.h2.value.ValueLob; ...@@ -54,7 +55,8 @@ import org.h2.value.ValueLob;
import org.h2.value.ValueString; import org.h2.value.ValueString;
/** /**
* Represents a SCRIPT statement. * This class represents the statement
* SCRIPT
*/ */
public class ScriptCommand extends ScriptBase { public class ScriptCommand extends ScriptBase {
...@@ -407,7 +409,7 @@ public class ScriptCommand extends ScriptBase { ...@@ -407,7 +409,7 @@ public class ScriptCommand extends ScriptBase {
private void reset() throws SQLException { private void reset() throws SQLException {
result = null; result = null;
buffer = null; buffer = null;
lineSeparator = StringUtils.utf8Encode(System.getProperty("line.separator")); lineSeparator = StringUtils.utf8Encode(SysProperties.LINE_SEPARATOR);
} }
private void add(String s, boolean insert) throws SQLException, IOException { private void add(String s, boolean insert) throws SQLException, IOException {
......
...@@ -28,7 +28,8 @@ import org.h2.value.CompareMode; ...@@ -28,7 +28,8 @@ import org.h2.value.CompareMode;
import org.h2.value.ValueInt; import org.h2.value.ValueInt;
/** /**
* Represents a SET statement. * This class represents the statement
* SET
*/ */
public class Set extends Prepared { public class Set extends Prepared {
......
...@@ -23,7 +23,8 @@ import org.h2.util.StringUtils; ...@@ -23,7 +23,8 @@ import org.h2.util.StringUtils;
import org.h2.value.Value; import org.h2.value.Value;
/** /**
* Represents a union UPDATE statement. * This class represents the statement
* UPDATE
*/ */
public class Update extends Prepared { public class Update extends Prepared {
......
...@@ -13,6 +13,9 @@ import java.util.zip.Inflater; ...@@ -13,6 +13,9 @@ import java.util.zip.Inflater;
import org.h2.constant.ErrorCode; import org.h2.constant.ErrorCode;
import org.h2.message.Message; import org.h2.message.Message;
/**
* This is a wrapper class for the Deflater class.
*/
public class CompressDeflate implements Compressor { public class CompressDeflate implements Compressor {
private int level = Deflater.BEST_SPEED; private int level = Deflater.BEST_SPEED;
......
...@@ -31,6 +31,10 @@ ...@@ -31,6 +31,10 @@
package org.h2.compress; package org.h2.compress;
/**
* This class implements the LZF lossless data compression algorithm.
* LZF is optimized for speed.
*/
public class CompressLZF implements Compressor { public class CompressLZF implements Compressor {
public void setOptions(String options) { public void setOptions(String options) {
......
...@@ -4,6 +4,11 @@ ...@@ -4,6 +4,11 @@
*/ */
package org.h2.compress; package org.h2.compress;
/**
* This class implements a data compression algorithm that does in fact not compress.
* This is useful if the data can not be compressed because it is encrypted,
* already compressed, or random.
*/
public class CompressNo implements Compressor { public class CompressNo implements Compressor {
public int getAlgorithm() { public int getAlgorithm() {
......
...@@ -6,6 +6,9 @@ package org.h2.compress; ...@@ -6,6 +6,9 @@ package org.h2.compress;
import java.sql.SQLException; import java.sql.SQLException;
/**
* Each data compression algorithm must implement this interface.
*/
public interface Compressor { public interface Compressor {
int NO = 0, LZF = 1, DEFLATE = 2; int NO = 0, LZF = 1, DEFLATE = 2;
......
...@@ -7,6 +7,10 @@ package org.h2.compress; ...@@ -7,6 +7,10 @@ package org.h2.compress;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
/**
* An input stream to read from an LZF stream.
* The data is automatically expanded.
*/
public class LZFInputStream extends InputStream { public class LZFInputStream extends InputStream {
private final InputStream in; private final InputStream in;
......
...@@ -9,6 +9,10 @@ import java.io.OutputStream; ...@@ -9,6 +9,10 @@ import java.io.OutputStream;
import org.h2.engine.Constants; import org.h2.engine.Constants;
/**
* An output stream to write an LZF stream.
* The data is automatically compressed.
*/
public class LZFOutputStream extends OutputStream { public class LZFOutputStream extends OutputStream {
static final int MAGIC = ('H' << 24) | ('2' << 16) | ('I' << 8) | 'S'; static final int MAGIC = ('H' << 24) | ('2' << 16) | ('I' << 8) | 'S';
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
package org.h2.constant; package org.h2.constant;
/** /**
* This class defines the error codes used for sql exceptions * This class defines the error codes used for SQL exceptions.
*/ */
public class ErrorCode { public class ErrorCode {
......
...@@ -21,6 +21,11 @@ import org.h2.message.TraceSystem; ...@@ -21,6 +21,11 @@ import org.h2.message.TraceSystem;
*/ */
public class SysProperties { public class SysProperties {
public static final String LINE_SEPARATOR = getStringSetting("line.separator", "\n");
public static final String FILE_SEPARATOR = getStringSetting("file.separator", "/");
public static final String USER_HOME = getStringSetting("user.home", "");
public static final String FILE_ENCODING = getStringSetting("file.encoding", "Cp1252");
public static final int MIN_WRITE_DELAY = getIntSetting("h2.minWriteDelay", 5); public static final int MIN_WRITE_DELAY = getIntSetting("h2.minWriteDelay", 5);
public static final boolean CHECK = getBooleanSetting("h2.check", true); public static final boolean CHECK = getBooleanSetting("h2.check", true);
public static final boolean CHECK2 = getBooleanSetting("h2.check2", false); public static final boolean CHECK2 = getBooleanSetting("h2.check2", false);
...@@ -68,7 +73,7 @@ public class SysProperties { ...@@ -68,7 +73,7 @@ public class SysProperties {
public static final int DEFAULT_MAX_OPERATION_MEMORY = getIntSetting("h2.defaultMaxOperationMemory", 100000); public static final int DEFAULT_MAX_OPERATION_MEMORY = getIntSetting("h2.defaultMaxOperationMemory", 100000);
private static boolean getBooleanSetting(String name, boolean defaultValue) { private static boolean getBooleanSetting(String name, boolean defaultValue) {
String s = System.getProperty(name); String s = getProperty(name);
if (s != null) { if (s != null) {
try { try {
return Boolean.valueOf(s).booleanValue(); return Boolean.valueOf(s).booleanValue();
...@@ -78,13 +83,22 @@ public class SysProperties { ...@@ -78,13 +83,22 @@ public class SysProperties {
return defaultValue; return defaultValue;
} }
private static String getStringSetting(String name, String defaultValue) { private static String getProperty(String name) {
String s = System.getProperty(name); try {
return System.getProperty(name);
} catch (SecurityException e) {
// applets may not do that - ignore
return null;
}
}
public static String getStringSetting(String name, String defaultValue) {
String s = getProperty(name);
return s == null ? defaultValue : s; return s == null ? defaultValue : s;
} }
private static int getIntSetting(String name, int defaultValue) { private static int getIntSetting(String name, int defaultValue) {
String s = System.getProperty(name); String s = getProperty(name);
if (s != null) { if (s != null) {
try { try {
return Integer.decode(s).intValue(); return Integer.decode(s).intValue();
......
...@@ -17,7 +17,7 @@ import org.h2.table.Column; ...@@ -17,7 +17,7 @@ import org.h2.table.Column;
import org.h2.table.Table; import org.h2.table.Table;
/** /**
* @author Thomas * The base calss for constraint checking.
*/ */
public abstract class Constraint extends SchemaObjectBase { public abstract class Constraint extends SchemaObjectBase {
......
...@@ -20,9 +20,8 @@ import org.h2.table.TableFilter; ...@@ -20,9 +20,8 @@ import org.h2.table.TableFilter;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
/** /**
* @author Thomas * A check contraint.
*/ */
public class ConstraintCheck extends Constraint { public class ConstraintCheck extends Constraint {
private TableFilter filter; private TableFilter filter;
......
...@@ -27,9 +27,8 @@ import org.h2.value.Value; ...@@ -27,9 +27,8 @@ import org.h2.value.Value;
import org.h2.value.ValueNull; import org.h2.value.ValueNull;
/** /**
* @author Thomas * A referential contraint.
*/ */
public class ConstraintReferential extends Constraint { public class ConstraintReferential extends Constraint {
public static final int RESTRICT = 0, CASCADE = 1, SET_DEFAULT = 2, SET_NULL = 3; public static final int RESTRICT = 0, CASCADE = 1, SET_DEFAULT = 2, SET_NULL = 3;
......
...@@ -15,9 +15,8 @@ import org.h2.table.Table; ...@@ -15,9 +15,8 @@ import org.h2.table.Table;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
/** /**
* @author Thomas * A unique contraint. This object always backed by a unique index.
*/ */
public class ConstraintUnique extends Constraint { public class ConstraintUnique extends Constraint {
private Index index; private Index index;
......
...@@ -11,6 +11,9 @@ import org.h2.message.Trace; ...@@ -11,6 +11,9 @@ import org.h2.message.Trace;
import org.h2.table.Table; import org.h2.table.Table;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
/**
* Represents a database object comment.
*/
public class Comment extends DbObjectBase { public class Comment extends DbObjectBase {
private final int objectType; private final int objectType;
......
...@@ -20,6 +20,9 @@ import org.h2.util.MathUtils; ...@@ -20,6 +20,9 @@ import org.h2.util.MathUtils;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
/**
* Encapsulates the connection settings, including user name and password.
*/
public class ConnectionInfo { public class ConnectionInfo {
private static final HashSet KNOWN_SETTINGS = new HashSet(); private static final HashSet KNOWN_SETTINGS = new HashSet();
private final Properties prop = new Properties(); private final Properties prop = new Properties();
...@@ -110,7 +113,7 @@ public class ConnectionInfo { ...@@ -110,7 +113,7 @@ public class ConnectionInfo {
public void setBaseDir(String dir) { public void setBaseDir(String dir) {
if (persistent) { if (persistent) {
name = dir + System.getProperty("file.separator") + name; name = dir + SysProperties.FILE_SEPARATOR + name;
} }
} }
......
...@@ -61,8 +61,7 @@ import org.h2.value.ValueInt; ...@@ -61,8 +61,7 @@ import org.h2.value.ValueInt;
/** /**
* There is one database object per open database. * There is one database object per open database.
*
* @author Thomas
* @since 2004-04-15 22:49 * @since 2004-04-15 22:49
*/ */
/* /*
...@@ -197,6 +196,8 @@ public class Database implements DataHandler { ...@@ -197,6 +196,8 @@ public class Database implements DataHandler {
// shutdown in progress - just don't register the handler // shutdown in progress - just don't register the handler
// (maybe an application wants to write something into a // (maybe an application wants to write something into a
// database at shutdown time) // database at shutdown time)
} catch (SecurityException e) {
// applets may not do that - ignore
} }
} }
} catch (Throwable e) { } catch (Throwable e) {
...@@ -870,6 +871,8 @@ public class Database implements DataHandler { ...@@ -870,6 +871,8 @@ public class Database implements DataHandler {
Runtime.getRuntime().removeShutdownHook(closeOnExit); Runtime.getRuntime().removeShutdownHook(closeOnExit);
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
// ignore // ignore
} catch (SecurityException e) {
// applets may not do that - ignore
} }
closeOnExit = null; closeOnExit = null;
} }
......
...@@ -8,6 +8,9 @@ import java.sql.SQLException; ...@@ -8,6 +8,9 @@ import java.sql.SQLException;
import org.h2.table.Table; import org.h2.table.Table;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
/**
* A database object such as a table, an index, or a user.
*/
public interface DbObject { public interface DbObject {
int INDEX = 1; int INDEX = 1;
int SEQUENCE = 3; int SEQUENCE = 3;
......
...@@ -13,9 +13,8 @@ import org.h2.table.Table; ...@@ -13,9 +13,8 @@ import org.h2.table.Table;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
/** /**
* @author Thomas * The base class for all database objects.
*/ */
public abstract class DbObjectBase implements DbObject { public abstract class DbObjectBase implements DbObject {
private int id; private int id;
......
...@@ -16,7 +16,9 @@ import org.h2.message.Trace; ...@@ -16,7 +16,9 @@ import org.h2.message.Trace;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
/** /**
* @author Thomas * The engine contains a map of all open databases.
* It is also responsible for opening and creating new databases.
* This is a singleton class.
*/ */
public class Engine { public class Engine {
// TODO use a 'engine'/'master' database to allow shut down the server, view & kill sessions and so on // TODO use a 'engine'/'master' database to allow shut down the server, view & kill sessions and so on
......
...@@ -19,6 +19,9 @@ import org.h2.value.DataType; ...@@ -19,6 +19,9 @@ import org.h2.value.DataType;
import org.h2.value.Value; import org.h2.value.Value;
import org.h2.value.ValueNull; import org.h2.value.ValueNull;
/**
* Represents a user defined function, or alias.
*/
public class FunctionAlias extends DbObjectBase { public class FunctionAlias extends DbObjectBase {
private boolean hasConnectionParam; private boolean hasConnectionParam;
......
...@@ -16,6 +16,10 @@ import org.h2.util.ObjectArray; ...@@ -16,6 +16,10 @@ import org.h2.util.ObjectArray;
import org.h2.value.ValueInt; import org.h2.value.ValueInt;
import org.h2.value.ValueString; import org.h2.value.ValueString;
/**
* A record in the system table of the database.
* It contains the SQL statement to create the database object.
*/
public class MetaRecord { public class MetaRecord {
private int id; private int id;
......
...@@ -8,6 +8,10 @@ import java.util.HashMap; ...@@ -8,6 +8,10 @@ import java.util.HashMap;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
/**
* The compatibility modes. There is a fixed set of modes (for example PostgreSQL, MySQL).
* Each mode has different settings.
*/
public class Mode { public class Mode {
public static final String REGULAR = "REGULAR"; public static final String REGULAR = "REGULAR";
......
...@@ -6,6 +6,9 @@ package org.h2.engine; ...@@ -6,6 +6,9 @@ package org.h2.engine;
import org.h2.command.Prepared; import org.h2.command.Prepared;
/**
* Represents a procedure. Procedures are implemented for PostgreSQL compatibility.
*/
public class Procedure { public class Procedure {
private final String name; private final String name;
......
...@@ -10,6 +10,9 @@ import org.h2.message.Message; ...@@ -10,6 +10,9 @@ import org.h2.message.Message;
import org.h2.message.Trace; import org.h2.message.Trace;
import org.h2.table.Table; import org.h2.table.Table;
/**
* An access right. Rights are regular database objects, but have generated names.
*/
public class Right extends DbObjectBase { public class Right extends DbObjectBase {
public static final int SELECT = 1, DELETE = 2, INSERT = 4, UPDATE = 8, ALL = 15; public static final int SELECT = 1, DELETE = 2, INSERT = 4, UPDATE = 8, ALL = 15;
......
...@@ -12,6 +12,9 @@ import org.h2.constant.ErrorCode; ...@@ -12,6 +12,9 @@ import org.h2.constant.ErrorCode;
import org.h2.message.Message; import org.h2.message.Message;
import org.h2.table.Table; import org.h2.table.Table;
/**
* A right owner (sometimes called principal).
*/
public abstract class RightOwner extends DbObjectBase { public abstract class RightOwner extends DbObjectBase {
// key: role; value: right // key: role; value: right
......
...@@ -11,6 +11,9 @@ import org.h2.message.Trace; ...@@ -11,6 +11,9 @@ import org.h2.message.Trace;
import org.h2.table.Table; import org.h2.table.Table;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
/**
* Represents a role. Roles can be granted to users, and to other roles.
*/
public class Role extends RightOwner { public class Role extends RightOwner {
private final boolean system; private final boolean system;
......
...@@ -36,7 +36,8 @@ import org.h2.value.Value; ...@@ -36,7 +36,8 @@ import org.h2.value.Value;
import org.h2.value.ValueLong; import org.h2.value.ValueLong;
/** /**
* @author Thomas * A session represents a database connection. When using the server mode,
* this object resides on the server side and communicates with a RemoteSession on the client side.
*/ */
public class Session implements SessionInterface { public class Session implements SessionInterface {
......
...@@ -10,6 +10,9 @@ import org.h2.command.CommandInterface; ...@@ -10,6 +10,9 @@ import org.h2.command.CommandInterface;
import org.h2.message.Trace; import org.h2.message.Trace;
import org.h2.store.DataHandler; import org.h2.store.DataHandler;
/**
* A local or remote session. A session represents a database connection.
*/
public interface SessionInterface { public interface SessionInterface {
CommandInterface prepareCommand(String sql) throws SQLException; CommandInterface prepareCommand(String sql) throws SQLException;
void close() throws SQLException; void close() throws SQLException;
......
...@@ -27,6 +27,10 @@ import org.h2.util.StringUtils; ...@@ -27,6 +27,10 @@ import org.h2.util.StringUtils;
import org.h2.value.Transfer; import org.h2.value.Transfer;
import org.h2.value.Value; import org.h2.value.Value;
/**
* The client side part of a session when using the server mode.
* This object communicates with a Session on the server side.
*/
public class SessionRemote implements SessionInterface, DataHandler { public class SessionRemote implements SessionInterface, DataHandler {
public static final int SESSION_PREPARE = 0; public static final int SESSION_PREPARE = 0;
......
...@@ -10,6 +10,9 @@ import org.h2.message.Message; ...@@ -10,6 +10,9 @@ import org.h2.message.Message;
import org.h2.message.Trace; import org.h2.message.Trace;
import org.h2.table.Table; import org.h2.table.Table;
/**
* A persistent database setting.
*/
public class Setting extends DbObjectBase { public class Setting extends DbObjectBase {
private int intValue; private int intValue;
......
...@@ -20,6 +20,9 @@ import org.h2.util.ObjectArray; ...@@ -20,6 +20,9 @@ import org.h2.util.ObjectArray;
import org.h2.util.RandomUtils; import org.h2.util.RandomUtils;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
/**
* Represents a user object.
*/
public class User extends RightOwner { public class User extends RightOwner {
private final boolean systemUser; private final boolean systemUser;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论