Package org.apache.wiki.event

# Class WikiEvent

java.lang.Object
java.util.EventObject
org.apache.wiki.event.WikiEvent

All Implemented Interfaces:
  `Serializable`

Direct Known Subclasses:
  `WikiEngineEvent`, `WikiPageEvent`, `WikiSecurityEvent`, `WorkflowEvent`

public abstract class WikiEvent extends EventObject
Abstract parent class for wiki events.

Since:
  2.3.79
See Also:
  - Serialized Form

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`ERROR`
Indicates a exception or error state.
`static final int`
`UNDEFINED`
Indicates an undefined state.

### Fields inherited from class java.util.EventObject

`source`

## Constructor Summary

Constructors
Constructor
Description
`WikiEvent(Object src, int type)`
Constructs an instance of this event.
`WikiEvent(Object src, int type, Object... args)`
Constructs an instance of this event.

## Method Summary

Modifier and Type
Method
Description
`String`
`eventName()`
Returns a textual representation of an event type.
`<T> T`
`getArg(int index, Class<T> cls)`
Returns the requested arg, if any.
`Object[]`
`getArgs()`
Returns the args associated to src, if any.
`Map<Object,Object>`
`getAttributes()`
gets a live reference to a hash map, primarily used for the audit logger
`<T> T`
`getSrc()`
Convenience method that returns the typed object to which the event applied.
`int`
`getType()`
Returns the type of this event.
`String`
`getTypeDescription()`
Returns a String (human-readable) description of an event type.
`long`
`getWhen()`
Returns the timestamp of when this WikiEvent occurred.
`static boolean`
`isValidType(int type)`
Returns true if the int value is a valid WikiEvent type.
`protected void`
`setType(int type)`
Sets the type of this event.
`String`
`toString()`
Prints a String (human-readable) representation of this object.

### Methods inherited from class java.util.EventObject

`getSource`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Field Details

### ERROR

public static final int ERROR
Indicates a exception or error state.

See Also:
  - Constant Field Values

### UNDEFINED

public static final int UNDEFINED
Indicates an undefined state.

See Also:
  - Constant Field Values

## Constructor Details

### WikiEvent

public WikiEvent(Object src, int type)
Constructs an instance of this event.

Parameters:
  `src` - the Object that is the source of the event. Typically, this is the Wiki `Engine`
  `type` - the event type. Typically this is a constant reference to `WikiPageEvent`

### WikiEvent

public WikiEvent(Object src, int type, Object... args)
Constructs an instance of this event.

Parameters:
  `src` - the Object that is the source of the event. Typically, this is the Wiki `Engine`
  `type` - the event type. Typically this is a constant reference to `WikiPageEvent`
  `args` - typically the first arg is the page name that triggered the event.

## Method Details

### getAttributes

public Map<Object,Object> getAttributes()
gets a live reference to a hash map, primarily used for the audit logger

Returns:
Since:
  3.0.0

### getSrc

public <T> T getSrc()
Convenience method that returns the typed object to which the event applied.

Returns:
  the typed object to which the event applied.

### getWhen

public long getWhen()
Returns the timestamp of when this WikiEvent occurred.

Returns:
  this event's timestamp
Since:
  2.4.74

### setType

protected void setType(int type)
Sets the type of this event. Validation of acceptable type values is the responsibility of each subclass.

Parameters:
  `type` - the type of this WikiEvent.

### getType

public int getType()
Returns the type of this event.

Returns:
  the type of this WikiEvent. See the enumerated values defined in `WikiEvent`).

### getArgs

public Object[] getArgs()
Returns the args associated to src, if any.

Returns:
  args associated to src, if any.

### getArg

public <T> T getArg(int index, Class<T> cls)
Returns the requested arg, if any.

Returns:
  requested arg or null.

### getTypeDescription

public String getTypeDescription()
Returns a String (human-readable) description of an event type. This should be subclassed as necessary.

Returns:
  the String description

### isValidType

public static boolean isValidType(int type)
Returns true if the int value is a valid WikiEvent type. Because the WikiEvent class does not itself any event types, this method returns true if the event type is anything except `ERROR` or `UNDEFINED`. This method is meant to be subclassed as appropriate.

Parameters:
  `type` - The value to test.
Returns:
  true, if the value is a valid WikiEvent type.

### eventName

public String eventName()
Returns a textual representation of an event type.

Returns:
  the String representation

### toString

public String toString()
Prints a String (human-readable) representation of this object. This should be subclassed as necessary.

Overrides:
  `toString` in class `EventObject`
Returns:
  the String representation
See Also:
  - `Object.toString()`