/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package API; import java.util.Map; /** * * @author Eugenio * @param */ public class Instruction extends RegistroBase { public Instruction(String type, String inst) { S("type", type).S("inst", inst); } public Instruction(String inst) { S("inst", inst); } public Instruction() { } @Override public Instruction set(String attrib, int valor) { super.set(attrib, valor); //To change body of generated methods, choose Tools | Templates. return this; } @Override public Instruction set(String attrib, Long valor) { super.set(attrib, valor); //To change body of generated methods, choose Tools | Templates. return this; } @Override public String toString() { return "Instruction" + super.toString(); //To change body of generated methods, choose Tools | Templates. } /** * * @param attrib * @param value * @return */ @Override public Instruction S(String attrib, String value) { super.S(attrib, value); //To change body of generated methods, choose Tools | Templates. return this; } public Instruction S(String attrib, long value) { super.S(attrib, "" + value); //To change body of generated methods, choose Tools | Templates. return this; } @Override public Instruction R(String attributes) { super.R(attributes); //To change body of generated methods, choose Tools | Templates. return this; } public Instruction S(String attrib, int value) { super.set(attrib, value); //To change body of generated methods, choose Tools | Templates. return this; } public boolean igual(String atributo, Instruction r2) { return eq(atributo, r2.G(atributo)); } public boolean maior(String atributo, int i) throws Exception { if (!isNumber(atributo)) { return false; } return getInt(atributo) > i; } public boolean menor(String atributo, int i) throws Exception { if (!isNumber(atributo)) { return false; } return getInt(atributo) < i; } public int getInt(String indice, int val) { try { return getInt(indice); } catch (Exception e) { return val; } } public Instruction copy(String atrib, Instruction r) { if (r != null) { for (String a : atrib.split(",")) { this.S(a, r.G(a)); } } return this; } public Instruction Merge(String attrs, Instruction src) { if (src != null) { for (String a : attrs.split(",")) { if (!this.Has(a) && src.Has(a)) { this.S(a, src.G(a)); } } } return this; } public void Prepend(String attrib, String p) { if (Has(attrib)) { S(attrib, p + G(attrib)); } } public void Append(String attrib, String p) { if (Has(attrib)) { S(attrib, G(attrib) + p); } } public Instruction copy() { Instruction rb = new Instruction(); for (Map.Entry entry : attr.entrySet()) { rb.S(entry.getKey(), entry.getValue()); } return rb; } }