提交 fcb43bb7 authored 作者: tledkov's avatar tledkov

Prepere to release: javadoc cleanup, fix maven build, fix javadoc build

上级 a084ae8d
......@@ -109,6 +109,12 @@
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>6.1</version>
<scope>test</scope>
</dependency>
<!-- END TEST DEPENDENCIES !-->
</dependencies>
......
......@@ -6937,8 +6937,15 @@ public class Parser {
return command;
}
/**
* Checks the table is the DUAL special table.
*
* @param tableName table name.
* @return {@code true} if the table is DUAL special table. Otherwise returns {@code false}.
* @see <a href="https://en.wikipedia.org/wiki/DUAL_table">Wikipedia: DUAL table</a>
*/
boolean isDualTable(String tableName) {
return ((schemaName == null || equalsToken(schemaName, "SYS")) && equalsToken("DUAL", tableName))
return ((schemaName == null || equalsToken(schemaName, "SYS")) && equalsToken("F", tableName))
|| (database.getMode().sysDummy1 && (schemaName == null || equalsToken(schemaName, "SYSIBM"))
&& equalsToken("SYSDUMMY1", tableName));
}
......
......@@ -52,8 +52,14 @@ public abstract class Query extends Prepared {
*/
Expression[] expressionArray;
/**
* Describes one element of the ORDER BY clause of a query.
*/
ArrayList<SelectOrderBy> orderList;
/**
* A sort order represents an ORDER BY clause in a query.
*/
SortOrder sort;
/**
......@@ -397,7 +403,7 @@ public abstract class Query extends Prepared {
}
fireBeforeSelectTriggers();
if (noCache || !session.getDatabase().getOptimizeReuseResults() ||
(session.isLazyQueryExecution() && !neverLazy)) {
(session.isLazyQueryExecution() /* && !neverLazy*/)) {
return queryWithoutCacheLazyCheck(limit, target);
}
Value[] params = getParameterValues();
......@@ -459,6 +465,18 @@ public abstract class Query extends Prepared {
}
}
/**
* Initialize the order or distinct expression.
*
* @param session the session
* @param expressions the select list expressions
* @param expressionSQL the select list SQL snippets
* @param e the expression.
* @param visible the number of visible columns in the select list
* @param mustBeInResult all order by expressions must be in the select list
* @param filters the table filters1
* @return index on the expression in the {@link #expressions} list.
*/
static int initExpression(Session session, ArrayList<Expression> expressions,
ArrayList<String> expressionSQL, Expression e, int visible, boolean mustBeInResult,
ArrayList<TableFilter> filters) {
......@@ -690,6 +708,11 @@ public abstract class Query extends Prepared {
return visitor.getMaxDataModificationId();
}
/**
* Appends query limits info to the plan.
*
* @param buff sl plan string builder.
*/
void appendLimitToSQL(StringBuilder buff) {
if (offsetExpr != null) {
String count = StringUtils.unEnclose(offsetExpr.getSQL());
......
......@@ -72,7 +72,7 @@ public class Select extends Query {
/**
* The main (top) table filter.
*/
TableFilter topTableFilter;
private TableFilter topTableFilter;
private final ArrayList<TableFilter> filters = Utils.newSmallArrayList();
private final ArrayList<TableFilter> topFilters = Utils.newSmallArrayList();
......@@ -83,7 +83,7 @@ public class Select extends Query {
/**
* The visible columns (the ones required in the result).
*/
int visibleColumnCount;
private int visibleColumnCount;
/**
* {@code DISTINCT ON(...)} expressions.
......@@ -98,17 +98,17 @@ public class Select extends Query {
/**
* The indexes of the group-by columns.
*/
int[] groupIndex;
private int[] groupIndex;
/**
* Whether a column in the expression list is part of a group-by.
*/
boolean[] groupByExpression;
private boolean[] groupByExpression;
SelectGroups groupData;
private SelectGroups groupData;
private int havingIndex;
boolean isGroupQuery;
private boolean isGroupQuery;
private boolean isGroupSortedQuery;
private boolean isWindowQuery;
private boolean isForUpdate, isForUpdateMvcc;
......
......@@ -194,8 +194,14 @@ public abstract class SelectGroups {
}
}
/**
* H2 session.
*/
final Session session;
/**
* The query's column list, including invisible expressions such as order by expressions.
*/
final ArrayList<Expression> expressions;
/**
......@@ -235,6 +241,7 @@ public abstract class SelectGroups {
* is this query is a group query
* @param groupIndex
* the indexes of group expressions, or null
* @return new instance of the grouped data.
*/
public static SelectGroups getInstance(Session session, ArrayList<Expression> expressions, boolean isGroupQuery,
int[] groupIndex) {
......@@ -247,7 +254,10 @@ public abstract class SelectGroups {
}
/**
* Is there currently a group-by active
* Is there currently a group-by active.
*
* @return {@code true} if there is currently a group-by active,
* otherwise returns {@code false}.
*/
public boolean isCurrentGroup() {
return currentGroupByExprData != null;
......@@ -273,7 +283,7 @@ public abstract class SelectGroups {
*
* @param expr
* expression
* @param object
* @param obj
* expression data to set
*/
public final void setCurrentGroupExprData(Expression expr, Object obj) {
......@@ -292,6 +302,11 @@ public abstract class SelectGroups {
currentGroupByExprData[index] = obj;
}
/**
* Creates new object arrays to holds group-by data.
*
* @return new object array to holds group-by data.
*/
final Object[] createRow() {
return new Object[Math.max(exprToIndexInGroupByData.size(), expressions.size())];
}
......@@ -321,7 +336,7 @@ public abstract class SelectGroups {
* expression
* @param partitionKey
* a key of partition
* @param object
* @param obj
* window expression data to set
*/
public final void setWindowExprData(DataAnalysisOperation expr, Value partitionKey, PartitionData obj) {
......@@ -338,6 +353,10 @@ public abstract class SelectGroups {
}
}
/**
* Update group-by data specified by implementation.
* The
*/
abstract void updateCurrentGroupExprData();
/**
......@@ -412,4 +431,10 @@ public abstract class SelectGroups {
currentGroupRowId++;
}
/**
* @return Expressions.
*/
public ArrayList<Expression> expressions() {
return expressions;
}
}
......@@ -1123,6 +1123,11 @@ public class Database implements DataHandler {
}
}
/**
* Release IDs.
*
* @param idsToRelease IDs to release.
*/
void releaseDatabaseObjectIds(BitSet idsToRelease) {
synchronized (objectIds) {
objectIds.andNot(idsToRelease);
......
......@@ -22,6 +22,11 @@ class OnExitDatabaseCloser extends Thread {
private static boolean terminated;
/**
* Register database instance to close one on the JVM process shutdown.
*
* @param db Database instance.
*/
static synchronized void register(Database db) {
if (terminated) {
// Shutdown in progress
......@@ -46,6 +51,11 @@ class OnExitDatabaseCloser extends Thread {
}
}
/**
* Unregister database instance.
*
* @param db Database instance.
*/
static synchronized void unregister(Database db) {
if (terminated) {
// Shutdown in progress, do nothing
......
......@@ -65,6 +65,14 @@ public class ConditionInParameter extends Condition {
private final Parameter parameter;
/**
* Gets evaluated condition value.
*
* @param database database instance.
* @param l left value.
* @param value parameter value.
* @return Evaluated condition value.
*/
static Value getValue(Database database, Value l, Value value) {
boolean hasNull = false;
if (value.containsNull()) {
......
......@@ -69,8 +69,19 @@ public abstract class JdbcLob extends TraceObject {
CLOSED;
}
/**
* JDBC connection.
*/
final JdbcConnection conn;
/**
* Value.
*/
Value value;
/**
* State.
*/
State state;
JdbcLob(JdbcConnection conn, Value value, State state, int type, int id) {
......@@ -80,6 +91,10 @@ public abstract class JdbcLob extends TraceObject {
this.state = state;
}
/**
* Check that connection and LOB is not closed, otherwise throws exception with
* error code {@link org.h2.api.ErrorCode#OBJECT_CLOSED}.
*/
void checkClosed() {
conn.checkClosed();
if (state == State.CLOSED) {
......@@ -87,6 +102,10 @@ public abstract class JdbcLob extends TraceObject {
}
}
/**
* Check the state of the LOB and throws the exception when check failed
* (set is supported only for a new LOB).
*/
void checkEditable() {
checkClosed();
if (state != State.NEW) {
......@@ -94,6 +113,10 @@ public abstract class JdbcLob extends TraceObject {
}
}
/**
* Check the state of the LOB and throws the exception when check failed
* (the LOB must be set completely before read).
*/
void checkReadable() throws SQLException, IOException {
checkClosed();
if (state == State.SET_CALLED) {
......@@ -101,6 +124,10 @@ public abstract class JdbcLob extends TraceObject {
}
}
/**
* Change the state LOB state (LOB value is set completely and available to read).
* @param blob LOB value.
*/
void completeWrite(Value blob) {
checkClosed();
state = State.WITH_VALUE;
......@@ -146,10 +173,22 @@ public abstract class JdbcLob extends TraceObject {
}
}
/**
* Returns the writer.
*
* @return Writer.
* @throws IOException If an I/O error occurs.
*/
Writer setCharacterStreamImpl() throws IOException {
return IOUtils.getBufferedWriter(setClobOutputStreamImpl());
}
/**
* Returns the writer stream.
*
* @return Output stream..
* @throws IOException If an I/O error occurs.
*/
LobPipedOutputStream setClobOutputStreamImpl() throws IOException {
// PipedReader / PipedWriter are a lot slower
// than PipedInputStream / PipedOutputStream
......
......@@ -3606,7 +3606,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet, JdbcResultS
* Updates a column in the current or insert row.
*
* @param columnIndex (1,2,...)
* @param x the value
* @param xmlObject the value
* @throws SQLException if the result set is closed or not updatable
*/
@Override
......@@ -3633,7 +3633,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet, JdbcResultS
* Updates a column in the current or insert row.
*
* @param columnLabel the column label
* @param x the value
* @param xmlObject the value
* @throws SQLException if the result set is closed or not updatable
*/
@Override
......
......@@ -55,6 +55,10 @@ public class DbException extends RuntimeException {
private static final Properties MESSAGES = new Properties();
/**
* Thrown when OOME exception is happened on handle error
* inside {@link #convert(java.lang.Throwable)}.
*/
public static final SQLException SQL_OOME =
new SQLException("OutOfMemoryError", "HY000", OUT_OF_MEMORY, new OutOfMemoryError());
private static final DbException OOME = new DbException(SQL_OOME);
......@@ -432,6 +436,7 @@ public class DbException extends RuntimeException {
* @param errorCode the error code
* @param cause the exception that was the reason for this exception
* @param stackTrace the stack trace
* @return the SQLException object
*/
public static SQLException getJdbcSQLException(String message, String sql, String state, int errorCode,
Throwable cause, String stackTrace) {
......
......@@ -252,6 +252,7 @@ public final class DataUtils {
*
* @param out the output stream
* @param x the value
* @throws IOException if some data could not be written
*/
public static void writeVarInt(OutputStream out, int x) throws IOException {
while ((x & ~0x7f) != 0) {
......@@ -341,6 +342,7 @@ public final class DataUtils {
*
* @param out the output stream
* @param x the value
* @throws IOException if some data could not be written
*/
public static void writeVarLong(OutputStream out, long x)
throws IOException {
......
......@@ -154,6 +154,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
*
* @param key the key (may not be null)
* @param value the value (may not be null)
* @param decisionMaker callback object for update logic
* @return the old value if the key existed, or null otherwise
*/
public final V put(K key, V value, DecisionMaker<? super V> decisionMaker) {
......@@ -873,6 +874,9 @@ public class MVMap<K, V> extends AbstractMap<K, V>
* @param oldRoot the old root reference, will use the current root reference,
* if null is specified
* @param newRoot the new root page
* @param attemptUpdateCounter how many attempt (including current)
* were made to update root
* @return new RootReference or null if update failed
*/
protected final boolean updateRoot(RootReference oldRoot, Page newRoot, int attemptUpdateCounter) {
return setNewRoot(oldRoot, newRoot, attemptUpdateCounter, true) != null;
......
......@@ -474,6 +474,7 @@ public class MVStore implements AutoCloseable {
* does not yet exist. If a map with this name is already open, this map is
* returned.
*
* @param <M> the map type
* @param <K> the key type
* @param <V> the value type
* @param name the name of the map
......
......@@ -95,6 +95,7 @@ public class StreamStore {
*
* @param in the stream
* @return the id (potentially an empty array)
* @throws IOException If an I/O error occurs
*/
@SuppressWarnings("resource")
public byte[] put(InputStream in) throws IOException {
......
......@@ -546,6 +546,8 @@ public class Transaction {
/**
* Remove the map.
*
* @param <K> the key type
* @param <V> the value type
* @param map the map
*/
public <K, V> void removeMap(TransactionMap<K, V> map) {
......
......@@ -19,17 +19,17 @@ public class SimpleResult implements ResultInterface {
static final class Column {
final String alias;
private final String alias;
final String columnName;
private final String columnName;
final int columnType;
private final int columnType;
final long columnPrecision;
private final long columnPrecision;
final int columnScale;
private final int columnScale;
final int displaySize;
private final int displaySize;
Column(String alias, String columnName, int columnType, long columnPrecision, int columnScale,
int displaySize) {
......@@ -94,16 +94,36 @@ public class SimpleResult implements ResultInterface {
this.rowId = -1;
}
/**
* Add column to the result.
*
* @param alias Column's alias.
* @param columnName Column's name.
* @param columnType Column's type.
* @param columnPrecision Column's precision.
* @param columnScale Column's scale.
* @param displaySize Column's display data size.
*/
public void addColumn(String alias, String columnName, int columnType, long columnPrecision, int columnScale,
int displaySize) {
addColumn(new Column(alias, columnName, columnType, columnPrecision, columnScale, displaySize));
}
/**
* Add column to the result.
*
* @param column Column info.
*/
void addColumn(Column column) {
assert rows.isEmpty();
columns.add(column);
}
/**
* Add row to result.
*
* @param values Row's values.
*/
public void addRow(Value... values) {
assert values.length == columns.size();
rows.add(values);
......
......@@ -20,7 +20,7 @@ public class AuthenticationInfo {
private String realm;
/*
* Can be used by authenticator to hold informations
* Can be used by authenticator to hold information.
*/
Object nestedIdentity;
......@@ -58,14 +58,16 @@ public class AuthenticationInfo {
}
/**
* get nested identity
* Gets nested identity.
*
* @return nested identity object.
*/
public Object getNestedIdentity() {
return nestedIdentity;
}
/**
* Method used by authenticators to hold informations about authenticated
* Method used by authenticators to hold information about authenticated
* user
*
* @param nestedIdentity
......@@ -75,6 +77,9 @@ public class AuthenticationInfo {
this.nestedIdentity = nestedIdentity;
}
/**
* Clean authentication data.
*/
public void clean() {
this.password = null;
this.nestedIdentity = null;
......
......@@ -16,6 +16,8 @@ public interface Authenticator {
/**
* Perform user authentication.
*
* @param authenticationInfo authentication info.
* @param database target database instance.
* @return valid database user or null if user doesn't exists in the
* database
*/
......
......@@ -10,6 +10,10 @@ package org.h2.security.auth;
*/
public class AuthenticatorFactory {
/**
* Factory method.
* @return authenticator instance.
*/
public static Authenticator createAuthenticator() {
return DefaultAuthenticator.getInstance();
}
......
......@@ -38,6 +38,13 @@ public class ConfigProperties {
}
}
/**
* Returns the string value of specified property.
*
* @param name property name.
* @param defaultValue default value.
* @return the string property value or {@code defaultValue} if the property is missing.
*/
public String getStringValue(String name, String defaultValue) {
String result = properties.get(name);
if (result == null) {
......@@ -46,6 +53,13 @@ public class ConfigProperties {
return result;
}
/**
* Returns the string value of specified property.
*
* @param name property name.
* @return the string property value.
* @throws AuthConfigException if the property is missing.
*/
public String getStringValue(String name) {
String result = properties.get(name);
if (result == null) {
......@@ -54,6 +68,13 @@ public class ConfigProperties {
return result;
}
/**
* Returns the integer value of specified property.
*
* @param name property name.
* @param defaultValue default value.
* @return the integer property value or {@code defaultValue} if the property is missing.
*/
public int getIntValue(String name, int defaultValue) {
String result = properties.get(name);
if (result == null) {
......@@ -62,6 +83,13 @@ public class ConfigProperties {
return Integer.parseInt(result);
}
/**
* Returns the integer value of specified property.
*
* @param name property name.
* @return the integer property value.
* @throws AuthConfigException if the property is missing.
*/
public int getIntValue(String name) {
String result = properties.get(name);
if (result == null) {
......@@ -70,6 +98,13 @@ public class ConfigProperties {
return Integer.parseInt(result);
}
/**
* Returns the boolean value of specified property.
*
* @param name property name.
* @param defaultValue default value.
* @return the boolean property value or {@code defaultValue} if the property is missing.
*/
public boolean getBooleanValue(String name, boolean defaultValue) {
String result = properties.get(name);
if (result == null) {
......
......@@ -54,19 +54,12 @@ public class DefaultAuthenticator implements Authenticator {
public static final String DEFAULT_REALMNAME = "H2";
private Map<String, CredentialsValidator> realms = new HashMap<>();
private List<UserToRolesMapper> userToRolesMappers = new ArrayList<>();
private boolean allowUserRegistration;
private boolean persistUsers;
private boolean createMissingRoles;
private boolean skipDefaultInitialization;
private boolean initialized;
private static DefaultAuthenticator instance;
protected static final DefaultAuthenticator getInstance() {
......@@ -95,34 +88,62 @@ public class DefaultAuthenticator implements Authenticator {
/**
* If set save users externals defined during the authentication.
*
* @return {@code true} if user will be persisted,
* otherwise returns {@code false}
*/
public boolean isPersistUsers() {
return persistUsers;
}
/**
* If set to {@code true} saves users externals defined during the authentication.
*
* @param persistUsers {@code true} if user will be persisted,
* otherwise {@code false}.
*/
public void setPersistUsers(boolean persistUsers) {
this.persistUsers = persistUsers;
}
/**
* If set create external users in the database if not present.
*
* @return {@code true} if creation external user is allowed,
* otherwise returns {@code false}
*/
public boolean isAllowUserRegistration() {
return allowUserRegistration;
}
/**
* If set to{@code true} creates external users in the database if not present.
*
* @param allowUserRegistration {@code true} if creation external user is allowed,
* otherwise returns {@code false}
*/
public void setAllowUserRegistration(boolean allowUserRegistration) {
this.allowUserRegistration = allowUserRegistration;
}
/**
* When set create roles not found in the database. If not set roles not
* found in the database are silently skipped
* found in the database are silently skipped.
*
* @return {@code true} if not found roles will be created,
* {@code false} roles are silently skipped.
*/
public boolean isCreateMissingRoles() {
return createMissingRoles;
}
/**
* Sets the flag that define behavior in case external roles not found in the database.
*
*
* @param createMissingRoles when is {@code true} not found roles are created,
* when is {@code false} roles are silently skipped.
*/
public void setCreateMissingRoles(boolean createMissingRoles) {
this.createMissingRoles = createMissingRoles;
}
......@@ -209,7 +230,7 @@ public class DefaultAuthenticator implements Authenticator {
}
}
void defaultConfiguration() {
private void defaultConfiguration() {
createMissingRoles = false;
allowUserRegistration = true;
realms = new HashMap<>();
......@@ -232,7 +253,7 @@ public class DefaultAuthenticator implements Authenticator {
configureFrom(config);
}
void configureFrom(H2AuthConfig config) throws AuthenticationException {
private void configureFrom(H2AuthConfig config) throws AuthenticationException {
allowUserRegistration = config.isAllowUserRegistration();
createMissingRoles = config.isCreateMissingRoles();
Map<String, CredentialsValidator> newRealms = new HashMap<>();
......@@ -270,7 +291,7 @@ public class DefaultAuthenticator implements Authenticator {
this.userToRolesMappers = newUserToRolesMapper;
}
boolean updateRoles(AuthenticationInfo authenticationInfo, User user, Database database)
private boolean updateRoles(AuthenticationInfo authenticationInfo, User user, Database database)
throws AuthenticationException {
boolean updatedDb = false;
Set<String> roles = new HashSet<>();
......
......@@ -9,32 +9,54 @@ import java.util.ArrayList;
import java.util.List;
/**
* Describe configuration of H2 DefaultAuthenticator
* Describe configuration of H2 DefaultAuthenticator.
*/
public class H2AuthConfig {
private boolean allowUserRegistration=true;
private boolean createMissingRoles=true;
private List<RealmConfig> realms;
private List<UserToRolesMapperConfig> userToRolesMappers;
/**
* Allow user registration flag. If set to {@code true}
* creates external users in the database if not present.
*
* @return {@code true} in case user registration is allowed,
* otherwise returns {@code false}.
*/
public boolean isAllowUserRegistration() {
return allowUserRegistration;
}
/**
* @param allowUserRegistration Allow user registration flag.
*/
public void setAllowUserRegistration(boolean allowUserRegistration) {
this.allowUserRegistration = allowUserRegistration;
}
boolean createMissingRoles=true;
/**
* When set create roles not found in the database. If not set roles not
* found in the database are silently skipped.
* @return {@code true} if the flag is set, otherwise returns {@code false}.
*/
public boolean isCreateMissingRoles() {
return createMissingRoles;
}
/**
* When set create roles not found in the database. If not set roles not
* found in the database are silently skipped
* @param createMissingRoles missing roles flag.
*/
public void setCreateMissingRoles(boolean createMissingRoles) {
this.createMissingRoles = createMissingRoles;
}
List<RealmConfig> realms;
/**
* @return configuration of authentication realms.
*/
public List<RealmConfig> getRealms() {
if (realms == null) {
realms = new ArrayList<>();
......@@ -42,12 +64,16 @@ public class H2AuthConfig {
return realms;
}
/**
* @param realms configuration of authentication realms.
*/
public void setRealms(List<RealmConfig> realms) {
this.realms = realms;
}
List<UserToRolesMapperConfig> userToRolesMappers;
/**
* @return configuration of the mappers external users to database roles.
*/
public List<UserToRolesMapperConfig> getUserToRolesMappers() {
if (userToRolesMappers == null) {
userToRolesMappers = new ArrayList<>();
......@@ -55,6 +81,9 @@ public class H2AuthConfig {
return userToRolesMappers;
}
/**
* @param userToRolesMappers configuration of the mappers external users to database roles.
*/
public void setUserToRolesMappers(List<UserToRolesMapperConfig> userToRolesMappers) {
this.userToRolesMappers = userToRolesMappers;
}
......
......@@ -20,9 +20,8 @@ import org.xml.sax.helpers.DefaultHandler;
*/
public class H2AuthConfigXml extends DefaultHandler{
H2AuthConfig result;
HasConfigProperties lastConfigProperties;
private H2AuthConfig result;
private HasConfigProperties lastConfigProperties;
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
......@@ -68,7 +67,7 @@ public class H2AuthConfigXml extends DefaultHandler{
}
}
static String getMandatoryAttributeValue(String attributeName, Attributes attributes) throws SAXException {
private static String getMandatoryAttributeValue(String attributeName, Attributes attributes) throws SAXException {
String attributeValue=attributes.getValue(attributeName);
if (attributeValue==null || attributeValue.trim().equals("")) {
throw new SAXException("missing attribute "+attributeName);
......@@ -77,7 +76,7 @@ public class H2AuthConfigXml extends DefaultHandler{
}
static String getAttributeValueOr(String attributeName, Attributes attributes, String defaultValue) {
private static String getAttributeValueOr(String attributeName, Attributes attributes, String defaultValue) {
String attributeValue=attributes.getValue(attributeName);
if (attributeValue==null || attributeValue.trim().equals("")) {
return defaultValue;
......@@ -85,12 +84,23 @@ public class H2AuthConfigXml extends DefaultHandler{
return attributeValue;
}
/**
* Returns parsed authenticator configuration.
*
* @return Authenticator configuration.
*/
public H2AuthConfig getResult() {
return result;
}
/**
* Parse the xml
* Parse the xml.
*
* @param url the source of the xml configuration.
* @return Authenticator configuration.
* @throws ParserConfigurationException if a parser cannot be created.
* @throws SAXException for SAX errors.
* @throws IOException If an I/O error occurs
*/
public static H2AuthConfig parseFrom(URL url)
throws SAXException, IOException, ParserConfigurationException {
......@@ -99,6 +109,15 @@ public class H2AuthConfigXml extends DefaultHandler{
}
}
/**
* Parse the xml.
*
* @param inputStream the source of the xml configuration.
* @return Authenticator configuration.
* @throws ParserConfigurationException if a parser cannot be created.
* @throws SAXException for SAX errors.
* @throws IOException If an I/O error occurs
*/
public static H2AuthConfig parseFrom(InputStream inputStream)
throws SAXException, IOException, ParserConfigurationException {
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
......
......@@ -14,6 +14,8 @@ import java.util.List;
public class RealmConfig implements HasConfigProperties {
private String name;
private String validatorClass;
private List<PropertyConfig> properties;
public String getName() {
return name;
......@@ -23,7 +25,6 @@ public class RealmConfig implements HasConfigProperties {
this.name = name;
}
String validatorClass;
public String getValidatorClass() {
return validatorClass;
......@@ -33,8 +34,6 @@ public class RealmConfig implements HasConfigProperties {
this.validatorClass = validatorClass;
}
List<PropertyConfig> properties;
@Override
public List<PropertyConfig> getProperties() {
if (properties == null) {
......
......@@ -10,21 +10,31 @@ import java.util.List;
/**
* Configuration for class that maps users to their roles.
*
* @see org.h2.api.UserToRolesMapper
*/
public class UserToRolesMapperConfig implements HasConfigProperties {
private String className;
private List<PropertyConfig> properties;
/**
* @return Mapper class name.
*/
public String getClassName() {
return className;
}
/**
* @param className mapper class name.
*/
public void setClassName(String className) {
this.className = className;
}
/**
* @return Mapper properties.
*/
@Override
public List<PropertyConfig> getProperties() {
if (properties == null) {
......
......@@ -218,6 +218,7 @@ public abstract class FilePath {
* @param append if true, the file will grow, if false, the file will be
* truncated first
* @return the output stream
* @throws IOException If an I/O error occurs
*/
public abstract OutputStream newOutputStream(boolean append) throws IOException;
......@@ -226,6 +227,7 @@ public abstract class FilePath {
*
* @param mode the access mode. Supported are r, rw, rws, rwd
* @return the file object
* @throws IOException If an I/O error occurs
*/
public abstract FileChannel open(String mode) throws IOException;
......@@ -233,6 +235,7 @@ public abstract class FilePath {
* Create an input stream to read from the file.
*
* @return the input stream
* @throws IOException If an I/O error occurs
*/
public abstract InputStream newInputStream() throws IOException;
......
......@@ -656,6 +656,13 @@ public abstract class Table extends SchemaObjectBase {
}
}
/**
* Create a new row for a table.
*
* @param data the values.
* @param memory whether the row is in memory.
* @return the created row.
*/
public Row createRow(Value[] data, int memory) {
return database.createRow(data, memory);
}
......
......@@ -457,6 +457,14 @@ public class DateTimeUtils {
return ((((hour * 60L) + minute) * 60) + second) * NANOS_PER_SECOND + nanos;
}
/**
* Parse nanoseconds.
*
* @param s String to parse.
* @param start Begin position at the string to read.
* @param end End position at the string to read.
* @return Parsed nanoseconds.
*/
static int parseNanos(String s, int start, int end) {
if (start >= end) {
throw new IllegalArgumentException(s);
......@@ -1230,6 +1238,8 @@ public class DateTimeUtils {
}
/**
* Creates the instance of the {@link ValueTimestampTimeZone} from milliseconds.
*
* @param ms milliseconds since 1970-01-01 (UTC)
* @return timestamp with time zone with specified value and current time zone
*/
......@@ -1473,6 +1483,11 @@ public class DateTimeUtils {
}
}
/**
* Skip trailing zeroes.
*
* @param buff String buffer.
*/
static void stripTrailingZeroes(StringBuilder buff) {
int i = buff.length() - 1;
if (buff.charAt(i) == '0') {
......
......@@ -665,6 +665,8 @@ public class IntervalUtils {
}
/**
* Returns years value of interval, if any.
*
* @param qualifier
* qualifier
* @param negative
......@@ -688,6 +690,8 @@ public class IntervalUtils {
}
/**
* Returns months value of interval, if any.
*
* @param qualifier
* qualifier
* @param negative
......@@ -715,6 +719,8 @@ public class IntervalUtils {
}
/**
* Returns days value of interval, if any.
*
* @param qualifier
* qualifier
* @param negative
......@@ -723,7 +729,7 @@ public class IntervalUtils {
* value of leading field
* @param remaining
* values of all remaining fields
* @return months, or 0
* @return days, or 0
*/
public static long daysFromInterval(IntervalQualifier qualifier, boolean negative, long leading, long remaining) {
switch (qualifier) {
......@@ -742,6 +748,8 @@ public class IntervalUtils {
}
/**
* Returns hours value of interval, if any.
*
* @param qualifier
* qualifier
* @param negative
......@@ -779,6 +787,8 @@ public class IntervalUtils {
}
/**
* Returns minutes value of interval, if any.
*
* @param qualifier
* qualifier
* @param negative
......@@ -819,6 +829,8 @@ public class IntervalUtils {
}
/**
* Returns nanoseconds value of interval, if any.
*
* @param qualifier
* qualifier
* @param negative
......
......@@ -10,6 +10,8 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import org.h2.message.DbException;
import org.h2.value.Value;
import org.h2.value.ValueNull;
......@@ -35,7 +37,14 @@ import org.h2.value.ValueNull;
*/
public class ValueHashMap<V> extends HashBase {
/**
* Keys array.
*/
Value[] keys;
/**
* Values array.
*/
V[] values;
@Override
......@@ -202,6 +211,11 @@ public class ValueHashMap<V> extends HashBase {
}
}
/**
* Gets all map's entries.
*
* @return all map's entries.
*/
public Iterable<Map.Entry<Value, V>> entries() {
return new EntryIterable();
}
......
......@@ -269,7 +269,7 @@ public final class EWKBUtils {
*
* @param ewkb
* source EWKB
* @param dimension
* @param dimensionSystem
* dimension system
* @return canonical EWKB, may be the same as the source
*/
......
......@@ -563,7 +563,7 @@ public final class EWKTUtils {
*
* @param ewkb
* source EWKB
* @param dimension
* @param dimensionSystem
* dimension system
* @return EWKT representation
*/
......@@ -594,7 +594,7 @@ public final class EWKTUtils {
*
* @param ewkt
* source EWKT
* @param dimension
* @param dimensionSystem
* dimension system
* @return EWKB representation
*/
......@@ -608,7 +608,7 @@ public final class EWKTUtils {
/**
* Parses a EWKB.
*
* @param source
* @param ewkt
* source EWKT
* @param target
* output target
......
......@@ -1347,6 +1347,12 @@ public abstract class Value {
return ValueResultSet.get(result);
}
/**
* Creates new instance of the DbException for data conversion error.
*
* @param targetType Target data type.
* @return instance of the DbException.
*/
DbException getDataConversionError(int targetType) {
DataType from = DataType.getDataType(getType());
DataType to = DataType.getDataType(targetType);
......@@ -1489,6 +1495,13 @@ public abstract class Value {
return (short) x;
}
/**
* Checks value by Integer type numeric range.
*
* @param x integer value.
* @param column Column info.
* @return x
*/
public static int convertToInt(long x, Object column) {
if (x > Integer.MAX_VALUE || x < Integer.MIN_VALUE) {
throw DbException.get(
......
......@@ -16,6 +16,9 @@ import org.h2.util.MathUtils;
*/
public abstract class ValueCollectionBase extends Value {
/**
* Values.
*/
final Value[] values;
private int hash;
......
......@@ -53,6 +53,8 @@ public class ValueInterval extends Value {
private final long remaining;
/**
* Creates interval value.
*
* @param qualifier
* qualifier
* @param negative
......@@ -80,6 +82,7 @@ public class ValueInterval extends Value {
* @param scale
* fractional seconds precision. Ignored if specified type of
* interval does not have seconds.
* @return displayed size.
*/
public static int getDisplaySize(int type, int precision, int scale) {
switch (type) {
......
......@@ -439,6 +439,10 @@ java org.h2.test.TestAll timer
private Server server;
/**
* The map of executed tests to detect not executed tests.
* Boolean value is 'false' for a disabled test.
*/
HashMap<Class<? extends TestBase>, Boolean> executedTests = new HashMap<>();
/**
......
......@@ -185,7 +185,7 @@ public class TestSQLXML extends TestDb {
}
}
void testSettersImpl(SQLXML sqlxml) throws SQLException {
private void testSettersImpl(SQLXML sqlxml) throws SQLException {
PreparedStatement prep = conn.prepareStatement("UPDATE TEST SET X = ?");
prep.setSQLXML(1, sqlxml);
assertEquals(1, prep.executeUpdate());
......
......@@ -289,7 +289,7 @@ public class TestScript extends TestDb {
return s;
}
public void putBack(String line) {
private void putBack(String line) {
putBack.addLast(line);
}
......
......@@ -50,7 +50,8 @@ public class TestLocalResultFactory extends TestBase {
* Test local result factory.
*/
public static class MyTestLocalResultFactory extends LocalResultFactory {
static final AtomicInteger COUNTER = new AtomicInteger();
/** Call counter for the factory methods. */
private static final AtomicInteger COUNTER = new AtomicInteger();
@Override public LocalResult create(Session session, Expression[] expressions, int visibleColumnCount) {
COUNTER.incrementAndGet();
......
......@@ -483,7 +483,7 @@ public class TestValue extends TestDb {
return lob1.compareTypeSafe(lob2, null);
}
static Value createLob(DataHandler dh, int type, byte[] bytes) {
private static Value createLob(DataHandler dh, int type, byte[] bytes) {
if (dh == null) {
return ValueLobDb.createSmallLob(type, bytes);
}
......
......@@ -668,7 +668,9 @@ public class Build extends BuildBase {
File.pathSeparator + "ext/lucene-queryparser-5.5.5.jar" +
File.pathSeparator + "ext/org.osgi.core-4.2.0.jar" +
File.pathSeparator + "ext/org.osgi.enterprise-4.2.0.jar" +
File.pathSeparator + "ext/jts-core-1.15.0.jar",
File.pathSeparator + "ext/jts-core-1.15.0.jar" +
File.pathSeparator + "ext/asm-6.1.jar" +
File.pathSeparator + "ext/junit-4.12.jar",
"-subpackages", "org.h2");
mkdir("docs/javadocImpl3");
......@@ -684,7 +686,9 @@ public class Build extends BuildBase {
File.pathSeparator + "ext/lucene-queryparser-5.5.5.jar" +
File.pathSeparator + "ext/org.osgi.core-4.2.0.jar" +
File.pathSeparator + "ext/org.osgi.enterprise-4.2.0.jar" +
File.pathSeparator + "ext/jts-core-1.15.0.jar",
File.pathSeparator + "ext/jts-core-1.15.0.jar" +
File.pathSeparator + "ext/asm-6.1.jar" +
File.pathSeparator + "ext/junit-4.12.jar",
"-subpackages", "org.h2.mvstore",
"-exclude", "org.h2.mvstore.db");
......@@ -701,7 +705,9 @@ public class Build extends BuildBase {
File.pathSeparator + "ext/lucene-queryparser-5.5.5.jar" +
File.pathSeparator + "ext/org.osgi.core-4.2.0.jar" +
File.pathSeparator + "ext/org.osgi.enterprise-4.2.0.jar" +
File.pathSeparator + "ext/jts-core-1.15.0.jar",
File.pathSeparator + "ext/jts-core-1.15.0.jar" +
File.pathSeparator + "ext/asm-6.1.jar" +
File.pathSeparator + "ext/junit-4.12.jar",
"-subpackages", "org.h2",
"-package",
"-docletpath", "bin" + File.pathSeparator + "temp",
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论