Project

General

Profile

« Previous | Next » 

Revision 1402

Added by Jing Tao almost 22 years ago

Add copy object method.

View differences:

src/edu/ucsb/nceas/metacat/AccessRule.java
36 36
 */
37 37
public class AccessRule
38 38
{
39
  private Vector principle = new Vector();
40
  private int permission = -1;
39
  private String permissionType = null;
40
  private Vector principal = new Vector();
41
  private int permission = 0;
42
  
43
  /** Set the permssionType */
44
  public void setPermissionType(String type)
45
  {
46
    permissionType = type;
47
  }
48
  
49
  public String getPermissionType()
50
  {
51
     return permissionType;
52
  }
53
    
54
  /** Set the a principle */
55
  public void addPrincipal(String newPrincipal) 
56
  {
57
    this.principal.addElement(newPrincipal);
58
  }
41 59

  
42
    /** Set the a principle */
43
    public void addPrinciple(String newPrinciple) 
44
    {
45
      this.principle.addElement(newPrinciple);
46
    }
60
  /** Get the principle vector */
61
  public Vector getPrincipal() 
62
  {
63
    return principal;
64
  }
47 65

  
48
    /** Get the principle vector */
49
    public Vector getPrinciple() 
50
    {
51
      return principle;
52
    }
53

  
54
    /** 
55
     * Set a permission. 
56
     */
57
    public void setPermission(int myPermission) 
58
    {
59
      permission = myPermission;
60
    }
66
  /** 
67
   * Set a permission. 
68
   */
69
  public void setPermission(int myPermission) 
70
  {
71
    permission = myPermission;
72
  }
61 73
    
62
    /**
63
     * Get permission
64
     */
65
    public int getPermission()
74
  /**
75
   * Get permission
76
   */
77
  public int getPermission()
78
  {
79
    return permission;
80
  }
81
  
82
  /**
83
   * Copy a AccessRule to another accessrule object
84
   */
85
  public AccessRule copyAccessRule(AccessRule rule)
86
  {
87
    // create a new object
88
    AccessRule newRule = new AccessRule();
89
    // set permissiontype
90
    newRule.setPermissionType(rule.getPermissionType());
91
    // set permission
92
    newRule.setPermission(rule.getPermission());
93
    // walk through all the principals
94
    Vector principalVector = rule.getPrincipal();
95
    for (int i=0; i<principalVector.size(); i++)
66 96
    {
67
      return permission;
97
      String name = (String)principalVector.elementAt(i);
98
      // Add this name to newrules
99
      newRule.addPrincipal(name);
68 100
    }
69
}
101
    return newRule;
102
  }
103
  
104
  public Object clone()
105
  {
106
    return this.clone();
107
  }
108
}//AccessRule

Also available in: Unified diff