All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.easyinnova.policy_checker.model.Rules Maven / Gradle / Ivy

The newest version!
/**
 * 

Rules.java

This program is free software: you can redistribute it * and/or modify it under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) any later version; or, * at your choice, under the terms of the Mozilla Public License, v. 2.0. SPDX GPL-3.0+ or MPL-2.0+. *

This program is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License and the Mozilla Public License for more details.

*

You should have received a copy of the GNU General Public License and the Mozilla Public * License along with this program. If not, see http://www.gnu.org/licenses/ * and at http://mozilla.org/MPL/2.0 .

NB: for the * © statement, include Easy Innova SL or other company/Person contributing the code.

© * 2015 Easy Innova, SL

* * @author Víctor Muñoz Sola * @version 1.0 * @since 23/7/2015 */ package com.easyinnova.policy_checker.model; import java.io.PrintWriter; import java.io.Serializable; import java.util.ArrayList; /** * Created by easy on 06/10/2015. */ public class Rules implements Serializable { private ArrayList rules; /** * Instantiates a new Rules. */ public Rules() { rules = new ArrayList(); } /** * Gets rules. * * @return the rules */ public ArrayList getRules() { return rules; } public void set(ArrayList rules) { this.rules = rules; } /** * Write. * * @param pw the pw */ public void Write(PrintWriter pw) { for (Rule rule : rules) { pw.println("RULE\t" + rule.Txt()); } } /** * Add rule from txt. * * @param txt the txt */ public void addRuleFromTxt(String txt) { Rule rule = new Rule(); rule.ReadTxt(txt); rules.add(rule); } /** * Add rule from parameters. * * @param tag the tag * @param operator the operator * @param value the value * @param warning the warning */ public void addRule(String tag, String operator, String value, boolean warning) { Rule rule = new Rule(); rule.setTag(tag); rule.setOperator(operator); rule.setValue(value); rule.setWarning(warning); rules.add(rule); } public boolean removeRule(String tag, String operator, String value, boolean warning){ Rule toDelete = null; for (Rule rule : rules){ if (rule.getTag().equals(tag) && rule.getOperator().equals(operator) && rule.getValue().equals(value) && rule.getWarning() == warning){ toDelete = rule; break; } } if (toDelete != null){ rules.remove(toDelete); return true; } return false; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy