本文整理汇总了Java中org.hsqldb.lib.ArrayUtil.find方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayUtil.find方法的具体用法?Java ArrayUtil.find怎么用?Java ArrayUtil.find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hsqldb.lib.ArrayUtil
的用法示例。
在下文中一共展示了ArrayUtil.find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hasColumn
import org.hsqldb.lib.ArrayUtil; //导入方法依赖的package包/类
boolean hasColumn(int colIndex) {
switch (constType) {
case SchemaObject.ConstraintTypes.CHECK :
return rangeVariable.usedColumns[colIndex];
case SchemaObject.ConstraintTypes.PRIMARY_KEY :
case SchemaObject.ConstraintTypes.UNIQUE :
case SchemaObject.ConstraintTypes.MAIN :
return ArrayUtil.find(core.mainCols, colIndex) != -1;
case SchemaObject.ConstraintTypes.FOREIGN_KEY :
return ArrayUtil.find(core.refCols, colIndex) != -1;
default :
throw Error.runtimeError(ErrorCode.U_S0500, "Constraint");
}
}
示例2: getStatement
import org.hsqldb.lib.ArrayUtil; //导入方法依赖的package包/类
String getStatement(int startPosition, short[] startTokens) {
while (true) {
if (token.tokenType == Tokens.SEMICOLON) {
break;
} else if (token.tokenType == Tokens.X_ENDPARSE) {
break;
} else {
if (ArrayUtil.find(startTokens, token.tokenType) != -1) {
break;
}
}
read();
}
String sql = scanner.getPart(startPosition,
scanner.getTokenPosition());
return sql;
}
示例3: getIntegerProperty
import org.hsqldb.lib.ArrayUtil; //导入方法依赖的package包/类
/**
* Choice limited to values list, defaultValue must be in the values list.
*/
public int getIntegerProperty(String key, int defaultValue, int[] values) {
String prop = getProperty(key);
int value = defaultValue;
try {
if (prop != null) {
value = Integer.parseInt(prop);
}
} catch (NumberFormatException e) {}
if (ArrayUtil.find(values, value) == -1) {
return defaultValue;
}
return value;
}
示例4: getStatement
import org.hsqldb.lib.ArrayUtil; //导入方法依赖的package包/类
String getStatement(int startPosition, short[] startTokens) {
int semiPosition = 0;
while (true) {
if (token.tokenType == Tokens.SEMICOLON) {
semiPosition = scanner.getPosition();
} else if (token.tokenType == Tokens.X_ENDPARSE) {
if (semiPosition == 0) {
break;
} else {
rewind(semiPosition);
break;
}
} else {
semiPosition = 0;
if (ArrayUtil.find(startTokens, token.tokenType) != -1) {
break;
}
}
read();
}
String sql = scanner.getPart(startPosition, scanner.getPosition());
return sql;
}
示例5: validateProperty
import org.hsqldb.lib.ArrayUtil; //导入方法依赖的package包/类
public boolean validateProperty(String name, int number) {
Object[] meta = (Object[]) metaData.get(name);
if (meta == null) {
return false;
}
if (meta[indexClass].equals("Integer")) {
if (Boolean.TRUE.equals(meta[indexIsRange])) {
int low = ((Integer) meta[indexRangeLow]).intValue();
int high = ((Integer) meta[indexRangeHigh]).intValue();
if (number < low || high < number) {
return false;
}
}
if (meta[indexValues] != null) {
int[] values = (int[]) meta[indexValues];
if (ArrayUtil.find(values, number) == -1) {
return false;
}
}
return true;
}
return false;
}
示例6: getUniqueConstraintForColumns
import org.hsqldb.lib.ArrayUtil; //导入方法依赖的package包/类
/**
* Returns the UNIQUE or PK constraint with the given column signature.
* Modifies the composition of refTableCols if necessary.
*/
Constraint getUniqueConstraintForColumns(int[] mainTableCols, int[] refTableCols) {
for (int i = 0, size = constraintList.length; i < size; i++) {
Constraint c = constraintList[i];
int type = c.getConstraintType();
if (type != Constraint.UNIQUE && type != Constraint.PRIMARY_KEY) {
continue;
}
int[] constraintCols = c.getMainColumns();
if (constraintCols.length != mainTableCols.length) {
continue;
}
if (ArrayUtil.areEqual(constraintCols, mainTableCols, mainTableCols.length, true)) {
return c;
}
if (ArrayUtil.areEqualSets(constraintCols, mainTableCols)) {
int[] newRefTableCols = new int[mainTableCols.length];
for (int j = 0; j < mainTableCols.length; j++) {
int pos = ArrayUtil.find(constraintCols, mainTableCols[j]);
newRefTableCols[pos] = refTableCols[j];
}
for (int j = 0; j < mainTableCols.length; j++) {
refTableCols[j] = newRefTableCols[j];
}
return c;
}
}
return null;
}
示例7: position
import org.hsqldb.lib.ArrayUtil; //导入方法依赖的package包/类
public long position(SessionInterface session, byte[] pattern,
long start) {
if (pattern.length > data.length) {
return -1;
}
if (start >= data.length) {
return -1;
}
return ArrayUtil.find(data, (int) start, data.length, pattern);
}
示例8: getDBIndex
import org.hsqldb.lib.ArrayUtil; //导入方法依赖的package包/类
/**
* return database ID
*/
synchronized final int getDBIndex(String aliasPath) {
int semipos = aliasPath.indexOf(';');
String alias = aliasPath;
String filepath = null;
if (semipos != -1) {
alias = aliasPath.substring(0, semipos);
filepath = aliasPath.substring(semipos + 1);
}
int dbIndex = ArrayUtil.find(dbAlias, alias);
if (dbIndex == -1) {
if (filepath == null) {
HsqlException e = Error.error(ErrorCode.GENERAL_ERROR,
"database alias does not exist");
printError("database alias=" + alias + " does not exist");
setServerError(e);
throw e;
} else {
return openDatabase(alias, filepath);
}
} else {
return dbIndex;
}
}
示例9: getContainingIndexNames
import org.hsqldb.lib.ArrayUtil; //导入方法依赖的package包/类
OrderedHashSet getContainingIndexNames(int colIndex) {
OrderedHashSet set = new OrderedHashSet();
for (int i = 0, size = indexList.length; i < size; i++) {
Index index = indexList[i];
if (ArrayUtil.find(index.getColumns(), colIndex) != -1) {
set.add(index.getName());
}
}
return set;
}
示例10: hasColumnPlus
import org.hsqldb.lib.ArrayUtil; //导入方法依赖的package包/类
boolean hasColumnPlus(int colIndex) {
switch (constType) {
case CHECK :
return rangeVariable.usedColumns[colIndex] && ArrayUtil
.countTrueElements(rangeVariable.usedColumns) > 1;
case PRIMARY_KEY :
case UNIQUE :
return core.mainCols.length != 1
&& ArrayUtil.find(core.mainCols, colIndex) != -1;
case MAIN :
return ArrayUtil.find(core.mainCols, colIndex) != -1
&& (core.mainCols.length != 1
|| core.mainTable != core.refTable);
case FOREIGN_KEY :
return ArrayUtil.find(core.refCols, colIndex) != -1
&& (core.mainCols.length != 1
|| core.mainTable == core.refTable);
default :
throw Error.runtimeError(ErrorCode.U_S0500, "Constraint");
}
}
示例11: getDBID
import org.hsqldb.lib.ArrayUtil; //导入方法依赖的package包/类
/**
* return database ID
*/
synchronized final int getDBID(String aliasPath) throws HsqlException {
int semipos = aliasPath.indexOf(';');
String alias = aliasPath;
String filepath = null;
if (semipos != -1) {
alias = aliasPath.substring(0, semipos);
filepath = aliasPath.substring(semipos + 1);
}
int dbIndex = ArrayUtil.find(dbAlias, alias);
if (dbIndex == -1) {
if (filepath == null) {
RuntimeException e =
new RuntimeException("database alias does not exist");
printError("database alias=" + alias + " does not exist");
setServerError(e);
throw e;
} else {
return openDatabase(alias, filepath);
}
} else {
return dbID[dbIndex];
}
}
示例12: validateProperty
import org.hsqldb.lib.ArrayUtil; //导入方法依赖的package包/类
/**
* Performs any range checking for property and return an error message
*/
public static String validateProperty(String key, String value,
Object[] meta) {
if (meta[indexClass].equals("Boolean")) {
value = value.toLowerCase();
if (value.equals("true") || value.equals("false")) {
return null;
}
return "invalid boolean value for property: " + key;
}
if (meta[indexClass].equals("String")) {
return null;
}
if (meta[indexClass].equals("Long")) {
return null;
}
if (meta[indexClass].equals("Integer")) {
try {
int number = Integer.parseInt(value);
if (Boolean.TRUE.equals(meta[indexIsRange])) {
int low = ((Integer) meta[indexRangeLow]).intValue();
int high = ((Integer) meta[indexRangeHigh]).intValue();
if (number < low || high < number) {
return "value outside range for property: " + key;
}
}
if (meta[indexValues] != null) {
int[] values = (int[]) meta[indexValues];
if (ArrayUtil.find(values, number) == -1) {
return "value not supported for property: " + key;
}
}
} catch (NumberFormatException e) {
return "invalid integer value for property: " + key;
}
return null;
}
return null;
}
示例13: readIntervalType
import org.hsqldb.lib.ArrayUtil; //导入方法依赖的package包/类
IntervalType readIntervalType() {
int precision = -1;
int scale = -1;
int startToken;
int endToken;
startToken = endToken = token.tokenType;
read();
if (token.tokenType == Tokens.OPENBRACKET) {
read();
precision = readInteger();
if (precision <= 0) {
throw Error.error(ErrorCode.X_42592);
}
if (token.tokenType == Tokens.COMMA) {
if (startToken != Tokens.SECOND) {
throw unexpectedToken();
}
read();
scale = readInteger();
if (scale < 0) {
throw Error.error(ErrorCode.X_42592);
}
}
readThis(Tokens.CLOSEBRACKET);
}
if (token.tokenType == Tokens.TO) {
read();
endToken = token.tokenType;
read();
}
if (token.tokenType == Tokens.OPENBRACKET) {
if (endToken != Tokens.SECOND || endToken == startToken) {
throw unexpectedToken();
}
read();
scale = readInteger();
if (scale < 0) {
throw Error.error(ErrorCode.X_42592);
}
readThis(Tokens.CLOSEBRACKET);
}
int startIndex = ArrayUtil.find(Tokens.SQL_INTERVAL_FIELD_CODES,
startToken);
int endIndex = ArrayUtil.find(Tokens.SQL_INTERVAL_FIELD_CODES,
endToken);
return IntervalType.getIntervalType(startIndex, endIndex, precision,
scale);
}
示例14: enforceRowConstraints
import org.hsqldb.lib.ArrayUtil; //导入方法依赖的package包/类
/**
* Enforce max field sizes according to SQL column definition.
* SQL92 13.8
*/
public void enforceRowConstraints(Session session, Object[] data) {
for (int i = 0; i < columnCount; i++) {
Type type = colTypes[i];
ColumnSchema column;
if (hasDomainColumns && type.isDomainType()) {
Constraint[] constraints =
type.userTypeModifier.getConstraints();
column = getColumn(i);
for (int j = 0; j < constraints.length; j++) {
constraints[j].checkCheckConstraint(session, this, column,
data[i]);
}
}
if (colNotNull[i] && data[i] == null) {
String constraintName;
Constraint c = getNotNullConstraintForColumn(i);
if (c == null) {
if (ArrayUtil.find(getPrimaryKey(), i) > -1) {
c = getPrimaryConstraint();
}
}
constraintName = c == null ? ""
: c.getName().name;
column = getColumn(i);
String[] info = new String[] {
constraintName, tableName.statementName,
column.getName().statementName
};
throw Error.error(null, ErrorCode.X_23502,
ErrorCode.COLUMN_CONSTRAINT, info);
}
}
}
示例15: readIntervalType
import org.hsqldb.lib.ArrayUtil; //导入方法依赖的package包/类
IntervalType readIntervalType(boolean maxPrecisionDefault) {
int precision = -1;
int scale = -1;
int startToken;
int endToken;
startToken = endToken = token.tokenType;
read();
if (token.tokenType == Tokens.OPENBRACKET) {
read();
precision = readInteger();
if (precision <= 0) {
throw Error.error(ErrorCode.X_42592);
}
if (token.tokenType == Tokens.COMMA) {
if (startToken != Tokens.SECOND) {
throw unexpectedToken();
}
read();
scale = readInteger();
if (scale < 0) {
throw Error.error(ErrorCode.X_42592);
}
}
readThis(Tokens.CLOSEBRACKET);
}
if (token.tokenType == Tokens.TO) {
read();
endToken = token.tokenType;
read();
}
if (token.tokenType == Tokens.OPENBRACKET) {
if (endToken != Tokens.SECOND || endToken == startToken) {
throw unexpectedToken();
}
read();
scale = readInteger();
if (scale < 0) {
throw Error.error(ErrorCode.X_42592);
}
readThis(Tokens.CLOSEBRACKET);
}
int startIndex = ArrayUtil.find(Tokens.SQL_INTERVAL_FIELD_CODES,
startToken);
int endIndex = ArrayUtil.find(Tokens.SQL_INTERVAL_FIELD_CODES,
endToken);
if (precision == -1 && maxPrecisionDefault) {
if (startIndex == IntervalType.INTERVAL_SECOND_INDEX) {
precision = IntervalType.maxIntervalSecondPrecision;
} else {
precision = IntervalType.maxIntervalPrecision;
}
}
return IntervalType.getIntervalType(startIndex, endIndex, precision,
scale);
}