I added methods to check for valid version and optimization levels that

Rhino embeddings can use to check the validity of data.
This commit is contained in:
igor%mir2.org 2004-09-28 21:52:19 +00:00
Родитель 4798ba8ae0
Коммит ceb8cb57de
1 изменённых файлов: 21 добавлений и 6 удалений

Просмотреть файл

@ -771,7 +771,7 @@ public class Context
this.version = version;
}
static void checkLanguageVersion(int version)
public static boolean isValidLanguageVersion(int version)
{
switch (version) {
case VERSION_DEFAULT:
@ -782,6 +782,14 @@ public class Context
case VERSION_1_4:
case VERSION_1_5:
case VERSION_1_6:
return true;
}
return false;
}
public static void checkLanguageVersion(int version)
{
if (isValidLanguageVersion(version)) {
return;
}
throw new IllegalArgumentException("Bad language version: "+version);
@ -1841,9 +1849,16 @@ public class Context
this.optimizationLevel = optimizationLevel;
}
static void checkOptimizationLevel(int optimizationLevel)
public static boolean isValidOptimizationLevel(int optimizationLevel)
{
if (!(-1 <= optimizationLevel && optimizationLevel <= 9))
return -1 <= optimizationLevel && optimizationLevel <= 9;
}
public static void checkOptimizationLevel(int optimizationLevel)
{
if (isValidOptimizationLevel(optimizationLevel)) {
return;
}
throw new IllegalArgumentException(
"Optimization level outside [-1..9]: "+optimizationLevel);
}