View Javadoc

1   /**
2      This file is part of GoldenGate Project (named also GoldenGate or GG).
3   
4      Copyright 2009, Frederic Bregier, and individual contributors by the @author
5      tags. See the COPYRIGHT.txt in the distribution for a full listing of
6      individual contributors.
7   
8      All GoldenGate Project is free software: you can redistribute it and/or 
9      modify it under the terms of the GNU General Public License as published 
10     by the Free Software Foundation, either version 3 of the License, or
11     (at your option) any later version.
12  
13     GoldenGate is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU General Public License for more details.
17  
18     You should have received a copy of the GNU General Public License
19     along with GoldenGate .  If not, see <http://www.gnu.org/licenses/>.
20   */
21  package goldengate.common.role;
22  
23  /**
24   * Role to be used in GoldenGate projects
25   * 
26   * FIXME not functional for the moment: early stage development
27   * 
28   * @author Frederic Bregier
29   *
30   */
31  public class RoleDefault {
32      public static byte NOACCESS = ((byte) 0);
33      public static byte READONLY = ((byte) 1); 
34      public static byte TRANSFER = ((byte) 2);
35      public static byte RULE = ((byte) 4); 
36      public static byte HOST = ((byte) 8);
37      public static byte LIMIT = ((byte) 16); 
38      public static byte SYSTEM = ((byte) 32);
39      public static byte UNUSED1 = ((byte) 64);
40      public static byte UNUSED2 = ((byte) -128);
41      
42      private byte role;
43      
44      public RoleDefault() {
45          this.role = NOACCESS;
46      }
47      
48      public void addRole(byte newrole) {
49          this.role |= newrole;
50      }
51      
52      public void setRole(byte newrole) {
53          this.role = newrole;
54      }
55      
56      public void clear() {
57          this.role = NOACCESS;
58      }
59      
60      public byte getRole() {
61          return this.role;
62      }
63      public boolean hasReadOnly() {
64          return (role&READONLY)!=0;
65      }
66      public boolean hasTransfer() {
67          return (role&TRANSFER)!=0;
68      }
69      public boolean hasRule() {
70          return (role&RULE)!=0;
71      }
72      public boolean hasHost() {
73          return (role&HOST)!=0;
74      }
75      public boolean hasLimit() {
76          return (role&LIMIT)!=0;
77      }
78      public boolean hasSystem() {
79          return (role&SYSTEM)!=0;
80      }
81      public boolean hasUnused1() {
82          return (role&UNUSED1)!=0;
83      }
84      public boolean hasUnused2() {
85          return (role&UNUSED2)!=0;
86      }
87      
88      
89      public static boolean HasReadOnly(byte role) {
90          return (role&READONLY)!=0;
91      }
92      public static boolean HasTransfer(byte role) {
93          return (role&TRANSFER)!=0;
94      }
95      public static boolean HasRule(byte role) {
96          return (role&RULE)!=0;
97      }
98      public static boolean HasHost(byte role) {
99          return (role&HOST)!=0;
100     }
101     public static boolean HasLimit(byte role) {
102         return (role&LIMIT)!=0;
103     }
104     public static boolean HasSystem(byte role) {
105         return (role&SYSTEM)!=0;
106     }
107     public static boolean HasUnused1(byte role) {
108         return (role&UNUSED1)!=0;
109     }
110     public static boolean HasUnused2(byte role) {
111         return (role&UNUSED2)!=0;
112     }
113     
114 }