@@ -24,13 +24,14 @@ This file is part of the iText (R) project.
24
24
25
25
import com .itextpdf .commons .actions .contexts .IMetaInfo ;
26
26
import com .itextpdf .commons .actions .data .ProductData ;
27
+ import com .itextpdf .commons .exceptions .CommonsExceptionMessageConstant ;
27
28
28
29
/**
29
30
* Represents a context-based event. See also {@link AbstractContextBasedEventHandler}.
30
31
* Only for internal usage.
31
32
*/
32
33
public abstract class AbstractContextBasedITextEvent extends AbstractProductITextEvent {
33
- private final IMetaInfo metaInfo ;
34
+ private IMetaInfo metaInfo ;
34
35
35
36
/**
36
37
* Creates an event containing auxiliary meta data.
@@ -44,20 +45,34 @@ protected AbstractContextBasedITextEvent(ProductData productData, IMetaInfo meta
44
45
}
45
46
46
47
/**
47
- * Obtains stored meta info associated with the event .
48
+ * Obtains the current event context class .
48
49
*
49
- * @return meta info
50
+ * @return context class
50
51
*/
51
- IMetaInfo getMetaInfo () {
52
- return metaInfo ;
52
+ public Class <?> getClassFromContext () {
53
+ return this . getClass () ;
53
54
}
54
55
55
56
/**
56
- * Obtains a current event context class .
57
+ * Sets meta info .
57
58
*
58
- * @return context class
59
+ * @param metaInfo meta info
60
+ *
61
+ * @throws IllegalStateException if the current event already has not null meta info associated with it
59
62
*/
60
- public Class <?> getClassFromContext () {
61
- return this .getClass ();
63
+ public void setMetaInfo (IMetaInfo metaInfo ) throws IllegalStateException {
64
+ if (this .metaInfo != null ) {
65
+ throw new IllegalStateException (CommonsExceptionMessageConstant .META_INFO_SHOULDNT_BE_NULL );
66
+ }
67
+ this .metaInfo = metaInfo ;
68
+ }
69
+
70
+ /**
71
+ * Obtains stored meta info associated with the event.
72
+ *
73
+ * @return meta info
74
+ */
75
+ IMetaInfo getMetaInfo () {
76
+ return metaInfo ;
62
77
}
63
78
}
0 commit comments