public void add(Field.Name fieldName) { int mask = MASK_READONLY; // for NEW states, normally all Fields on the Item are editable if (status == NEW) { mask = MASK_MANDATORY; } fields.put(fieldName, mask); }
public State(Element e) { this.status = Integer.parseInt(e.attributeValue(STATUS)); for (Object o : e.elements(TRANSITION)) { Element t = (Element) o; transitions.add(new Integer(t.attributeValue(STATUS))); } for (Object o : e.elements(FIELD)) { Element f = (Element) o; String fieldName = f.attributeValue(NAME); fields.put(Field.convertToName(fieldName), new Integer(f.attributeValue(MASK))); } }
/* copy object values into an existing XML Element */ private void copyTo(Element e) { // appending empty strings to create new objects for "clone" support e.addAttribute(STATUS, status + ""); for (Integer toStatus : transitions) { Element t = e.addElement(TRANSITION); t.addAttribute(STATUS, toStatus + ""); } for (Map.Entry<Field.Name, Integer> entry : fields.entrySet()) { Element f = e.addElement(FIELD); f.addAttribute(NAME, entry.getKey() + ""); f.addAttribute(MASK, entry.getValue() + ""); } }
public void remove(Field.Name fieldName) { fields.remove(fieldName); }