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

org.mitre.cybox.objects.EmailMessage 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.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.cybox.common_2.StringObjectPropertyType;
import org.mitre.stix.DocumentUtilities;
import org.mitre.stix.STIXSchema;
import org.mitre.stix.ValidationEventHandler;
import org.xml.sax.SAXException;

/**
 * The EmailMessageObjectType type is intended to characterize an individual email message.
 * 
 * 

Java class for EmailMessageObjectType complex type. * *

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

 * <complexType name="EmailMessageObjectType">
 *   <complexContent>
 *     <extension base="{http://cybox.mitre.org/common-2}ObjectPropertiesType">
 *       <sequence>
 *         <element name="Header" type="{http://cybox.mitre.org/objects#EmailMessageObject-2}EmailHeaderType" minOccurs="0"/>
 *         <element name="Email_Server" type="{http://cybox.mitre.org/common-2}StringObjectPropertyType" minOccurs="0"/>
 *         <element name="Raw_Body" type="{http://cybox.mitre.org/common-2}StringObjectPropertyType" minOccurs="0"/>
 *         <element name="Raw_Header" type="{http://cybox.mitre.org/common-2}StringObjectPropertyType" minOccurs="0"/>
 *         <element name="Attachments" type="{http://cybox.mitre.org/objects#EmailMessageObject-2}AttachmentsType" minOccurs="0"/>
 *         <element name="Links" type="{http://cybox.mitre.org/objects#EmailMessageObject-2}LinksType" minOccurs="0"/>
 *       </sequence>
 *     </extension>
 *   </complexContent>
 * </complexType>
 * 
* * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "EmailMessageObjectType", namespace = "http://cybox.mitre.org/objects#EmailMessageObject-2", propOrder = { "header", "emailServer", "rawBody", "rawHeader", "attachments", "links" }) @XmlRootElement(name = "Email_Message", namespace = "http://cybox.mitre.org/objects#EmailMessageObject-2") public class EmailMessage extends ObjectPropertiesType implements Equals, HashCode, ToString { @XmlElement(name = "Header") protected EmailHeaderType header; @XmlElement(name = "Email_Server") protected StringObjectPropertyType emailServer; @XmlElement(name = "Raw_Body") protected StringObjectPropertyType rawBody; @XmlElement(name = "Raw_Header") protected StringObjectPropertyType rawHeader; @XmlElement(name = "Attachments") protected AttachmentsType attachments; @XmlElement(name = "Links") protected LinksType links; /** * Default no-arg constructor * */ public EmailMessage() { super(); } /** * Fully-initialising value constructor * */ public EmailMessage(final CustomPropertiesType customProperties, final QName objectReference, final EmailHeaderType header, final StringObjectPropertyType emailServer, final StringObjectPropertyType rawBody, final StringObjectPropertyType rawHeader, final AttachmentsType attachments, final LinksType links) { super(customProperties, objectReference); this.header = header; this.emailServer = emailServer; this.rawBody = rawBody; this.rawHeader = rawHeader; this.attachments = attachments; this.links = links; } /** * Gets the value of the header property. * * @return * possible object is * {@link EmailHeaderType } * */ public EmailHeaderType getHeader() { return header; } /** * Sets the value of the header property. * * @param value * allowed object is * {@link EmailHeaderType } * */ public void setHeader(EmailHeaderType value) { this.header = value; } /** * Gets the value of the emailServer property. * * @return * possible object is * {@link StringObjectPropertyType } * */ public StringObjectPropertyType getEmailServer() { return emailServer; } /** * Sets the value of the emailServer property. * * @param value * allowed object is * {@link StringObjectPropertyType } * */ public void setEmailServer(StringObjectPropertyType value) { this.emailServer = value; } /** * Gets the value of the rawBody property. * * @return * possible object is * {@link StringObjectPropertyType } * */ public StringObjectPropertyType getRawBody() { return rawBody; } /** * Sets the value of the rawBody property. * * @param value * allowed object is * {@link StringObjectPropertyType } * */ public void setRawBody(StringObjectPropertyType value) { this.rawBody = value; } /** * Gets the value of the rawHeader property. * * @return * possible object is * {@link StringObjectPropertyType } * */ public StringObjectPropertyType getRawHeader() { return rawHeader; } /** * Sets the value of the rawHeader property. * * @param value * allowed object is * {@link StringObjectPropertyType } * */ public void setRawHeader(StringObjectPropertyType value) { this.rawHeader = value; } /** * Gets the value of the attachments property. * * @return * possible object is * {@link AttachmentsType } * */ public AttachmentsType getAttachments() { return attachments; } /** * Sets the value of the attachments property. * * @param value * allowed object is * {@link AttachmentsType } * */ public void setAttachments(AttachmentsType value) { this.attachments = value; } /** * Gets the value of the links property. * * @return * possible object is * {@link LinksType } * */ public LinksType getLinks() { return links; } /** * Sets the value of the links property. * * @param value * allowed object is * {@link LinksType } * */ public void setLinks(LinksType value) { this.links = value; } public boolean equals(ObjectLocator thisLocator, ObjectLocator thatLocator, Object object, EqualsStrategy strategy) { if (!(object instanceof EmailMessage)) { return false; } if (this == object) { return true; } if (!super.equals(thisLocator, thatLocator, object, strategy)) { return false; } final EmailMessage that = ((EmailMessage) object); { EmailHeaderType lhsHeader; lhsHeader = this.getHeader(); EmailHeaderType rhsHeader; rhsHeader = that.getHeader(); if (!strategy.equals( LocatorUtils.property(thisLocator, "header", lhsHeader), LocatorUtils.property(thatLocator, "header", rhsHeader), lhsHeader, rhsHeader)) { return false; } } { StringObjectPropertyType lhsEmailServer; lhsEmailServer = this.getEmailServer(); StringObjectPropertyType rhsEmailServer; rhsEmailServer = that.getEmailServer(); if (!strategy.equals(LocatorUtils.property(thisLocator, "emailServer", lhsEmailServer), LocatorUtils.property( thatLocator, "emailServer", rhsEmailServer), lhsEmailServer, rhsEmailServer)) { return false; } } { StringObjectPropertyType lhsRawBody; lhsRawBody = this.getRawBody(); StringObjectPropertyType rhsRawBody; rhsRawBody = that.getRawBody(); if (!strategy.equals( LocatorUtils.property(thisLocator, "rawBody", lhsRawBody), LocatorUtils.property(thatLocator, "rawBody", rhsRawBody), lhsRawBody, rhsRawBody)) { return false; } } { StringObjectPropertyType lhsRawHeader; lhsRawHeader = this.getRawHeader(); StringObjectPropertyType rhsRawHeader; rhsRawHeader = that.getRawHeader(); if (!strategy.equals(LocatorUtils.property(thisLocator, "rawHeader", lhsRawHeader), LocatorUtils.property( thatLocator, "rawHeader", rhsRawHeader), lhsRawHeader, rhsRawHeader)) { return false; } } { AttachmentsType lhsAttachments; lhsAttachments = this.getAttachments(); AttachmentsType rhsAttachments; rhsAttachments = that.getAttachments(); if (!strategy.equals(LocatorUtils.property(thisLocator, "attachments", lhsAttachments), LocatorUtils.property( thatLocator, "attachments", rhsAttachments), lhsAttachments, rhsAttachments)) { return false; } } { LinksType lhsLinks; lhsLinks = this.getLinks(); LinksType rhsLinks; rhsLinks = that.getLinks(); if (!strategy.equals( LocatorUtils.property(thisLocator, "links", lhsLinks), LocatorUtils.property(thatLocator, "links", rhsLinks), lhsLinks, rhsLinks)) { 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); { EmailHeaderType theHeader; theHeader = this.getHeader(); currentHashCode = strategy.hashCode( LocatorUtils.property(locator, "header", theHeader), currentHashCode, theHeader); } { StringObjectPropertyType theEmailServer; theEmailServer = this.getEmailServer(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "emailServer", theEmailServer), currentHashCode, theEmailServer); } { StringObjectPropertyType theRawBody; theRawBody = this.getRawBody(); currentHashCode = strategy.hashCode( LocatorUtils.property(locator, "rawBody", theRawBody), currentHashCode, theRawBody); } { StringObjectPropertyType theRawHeader; theRawHeader = this.getRawHeader(); currentHashCode = strategy.hashCode( LocatorUtils.property(locator, "rawHeader", theRawHeader), currentHashCode, theRawHeader); } { AttachmentsType theAttachments; theAttachments = this.getAttachments(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "attachments", theAttachments), currentHashCode, theAttachments); } { LinksType theLinks; theLinks = this.getLinks(); currentHashCode = strategy.hashCode( LocatorUtils.property(locator, "links", theLinks), currentHashCode, theLinks); } return currentHashCode; } public int hashCode() { final HashCodeStrategy strategy = JAXBHashCodeStrategy.INSTANCE; return this.hashCode(null, strategy); } public EmailMessage withHeader(EmailHeaderType value) { setHeader(value); return this; } public EmailMessage withEmailServer(StringObjectPropertyType value) { setEmailServer(value); return this; } public EmailMessage withRawBody(StringObjectPropertyType value) { setRawBody(value); return this; } public EmailMessage withRawHeader(StringObjectPropertyType value) { setRawHeader(value); return this; } public EmailMessage withAttachments(AttachmentsType value) { setAttachments(value); return this; } public EmailMessage withLinks(LinksType value) { setLinks(value); return this; } @Override public EmailMessage withCustomProperties(CustomPropertiesType value) { setCustomProperties(value); return this; } @Override public EmailMessage 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); { EmailHeaderType theHeader; theHeader = this.getHeader(); strategy.appendField(locator, this, "header", buffer, theHeader); } { StringObjectPropertyType theEmailServer; theEmailServer = this.getEmailServer(); strategy.appendField(locator, this, "emailServer", buffer, theEmailServer); } { StringObjectPropertyType theRawBody; theRawBody = this.getRawBody(); strategy.appendField(locator, this, "rawBody", buffer, theRawBody); } { StringObjectPropertyType theRawHeader; theRawHeader = this.getRawHeader(); strategy.appendField(locator, this, "rawHeader", buffer, theRawHeader); } { AttachmentsType theAttachments; theAttachments = this.getAttachments(); strategy.appendField(locator, this, "attachments", buffer, theAttachments); } { LinksType theLinks; theLinks = this.getLinks(); strategy.appendField(locator, this, "links", buffer, theLinks); } 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, EmailMessage.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 EmailMessage instance for XML String * * @param text * XML String for the document * @return The EmailMessage instance for the passed XML String */ public static EmailMessage fromXMLString(String text) { JAXBContext jaxbContext; try { jaxbContext = JAXBContext.newInstance(EmailMessage.class .getPackage().getName()); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); unmarshaller.setSchema(STIXSchema.getInstance().getSchema()); unmarshaller.setEventHandler(new ValidationEventHandler()); StreamSource streamSource = new StreamSource(new StringReader(text)); return (EmailMessage) unmarshaller.unmarshal(streamSource); } catch (JAXBException e) { throw new RuntimeException(e); } } /** * Validates the XML representation of this EmailMessage 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