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

org.mitre.cybox.objects.DNSQuery Maven / Gradle / Ivy

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.HexBinaryObjectPropertyType;
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 DNSQueryType is intended to characterize a single DNS query and its components.
 * 
 * 

Java class for DNSQueryObjectType complex type. * *

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

 * <complexType name="DNSQueryObjectType">
 *   <complexContent>
 *     <extension base="{http://cybox.mitre.org/common-2}ObjectPropertiesType">
 *       <sequence>
 *         <element name="Transaction_ID" type="{http://cybox.mitre.org/common-2}HexBinaryObjectPropertyType" minOccurs="0"/>
 *         <element name="Question" type="{http://cybox.mitre.org/objects#DNSQueryObject-2}DNSQuestionType" minOccurs="0"/>
 *         <element name="Answer_Resource_Records" type="{http://cybox.mitre.org/objects#DNSQueryObject-2}DNSResourceRecordsType" minOccurs="0"/>
 *         <element name="Authority_Resource_Records" type="{http://cybox.mitre.org/objects#DNSQueryObject-2}DNSResourceRecordsType" minOccurs="0"/>
 *         <element name="Additional_Records" type="{http://cybox.mitre.org/objects#DNSQueryObject-2}DNSResourceRecordsType" minOccurs="0"/>
 *         <element name="Date_Ran" type="{http://cybox.mitre.org/common-2}DateTimeObjectPropertyType" minOccurs="0"/>
 *         <element name="Service_Used" type="{http://cybox.mitre.org/common-2}StringObjectPropertyType" minOccurs="0"/>
 *       </sequence>
 *       <attribute name="successful" type="{http://www.w3.org/2001/XMLSchema}boolean" />
 *     </extension>
 *   </complexContent>
 * </complexType>
 * 
* * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "DNSQueryObjectType", namespace = "http://cybox.mitre.org/objects#DNSQueryObject-2", propOrder = { "transactionID", "question", "answerResourceRecords", "authorityResourceRecords", "additionalRecords", "dateRan", "serviceUsed" }) @XmlRootElement(name = "DNS_Query", namespace = "http://cybox.mitre.org/objects#DNSQueryObject-2") public class DNSQuery extends ObjectPropertiesType implements Equals, HashCode, ToString { @XmlElement(name = "Transaction_ID") protected HexBinaryObjectPropertyType transactionID; @XmlElement(name = "Question") protected DNSQuestionType question; @XmlElement(name = "Answer_Resource_Records") protected DNSResourceRecordsType answerResourceRecords; @XmlElement(name = "Authority_Resource_Records") protected DNSResourceRecordsType authorityResourceRecords; @XmlElement(name = "Additional_Records") protected DNSResourceRecordsType additionalRecords; @XmlElement(name = "Date_Ran") protected DateTimeObjectPropertyType dateRan; @XmlElement(name = "Service_Used") protected StringObjectPropertyType serviceUsed; @XmlAttribute(name = "successful") protected Boolean successful; /** * Default no-arg constructor * */ public DNSQuery() { super(); } /** * Fully-initialising value constructor * */ public DNSQuery(final CustomPropertiesType customProperties, final QName objectReference, final HexBinaryObjectPropertyType transactionID, final DNSQuestionType question, final DNSResourceRecordsType answerResourceRecords, final DNSResourceRecordsType authorityResourceRecords, final DNSResourceRecordsType additionalRecords, final DateTimeObjectPropertyType dateRan, final StringObjectPropertyType serviceUsed, final Boolean successful) { super(customProperties, objectReference); this.transactionID = transactionID; this.question = question; this.answerResourceRecords = answerResourceRecords; this.authorityResourceRecords = authorityResourceRecords; this.additionalRecords = additionalRecords; this.dateRan = dateRan; this.serviceUsed = serviceUsed; this.successful = successful; } /** * Gets the value of the transactionID property. * * @return * possible object is * {@link HexBinaryObjectPropertyType } * */ public HexBinaryObjectPropertyType getTransactionID() { return transactionID; } /** * Sets the value of the transactionID property. * * @param value * allowed object is * {@link HexBinaryObjectPropertyType } * */ public void setTransactionID(HexBinaryObjectPropertyType value) { this.transactionID = value; } /** * Gets the value of the question property. * * @return * possible object is * {@link DNSQuestionType } * */ public DNSQuestionType getQuestion() { return question; } /** * Sets the value of the question property. * * @param value * allowed object is * {@link DNSQuestionType } * */ public void setQuestion(DNSQuestionType value) { this.question = value; } /** * Gets the value of the answerResourceRecords property. * * @return * possible object is * {@link DNSResourceRecordsType } * */ public DNSResourceRecordsType getAnswerResourceRecords() { return answerResourceRecords; } /** * Sets the value of the answerResourceRecords property. * * @param value * allowed object is * {@link DNSResourceRecordsType } * */ public void setAnswerResourceRecords(DNSResourceRecordsType value) { this.answerResourceRecords = value; } /** * Gets the value of the authorityResourceRecords property. * * @return * possible object is * {@link DNSResourceRecordsType } * */ public DNSResourceRecordsType getAuthorityResourceRecords() { return authorityResourceRecords; } /** * Sets the value of the authorityResourceRecords property. * * @param value * allowed object is * {@link DNSResourceRecordsType } * */ public void setAuthorityResourceRecords(DNSResourceRecordsType value) { this.authorityResourceRecords = value; } /** * Gets the value of the additionalRecords property. * * @return * possible object is * {@link DNSResourceRecordsType } * */ public DNSResourceRecordsType getAdditionalRecords() { return additionalRecords; } /** * Sets the value of the additionalRecords property. * * @param value * allowed object is * {@link DNSResourceRecordsType } * */ public void setAdditionalRecords(DNSResourceRecordsType value) { this.additionalRecords = value; } /** * Gets the value of the dateRan property. * * @return * possible object is * {@link DateTimeObjectPropertyType } * */ public DateTimeObjectPropertyType getDateRan() { return dateRan; } /** * Sets the value of the dateRan property. * * @param value * allowed object is * {@link DateTimeObjectPropertyType } * */ public void setDateRan(DateTimeObjectPropertyType value) { this.dateRan = value; } /** * Gets the value of the serviceUsed property. * * @return * possible object is * {@link StringObjectPropertyType } * */ public StringObjectPropertyType getServiceUsed() { return serviceUsed; } /** * Sets the value of the serviceUsed property. * * @param value * allowed object is * {@link StringObjectPropertyType } * */ public void setServiceUsed(StringObjectPropertyType value) { this.serviceUsed = value; } /** * Gets the value of the successful property. * * @return * possible object is * {@link Boolean } * */ public Boolean isSuccessful() { return successful; } /** * Sets the value of the successful property. * * @param value * allowed object is * {@link Boolean } * */ public void setSuccessful(Boolean value) { this.successful = value; } public boolean equals(ObjectLocator thisLocator, ObjectLocator thatLocator, Object object, EqualsStrategy strategy) { if (!(object instanceof DNSQuery)) { return false; } if (this == object) { return true; } if (!super.equals(thisLocator, thatLocator, object, strategy)) { return false; } final DNSQuery that = ((DNSQuery) object); { HexBinaryObjectPropertyType lhsTransactionID; lhsTransactionID = this.getTransactionID(); HexBinaryObjectPropertyType rhsTransactionID; rhsTransactionID = that.getTransactionID(); if (!strategy.equals(LocatorUtils.property(thisLocator, "transactionID", lhsTransactionID), LocatorUtils.property( thatLocator, "transactionID", rhsTransactionID), lhsTransactionID, rhsTransactionID)) { return false; } } { DNSQuestionType lhsQuestion; lhsQuestion = this.getQuestion(); DNSQuestionType rhsQuestion; rhsQuestion = that.getQuestion(); if (!strategy .equals(LocatorUtils.property(thisLocator, "question", lhsQuestion), LocatorUtils.property(thatLocator, "question", rhsQuestion), lhsQuestion, rhsQuestion)) { return false; } } { DNSResourceRecordsType lhsAnswerResourceRecords; lhsAnswerResourceRecords = this.getAnswerResourceRecords(); DNSResourceRecordsType rhsAnswerResourceRecords; rhsAnswerResourceRecords = that.getAnswerResourceRecords(); if (!strategy.equals(LocatorUtils.property(thisLocator, "answerResourceRecords", lhsAnswerResourceRecords), LocatorUtils.property(thatLocator, "answerResourceRecords", rhsAnswerResourceRecords), lhsAnswerResourceRecords, rhsAnswerResourceRecords)) { return false; } } { DNSResourceRecordsType lhsAuthorityResourceRecords; lhsAuthorityResourceRecords = this.getAuthorityResourceRecords(); DNSResourceRecordsType rhsAuthorityResourceRecords; rhsAuthorityResourceRecords = that.getAuthorityResourceRecords(); if (!strategy.equals(LocatorUtils.property(thisLocator, "authorityResourceRecords", lhsAuthorityResourceRecords), LocatorUtils.property(thatLocator, "authorityResourceRecords", rhsAuthorityResourceRecords), lhsAuthorityResourceRecords, rhsAuthorityResourceRecords)) { return false; } } { DNSResourceRecordsType lhsAdditionalRecords; lhsAdditionalRecords = this.getAdditionalRecords(); DNSResourceRecordsType rhsAdditionalRecords; rhsAdditionalRecords = that.getAdditionalRecords(); if (!strategy.equals(LocatorUtils.property(thisLocator, "additionalRecords", lhsAdditionalRecords), LocatorUtils .property(thatLocator, "additionalRecords", rhsAdditionalRecords), lhsAdditionalRecords, rhsAdditionalRecords)) { return false; } } { DateTimeObjectPropertyType lhsDateRan; lhsDateRan = this.getDateRan(); DateTimeObjectPropertyType rhsDateRan; rhsDateRan = that.getDateRan(); if (!strategy.equals( LocatorUtils.property(thisLocator, "dateRan", lhsDateRan), LocatorUtils.property(thatLocator, "dateRan", rhsDateRan), lhsDateRan, rhsDateRan)) { return false; } } { StringObjectPropertyType lhsServiceUsed; lhsServiceUsed = this.getServiceUsed(); StringObjectPropertyType rhsServiceUsed; rhsServiceUsed = that.getServiceUsed(); if (!strategy.equals(LocatorUtils.property(thisLocator, "serviceUsed", lhsServiceUsed), LocatorUtils.property( thatLocator, "serviceUsed", rhsServiceUsed), lhsServiceUsed, rhsServiceUsed)) { return false; } } { Boolean lhsSuccessful; lhsSuccessful = this.isSuccessful(); Boolean rhsSuccessful; rhsSuccessful = that.isSuccessful(); if (!strategy.equals(LocatorUtils.property(thisLocator, "successful", lhsSuccessful), LocatorUtils.property( thatLocator, "successful", rhsSuccessful), lhsSuccessful, rhsSuccessful)) { 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); { HexBinaryObjectPropertyType theTransactionID; theTransactionID = this.getTransactionID(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "transactionID", theTransactionID), currentHashCode, theTransactionID); } { DNSQuestionType theQuestion; theQuestion = this.getQuestion(); currentHashCode = strategy.hashCode( LocatorUtils.property(locator, "question", theQuestion), currentHashCode, theQuestion); } { DNSResourceRecordsType theAnswerResourceRecords; theAnswerResourceRecords = this.getAnswerResourceRecords(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "answerResourceRecords", theAnswerResourceRecords), currentHashCode, theAnswerResourceRecords); } { DNSResourceRecordsType theAuthorityResourceRecords; theAuthorityResourceRecords = this.getAuthorityResourceRecords(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "authorityResourceRecords", theAuthorityResourceRecords), currentHashCode, theAuthorityResourceRecords); } { DNSResourceRecordsType theAdditionalRecords; theAdditionalRecords = this.getAdditionalRecords(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "additionalRecords", theAdditionalRecords), currentHashCode, theAdditionalRecords); } { DateTimeObjectPropertyType theDateRan; theDateRan = this.getDateRan(); currentHashCode = strategy.hashCode( LocatorUtils.property(locator, "dateRan", theDateRan), currentHashCode, theDateRan); } { StringObjectPropertyType theServiceUsed; theServiceUsed = this.getServiceUsed(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "serviceUsed", theServiceUsed), currentHashCode, theServiceUsed); } { Boolean theSuccessful; theSuccessful = this.isSuccessful(); currentHashCode = strategy .hashCode(LocatorUtils.property(locator, "successful", theSuccessful), currentHashCode, theSuccessful); } return currentHashCode; } public int hashCode() { final HashCodeStrategy strategy = JAXBHashCodeStrategy.INSTANCE; return this.hashCode(null, strategy); } public DNSQuery withTransactionID(HexBinaryObjectPropertyType value) { setTransactionID(value); return this; } public DNSQuery withQuestion(DNSQuestionType value) { setQuestion(value); return this; } public DNSQuery withAnswerResourceRecords(DNSResourceRecordsType value) { setAnswerResourceRecords(value); return this; } public DNSQuery withAuthorityResourceRecords(DNSResourceRecordsType value) { setAuthorityResourceRecords(value); return this; } public DNSQuery withAdditionalRecords(DNSResourceRecordsType value) { setAdditionalRecords(value); return this; } public DNSQuery withDateRan(DateTimeObjectPropertyType value) { setDateRan(value); return this; } public DNSQuery withServiceUsed(StringObjectPropertyType value) { setServiceUsed(value); return this; } public DNSQuery withSuccessful(Boolean value) { setSuccessful(value); return this; } @Override public DNSQuery withCustomProperties(CustomPropertiesType value) { setCustomProperties(value); return this; } @Override public DNSQuery 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); { HexBinaryObjectPropertyType theTransactionID; theTransactionID = this.getTransactionID(); strategy.appendField(locator, this, "transactionID", buffer, theTransactionID); } { DNSQuestionType theQuestion; theQuestion = this.getQuestion(); strategy.appendField(locator, this, "question", buffer, theQuestion); } { DNSResourceRecordsType theAnswerResourceRecords; theAnswerResourceRecords = this.getAnswerResourceRecords(); strategy.appendField(locator, this, "answerResourceRecords", buffer, theAnswerResourceRecords); } { DNSResourceRecordsType theAuthorityResourceRecords; theAuthorityResourceRecords = this.getAuthorityResourceRecords(); strategy.appendField(locator, this, "authorityResourceRecords", buffer, theAuthorityResourceRecords); } { DNSResourceRecordsType theAdditionalRecords; theAdditionalRecords = this.getAdditionalRecords(); strategy.appendField(locator, this, "additionalRecords", buffer, theAdditionalRecords); } { DateTimeObjectPropertyType theDateRan; theDateRan = this.getDateRan(); strategy.appendField(locator, this, "dateRan", buffer, theDateRan); } { StringObjectPropertyType theServiceUsed; theServiceUsed = this.getServiceUsed(); strategy.appendField(locator, this, "serviceUsed", buffer, theServiceUsed); } { Boolean theSuccessful; theSuccessful = this.isSuccessful(); strategy.appendField(locator, this, "successful", buffer, theSuccessful); } 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, DNSQuery.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 DNSQuery instance for XML String * * @param text * XML String for the document * @return The DNSQuery instance for the passed XML String */ public static DNSQuery fromXMLString(String text) { JAXBContext jaxbContext; try { jaxbContext = JAXBContext.newInstance(DNSQuery.class.getPackage() .getName()); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); unmarshaller.setSchema(STIXSchema.getInstance().getSchema()); unmarshaller.setEventHandler(new ValidationEventHandler()); StreamSource streamSource = new StreamSource(new StringReader(text)); return (DNSQuery) unmarshaller.unmarshal(streamSource); } catch (JAXBException e) { throw new RuntimeException(e); } } /** * Validates the XML representation of this DNSQuery 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