org.mitre.cybox.objects.NetworkFlowObject Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stix Show documentation
Show all versions of stix Show documentation
The Java bindings for STIX v.1.2.0.2
The 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:19:53 PM EDT
//
package org.mitre.cybox.objects;
import java.io.StringReader;
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.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.CustomPropertiesType;
import org.mitre.cybox.common_2.ObjectPropertiesType;
import org.mitre.stix.DocumentUtilities;
import org.mitre.stix.STIXSchema;
import org.mitre.stix.ValidationEventHandler;
import org.xml.sax.SAXException;
/**
* Defines the fields necessary to summarize network traffic, expressed as flows of multiple packets. Does not include the packet payload data (i.e. the actual data that was uploaded/downloaded to and from the Dest IP to Source IP as included in packet monitoring tools, such as Wireshark).
*
* Java class for NetworkFlowObjectType complex type.
*
*
The following schema fragment specifies the expected content contained within this class.
*
*
* <complexType name="NetworkFlowObjectType">
* <complexContent>
* <extension base="{http://cybox.mitre.org/common-2}ObjectPropertiesType">
* <sequence>
* <element name="Network_Flow_Label" type="{http://cybox.mitre.org/objects#NetworkFlowObject-2}NetworkFlowLabelType" minOccurs="0"/>
* <choice minOccurs="0">
* <element name="Unidirectional_Flow_Record" type="{http://cybox.mitre.org/objects#NetworkFlowObject-2}UnidirectionalRecordType" minOccurs="0"/>
* <element name="Bidirectional_Flow_Record" type="{http://cybox.mitre.org/objects#NetworkFlowObject-2}BidirectionalRecordType" minOccurs="0"/>
* </choice>
* </sequence>
* </extension>
* </complexContent>
* </complexType>
*
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "NetworkFlowObjectType", namespace = "http://cybox.mitre.org/objects#NetworkFlowObject-2", propOrder = {
"networkFlowLabel", "bidirectionalFlowRecord",
"unidirectionalFlowRecord" })
@XmlRootElement(name = "Network_Flow_Object", namespace = "http://cybox.mitre.org/objects#NetworkFlowObject-2")
public class NetworkFlowObject extends ObjectPropertiesType implements Equals,
HashCode, ToString {
@XmlElement(name = "Network_Flow_Label")
protected NetworkFlowLabelType networkFlowLabel;
@XmlElement(name = "Bidirectional_Flow_Record")
protected BidirectionalRecordType bidirectionalFlowRecord;
@XmlElement(name = "Unidirectional_Flow_Record")
protected UnidirectionalRecordType unidirectionalFlowRecord;
/**
* Default no-arg constructor
*
*/
public NetworkFlowObject() {
super();
}
/**
* Fully-initialising value constructor
*
*/
public NetworkFlowObject(final CustomPropertiesType customProperties,
final QName objectReference,
final NetworkFlowLabelType networkFlowLabel,
final BidirectionalRecordType bidirectionalFlowRecord,
final UnidirectionalRecordType unidirectionalFlowRecord) {
super(customProperties, objectReference);
this.networkFlowLabel = networkFlowLabel;
this.bidirectionalFlowRecord = bidirectionalFlowRecord;
this.unidirectionalFlowRecord = unidirectionalFlowRecord;
}
/**
* Gets the value of the networkFlowLabel property.
*
* @return
* possible object is
* {@link NetworkFlowLabelType }
*
*/
public NetworkFlowLabelType getNetworkFlowLabel() {
return networkFlowLabel;
}
/**
* Sets the value of the networkFlowLabel property.
*
* @param value
* allowed object is
* {@link NetworkFlowLabelType }
*
*/
public void setNetworkFlowLabel(NetworkFlowLabelType value) {
this.networkFlowLabel = value;
}
/**
* Gets the value of the bidirectionalFlowRecord property.
*
* @return
* possible object is
* {@link BidirectionalRecordType }
*
*/
public BidirectionalRecordType getBidirectionalFlowRecord() {
return bidirectionalFlowRecord;
}
/**
* Sets the value of the bidirectionalFlowRecord property.
*
* @param value
* allowed object is
* {@link BidirectionalRecordType }
*
*/
public void setBidirectionalFlowRecord(BidirectionalRecordType value) {
this.bidirectionalFlowRecord = value;
}
/**
* Gets the value of the unidirectionalFlowRecord property.
*
* @return
* possible object is
* {@link UnidirectionalRecordType }
*
*/
public UnidirectionalRecordType getUnidirectionalFlowRecord() {
return unidirectionalFlowRecord;
}
/**
* Sets the value of the unidirectionalFlowRecord property.
*
* @param value
* allowed object is
* {@link UnidirectionalRecordType }
*
*/
public void setUnidirectionalFlowRecord(UnidirectionalRecordType value) {
this.unidirectionalFlowRecord = value;
}
public boolean equals(ObjectLocator thisLocator, ObjectLocator thatLocator,
Object object, EqualsStrategy strategy) {
if (!(object instanceof NetworkFlowObject)) {
return false;
}
if (this == object) {
return true;
}
if (!super.equals(thisLocator, thatLocator, object, strategy)) {
return false;
}
final NetworkFlowObject that = ((NetworkFlowObject) object);
{
NetworkFlowLabelType lhsNetworkFlowLabel;
lhsNetworkFlowLabel = this.getNetworkFlowLabel();
NetworkFlowLabelType rhsNetworkFlowLabel;
rhsNetworkFlowLabel = that.getNetworkFlowLabel();
if (!strategy.equals(LocatorUtils.property(thisLocator,
"networkFlowLabel", lhsNetworkFlowLabel), LocatorUtils
.property(thatLocator, "networkFlowLabel",
rhsNetworkFlowLabel), lhsNetworkFlowLabel,
rhsNetworkFlowLabel)) {
return false;
}
}
{
BidirectionalRecordType lhsBidirectionalFlowRecord;
lhsBidirectionalFlowRecord = this.getBidirectionalFlowRecord();
BidirectionalRecordType rhsBidirectionalFlowRecord;
rhsBidirectionalFlowRecord = that.getBidirectionalFlowRecord();
if (!strategy.equals(LocatorUtils.property(thisLocator,
"bidirectionalFlowRecord", lhsBidirectionalFlowRecord),
LocatorUtils.property(thatLocator,
"bidirectionalFlowRecord",
rhsBidirectionalFlowRecord),
lhsBidirectionalFlowRecord, rhsBidirectionalFlowRecord)) {
return false;
}
}
{
UnidirectionalRecordType lhsUnidirectionalFlowRecord;
lhsUnidirectionalFlowRecord = this.getUnidirectionalFlowRecord();
UnidirectionalRecordType rhsUnidirectionalFlowRecord;
rhsUnidirectionalFlowRecord = that.getUnidirectionalFlowRecord();
if (!strategy.equals(LocatorUtils.property(thisLocator,
"unidirectionalFlowRecord", lhsUnidirectionalFlowRecord),
LocatorUtils.property(thatLocator,
"unidirectionalFlowRecord",
rhsUnidirectionalFlowRecord),
lhsUnidirectionalFlowRecord, rhsUnidirectionalFlowRecord)) {
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 = super.hashCode(locator, strategy);
{
NetworkFlowLabelType theNetworkFlowLabel;
theNetworkFlowLabel = this.getNetworkFlowLabel();
currentHashCode = strategy.hashCode(LocatorUtils.property(locator,
"networkFlowLabel", theNetworkFlowLabel), currentHashCode,
theNetworkFlowLabel);
}
{
BidirectionalRecordType theBidirectionalFlowRecord;
theBidirectionalFlowRecord = this.getBidirectionalFlowRecord();
currentHashCode = strategy.hashCode(LocatorUtils.property(locator,
"bidirectionalFlowRecord", theBidirectionalFlowRecord),
currentHashCode, theBidirectionalFlowRecord);
}
{
UnidirectionalRecordType theUnidirectionalFlowRecord;
theUnidirectionalFlowRecord = this.getUnidirectionalFlowRecord();
currentHashCode = strategy.hashCode(LocatorUtils.property(locator,
"unidirectionalFlowRecord", theUnidirectionalFlowRecord),
currentHashCode, theUnidirectionalFlowRecord);
}
return currentHashCode;
}
public int hashCode() {
final HashCodeStrategy strategy = JAXBHashCodeStrategy.INSTANCE;
return this.hashCode(null, strategy);
}
public NetworkFlowObject withNetworkFlowLabel(NetworkFlowLabelType value) {
setNetworkFlowLabel(value);
return this;
}
public NetworkFlowObject withBidirectionalFlowRecord(
BidirectionalRecordType value) {
setBidirectionalFlowRecord(value);
return this;
}
public NetworkFlowObject withUnidirectionalFlowRecord(
UnidirectionalRecordType value) {
setUnidirectionalFlowRecord(value);
return this;
}
@Override
public NetworkFlowObject withCustomProperties(CustomPropertiesType value) {
setCustomProperties(value);
return this;
}
@Override
public NetworkFlowObject withObjectReference(QName value) {
setObjectReference(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) {
super.appendFields(locator, buffer, strategy);
{
NetworkFlowLabelType theNetworkFlowLabel;
theNetworkFlowLabel = this.getNetworkFlowLabel();
strategy.appendField(locator, this, "networkFlowLabel", buffer,
theNetworkFlowLabel);
}
{
BidirectionalRecordType theBidirectionalFlowRecord;
theBidirectionalFlowRecord = this.getBidirectionalFlowRecord();
strategy.appendField(locator, this, "bidirectionalFlowRecord",
buffer, theBidirectionalFlowRecord);
}
{
UnidirectionalRecordType theUnidirectionalFlowRecord;
theUnidirectionalFlowRecord = this.getUnidirectionalFlowRecord();
strategy.appendField(locator, this, "unidirectionalFlowRecord",
buffer, theUnidirectionalFlowRecord);
}
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, NetworkFlowObject.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 NetworkFlowObject instance for XML String
*
* @param text
* XML String for the document
* @return The NetworkFlowObject instance for the passed XML String
*/
public static NetworkFlowObject fromXMLString(String text) {
JAXBContext jaxbContext;
try {
jaxbContext = JAXBContext.newInstance(NetworkFlowObject.class
.getPackage().getName());
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
unmarshaller.setSchema(STIXSchema.getInstance().getSchema());
unmarshaller.setEventHandler(new ValidationEventHandler());
StreamSource streamSource = new StreamSource(new StringReader(text));
return (NetworkFlowObject) unmarshaller.unmarshal(streamSource);
} catch (JAXBException e) {
throw new RuntimeException(e);
}
}
/**
* Validates the XML representation of this NetworkFlowObject 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());
}
}