All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mitre.cybox.cybox_2.Observable Maven / Gradle / Ivy

There is a newer version: 1.2.0.2
Show newest version
/**
 * 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.07.01 at 03:30:29 PM EDT 
//

package org.mitre.cybox.cybox_2;

import java.io.StringReader;
import java.math.BigInteger;
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.XmlSchemaType;
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.MeasureSourceType;
import org.mitre.cybox.common_2.StructuredTextType;
import org.mitre.stix.DocumentUtilities;
import org.mitre.stix.STIXSchema;
import org.mitre.stix.ValidationEventHandler;
import org.xml.sax.SAXException;

/**
 * The ObservableType is a type representing a description of a single cyber observable.
 * 
 * 

Java class for ObservableType complex type. * *

The following schema fragment specifies the expected content contained within this class. * *

 * <complexType name="ObservableType">
 *   <complexContent>
 *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       <sequence>
 *         <element name="Title" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         <element name="Description" type="{http://cybox.mitre.org/common-2}StructuredTextType" minOccurs="0"/>
 *         <element name="Keywords" type="{http://cybox.mitre.org/cybox-2}KeywordsType" minOccurs="0"/>
 *         <element name="Observable_Source" type="{http://cybox.mitre.org/common-2}MeasureSourceType" maxOccurs="unbounded" minOccurs="0"/>
 *         <choice minOccurs="0">
 *           <element ref="{http://cybox.mitre.org/cybox-2}Object" minOccurs="0"/>
 *           <element ref="{http://cybox.mitre.org/cybox-2}Event" minOccurs="0"/>
 *           <element name="Observable_Composition" type="{http://cybox.mitre.org/cybox-2}ObservableCompositionType" minOccurs="0"/>
 *         </choice>
 *         <element name="Pattern_Fidelity" type="{http://cybox.mitre.org/cybox-2}PatternFidelityType" minOccurs="0"/>
 *       </sequence>
 *       <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}QName" />
 *       <attribute name="idref" type="{http://www.w3.org/2001/XMLSchema}QName" />
 *       <attribute name="negate" type="{http://www.w3.org/2001/XMLSchema}boolean" default="false" />
 *       <attribute name="sighting_count" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" />
 *     </restriction>
 *   </complexContent>
 * </complexType>
 * 
* * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "ObservableType", propOrder = { "title", "description", "keywords", "observableSources", "observableComposition", "event", "object", "patternFidelity" }) @XmlRootElement(name = "Observable") public class Observable implements Equals, HashCode, ToString { @XmlElement(name = "Title") protected String title; @XmlElement(name = "Description") protected StructuredTextType description; @XmlElement(name = "Keywords") protected KeywordsType keywords; @XmlElement(name = "Observable_Source") protected List observableSources; @XmlElement(name = "Observable_Composition") protected ObservableCompositionType observableComposition; @XmlElement(name = "Event") protected Event event; @XmlElement(name = "Object") protected ObjectType object; @XmlElement(name = "Pattern_Fidelity") protected PatternFidelityType patternFidelity; @XmlAttribute(name = "id") protected QName id; @XmlAttribute(name = "idref") protected QName idref; @XmlAttribute(name = "negate") protected Boolean negate; @XmlAttribute(name = "sighting_count") @XmlSchemaType(name = "positiveInteger") protected BigInteger sightingCount; /** * Default no-arg constructor * */ public Observable() { super(); } /** * Fully-initialising value constructor * */ public Observable(final String title, final StructuredTextType description, final KeywordsType keywords, final List observableSources, final ObservableCompositionType observableComposition, final Event event, final ObjectType object, final PatternFidelityType patternFidelity, final QName id, final QName idref, final Boolean negate, final BigInteger sightingCount) { this.title = title; this.description = description; this.keywords = keywords; this.observableSources = observableSources; this.observableComposition = observableComposition; this.event = event; this.object = object; this.patternFidelity = patternFidelity; this.id = id; this.idref = idref; this.negate = negate; this.sightingCount = sightingCount; } /** * Gets the value of the title property. * * @return * possible object is * {@link String } * */ public String getTitle() { return title; } /** * Sets the value of the title property. * * @param value * allowed object is * {@link String } * */ public void setTitle(String value) { this.title = 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 keywords property. * * @return * possible object is * {@link KeywordsType } * */ public KeywordsType getKeywords() { return keywords; } /** * Sets the value of the keywords property. * * @param value * allowed object is * {@link KeywordsType } * */ public void setKeywords(KeywordsType value) { this.keywords = value; } /** * Gets the value of the observableSources 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 observableSources property. * *

* For example, to add a new item, do as follows: *

	 *    getObservableSources().add(newItem);
	 * 
* * *

* Objects of the following type(s) are allowed in the list * {@link MeasureSourceType } * * */ public List getObservableSources() { if (observableSources == null) { observableSources = new ArrayList(); } return this.observableSources; } /** * Gets the value of the observableComposition property. * * @return * possible object is * {@link ObservableCompositionType } * */ public ObservableCompositionType getObservableComposition() { return observableComposition; } /** * Sets the value of the observableComposition property. * * @param value * allowed object is * {@link ObservableCompositionType } * */ public void setObservableComposition(ObservableCompositionType value) { this.observableComposition = value; } /** * The Event construct enables specification of 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). * * @return * possible object is * {@link Event } * */ public Event getEvent() { return event; } /** * Sets the value of the event property. * * @param value * allowed object is * {@link Event } * */ public void setEvent(Event value) { this.event = value; } /** * The Object construct identifies and specifies the characteristics of a specific cyber-relevant object (e.g. a file, a registry key or a process). * * @return * possible object is * {@link ObjectType } * */ public ObjectType getObject() { return object; } /** * Sets the value of the object property. * * @param value * allowed object is * {@link ObjectType } * */ public void setObject(ObjectType value) { this.object = value; } /** * Gets the value of the patternFidelity property. * * @return * possible object is * {@link PatternFidelityType } * */ public PatternFidelityType getPatternFidelity() { return patternFidelity; } /** * Sets the value of the patternFidelity property. * * @param value * allowed object is * {@link PatternFidelityType } * */ public void setPatternFidelity(PatternFidelityType value) { this.patternFidelity = 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; } /** * Gets the value of the negate property. * * @return * possible object is * {@link Boolean } * */ public boolean isNegate() { if (negate == null) { return false; } else { return negate; } } /** * Sets the value of the negate property. * * @param value * allowed object is * {@link Boolean } * */ public void setNegate(Boolean value) { this.negate = value; } /** * Gets the value of the sightingCount property. * * @return * possible object is * {@link BigInteger } * */ public BigInteger getSightingCount() { return sightingCount; } /** * Sets the value of the sightingCount property. * * @param value * allowed object is * {@link BigInteger } * */ public void setSightingCount(BigInteger value) { this.sightingCount = value; } public boolean equals(ObjectLocator thisLocator, ObjectLocator thatLocator, Object object, EqualsStrategy strategy) { if (!(object instanceof Observable)) { return false; } if (this == object) { return true; } final Observable that = ((Observable) object); { String lhsTitle; lhsTitle = this.getTitle(); String rhsTitle; rhsTitle = that.getTitle(); if (!strategy.equals( LocatorUtils.property(thisLocator, "title", lhsTitle), LocatorUtils.property(thatLocator, "title", rhsTitle), lhsTitle, rhsTitle)) { 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; } } { KeywordsType lhsKeywords; lhsKeywords = this.getKeywords(); KeywordsType rhsKeywords; rhsKeywords = that.getKeywords(); if (!strategy .equals(LocatorUtils.property(thisLocator, "keywords", lhsKeywords), LocatorUtils.property(thatLocator, "keywords", rhsKeywords), lhsKeywords, rhsKeywords)) { return false; } } { List lhsObservableSources; lhsObservableSources = (((this.observableSources != null) && (!this.observableSources .isEmpty())) ? this.getObservableSources() : null); List rhsObservableSources; rhsObservableSources = (((that.observableSources != null) && (!that.observableSources .isEmpty())) ? that.getObservableSources() : null); if (!strategy.equals(LocatorUtils.property(thisLocator, "observableSources", lhsObservableSources), LocatorUtils .property(thatLocator, "observableSources", rhsObservableSources), lhsObservableSources, rhsObservableSources)) { return false; } } { ObservableCompositionType lhsObservableComposition; lhsObservableComposition = this.getObservableComposition(); ObservableCompositionType rhsObservableComposition; rhsObservableComposition = that.getObservableComposition(); if (!strategy.equals(LocatorUtils.property(thisLocator, "observableComposition", lhsObservableComposition), LocatorUtils.property(thatLocator, "observableComposition", rhsObservableComposition), lhsObservableComposition, rhsObservableComposition)) { return false; } } { Event lhsEvent; lhsEvent = this.getEvent(); Event rhsEvent; rhsEvent = that.getEvent(); if (!strategy.equals( LocatorUtils.property(thisLocator, "event", lhsEvent), LocatorUtils.property(thatLocator, "event", rhsEvent), lhsEvent, rhsEvent)) { return false; } } { ObjectType lhsObject; lhsObject = this.getObject(); ObjectType rhsObject; rhsObject = that.getObject(); if (!strategy.equals( LocatorUtils.property(thisLocator, "object", lhsObject), LocatorUtils.property(thatLocator, "object", rhsObject), lhsObject, rhsObject)) { return false; } } { PatternFidelityType lhsPatternFidelity; lhsPatternFidelity = this.getPatternFidelity(); PatternFidelityType rhsPatternFidelity; rhsPatternFidelity = that.getPatternFidelity(); if (!strategy.equals(LocatorUtils.property(thisLocator, "patternFidelity", lhsPatternFidelity), LocatorUtils .property(thatLocator, "patternFidelity", rhsPatternFidelity), lhsPatternFidelity, rhsPatternFidelity)) { 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; } } { boolean lhsNegate; lhsNegate = ((this.negate != null) ? this.isNegate() : false); boolean rhsNegate; rhsNegate = ((that.negate != null) ? that.isNegate() : false); if (!strategy.equals( LocatorUtils.property(thisLocator, "negate", lhsNegate), LocatorUtils.property(thatLocator, "negate", rhsNegate), lhsNegate, rhsNegate)) { return false; } } { BigInteger lhsSightingCount; lhsSightingCount = this.getSightingCount(); BigInteger rhsSightingCount; rhsSightingCount = that.getSightingCount(); if (!strategy.equals(LocatorUtils.property(thisLocator, "sightingCount", lhsSightingCount), LocatorUtils.property( thatLocator, "sightingCount", rhsSightingCount), lhsSightingCount, rhsSightingCount)) { 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; { String theTitle; theTitle = this.getTitle(); currentHashCode = strategy.hashCode( LocatorUtils.property(locator, "title", theTitle), currentHashCode, theTitle); } { StructuredTextType theDescription; theDescription = this.getDescription(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "description", theDescription), currentHashCode, theDescription); } { KeywordsType theKeywords; theKeywords = this.getKeywords(); currentHashCode = strategy.hashCode( LocatorUtils.property(locator, "keywords", theKeywords), currentHashCode, theKeywords); } { List theObservableSources; theObservableSources = (((this.observableSources != null) && (!this.observableSources .isEmpty())) ? this.getObservableSources() : null); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "observableSources", theObservableSources), currentHashCode, theObservableSources); } { ObservableCompositionType theObservableComposition; theObservableComposition = this.getObservableComposition(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "observableComposition", theObservableComposition), currentHashCode, theObservableComposition); } { Event theEvent; theEvent = this.getEvent(); currentHashCode = strategy.hashCode( LocatorUtils.property(locator, "event", theEvent), currentHashCode, theEvent); } { ObjectType theObject; theObject = this.getObject(); currentHashCode = strategy.hashCode( LocatorUtils.property(locator, "object", theObject), currentHashCode, theObject); } { PatternFidelityType thePatternFidelity; thePatternFidelity = this.getPatternFidelity(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "patternFidelity", thePatternFidelity), currentHashCode, thePatternFidelity); } { 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); } { boolean theNegate; theNegate = ((this.negate != null) ? this.isNegate() : false); currentHashCode = strategy.hashCode( LocatorUtils.property(locator, "negate", theNegate), currentHashCode, theNegate); } { BigInteger theSightingCount; theSightingCount = this.getSightingCount(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "sightingCount", theSightingCount), currentHashCode, theSightingCount); } return currentHashCode; } public int hashCode() { final HashCodeStrategy strategy = JAXBHashCodeStrategy.INSTANCE; return this.hashCode(null, strategy); } public Observable withTitle(String value) { setTitle(value); return this; } public Observable withDescription(StructuredTextType value) { setDescription(value); return this; } public Observable withKeywords(KeywordsType value) { setKeywords(value); return this; } public Observable withObservableSources(MeasureSourceType... values) { if (values != null) { for (MeasureSourceType value : values) { getObservableSources().add(value); } } return this; } public Observable withObservableSources(Collection values) { if (values != null) { getObservableSources().addAll(values); } return this; } public Observable withObservableComposition(ObservableCompositionType value) { setObservableComposition(value); return this; } public Observable withEvent(Event value) { setEvent(value); return this; } public Observable withObject(ObjectType value) { setObject(value); return this; } public Observable withPatternFidelity(PatternFidelityType value) { setPatternFidelity(value); return this; } public Observable withId(QName value) { setId(value); return this; } public Observable withIdref(QName value) { setIdref(value); return this; } public Observable withNegate(Boolean value) { setNegate(value); return this; } public Observable withSightingCount(BigInteger value) { setSightingCount(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) { { String theTitle; theTitle = this.getTitle(); strategy.appendField(locator, this, "title", buffer, theTitle); } { StructuredTextType theDescription; theDescription = this.getDescription(); strategy.appendField(locator, this, "description", buffer, theDescription); } { KeywordsType theKeywords; theKeywords = this.getKeywords(); strategy.appendField(locator, this, "keywords", buffer, theKeywords); } { List theObservableSources; theObservableSources = (((this.observableSources != null) && (!this.observableSources .isEmpty())) ? this.getObservableSources() : null); strategy.appendField(locator, this, "observableSources", buffer, theObservableSources); } { ObservableCompositionType theObservableComposition; theObservableComposition = this.getObservableComposition(); strategy.appendField(locator, this, "observableComposition", buffer, theObservableComposition); } { Event theEvent; theEvent = this.getEvent(); strategy.appendField(locator, this, "event", buffer, theEvent); } { ObjectType theObject; theObject = this.getObject(); strategy.appendField(locator, this, "object", buffer, theObject); } { PatternFidelityType thePatternFidelity; thePatternFidelity = this.getPatternFidelity(); strategy.appendField(locator, this, "patternFidelity", buffer, thePatternFidelity); } { QName theId; theId = this.getId(); strategy.appendField(locator, this, "id", buffer, theId); } { QName theIdref; theIdref = this.getIdref(); strategy.appendField(locator, this, "idref", buffer, theIdref); } { boolean theNegate; theNegate = ((this.negate != null) ? this.isNegate() : false); strategy.appendField(locator, this, "negate", buffer, theNegate); } { BigInteger theSightingCount; theSightingCount = this.getSightingCount(); strategy.appendField(locator, this, "sightingCount", buffer, theSightingCount); } 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, Observable.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 Observable instance for XML String * * @param text * XML String for the document * @return The Observable instance for the passed XML String */ public static Observable fromXMLString(String text) { JAXBContext jaxbContext; try { jaxbContext = JAXBContext.newInstance(Observable.class.getPackage() .getName()); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); unmarshaller.setSchema(STIXSchema.getInstance().getSchema()); unmarshaller.setEventHandler(new ValidationEventHandler()); StreamSource streamSource = new StreamSource(new StringReader(text)); return (Observable) unmarshaller.unmarshal(streamSource); } catch (JAXBException e) { throw new RuntimeException(e); } } /** * Validates the XML representation of this Observable instance * Returning true indicating a successful validation, false if not. * * @return boolean True If it validates against the schema * @throws SAXException * If the a validation ErrorHandler has not been set, and * validation throws a SAXException */ public boolean validate() throws SAXException { return STIXSchema.getInstance().validate(toXMLString()); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy