![JAR search and dependency download from the Maven repository](/logo.png)
nl.basjes.parse.useragent.analyze.treewalker.steps.compare.StepIsNotInSet Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of yauaa Show documentation
Show all versions of yauaa Show documentation
A parsing an analyzing library to get information from a useragent string.
/*
* Yet Another UserAgent Analyzer
* Copyright (C) 2013-2024 Niels Basjes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.basjes.parse.useragent.analyze.treewalker.steps.compare;
import nl.basjes.parse.useragent.analyze.treewalker.steps.Step;
import nl.basjes.parse.useragent.analyze.treewalker.steps.WalkList.WalkResult;
import org.antlr.v4.runtime.tree.ParseTree;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.Locale;
import java.util.Set;
public class StepIsNotInSet extends Step {
private final String listName;
private final Set list;
@SuppressWarnings("unused") // Private constructor for serialization systems ONLY (like Kryo)
private StepIsNotInSet() {
listName = "<< Should not be seen anywhere >>";
list = Collections.emptySet();
}
public StepIsNotInSet(String listName, Set list) {
this.listName = listName;
this.list = list;
}
@Override
public WalkResult walk(@Nonnull ParseTree tree, @Nullable String value) {
String actualValue = getActualValue(tree, value);
if (!list.contains(actualValue.toLowerCase(Locale.ROOT))) {
return walkNextStep(tree, actualValue);
}
return null;
}
@Override
public String toString() {
return "IsNotInSet(@" + listName + ")";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy