Adding multiple schemas to schemainclusionrule schema crawler
-
01-07-2021 - |
Domanda
I have to add selected schemas to be crawled using schemacrawler. How can we add multiple schemas into inclusion rule of schemacrawler?
like :
final SchemaCrawlerOptions options = new SchemaCrawlerOptions();
options.setSchemaInclusionRule(new InclusionRule("schema1,schema2", InclusionRule.NONE));
Soluzione
InclusionRule accepts regexp pattern. You can pass java.util.regex.Pattern instance or String, in latter case it will be compiled for you. If I am not mistaken, you can use |
sign to make pattern match multiple options. E.g., "schema1|schema2"
.
You can test your patterns with a simple program; e.g.
import java.util.regex.Pattern;
public class PatternTest {
public static void main(String[] args) {
Pattern p = Pattern.compile("schema1|schema2");
System.out.println(p.matcher("schema0").matches());
System.out.println(p.matcher("schema1").matches());
System.out.println(p.matcher("schema2").matches());
System.out.println(p.matcher("schema3").matches());
}
}
.. which prints:
false
true
true
false
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow