1 5 package com.opensymphony.workflow.loader; 6 7 import org.w3c.dom.Element ; 8 9 import java.io.PrintWriter ; 10 11 12 16 public class PermissionDescriptor extends AbstractDescriptor { 17 19 protected RestrictionDescriptor restriction; 20 protected String name; 21 22 24 public PermissionDescriptor() { 25 } 26 27 public PermissionDescriptor(Element permission) { 28 init(permission); 29 } 30 31 33 public void setName(String name) { 34 this.name = name; 35 } 36 37 public String getName() { 38 return name; 39 } 40 41 public void setRestriction(RestrictionDescriptor restriction) { 42 this.restriction = restriction; 43 } 44 45 public RestrictionDescriptor getRestriction() { 46 return restriction; 47 } 48 49 public void writeXML(PrintWriter out, int indent) { 50 XMLUtil.printIndent(out, indent++); 51 out.print("<permission "); 52 53 if (hasId()) { 54 out.print("id=\"" + getId() + "\" "); 55 } 56 57 out.println("name=\"" + name + "\">"); 58 restriction.writeXML(out, indent); 59 XMLUtil.printIndent(out, --indent); 60 out.println("</permission>"); 61 } 62 63 protected void init(Element permission) { 64 name = permission.getAttribute("name"); 65 66 try { 67 setId(Integer.parseInt(permission.getAttribute("id"))); 68 } catch (NumberFormatException e) { 69 } 70 71 restriction = new RestrictionDescriptor(XMLUtil.getChildElement(permission, "restrict-to")); 72 } 73 } 74 | Popular Tags |