public class CidrMatchOperator extends Object
if (cidrmatch("10.10.1.32/27").on("10.10.1.44").check()) {
// "10.10.1.44" belongs to "10.10.1.32/27"
...
}
You can use 'into' to store the check result in some tuple.
cidrmatch("10.10.1.32/27").on("10.10.1.44").into([check]);
That will create a [check] field with value 'true'.
A cidrmatch operator can be created with a map of subnets instead of just one subnet. For example say you define a json resource file subnets.json containing:
{
"10.10.1.32/27" : "domain0",
"11.10.1.32/27" : "domain1"
}
cidrmatch(subnets).on("10.10.1.44").check()) will return true. Using into will give you back all
the matched values. I.e cidrmatch(subnets).on("10.10.1.44").into([matches])); produces
{ "matches" : ["domain0"] }
The cidrmatch operator is not efficient, if you have many entries and need to find matching subnets using an
interval search, use the FindByIntervalOperator operator instead.
| Constructor and Description |
|---|
CidrMatchOperator(Map<org.apache.commons.net.util.SubnetUtils,String> map)
Ctor.
|
CidrMatchOperator(org.apache.commons.net.util.SubnetUtils subnet)
Ctor.
|
CidrMatchOperator(Tuple tupleMap)
Ctor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
check()
Final action, return true or false if the given IP matches the subnet.
|
CidrMatchOperator |
firstMatch()
Make the operator only match the first element.
|
boolean |
into(Tuple tuple)
Fire the operator and put the result into the provided tuple
|
CidrMatchOperator |
on(String input)
Make the operator ready to act on the provided String.
|
CidrMatchOperator |
on(Tuple tuple)
Make the operator ready to act on the provided tuple.
|
List<String> |
run()
Fire the operator.
|
public CidrMatchOperator(Tuple tupleMap)
tupleMap - the provided resource tuple.public CidrMatchOperator(Map<org.apache.commons.net.util.SubnetUtils,String> map)
map - the provided resource map.public CidrMatchOperator(org.apache.commons.net.util.SubnetUtils subnet)
subnet - an apache subnet utils.public CidrMatchOperator on(Tuple tuple)
tuple - the input tuplepublic CidrMatchOperator on(String input)
input - the input stringpublic List<String> run()
public boolean into(Tuple tuple)
tuple - the output tuplepublic boolean check()
This can be used only for a cidrmatch operator working on a single subnet.
public CidrMatchOperator firstMatch()
Copyright © 2022. All rights reserved.