dpfmanager.conformancechecker.tiff.metadata_fixer.Fixes Maven / Gradle / Ivy
/**
* Fixes.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 dpfmanager.conformancechecker.tiff.metadata_fixer;
import javafx.scene.Node;
import javafx.scene.control.CheckBox;
import javafx.scene.layout.VBox;
import java.io.PrintWriter;
import java.util.ArrayList;
/**
* Created by easy on 09/10/2015.
*/
public class Fixes {
private ArrayList fixes;
/**
* Instantiates a new Fixes.
*/
public Fixes() {
fixes = new ArrayList();
}
/**
* Gets fixes.
*
* @return the fixes
*/
public ArrayList getFixes() {
return fixes;
}
public void set(ArrayList fixes) {
this.fixes = fixes;
}
public void ReadAutofixes(VBox autoFixesBox) {
for (Node node : autoFixesBox.getChildren()) {
CheckBox check = (CheckBox) node;
if (check.isSelected()) {
addFixFromTxt(check.getId() + ",Yes");
}
}
}
/**
* Write.
*
* @param pw the pw
*/
public void Write(PrintWriter pw) {
for (Fix fix : fixes) {
pw.println("FIX\t" + fix.Txt());
}
}
/**
* Add fix from txt.
*
* @param txt the txt
*/
public void addFixFromTxt(String txt) {
Fix fix = new Fix();
fix.ReadTxt(txt);
fixes.add(fix);
}
/**
* Add fix from parameters.
*
* @param tag the tag
* @param operator the operator
* @param value the value
*/
public void addFix(String tag, String operator, String value) {
Fix fix = new Fix();
fix.setTag(tag);
fix.setOperator(operator);
fix.setValue(value);
fixes.add(fix);
}
public boolean removeFix(String tag, String operator, String value){
Fix toDelete = null;
for (Fix fix : fixes){
if (fix.getTag().equals(tag) && (operator != null && fix.getOperator().equals(operator)) && fix.getValue().equals(value)){
toDelete = fix;
break;
}
}
if (toDelete != null){
fixes.remove(toDelete);
return true;
}
return false;
}
public void addAutofix(String autofix) {
addFix(autofix, null, "Yes");
}
public boolean removeAutofix(String autofix){
return removeFix(autofix, null, "Yes");
}
public ArrayList getAutofixes() {
// TODO
return new ArrayList<>();
}
}