1 20 21 package org.apache.directory.ldapstudio.schemas.model; 22 23 24 33 public class LDAPModelEvent 34 { 35 36 42 public enum Reason 43 { 44 SchemaAdded, SchemaRemoved, SchemaSaved, OCAdded, OCModified, OCRemoved, ATAdded, ATModified, ATRemoved, PoolReloaded 45 } 46 47 48 private Reason reason; 49 50 51 private Object oldValue; 52 53 54 private Object newValue; 55 56 57 63 public LDAPModelEvent( Reason reason ) 64 { 65 this.reason = reason; 66 } 67 68 69 81 public LDAPModelEvent( Reason reason, ObjectClass oldObjectClass, ObjectClass newObjectClass ) throws Exception 82 { 83 this( reason ); 84 if ( ( reason == Reason.OCAdded ) || ( reason == Reason.OCModified ) || ( reason == Reason.OCRemoved ) ) 85 { 86 newValue = newObjectClass; 87 oldValue = oldObjectClass; 88 } 89 else 90 { 91 throw new Exception ( "Event creation exception " + reason + " " + newObjectClass ); } 93 } 94 95 96 108 public LDAPModelEvent( Reason reason, AttributeType oldAttributeType, AttributeType newAttributeType ) 109 throws Exception 110 { 111 this( reason ); 112 if ( ( reason == Reason.ATAdded ) || ( reason == Reason.ATModified ) || ( reason == Reason.ATRemoved ) ) 113 { 114 newValue = newAttributeType; 115 oldValue = oldAttributeType; 116 } 117 else 118 { 119 throw new Exception ( "Event creation exception " + reason + " " + oldAttributeType ); } 121 } 122 123 124 134 public LDAPModelEvent( Reason reason, Schema schema ) throws Exception 135 { 136 this( reason ); 137 138 if ( reason == Reason.SchemaAdded ) 139 { 140 oldValue = null; 141 newValue = schema; 142 } 143 else if ( reason == Reason.SchemaRemoved ) 144 { 145 oldValue = schema; 146 newValue = null; 147 } 148 else 149 { 150 throw new Exception ( "Event creation exception " + reason + " " + schema ); } 152 } 153 154 155 161 public Reason getReason() 162 { 163 return reason; 164 } 165 166 167 173 public Object getNewValue() 174 { 175 return newValue; 176 } 177 178 179 185 public Object getOldValue() 186 { 187 return oldValue; 188 } 189 } 190 | Popular Tags |