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

org.mitre.cybox.objects.NetworkSocket 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.06.23 at 10:59:44 AM 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.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.CustomPropertiesType;
import org.mitre.cybox.common_2.NonNegativeIntegerObjectPropertyType;
import org.mitre.cybox.common_2.ObjectPropertiesType;
import org.mitre.stix.DocumentUtilities;
import org.mitre.stix.STIXSchema;
import org.mitre.stix.ValidationEventHandler;

/**
 * The NetworkSocketObjectType is intended to characterize network sockets.
 * 
 * 

Java class for NetworkSocketObjectType complex type. * *

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

 * <complexType name="NetworkSocketObjectType">
 *   <complexContent>
 *     <extension base="{http://cybox.mitre.org/common-2}ObjectPropertiesType">
 *       <sequence>
 *         <element name="Address_Family" type="{http://cybox.mitre.org/objects#NetworkSocketObject-2}AddressFamilyType" minOccurs="0"/>
 *         <element name="Domain" type="{http://cybox.mitre.org/objects#NetworkSocketObject-2}DomainFamilyType" minOccurs="0"/>
 *         <element name="Local_Address" type="{http://cybox.mitre.org/objects#SocketAddressObject-1}SocketAddressObjectType" minOccurs="0"/>
 *         <element name="Options" type="{http://cybox.mitre.org/objects#NetworkSocketObject-2}SocketOptionsType" minOccurs="0"/>
 *         <element name="Protocol" type="{http://cybox.mitre.org/objects#NetworkSocketObject-2}ProtocolType" minOccurs="0"/>
 *         <element name="Remote_Address" type="{http://cybox.mitre.org/objects#SocketAddressObject-1}SocketAddressObjectType" minOccurs="0"/>
 *         <element name="Type" type="{http://cybox.mitre.org/objects#NetworkSocketObject-2}SocketType" minOccurs="0"/>
 *         <element name="Socket_Descriptor" type="{http://cybox.mitre.org/common-2}NonNegativeIntegerObjectPropertyType" minOccurs="0"/>
 *       </sequence>
 *       <attribute name="is_blocking" type="{http://www.w3.org/2001/XMLSchema}boolean" />
 *       <attribute name="is_listening" type="{http://www.w3.org/2001/XMLSchema}boolean" />
 *     </extension>
 *   </complexContent>
 * </complexType>
 * 
* * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "NetworkSocketObjectType", namespace = "http://cybox.mitre.org/objects#NetworkSocketObject-2", propOrder = { "addressFamily", "domain", "localAddress", "options", "protocol", "remoteAddress", "type", "socketDescriptor" }) @XmlRootElement(name = "Network_Socket", namespace = "http://cybox.mitre.org/objects#NetworkSocketObject-2") public class NetworkSocket extends ObjectPropertiesType implements Equals, HashCode, ToString { @XmlElement(name = "Address_Family") protected AddressFamilyType addressFamily; @XmlElement(name = "Domain") protected DomainFamilyType domain; @XmlElement(name = "Local_Address") protected SocketAddress localAddress; @XmlElement(name = "Options") protected SocketOptionsType options; @XmlElement(name = "Protocol") protected ProtocolType protocol; @XmlElement(name = "Remote_Address") protected SocketAddress remoteAddress; @XmlElement(name = "Type") protected SocketType type; @XmlElement(name = "Socket_Descriptor") protected NonNegativeIntegerObjectPropertyType socketDescriptor; @XmlAttribute(name = "is_blocking") protected Boolean isBlocking; @XmlAttribute(name = "is_listening") protected Boolean isListening; /** * Default no-arg constructor * */ public NetworkSocket() { super(); } /** * Fully-initialising value constructor * */ public NetworkSocket(final CustomPropertiesType customProperties, final QName objectReference, final AddressFamilyType addressFamily, final DomainFamilyType domain, final SocketAddress localAddress, final SocketOptionsType options, final ProtocolType protocol, final SocketAddress remoteAddress, final SocketType type, final NonNegativeIntegerObjectPropertyType socketDescriptor, final Boolean isBlocking, final Boolean isListening) { super(customProperties, objectReference); this.addressFamily = addressFamily; this.domain = domain; this.localAddress = localAddress; this.options = options; this.protocol = protocol; this.remoteAddress = remoteAddress; this.type = type; this.socketDescriptor = socketDescriptor; this.isBlocking = isBlocking; this.isListening = isListening; } /** * Gets the value of the addressFamily property. * * @return * possible object is * {@link AddressFamilyType } * */ public AddressFamilyType getAddressFamily() { return addressFamily; } /** * Sets the value of the addressFamily property. * * @param value * allowed object is * {@link AddressFamilyType } * */ public void setAddressFamily(AddressFamilyType value) { this.addressFamily = value; } /** * Gets the value of the domain property. * * @return * possible object is * {@link DomainFamilyType } * */ public DomainFamilyType getDomain() { return domain; } /** * Sets the value of the domain property. * * @param value * allowed object is * {@link DomainFamilyType } * */ public void setDomain(DomainFamilyType value) { this.domain = value; } /** * Gets the value of the localAddress property. * * @return * possible object is * {@link SocketAddress } * */ public SocketAddress getLocalAddress() { return localAddress; } /** * Sets the value of the localAddress property. * * @param value * allowed object is * {@link SocketAddress } * */ public void setLocalAddress(SocketAddress value) { this.localAddress = value; } /** * Gets the value of the options property. * * @return * possible object is * {@link SocketOptionsType } * */ public SocketOptionsType getOptions() { return options; } /** * Sets the value of the options property. * * @param value * allowed object is * {@link SocketOptionsType } * */ public void setOptions(SocketOptionsType value) { this.options = value; } /** * Gets the value of the protocol property. * * @return * possible object is * {@link ProtocolType } * */ public ProtocolType getProtocol() { return protocol; } /** * Sets the value of the protocol property. * * @param value * allowed object is * {@link ProtocolType } * */ public void setProtocol(ProtocolType value) { this.protocol = value; } /** * Gets the value of the remoteAddress property. * * @return * possible object is * {@link SocketAddress } * */ public SocketAddress getRemoteAddress() { return remoteAddress; } /** * Sets the value of the remoteAddress property. * * @param value * allowed object is * {@link SocketAddress } * */ public void setRemoteAddress(SocketAddress value) { this.remoteAddress = value; } /** * Gets the value of the type property. * * @return * possible object is * {@link SocketType } * */ public SocketType getType() { return type; } /** * Sets the value of the type property. * * @param value * allowed object is * {@link SocketType } * */ public void setType(SocketType value) { this.type = value; } /** * Gets the value of the socketDescriptor property. * * @return * possible object is * {@link NonNegativeIntegerObjectPropertyType } * */ public NonNegativeIntegerObjectPropertyType getSocketDescriptor() { return socketDescriptor; } /** * Sets the value of the socketDescriptor property. * * @param value * allowed object is * {@link NonNegativeIntegerObjectPropertyType } * */ public void setSocketDescriptor(NonNegativeIntegerObjectPropertyType value) { this.socketDescriptor = value; } /** * Gets the value of the isBlocking property. * * @return * possible object is * {@link Boolean } * */ public Boolean isIsBlocking() { return isBlocking; } /** * Sets the value of the isBlocking property. * * @param value * allowed object is * {@link Boolean } * */ public void setIsBlocking(Boolean value) { this.isBlocking = value; } /** * Gets the value of the isListening property. * * @return * possible object is * {@link Boolean } * */ public Boolean isIsListening() { return isListening; } /** * Sets the value of the isListening property. * * @param value * allowed object is * {@link Boolean } * */ public void setIsListening(Boolean value) { this.isListening = value; } public boolean equals(ObjectLocator thisLocator, ObjectLocator thatLocator, Object object, EqualsStrategy strategy) { if (!(object instanceof NetworkSocket)) { return false; } if (this == object) { return true; } if (!super.equals(thisLocator, thatLocator, object, strategy)) { return false; } final NetworkSocket that = ((NetworkSocket) object); { AddressFamilyType lhsAddressFamily; lhsAddressFamily = this.getAddressFamily(); AddressFamilyType rhsAddressFamily; rhsAddressFamily = that.getAddressFamily(); if (!strategy.equals(LocatorUtils.property(thisLocator, "addressFamily", lhsAddressFamily), LocatorUtils.property( thatLocator, "addressFamily", rhsAddressFamily), lhsAddressFamily, rhsAddressFamily)) { return false; } } { DomainFamilyType lhsDomain; lhsDomain = this.getDomain(); DomainFamilyType rhsDomain; rhsDomain = that.getDomain(); if (!strategy.equals( LocatorUtils.property(thisLocator, "domain", lhsDomain), LocatorUtils.property(thatLocator, "domain", rhsDomain), lhsDomain, rhsDomain)) { return false; } } { SocketAddress lhsLocalAddress; lhsLocalAddress = this.getLocalAddress(); SocketAddress rhsLocalAddress; rhsLocalAddress = that.getLocalAddress(); if (!strategy.equals(LocatorUtils.property(thisLocator, "localAddress", lhsLocalAddress), LocatorUtils.property( thatLocator, "localAddress", rhsLocalAddress), lhsLocalAddress, rhsLocalAddress)) { return false; } } { SocketOptionsType lhsOptions; lhsOptions = this.getOptions(); SocketOptionsType rhsOptions; rhsOptions = that.getOptions(); if (!strategy.equals( LocatorUtils.property(thisLocator, "options", lhsOptions), LocatorUtils.property(thatLocator, "options", rhsOptions), lhsOptions, rhsOptions)) { return false; } } { ProtocolType lhsProtocol; lhsProtocol = this.getProtocol(); ProtocolType rhsProtocol; rhsProtocol = that.getProtocol(); if (!strategy .equals(LocatorUtils.property(thisLocator, "protocol", lhsProtocol), LocatorUtils.property(thatLocator, "protocol", rhsProtocol), lhsProtocol, rhsProtocol)) { return false; } } { SocketAddress lhsRemoteAddress; lhsRemoteAddress = this.getRemoteAddress(); SocketAddress rhsRemoteAddress; rhsRemoteAddress = that.getRemoteAddress(); if (!strategy.equals(LocatorUtils.property(thisLocator, "remoteAddress", lhsRemoteAddress), LocatorUtils.property( thatLocator, "remoteAddress", rhsRemoteAddress), lhsRemoteAddress, rhsRemoteAddress)) { return false; } } { SocketType lhsType; lhsType = this.getType(); SocketType rhsType; rhsType = that.getType(); if (!strategy.equals( LocatorUtils.property(thisLocator, "type", lhsType), LocatorUtils.property(thatLocator, "type", rhsType), lhsType, rhsType)) { return false; } } { NonNegativeIntegerObjectPropertyType lhsSocketDescriptor; lhsSocketDescriptor = this.getSocketDescriptor(); NonNegativeIntegerObjectPropertyType rhsSocketDescriptor; rhsSocketDescriptor = that.getSocketDescriptor(); if (!strategy.equals(LocatorUtils.property(thisLocator, "socketDescriptor", lhsSocketDescriptor), LocatorUtils .property(thatLocator, "socketDescriptor", rhsSocketDescriptor), lhsSocketDescriptor, rhsSocketDescriptor)) { return false; } } { Boolean lhsIsBlocking; lhsIsBlocking = this.isIsBlocking(); Boolean rhsIsBlocking; rhsIsBlocking = that.isIsBlocking(); if (!strategy.equals(LocatorUtils.property(thisLocator, "isBlocking", lhsIsBlocking), LocatorUtils.property( thatLocator, "isBlocking", rhsIsBlocking), lhsIsBlocking, rhsIsBlocking)) { return false; } } { Boolean lhsIsListening; lhsIsListening = this.isIsListening(); Boolean rhsIsListening; rhsIsListening = that.isIsListening(); if (!strategy.equals(LocatorUtils.property(thisLocator, "isListening", lhsIsListening), LocatorUtils.property( thatLocator, "isListening", rhsIsListening), lhsIsListening, rhsIsListening)) { 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); { AddressFamilyType theAddressFamily; theAddressFamily = this.getAddressFamily(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "addressFamily", theAddressFamily), currentHashCode, theAddressFamily); } { DomainFamilyType theDomain; theDomain = this.getDomain(); currentHashCode = strategy.hashCode( LocatorUtils.property(locator, "domain", theDomain), currentHashCode, theDomain); } { SocketAddress theLocalAddress; theLocalAddress = this.getLocalAddress(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "localAddress", theLocalAddress), currentHashCode, theLocalAddress); } { SocketOptionsType theOptions; theOptions = this.getOptions(); currentHashCode = strategy.hashCode( LocatorUtils.property(locator, "options", theOptions), currentHashCode, theOptions); } { ProtocolType theProtocol; theProtocol = this.getProtocol(); currentHashCode = strategy.hashCode( LocatorUtils.property(locator, "protocol", theProtocol), currentHashCode, theProtocol); } { SocketAddress theRemoteAddress; theRemoteAddress = this.getRemoteAddress(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "remoteAddress", theRemoteAddress), currentHashCode, theRemoteAddress); } { SocketType theType; theType = this.getType(); currentHashCode = strategy.hashCode( LocatorUtils.property(locator, "type", theType), currentHashCode, theType); } { NonNegativeIntegerObjectPropertyType theSocketDescriptor; theSocketDescriptor = this.getSocketDescriptor(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "socketDescriptor", theSocketDescriptor), currentHashCode, theSocketDescriptor); } { Boolean theIsBlocking; theIsBlocking = this.isIsBlocking(); currentHashCode = strategy .hashCode(LocatorUtils.property(locator, "isBlocking", theIsBlocking), currentHashCode, theIsBlocking); } { Boolean theIsListening; theIsListening = this.isIsListening(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "isListening", theIsListening), currentHashCode, theIsListening); } return currentHashCode; } public int hashCode() { final HashCodeStrategy strategy = JAXBHashCodeStrategy.INSTANCE; return this.hashCode(null, strategy); } public NetworkSocket withAddressFamily(AddressFamilyType value) { setAddressFamily(value); return this; } public NetworkSocket withDomain(DomainFamilyType value) { setDomain(value); return this; } public NetworkSocket withLocalAddress(SocketAddress value) { setLocalAddress(value); return this; } public NetworkSocket withOptions(SocketOptionsType value) { setOptions(value); return this; } public NetworkSocket withProtocol(ProtocolType value) { setProtocol(value); return this; } public NetworkSocket withRemoteAddress(SocketAddress value) { setRemoteAddress(value); return this; } public NetworkSocket withType(SocketType value) { setType(value); return this; } public NetworkSocket withSocketDescriptor( NonNegativeIntegerObjectPropertyType value) { setSocketDescriptor(value); return this; } public NetworkSocket withIsBlocking(Boolean value) { setIsBlocking(value); return this; } public NetworkSocket withIsListening(Boolean value) { setIsListening(value); return this; } @Override public NetworkSocket withCustomProperties(CustomPropertiesType value) { setCustomProperties(value); return this; } @Override public NetworkSocket 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); { AddressFamilyType theAddressFamily; theAddressFamily = this.getAddressFamily(); strategy.appendField(locator, this, "addressFamily", buffer, theAddressFamily); } { DomainFamilyType theDomain; theDomain = this.getDomain(); strategy.appendField(locator, this, "domain", buffer, theDomain); } { SocketAddress theLocalAddress; theLocalAddress = this.getLocalAddress(); strategy.appendField(locator, this, "localAddress", buffer, theLocalAddress); } { SocketOptionsType theOptions; theOptions = this.getOptions(); strategy.appendField(locator, this, "options", buffer, theOptions); } { ProtocolType theProtocol; theProtocol = this.getProtocol(); strategy.appendField(locator, this, "protocol", buffer, theProtocol); } { SocketAddress theRemoteAddress; theRemoteAddress = this.getRemoteAddress(); strategy.appendField(locator, this, "remoteAddress", buffer, theRemoteAddress); } { SocketType theType; theType = this.getType(); strategy.appendField(locator, this, "type", buffer, theType); } { NonNegativeIntegerObjectPropertyType theSocketDescriptor; theSocketDescriptor = this.getSocketDescriptor(); strategy.appendField(locator, this, "socketDescriptor", buffer, theSocketDescriptor); } { Boolean theIsBlocking; theIsBlocking = this.isIsBlocking(); strategy.appendField(locator, this, "isBlocking", buffer, theIsBlocking); } { Boolean theIsListening; theIsListening = this.isIsListening(); strategy.appendField(locator, this, "isListening", buffer, theIsListening); } 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, NetworkSocket.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 NetworkSocket instance for XML String * * @param text * XML String for the document * @return The NetworkSocket instance for the passed XML String */ public static NetworkSocket fromXMLString(String text) { JAXBContext jaxbContext; try { jaxbContext = JAXBContext.newInstance(NetworkSocket.class .getPackage().getName()); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); unmarshaller.setSchema(STIXSchema.getInstance().getSchema()); unmarshaller.setEventHandler(new ValidationEventHandler()); StreamSource streamSource = new StreamSource(new StringReader(text)); return (NetworkSocket) unmarshaller.unmarshal(streamSource); } catch (JAXBException e) { throw new RuntimeException(e); } } /** * Validates the XML representation of this NetworkSocket instance * Returning true indicating a successful validation, false if not. * * @return boolean */ public boolean validate() { return STIXSchema.getInstance().validate(toXMLString()); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy