CommentingEvent.java
2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.osgi.service.event.Event
*/
package com.adobe.granite.comments;
import java.util.Dictionary;
import java.util.Hashtable;
import org.osgi.service.event.Event;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public final class CommentingEvent {
public static final String EVENT_TOPIC_BASE = "com/adobe/granite/comments";
private static final String PROPERTY_COMMENT_PATH = "commentPath";
private final String eventTopic;
private final String commentPath;
private CommentingEvent(Event event) {
this.eventTopic = event.getTopic();
this.commentPath = event.getProperty("commentPath") instanceof String ? (String)event.getProperty("commentPath") : null;
}
public CommentingEvent(Type eventTopic, String commentPath) {
this.eventTopic = "com/adobe/granite/comments/" + eventTopic.name().toLowerCase();
this.commentPath = commentPath;
}
public static CommentingEvent fromEvent(Event event) {
String eventType;
String topic = event.getTopic();
if (topic.substring(0, "com/adobe/granite/comments".length()).equalsIgnoreCase("com/adobe/granite/comments") && Type.valueOf((eventType = topic.substring("com/adobe/granite/comments".length() + 1)).toUpperCase()) == Type.COMMENTED) {
return new CommentingEvent(event);
}
return null;
}
public String getCommentPath() {
return this.commentPath;
}
public String getEventTopic() {
return this.eventTopic.toLowerCase();
}
public static CommentingEvent commented(String commentPath) {
return new CommentingEvent(Type.COMMENTED, commentPath);
}
public Event toEvent() {
return new Event(this.eventTopic, this.getEventProperties());
}
private Dictionary<String, Object> getEventProperties() {
Hashtable<String, Object> properties = new Hashtable<String, Object>();
if (this.commentPath != null) {
properties.put("commentPath", this.commentPath);
}
return properties;
}
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public static enum Type {
COMMENTED;
private Type() {
}
}
}