org.mitre.cybox.cybox_2.Event Maven / Gradle / Ivy
Show all versions of stix Show documentation
/**
* Copyright (c) 2015, The MITRE Corporation. All rights reserved.
* See LICENSE for complete terms.
*/
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.5-2
// See http://java.sun.com/xml/jaxb
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2015.06.23 at 10:59:44 AM EDT
//
package org.mitre.cybox.cybox_2;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.namespace.QName;
import javax.xml.transform.stream.StreamSource;
import org.jvnet.jaxb2_commons.lang.Equals;
import org.jvnet.jaxb2_commons.lang.EqualsStrategy;
import org.jvnet.jaxb2_commons.lang.HashCode;
import org.jvnet.jaxb2_commons.lang.HashCodeStrategy;
import org.jvnet.jaxb2_commons.lang.JAXBEqualsStrategy;
import org.jvnet.jaxb2_commons.lang.JAXBHashCodeStrategy;
import org.jvnet.jaxb2_commons.lang.JAXBToStringStrategy;
import org.jvnet.jaxb2_commons.lang.ToString;
import org.jvnet.jaxb2_commons.lang.ToStringStrategy;
import org.jvnet.jaxb2_commons.locator.ObjectLocator;
import org.jvnet.jaxb2_commons.locator.util.LocatorUtils;
import org.mitre.cybox.common_2.ControlledVocabularyStringType;
import org.mitre.cybox.common_2.LocationType;
import org.mitre.cybox.common_2.MeasureSourceType;
import org.mitre.cybox.common_2.StructuredTextType;
import org.mitre.stix.DocumentUtilities;
import org.mitre.stix.STIXSchema;
import org.mitre.stix.ValidationEventHandler;
/**
* The EventType is a complex type representing a cyber observable event that is dynamic in nature with specific action(s) taken against specific cyber relevant objects (e.g. a file is deleted, a registry key is created or an HTTP Get Request is received).
*
* Java class for EventType complex type.
*
*
The following schema fragment specifies the expected content contained within this class.
*
*
* <complexType name="EventType">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <choice>
* <sequence>
* <element name="Type" type="{http://cybox.mitre.org/common-2}ControlledVocabularyStringType" minOccurs="0"/>
* <element name="Description" type="{http://cybox.mitre.org/common-2}StructuredTextType" minOccurs="0"/>
* <element name="Observation_Method" type="{http://cybox.mitre.org/common-2}MeasureSourceType" minOccurs="0"/>
* <element name="Actions" type="{http://cybox.mitre.org/cybox-2}ActionsType" minOccurs="0"/>
* <element name="Location" type="{http://cybox.mitre.org/common-2}LocationType" minOccurs="0"/>
* <element name="Frequency" type="{http://cybox.mitre.org/cybox-2}FrequencyType" minOccurs="0"/>
* </sequence>
* <sequence maxOccurs="unbounded">
* <element name="Event" type="{http://cybox.mitre.org/cybox-2}EventType"/>
* </sequence>
* </choice>
* <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}QName" />
* <attribute name="idref" type="{http://www.w3.org/2001/XMLSchema}QName" />
* </restriction>
* </complexContent>
* </complexType>
*
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "EventType", propOrder = { "events", "type", "description",
"observationMethod", "actions", "location", "frequency" })
@XmlRootElement(name = "Event")
public class Event implements Equals, HashCode, ToString {
@XmlElement(name = "Event")
protected List events;
@XmlElement(name = "Type")
protected ControlledVocabularyStringType type;
@XmlElement(name = "Description")
protected StructuredTextType description;
@XmlElement(name = "Observation_Method")
protected MeasureSourceType observationMethod;
@XmlElement(name = "Actions")
protected ActionsType actions;
@XmlElement(name = "Location")
protected LocationType location;
@XmlElement(name = "Frequency")
protected FrequencyType frequency;
@XmlAttribute(name = "id")
protected QName id;
@XmlAttribute(name = "idref")
protected QName idref;
/**
* Default no-arg constructor
*
*/
public Event() {
super();
}
/**
* Fully-initialising value constructor
*
*/
public Event(final List events,
final ControlledVocabularyStringType type,
final StructuredTextType description,
final MeasureSourceType observationMethod,
final ActionsType actions, final LocationType location,
final FrequencyType frequency, final QName id, final QName idref) {
this.events = events;
this.type = type;
this.description = description;
this.observationMethod = observationMethod;
this.actions = actions;
this.location = location;
this.frequency = frequency;
this.id = id;
this.idref = idref;
}
/**
* Gets the value of the events property.
*
*
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a set
method for the events property.
*
*
* For example, to add a new item, do as follows:
*
* getEvents().add(newItem);
*
*
*
*
* Objects of the following type(s) are allowed in the list
* {@link Event }
*
*
*/
public List getEvents() {
if (events == null) {
events = new ArrayList();
}
return this.events;
}
/**
* Gets the value of the type property.
*
* @return
* possible object is
* {@link ControlledVocabularyStringType }
*
*/
public ControlledVocabularyStringType getType() {
return type;
}
/**
* Sets the value of the type property.
*
* @param value
* allowed object is
* {@link ControlledVocabularyStringType }
*
*/
public void setType(ControlledVocabularyStringType value) {
this.type = value;
}
/**
* Gets the value of the description property.
*
* @return
* possible object is
* {@link StructuredTextType }
*
*/
public StructuredTextType getDescription() {
return description;
}
/**
* Sets the value of the description property.
*
* @param value
* allowed object is
* {@link StructuredTextType }
*
*/
public void setDescription(StructuredTextType value) {
this.description = value;
}
/**
* Gets the value of the observationMethod property.
*
* @return
* possible object is
* {@link MeasureSourceType }
*
*/
public MeasureSourceType getObservationMethod() {
return observationMethod;
}
/**
* Sets the value of the observationMethod property.
*
* @param value
* allowed object is
* {@link MeasureSourceType }
*
*/
public void setObservationMethod(MeasureSourceType value) {
this.observationMethod = value;
}
/**
* Gets the value of the actions property.
*
* @return
* possible object is
* {@link ActionsType }
*
*/
public ActionsType getActions() {
return actions;
}
/**
* Sets the value of the actions property.
*
* @param value
* allowed object is
* {@link ActionsType }
*
*/
public void setActions(ActionsType value) {
this.actions = value;
}
/**
* Gets the value of the location property.
*
* @return
* possible object is
* {@link LocationType }
*
*/
public LocationType getLocation() {
return location;
}
/**
* Sets the value of the location property.
*
* @param value
* allowed object is
* {@link LocationType }
*
*/
public void setLocation(LocationType value) {
this.location = value;
}
/**
* Gets the value of the frequency property.
*
* @return
* possible object is
* {@link FrequencyType }
*
*/
public FrequencyType getFrequency() {
return frequency;
}
/**
* Sets the value of the frequency property.
*
* @param value
* allowed object is
* {@link FrequencyType }
*
*/
public void setFrequency(FrequencyType value) {
this.frequency = value;
}
/**
* Gets the value of the id property.
*
* @return
* possible object is
* {@link QName }
*
*/
public QName getId() {
return id;
}
/**
* Sets the value of the id property.
*
* @param value
* allowed object is
* {@link QName }
*
*/
public void setId(QName value) {
this.id = value;
}
/**
* Gets the value of the idref property.
*
* @return
* possible object is
* {@link QName }
*
*/
public QName getIdref() {
return idref;
}
/**
* Sets the value of the idref property.
*
* @param value
* allowed object is
* {@link QName }
*
*/
public void setIdref(QName value) {
this.idref = value;
}
public boolean equals(ObjectLocator thisLocator, ObjectLocator thatLocator,
Object object, EqualsStrategy strategy) {
if (!(object instanceof Event)) {
return false;
}
if (this == object) {
return true;
}
final Event that = ((Event) object);
{
List lhsEvents;
lhsEvents = (((this.events != null) && (!this.events.isEmpty())) ? this
.getEvents() : null);
List rhsEvents;
rhsEvents = (((that.events != null) && (!that.events.isEmpty())) ? that
.getEvents() : null);
if (!strategy.equals(
LocatorUtils.property(thisLocator, "events", lhsEvents),
LocatorUtils.property(thatLocator, "events", rhsEvents),
lhsEvents, rhsEvents)) {
return false;
}
}
{
ControlledVocabularyStringType lhsType;
lhsType = this.getType();
ControlledVocabularyStringType rhsType;
rhsType = that.getType();
if (!strategy.equals(
LocatorUtils.property(thisLocator, "type", lhsType),
LocatorUtils.property(thatLocator, "type", rhsType),
lhsType, rhsType)) {
return false;
}
}
{
StructuredTextType lhsDescription;
lhsDescription = this.getDescription();
StructuredTextType rhsDescription;
rhsDescription = that.getDescription();
if (!strategy.equals(LocatorUtils.property(thisLocator,
"description", lhsDescription), LocatorUtils.property(
thatLocator, "description", rhsDescription),
lhsDescription, rhsDescription)) {
return false;
}
}
{
MeasureSourceType lhsObservationMethod;
lhsObservationMethod = this.getObservationMethod();
MeasureSourceType rhsObservationMethod;
rhsObservationMethod = that.getObservationMethod();
if (!strategy.equals(LocatorUtils.property(thisLocator,
"observationMethod", lhsObservationMethod), LocatorUtils
.property(thatLocator, "observationMethod",
rhsObservationMethod), lhsObservationMethod,
rhsObservationMethod)) {
return false;
}
}
{
ActionsType lhsActions;
lhsActions = this.getActions();
ActionsType rhsActions;
rhsActions = that.getActions();
if (!strategy.equals(
LocatorUtils.property(thisLocator, "actions", lhsActions),
LocatorUtils.property(thatLocator, "actions", rhsActions),
lhsActions, rhsActions)) {
return false;
}
}
{
LocationType lhsLocation;
lhsLocation = this.getLocation();
LocationType rhsLocation;
rhsLocation = that.getLocation();
if (!strategy
.equals(LocatorUtils.property(thisLocator, "location",
lhsLocation), LocatorUtils.property(thatLocator,
"location", rhsLocation), lhsLocation, rhsLocation)) {
return false;
}
}
{
FrequencyType lhsFrequency;
lhsFrequency = this.getFrequency();
FrequencyType rhsFrequency;
rhsFrequency = that.getFrequency();
if (!strategy.equals(LocatorUtils.property(thisLocator,
"frequency", lhsFrequency), LocatorUtils.property(
thatLocator, "frequency", rhsFrequency), lhsFrequency,
rhsFrequency)) {
return false;
}
}
{
QName lhsId;
lhsId = this.getId();
QName rhsId;
rhsId = that.getId();
if (!strategy.equals(
LocatorUtils.property(thisLocator, "id", lhsId),
LocatorUtils.property(thatLocator, "id", rhsId), lhsId,
rhsId)) {
return false;
}
}
{
QName lhsIdref;
lhsIdref = this.getIdref();
QName rhsIdref;
rhsIdref = that.getIdref();
if (!strategy.equals(
LocatorUtils.property(thisLocator, "idref", lhsIdref),
LocatorUtils.property(thatLocator, "idref", rhsIdref),
lhsIdref, rhsIdref)) {
return false;
}
}
return true;
}
public boolean equals(Object object) {
final EqualsStrategy strategy = JAXBEqualsStrategy.INSTANCE;
return equals(null, null, object, strategy);
}
public int hashCode(ObjectLocator locator, HashCodeStrategy strategy) {
int currentHashCode = 1;
{
List theEvents;
theEvents = (((this.events != null) && (!this.events.isEmpty())) ? this
.getEvents() : null);
currentHashCode = strategy.hashCode(
LocatorUtils.property(locator, "events", theEvents),
currentHashCode, theEvents);
}
{
ControlledVocabularyStringType theType;
theType = this.getType();
currentHashCode = strategy.hashCode(
LocatorUtils.property(locator, "type", theType),
currentHashCode, theType);
}
{
StructuredTextType theDescription;
theDescription = this.getDescription();
currentHashCode = strategy.hashCode(LocatorUtils.property(locator,
"description", theDescription), currentHashCode,
theDescription);
}
{
MeasureSourceType theObservationMethod;
theObservationMethod = this.getObservationMethod();
currentHashCode = strategy.hashCode(LocatorUtils.property(locator,
"observationMethod", theObservationMethod),
currentHashCode, theObservationMethod);
}
{
ActionsType theActions;
theActions = this.getActions();
currentHashCode = strategy.hashCode(
LocatorUtils.property(locator, "actions", theActions),
currentHashCode, theActions);
}
{
LocationType theLocation;
theLocation = this.getLocation();
currentHashCode = strategy.hashCode(
LocatorUtils.property(locator, "location", theLocation),
currentHashCode, theLocation);
}
{
FrequencyType theFrequency;
theFrequency = this.getFrequency();
currentHashCode = strategy.hashCode(
LocatorUtils.property(locator, "frequency", theFrequency),
currentHashCode, theFrequency);
}
{
QName theId;
theId = this.getId();
currentHashCode = strategy.hashCode(
LocatorUtils.property(locator, "id", theId),
currentHashCode, theId);
}
{
QName theIdref;
theIdref = this.getIdref();
currentHashCode = strategy.hashCode(
LocatorUtils.property(locator, "idref", theIdref),
currentHashCode, theIdref);
}
return currentHashCode;
}
public int hashCode() {
final HashCodeStrategy strategy = JAXBHashCodeStrategy.INSTANCE;
return this.hashCode(null, strategy);
}
public Event withEvents(Event... values) {
if (values != null) {
for (Event value : values) {
getEvents().add(value);
}
}
return this;
}
public Event withEvents(Collection values) {
if (values != null) {
getEvents().addAll(values);
}
return this;
}
public Event withType(ControlledVocabularyStringType value) {
setType(value);
return this;
}
public Event withDescription(StructuredTextType value) {
setDescription(value);
return this;
}
public Event withObservationMethod(MeasureSourceType value) {
setObservationMethod(value);
return this;
}
public Event withActions(ActionsType value) {
setActions(value);
return this;
}
public Event withLocation(LocationType value) {
setLocation(value);
return this;
}
public Event withFrequency(FrequencyType value) {
setFrequency(value);
return this;
}
public Event withId(QName value) {
setId(value);
return this;
}
public Event withIdref(QName value) {
setIdref(value);
return this;
}
public String toString() {
final ToStringStrategy strategy = JAXBToStringStrategy.INSTANCE;
final StringBuilder buffer = new StringBuilder();
append(null, buffer, strategy);
return buffer.toString();
}
public StringBuilder append(ObjectLocator locator, StringBuilder buffer,
ToStringStrategy strategy) {
strategy.appendStart(locator, this, buffer);
appendFields(locator, buffer, strategy);
strategy.appendEnd(locator, this, buffer);
return buffer;
}
public StringBuilder appendFields(ObjectLocator locator,
StringBuilder buffer, ToStringStrategy strategy) {
{
List theEvents;
theEvents = (((this.events != null) && (!this.events.isEmpty())) ? this
.getEvents() : null);
strategy.appendField(locator, this, "events", buffer, theEvents);
}
{
ControlledVocabularyStringType theType;
theType = this.getType();
strategy.appendField(locator, this, "type", buffer, theType);
}
{
StructuredTextType theDescription;
theDescription = this.getDescription();
strategy.appendField(locator, this, "description", buffer,
theDescription);
}
{
MeasureSourceType theObservationMethod;
theObservationMethod = this.getObservationMethod();
strategy.appendField(locator, this, "observationMethod", buffer,
theObservationMethod);
}
{
ActionsType theActions;
theActions = this.getActions();
strategy.appendField(locator, this, "actions", buffer, theActions);
}
{
LocationType theLocation;
theLocation = this.getLocation();
strategy.appendField(locator, this, "location", buffer, theLocation);
}
{
FrequencyType theFrequency;
theFrequency = this.getFrequency();
strategy.appendField(locator, this, "frequency", buffer,
theFrequency);
}
{
QName theId;
theId = this.getId();
strategy.appendField(locator, this, "id", buffer, theId);
}
{
QName theIdref;
theIdref = this.getIdref();
strategy.appendField(locator, this, "idref", buffer, theIdref);
}
return buffer;
}
/**
* Returns A Document representation of this instance that is not formatted.
*
* @return The Document representation for this instance.
*/
public org.w3c.dom.Document toDocument() {
return toDocument(false);
}
/**
* Returns A Document representation for this instance.
*
* @param prettyPrint
* True for pretty print, otherwise false
*
* @return The Document representation for this instance.
*/
public org.w3c.dom.Document toDocument(boolean prettyPrint) {
return DocumentUtilities.toDocument(toJAXBElement(), prettyPrint);
}
/**
* Returns JAXBElement for this instance.
*
* @return The JAXBElement for this instance.
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public JAXBElement> toJAXBElement() {
QName qualifiedName = STIXSchema.getQualifiedName(this);
return new JAXBElement(qualifiedName, Event.class, this);
}
/**
* Returns String representation of this instance that is not formatted.
*
* @return The String containing the XML mark-up.
*/
public String toXMLString() {
return toXMLString(false);
}
/**
* Returns XML String for JAXB Document Object Model object.
*
* @param prettyPrint
* True for pretty print, otherwise false
*
* @return The String containing the XML mark-up.
*/
public String toXMLString(boolean prettyPrint) {
return DocumentUtilities.toXMLString(toDocument(), prettyPrint);
}
/**
* Creates Event instance for XML String
*
* @param text
* XML String for the document
* @return The Event instance for the passed XML String
*/
public static Event fromXMLString(String text) {
JAXBContext jaxbContext;
try {
jaxbContext = JAXBContext.newInstance(Event.class.getPackage()
.getName());
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
unmarshaller.setSchema(STIXSchema.getInstance().getSchema());
unmarshaller.setEventHandler(new ValidationEventHandler());
StreamSource streamSource = new StreamSource(new StringReader(text));
return (Event) unmarshaller.unmarshal(streamSource);
} catch (JAXBException e) {
throw new RuntimeException(e);
}
}
/**
* Validates the XML representation of this Event instance
* Returning true indicating a successful validation, false if not.
*
* @return boolean
*/
public boolean validate() {
return STIXSchema.getInstance().validate(toXMLString());
}
}