org.mitre.cybox.objects.NetworkConnection 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.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.DateTimeObjectPropertyType;
import org.mitre.cybox.common_2.Layer4ProtocolType;
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;
/**
* The NetworkConnectionObjectType is intended as a way of characterizing local or remote (i.e. Internet) network connections.
*
* Java class for NetworkConnectionObjectType complex type.
*
*
The following schema fragment specifies the expected content contained within this class.
*
*
* <complexType name="NetworkConnectionObjectType">
* <complexContent>
* <extension base="{http://cybox.mitre.org/common-2}ObjectPropertiesType">
* <sequence>
* <element name="Creation_Time" type="{http://cybox.mitre.org/common-2}DateTimeObjectPropertyType" minOccurs="0"/>
* <element name="Layer3_Protocol" type="{http://cybox.mitre.org/objects#NetworkConnectionObject-2}Layer3ProtocolType" minOccurs="0"/>
* <element name="Layer4_Protocol" type="{http://cybox.mitre.org/common-2}Layer4ProtocolType" minOccurs="0"/>
* <element name="Layer7_Protocol" type="{http://cybox.mitre.org/objects#NetworkConnectionObject-2}Layer7ProtocolType" minOccurs="0"/>
* <element name="Source_Socket_Address" type="{http://cybox.mitre.org/objects#SocketAddressObject-1}SocketAddressObjectType" minOccurs="0"/>
* <element name="Source_TCP_State" type="{http://cybox.mitre.org/objects#NetworkConnectionObject-2}TCPStateEnum" minOccurs="0"/>
* <element name="Destination_Socket_Address" type="{http://cybox.mitre.org/objects#SocketAddressObject-1}SocketAddressObjectType" minOccurs="0"/>
* <element name="Destination_TCP_State" type="{http://cybox.mitre.org/objects#NetworkConnectionObject-2}TCPStateEnum" minOccurs="0"/>
* <element name="Layer7_Connections" type="{http://cybox.mitre.org/objects#NetworkConnectionObject-2}Layer7ConnectionsType" minOccurs="0"/>
* </sequence>
* <attribute name="tls_used" type="{http://www.w3.org/2001/XMLSchema}boolean" />
* </extension>
* </complexContent>
* </complexType>
*
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "NetworkConnectionObjectType", namespace = "http://cybox.mitre.org/objects#NetworkConnectionObject-2", propOrder = {
"creationTime", "layer3Protocol", "layer4Protocol", "layer7Protocol",
"sourceSocketAddress", "sourceTCPState", "destinationSocketAddress",
"destinationTCPState", "layer7Connections" })
@XmlRootElement(name = "Network_Connection", namespace = "http://cybox.mitre.org/objects#NetworkConnectionObject-2")
public class NetworkConnection extends ObjectPropertiesType implements Equals,
HashCode, ToString {
@XmlElement(name = "Creation_Time")
protected DateTimeObjectPropertyType creationTime;
@XmlElement(name = "Layer3_Protocol")
protected Layer3ProtocolType layer3Protocol;
@XmlElement(name = "Layer4_Protocol")
protected Layer4ProtocolType layer4Protocol;
@XmlElement(name = "Layer7_Protocol")
protected Layer7ProtocolType layer7Protocol;
@XmlElement(name = "Source_Socket_Address")
protected SocketAddress sourceSocketAddress;
@XmlElement(name = "Source_TCP_State")
protected TCPStateEnum sourceTCPState;
@XmlElement(name = "Destination_Socket_Address")
protected SocketAddress destinationSocketAddress;
@XmlElement(name = "Destination_TCP_State")
protected TCPStateEnum destinationTCPState;
@XmlElement(name = "Layer7_Connections")
protected Layer7ConnectionsType layer7Connections;
@XmlAttribute(name = "tls_used")
protected Boolean tlsUsed;
/**
* Default no-arg constructor
*
*/
public NetworkConnection() {
super();
}
/**
* Fully-initialising value constructor
*
*/
public NetworkConnection(final CustomPropertiesType customProperties,
final QName objectReference,
final DateTimeObjectPropertyType creationTime,
final Layer3ProtocolType layer3Protocol,
final Layer4ProtocolType layer4Protocol,
final Layer7ProtocolType layer7Protocol,
final SocketAddress sourceSocketAddress,
final TCPStateEnum sourceTCPState,
final SocketAddress destinationSocketAddress,
final TCPStateEnum destinationTCPState,
final Layer7ConnectionsType layer7Connections, final Boolean tlsUsed) {
super(customProperties, objectReference);
this.creationTime = creationTime;
this.layer3Protocol = layer3Protocol;
this.layer4Protocol = layer4Protocol;
this.layer7Protocol = layer7Protocol;
this.sourceSocketAddress = sourceSocketAddress;
this.sourceTCPState = sourceTCPState;
this.destinationSocketAddress = destinationSocketAddress;
this.destinationTCPState = destinationTCPState;
this.layer7Connections = layer7Connections;
this.tlsUsed = tlsUsed;
}
/**
* Gets the value of the creationTime property.
*
* @return
* possible object is
* {@link DateTimeObjectPropertyType }
*
*/
public DateTimeObjectPropertyType getCreationTime() {
return creationTime;
}
/**
* Sets the value of the creationTime property.
*
* @param value
* allowed object is
* {@link DateTimeObjectPropertyType }
*
*/
public void setCreationTime(DateTimeObjectPropertyType value) {
this.creationTime = value;
}
/**
* Gets the value of the layer3Protocol property.
*
* @return
* possible object is
* {@link Layer3ProtocolType }
*
*/
public Layer3ProtocolType getLayer3Protocol() {
return layer3Protocol;
}
/**
* Sets the value of the layer3Protocol property.
*
* @param value
* allowed object is
* {@link Layer3ProtocolType }
*
*/
public void setLayer3Protocol(Layer3ProtocolType value) {
this.layer3Protocol = value;
}
/**
* Gets the value of the layer4Protocol property.
*
* @return
* possible object is
* {@link Layer4ProtocolType }
*
*/
public Layer4ProtocolType getLayer4Protocol() {
return layer4Protocol;
}
/**
* Sets the value of the layer4Protocol property.
*
* @param value
* allowed object is
* {@link Layer4ProtocolType }
*
*/
public void setLayer4Protocol(Layer4ProtocolType value) {
this.layer4Protocol = value;
}
/**
* Gets the value of the layer7Protocol property.
*
* @return
* possible object is
* {@link Layer7ProtocolType }
*
*/
public Layer7ProtocolType getLayer7Protocol() {
return layer7Protocol;
}
/**
* Sets the value of the layer7Protocol property.
*
* @param value
* allowed object is
* {@link Layer7ProtocolType }
*
*/
public void setLayer7Protocol(Layer7ProtocolType value) {
this.layer7Protocol = value;
}
/**
* Gets the value of the sourceSocketAddress property.
*
* @return
* possible object is
* {@link SocketAddress }
*
*/
public SocketAddress getSourceSocketAddress() {
return sourceSocketAddress;
}
/**
* Sets the value of the sourceSocketAddress property.
*
* @param value
* allowed object is
* {@link SocketAddress }
*
*/
public void setSourceSocketAddress(SocketAddress value) {
this.sourceSocketAddress = value;
}
/**
* Gets the value of the sourceTCPState property.
*
* @return
* possible object is
* {@link TCPStateEnum }
*
*/
public TCPStateEnum getSourceTCPState() {
return sourceTCPState;
}
/**
* Sets the value of the sourceTCPState property.
*
* @param value
* allowed object is
* {@link TCPStateEnum }
*
*/
public void setSourceTCPState(TCPStateEnum value) {
this.sourceTCPState = value;
}
/**
* Gets the value of the destinationSocketAddress property.
*
* @return
* possible object is
* {@link SocketAddress }
*
*/
public SocketAddress getDestinationSocketAddress() {
return destinationSocketAddress;
}
/**
* Sets the value of the destinationSocketAddress property.
*
* @param value
* allowed object is
* {@link SocketAddress }
*
*/
public void setDestinationSocketAddress(SocketAddress value) {
this.destinationSocketAddress = value;
}
/**
* Gets the value of the destinationTCPState property.
*
* @return
* possible object is
* {@link TCPStateEnum }
*
*/
public TCPStateEnum getDestinationTCPState() {
return destinationTCPState;
}
/**
* Sets the value of the destinationTCPState property.
*
* @param value
* allowed object is
* {@link TCPStateEnum }
*
*/
public void setDestinationTCPState(TCPStateEnum value) {
this.destinationTCPState = value;
}
/**
* Gets the value of the layer7Connections property.
*
* @return
* possible object is
* {@link Layer7ConnectionsType }
*
*/
public Layer7ConnectionsType getLayer7Connections() {
return layer7Connections;
}
/**
* Sets the value of the layer7Connections property.
*
* @param value
* allowed object is
* {@link Layer7ConnectionsType }
*
*/
public void setLayer7Connections(Layer7ConnectionsType value) {
this.layer7Connections = value;
}
/**
* Gets the value of the tlsUsed property.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean isTlsUsed() {
return tlsUsed;
}
/**
* Sets the value of the tlsUsed property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setTlsUsed(Boolean value) {
this.tlsUsed = value;
}
public boolean equals(ObjectLocator thisLocator, ObjectLocator thatLocator,
Object object, EqualsStrategy strategy) {
if (!(object instanceof NetworkConnection)) {
return false;
}
if (this == object) {
return true;
}
if (!super.equals(thisLocator, thatLocator, object, strategy)) {
return false;
}
final NetworkConnection that = ((NetworkConnection) object);
{
DateTimeObjectPropertyType lhsCreationTime;
lhsCreationTime = this.getCreationTime();
DateTimeObjectPropertyType rhsCreationTime;
rhsCreationTime = that.getCreationTime();
if (!strategy.equals(LocatorUtils.property(thisLocator,
"creationTime", lhsCreationTime), LocatorUtils.property(
thatLocator, "creationTime", rhsCreationTime),
lhsCreationTime, rhsCreationTime)) {
return false;
}
}
{
Layer3ProtocolType lhsLayer3Protocol;
lhsLayer3Protocol = this.getLayer3Protocol();
Layer3ProtocolType rhsLayer3Protocol;
rhsLayer3Protocol = that.getLayer3Protocol();
if (!strategy.equals(LocatorUtils.property(thisLocator,
"layer3Protocol", lhsLayer3Protocol),
LocatorUtils.property(thatLocator, "layer3Protocol",
rhsLayer3Protocol), lhsLayer3Protocol,
rhsLayer3Protocol)) {
return false;
}
}
{
Layer4ProtocolType lhsLayer4Protocol;
lhsLayer4Protocol = this.getLayer4Protocol();
Layer4ProtocolType rhsLayer4Protocol;
rhsLayer4Protocol = that.getLayer4Protocol();
if (!strategy.equals(LocatorUtils.property(thisLocator,
"layer4Protocol", lhsLayer4Protocol),
LocatorUtils.property(thatLocator, "layer4Protocol",
rhsLayer4Protocol), lhsLayer4Protocol,
rhsLayer4Protocol)) {
return false;
}
}
{
Layer7ProtocolType lhsLayer7Protocol;
lhsLayer7Protocol = this.getLayer7Protocol();
Layer7ProtocolType rhsLayer7Protocol;
rhsLayer7Protocol = that.getLayer7Protocol();
if (!strategy.equals(LocatorUtils.property(thisLocator,
"layer7Protocol", lhsLayer7Protocol),
LocatorUtils.property(thatLocator, "layer7Protocol",
rhsLayer7Protocol), lhsLayer7Protocol,
rhsLayer7Protocol)) {
return false;
}
}
{
SocketAddress lhsSourceSocketAddress;
lhsSourceSocketAddress = this.getSourceSocketAddress();
SocketAddress rhsSourceSocketAddress;
rhsSourceSocketAddress = that.getSourceSocketAddress();
if (!strategy.equals(LocatorUtils.property(thisLocator,
"sourceSocketAddress", lhsSourceSocketAddress),
LocatorUtils.property(thatLocator, "sourceSocketAddress",
rhsSourceSocketAddress), lhsSourceSocketAddress,
rhsSourceSocketAddress)) {
return false;
}
}
{
TCPStateEnum lhsSourceTCPState;
lhsSourceTCPState = this.getSourceTCPState();
TCPStateEnum rhsSourceTCPState;
rhsSourceTCPState = that.getSourceTCPState();
if (!strategy.equals(LocatorUtils.property(thisLocator,
"sourceTCPState", lhsSourceTCPState),
LocatorUtils.property(thatLocator, "sourceTCPState",
rhsSourceTCPState), lhsSourceTCPState,
rhsSourceTCPState)) {
return false;
}
}
{
SocketAddress lhsDestinationSocketAddress;
lhsDestinationSocketAddress = this.getDestinationSocketAddress();
SocketAddress rhsDestinationSocketAddress;
rhsDestinationSocketAddress = that.getDestinationSocketAddress();
if (!strategy.equals(LocatorUtils.property(thisLocator,
"destinationSocketAddress", lhsDestinationSocketAddress),
LocatorUtils.property(thatLocator,
"destinationSocketAddress",
rhsDestinationSocketAddress),
lhsDestinationSocketAddress, rhsDestinationSocketAddress)) {
return false;
}
}
{
TCPStateEnum lhsDestinationTCPState;
lhsDestinationTCPState = this.getDestinationTCPState();
TCPStateEnum rhsDestinationTCPState;
rhsDestinationTCPState = that.getDestinationTCPState();
if (!strategy.equals(LocatorUtils.property(thisLocator,
"destinationTCPState", lhsDestinationTCPState),
LocatorUtils.property(thatLocator, "destinationTCPState",
rhsDestinationTCPState), lhsDestinationTCPState,
rhsDestinationTCPState)) {
return false;
}
}
{
Layer7ConnectionsType lhsLayer7Connections;
lhsLayer7Connections = this.getLayer7Connections();
Layer7ConnectionsType rhsLayer7Connections;
rhsLayer7Connections = that.getLayer7Connections();
if (!strategy.equals(LocatorUtils.property(thisLocator,
"layer7Connections", lhsLayer7Connections), LocatorUtils
.property(thatLocator, "layer7Connections",
rhsLayer7Connections), lhsLayer7Connections,
rhsLayer7Connections)) {
return false;
}
}
{
Boolean lhsTlsUsed;
lhsTlsUsed = this.isTlsUsed();
Boolean rhsTlsUsed;
rhsTlsUsed = that.isTlsUsed();
if (!strategy.equals(
LocatorUtils.property(thisLocator, "tlsUsed", lhsTlsUsed),
LocatorUtils.property(thatLocator, "tlsUsed", rhsTlsUsed),
lhsTlsUsed, rhsTlsUsed)) {
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);
{
DateTimeObjectPropertyType theCreationTime;
theCreationTime = this.getCreationTime();
currentHashCode = strategy.hashCode(LocatorUtils.property(locator,
"creationTime", theCreationTime), currentHashCode,
theCreationTime);
}
{
Layer3ProtocolType theLayer3Protocol;
theLayer3Protocol = this.getLayer3Protocol();
currentHashCode = strategy.hashCode(LocatorUtils.property(locator,
"layer3Protocol", theLayer3Protocol), currentHashCode,
theLayer3Protocol);
}
{
Layer4ProtocolType theLayer4Protocol;
theLayer4Protocol = this.getLayer4Protocol();
currentHashCode = strategy.hashCode(LocatorUtils.property(locator,
"layer4Protocol", theLayer4Protocol), currentHashCode,
theLayer4Protocol);
}
{
Layer7ProtocolType theLayer7Protocol;
theLayer7Protocol = this.getLayer7Protocol();
currentHashCode = strategy.hashCode(LocatorUtils.property(locator,
"layer7Protocol", theLayer7Protocol), currentHashCode,
theLayer7Protocol);
}
{
SocketAddress theSourceSocketAddress;
theSourceSocketAddress = this.getSourceSocketAddress();
currentHashCode = strategy.hashCode(LocatorUtils.property(locator,
"sourceSocketAddress", theSourceSocketAddress),
currentHashCode, theSourceSocketAddress);
}
{
TCPStateEnum theSourceTCPState;
theSourceTCPState = this.getSourceTCPState();
currentHashCode = strategy.hashCode(LocatorUtils.property(locator,
"sourceTCPState", theSourceTCPState), currentHashCode,
theSourceTCPState);
}
{
SocketAddress theDestinationSocketAddress;
theDestinationSocketAddress = this.getDestinationSocketAddress();
currentHashCode = strategy.hashCode(LocatorUtils.property(locator,
"destinationSocketAddress", theDestinationSocketAddress),
currentHashCode, theDestinationSocketAddress);
}
{
TCPStateEnum theDestinationTCPState;
theDestinationTCPState = this.getDestinationTCPState();
currentHashCode = strategy.hashCode(LocatorUtils.property(locator,
"destinationTCPState", theDestinationTCPState),
currentHashCode, theDestinationTCPState);
}
{
Layer7ConnectionsType theLayer7Connections;
theLayer7Connections = this.getLayer7Connections();
currentHashCode = strategy.hashCode(LocatorUtils.property(locator,
"layer7Connections", theLayer7Connections),
currentHashCode, theLayer7Connections);
}
{
Boolean theTlsUsed;
theTlsUsed = this.isTlsUsed();
currentHashCode = strategy.hashCode(
LocatorUtils.property(locator, "tlsUsed", theTlsUsed),
currentHashCode, theTlsUsed);
}
return currentHashCode;
}
public int hashCode() {
final HashCodeStrategy strategy = JAXBHashCodeStrategy.INSTANCE;
return this.hashCode(null, strategy);
}
public NetworkConnection withCreationTime(DateTimeObjectPropertyType value) {
setCreationTime(value);
return this;
}
public NetworkConnection withLayer3Protocol(Layer3ProtocolType value) {
setLayer3Protocol(value);
return this;
}
public NetworkConnection withLayer4Protocol(Layer4ProtocolType value) {
setLayer4Protocol(value);
return this;
}
public NetworkConnection withLayer7Protocol(Layer7ProtocolType value) {
setLayer7Protocol(value);
return this;
}
public NetworkConnection withSourceSocketAddress(SocketAddress value) {
setSourceSocketAddress(value);
return this;
}
public NetworkConnection withSourceTCPState(TCPStateEnum value) {
setSourceTCPState(value);
return this;
}
public NetworkConnection withDestinationSocketAddress(SocketAddress value) {
setDestinationSocketAddress(value);
return this;
}
public NetworkConnection withDestinationTCPState(TCPStateEnum value) {
setDestinationTCPState(value);
return this;
}
public NetworkConnection withLayer7Connections(Layer7ConnectionsType value) {
setLayer7Connections(value);
return this;
}
public NetworkConnection withTlsUsed(Boolean value) {
setTlsUsed(value);
return this;
}
@Override
public NetworkConnection withCustomProperties(CustomPropertiesType value) {
setCustomProperties(value);
return this;
}
@Override
public NetworkConnection 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);
{
DateTimeObjectPropertyType theCreationTime;
theCreationTime = this.getCreationTime();
strategy.appendField(locator, this, "creationTime", buffer,
theCreationTime);
}
{
Layer3ProtocolType theLayer3Protocol;
theLayer3Protocol = this.getLayer3Protocol();
strategy.appendField(locator, this, "layer3Protocol", buffer,
theLayer3Protocol);
}
{
Layer4ProtocolType theLayer4Protocol;
theLayer4Protocol = this.getLayer4Protocol();
strategy.appendField(locator, this, "layer4Protocol", buffer,
theLayer4Protocol);
}
{
Layer7ProtocolType theLayer7Protocol;
theLayer7Protocol = this.getLayer7Protocol();
strategy.appendField(locator, this, "layer7Protocol", buffer,
theLayer7Protocol);
}
{
SocketAddress theSourceSocketAddress;
theSourceSocketAddress = this.getSourceSocketAddress();
strategy.appendField(locator, this, "sourceSocketAddress", buffer,
theSourceSocketAddress);
}
{
TCPStateEnum theSourceTCPState;
theSourceTCPState = this.getSourceTCPState();
strategy.appendField(locator, this, "sourceTCPState", buffer,
theSourceTCPState);
}
{
SocketAddress theDestinationSocketAddress;
theDestinationSocketAddress = this.getDestinationSocketAddress();
strategy.appendField(locator, this, "destinationSocketAddress",
buffer, theDestinationSocketAddress);
}
{
TCPStateEnum theDestinationTCPState;
theDestinationTCPState = this.getDestinationTCPState();
strategy.appendField(locator, this, "destinationTCPState", buffer,
theDestinationTCPState);
}
{
Layer7ConnectionsType theLayer7Connections;
theLayer7Connections = this.getLayer7Connections();
strategy.appendField(locator, this, "layer7Connections", buffer,
theLayer7Connections);
}
{
Boolean theTlsUsed;
theTlsUsed = this.isTlsUsed();
strategy.appendField(locator, this, "tlsUsed", buffer, theTlsUsed);
}
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, NetworkConnection.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 NetworkConnection instance for XML String
*
* @param text
* XML String for the document
* @return The NetworkConnection instance for the passed XML String
*/
public static NetworkConnection fromXMLString(String text) {
JAXBContext jaxbContext;
try {
jaxbContext = JAXBContext.newInstance(NetworkConnection.class
.getPackage().getName());
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
unmarshaller.setSchema(STIXSchema.getInstance().getSchema());
unmarshaller.setEventHandler(new ValidationEventHandler());
StreamSource streamSource = new StreamSource(new StringReader(text));
return (NetworkConnection) unmarshaller.unmarshal(streamSource);
} catch (JAXBException e) {
throw new RuntimeException(e);
}
}
/**
* Validates the XML representation of this NetworkConnection 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());
}
}