Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Just moving some duplicate methods into a utils package.
- Loading branch information
Showing
5 changed files
with
68 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../java/org/fcrepo/modeshape/Constants.java → ...org/fcrepo/modeshape/utils/Constants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package org.fcrepo.modeshape.utils; | ||
|
||
import javax.jcr.observation.Event; | ||
|
||
public enum EventType { | ||
NODE_ADDED, NODE_REMOVED, PROPERTY_ADDED, PROPERTY_REMOVED, PROPERTY_CHANGED, NODE_MOVED, PERSIST; | ||
|
||
public static EventType getEventType(Integer i) { | ||
switch (i) { | ||
case 0x1: | ||
return NODE_ADDED; | ||
case 0x2: | ||
return NODE_REMOVED; | ||
case 0x4: | ||
return PROPERTY_ADDED; | ||
case 0x8: | ||
return PROPERTY_REMOVED; | ||
case 0x10: | ||
return PROPERTY_CHANGED; | ||
case 0x20: | ||
return NODE_MOVED; | ||
case 0x40: | ||
return PERSIST; | ||
|
||
default: // no default | ||
throw new IllegalArgumentException("Invalid JCR event type: " + i); | ||
} | ||
} | ||
|
||
public static String getEventName(int jcrEvent) { | ||
|
||
switch (getEventType(jcrEvent)) { | ||
case NODE_ADDED: | ||
return "node added"; | ||
case NODE_REMOVED: | ||
return "node removed"; | ||
case PROPERTY_ADDED: | ||
return "property added"; | ||
case PROPERTY_CHANGED: | ||
return "property changed"; | ||
case PROPERTY_REMOVED: | ||
return "property removed"; | ||
case NODE_MOVED: | ||
return "node moved"; | ||
case PERSIST: | ||
return "persist"; | ||
|
||
default: // no default | ||
throw new IllegalArgumentException("Invalid JCR event type: " | ||
+ jcrEvent); | ||
} | ||
} | ||
} |