1 /*
2 * Copyright 2008 :torweg free software group
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 */18 package org.torweg.pulse.component.core.accesscontrol.attributes.admin;
19 20 import java.util.Set;
21 22 import org.jdom.Element;
23 importorg.torweg.pulse.accesscontrol.attributes.AbstractAttribute;
24 importorg.torweg.pulse.accesscontrol.attributes.AbstractTypedCheck;
25 importorg.torweg.pulse.util.adminui.RegistryEditorResult;
26 27 /**
28 * the result of the {@code AttributeRegistryEditor}.
29 *
30 * @author Daniel Dietz
31 * @version $Revision: 1809 $
32 */33 publicclass AttributeRegistryEditorResult extendsRegistryEditorResult {
34 35 /**
36 * the attribute of the result.
37 */38 privateAbstractAttribute<?> attribute;
39 40 /**
41 * the availableChecks of the result.
42 */43 private Set<Class<AbstractTypedCheck<?>>> availableChecks;
44 45 /**
46 * the check of the result.
47 */48 privateAbstractTypedCheck<?> check;
49 50 /**
51 * @return the result of the {@code AttributeRegistryEditor}
52 *
53 * @see org.torweg.pulse.bundle.JDOMable#deserializeToJDOM()
54 */55 @Override
56 public Element deserializeToJDOM() {
57 Element result = super.deserializeToJDOM().setAttribute("class",
58 getClass().getCanonicalName());
59 60 if (this.attribute != null) {
61 result.addContent(this.attribute.deserializeToJDOM());
62 }
63 64 if (this.check != null) {
65 result.addContent(this.check.deserializeToJDOM());
66 }
67 68 if (this.availableChecks != null) {
69 Element availableChecksEl = new Element("available-checks");
70 for (Class<AbstractTypedCheck<?>> c : this.availableChecks) {
71 availableChecksEl.addContent(new Element("check").setAttribute(
72 "class", c.getCanonicalName()));
73 }
74 result.addContent(availableChecksEl);
75 }
76 77 return result;
78 }
79 80 /**
81 * sets the attribute for the result.
82 *
83 * @param attr
84 * the attribute to set
85 */86 publicvoid setAttribute(finalAbstractAttribute<?> attr) {
87 this.attribute = attr;
88 }
89 90 /**
91 * sets the available checks for the current attribute.
92 *
93 * @param typedChecks
94 * the checks to set
95 */96 publicvoid setAvailableChecks(final Set<Class<AbstractTypedCheck<?>>> typedChecks) {
97 this.availableChecks = typedChecks;
98 }
99 100 /**
101 * set a attribute-check for the result.
102 *
103 * @param chk
104 * the check to set
105 */106 publicvoid setAttributeCheck(finalAbstractTypedCheck<?> chk) {
107 this.check = chk;
108 }
109 }
110