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

org.mitre.cybox.objects.Artifact 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.XmlSchemaType;
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.HashListType;
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 ArtifactObjectType type is intended to encapsulate and convey the content of a Raw Artifact.
 * 
 * 

Java class for ArtifactObjectType complex type. * *

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

 * <complexType name="ArtifactObjectType">
 *   <complexContent>
 *     <extension base="{http://cybox.mitre.org/common-2}ObjectPropertiesType">
 *       <sequence>
 *         <element name="Hashes" type="{http://cybox.mitre.org/common-2}HashListType" minOccurs="0"/>
 *         <element name="Packaging" type="{http://cybox.mitre.org/objects#ArtifactObject-2}PackagingType" minOccurs="0"/>
 *         <choice>
 *           <element name="Raw_Artifact" type="{http://cybox.mitre.org/objects#ArtifactObject-2}RawArtifactType" minOccurs="0"/>
 *           <element name="Raw_Artifact_Reference" type="{http://www.w3.org/2001/XMLSchema}anyURI" minOccurs="0"/>
 *         </choice>
 *       </sequence>
 *       <attribute name="type" type="{http://cybox.mitre.org/objects#ArtifactObject-2}ArtifactTypeEnum" />
 *       <attribute name="content_type" type="{http://www.w3.org/2001/XMLSchema}string" />
 *       <attribute name="content_type_version" type="{http://www.w3.org/2001/XMLSchema}string" />
 *       <attribute name="suspected_malicious" type="{http://www.w3.org/2001/XMLSchema}boolean" />
 *     </extension>
 *   </complexContent>
 * </complexType>
 * 
* * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "ArtifactObjectType", namespace = "http://cybox.mitre.org/objects#ArtifactObject-2", propOrder = { "hashes", "packaging", "rawArtifactReference", "rawArtifact" }) @XmlRootElement(name = "Artifact", namespace = "http://cybox.mitre.org/objects#ArtifactObject-2") public class Artifact extends ObjectPropertiesType implements Equals, HashCode, ToString { @XmlElement(name = "Hashes") protected HashListType hashes; @XmlElement(name = "Packaging") protected PackagingType packaging; @XmlElement(name = "Raw_Artifact_Reference") @XmlSchemaType(name = "anyURI") protected String rawArtifactReference; @XmlElement(name = "Raw_Artifact") protected RawArtifactType rawArtifact; @XmlAttribute(name = "type") protected ArtifactTypeEnum type; @XmlAttribute(name = "content_type") protected String contentType; @XmlAttribute(name = "content_type_version") protected String contentTypeVersion; @XmlAttribute(name = "suspected_malicious") protected Boolean suspectedMalicious; /** * Default no-arg constructor * */ public Artifact() { super(); } /** * Fully-initialising value constructor * */ public Artifact(final CustomPropertiesType customProperties, final QName objectReference, final HashListType hashes, final PackagingType packaging, final String rawArtifactReference, final RawArtifactType rawArtifact, final ArtifactTypeEnum type, final String contentType, final String contentTypeVersion, final Boolean suspectedMalicious) { super(customProperties, objectReference); this.hashes = hashes; this.packaging = packaging; this.rawArtifactReference = rawArtifactReference; this.rawArtifact = rawArtifact; this.type = type; this.contentType = contentType; this.contentTypeVersion = contentTypeVersion; this.suspectedMalicious = suspectedMalicious; } /** * Gets the value of the hashes property. * * @return * possible object is * {@link HashListType } * */ public HashListType getHashes() { return hashes; } /** * Sets the value of the hashes property. * * @param value * allowed object is * {@link HashListType } * */ public void setHashes(HashListType value) { this.hashes = value; } /** * Gets the value of the packaging property. * * @return * possible object is * {@link PackagingType } * */ public PackagingType getPackaging() { return packaging; } /** * Sets the value of the packaging property. * * @param value * allowed object is * {@link PackagingType } * */ public void setPackaging(PackagingType value) { this.packaging = value; } /** * Gets the value of the rawArtifactReference property. * * @return * possible object is * {@link String } * */ public String getRawArtifactReference() { return rawArtifactReference; } /** * Sets the value of the rawArtifactReference property. * * @param value * allowed object is * {@link String } * */ public void setRawArtifactReference(String value) { this.rawArtifactReference = value; } /** * Gets the value of the rawArtifact property. * * @return * possible object is * {@link RawArtifactType } * */ public RawArtifactType getRawArtifact() { return rawArtifact; } /** * Sets the value of the rawArtifact property. * * @param value * allowed object is * {@link RawArtifactType } * */ public void setRawArtifact(RawArtifactType value) { this.rawArtifact = value; } /** * Gets the value of the type property. * * @return * possible object is * {@link ArtifactTypeEnum } * */ public ArtifactTypeEnum getType() { return type; } /** * Sets the value of the type property. * * @param value * allowed object is * {@link ArtifactTypeEnum } * */ public void setType(ArtifactTypeEnum value) { this.type = value; } /** * Gets the value of the contentType property. * * @return * possible object is * {@link String } * */ public String getContentType() { return contentType; } /** * Sets the value of the contentType property. * * @param value * allowed object is * {@link String } * */ public void setContentType(String value) { this.contentType = value; } /** * Gets the value of the contentTypeVersion property. * * @return * possible object is * {@link String } * */ public String getContentTypeVersion() { return contentTypeVersion; } /** * Sets the value of the contentTypeVersion property. * * @param value * allowed object is * {@link String } * */ public void setContentTypeVersion(String value) { this.contentTypeVersion = value; } /** * Gets the value of the suspectedMalicious property. * * @return * possible object is * {@link Boolean } * */ public Boolean isSuspectedMalicious() { return suspectedMalicious; } /** * Sets the value of the suspectedMalicious property. * * @param value * allowed object is * {@link Boolean } * */ public void setSuspectedMalicious(Boolean value) { this.suspectedMalicious = value; } public boolean equals(ObjectLocator thisLocator, ObjectLocator thatLocator, Object object, EqualsStrategy strategy) { if (!(object instanceof Artifact)) { return false; } if (this == object) { return true; } if (!super.equals(thisLocator, thatLocator, object, strategy)) { return false; } final Artifact that = ((Artifact) object); { HashListType lhsHashes; lhsHashes = this.getHashes(); HashListType rhsHashes; rhsHashes = that.getHashes(); if (!strategy.equals( LocatorUtils.property(thisLocator, "hashes", lhsHashes), LocatorUtils.property(thatLocator, "hashes", rhsHashes), lhsHashes, rhsHashes)) { return false; } } { PackagingType lhsPackaging; lhsPackaging = this.getPackaging(); PackagingType rhsPackaging; rhsPackaging = that.getPackaging(); if (!strategy.equals(LocatorUtils.property(thisLocator, "packaging", lhsPackaging), LocatorUtils.property( thatLocator, "packaging", rhsPackaging), lhsPackaging, rhsPackaging)) { return false; } } { String lhsRawArtifactReference; lhsRawArtifactReference = this.getRawArtifactReference(); String rhsRawArtifactReference; rhsRawArtifactReference = that.getRawArtifactReference(); if (!strategy.equals(LocatorUtils.property(thisLocator, "rawArtifactReference", lhsRawArtifactReference), LocatorUtils.property(thatLocator, "rawArtifactReference", rhsRawArtifactReference), lhsRawArtifactReference, rhsRawArtifactReference)) { return false; } } { RawArtifactType lhsRawArtifact; lhsRawArtifact = this.getRawArtifact(); RawArtifactType rhsRawArtifact; rhsRawArtifact = that.getRawArtifact(); if (!strategy.equals(LocatorUtils.property(thisLocator, "rawArtifact", lhsRawArtifact), LocatorUtils.property( thatLocator, "rawArtifact", rhsRawArtifact), lhsRawArtifact, rhsRawArtifact)) { return false; } } { ArtifactTypeEnum lhsType; lhsType = this.getType(); ArtifactTypeEnum rhsType; rhsType = that.getType(); if (!strategy.equals( LocatorUtils.property(thisLocator, "type", lhsType), LocatorUtils.property(thatLocator, "type", rhsType), lhsType, rhsType)) { return false; } } { String lhsContentType; lhsContentType = this.getContentType(); String rhsContentType; rhsContentType = that.getContentType(); if (!strategy.equals(LocatorUtils.property(thisLocator, "contentType", lhsContentType), LocatorUtils.property( thatLocator, "contentType", rhsContentType), lhsContentType, rhsContentType)) { return false; } } { String lhsContentTypeVersion; lhsContentTypeVersion = this.getContentTypeVersion(); String rhsContentTypeVersion; rhsContentTypeVersion = that.getContentTypeVersion(); if (!strategy.equals(LocatorUtils.property(thisLocator, "contentTypeVersion", lhsContentTypeVersion), LocatorUtils .property(thatLocator, "contentTypeVersion", rhsContentTypeVersion), lhsContentTypeVersion, rhsContentTypeVersion)) { return false; } } { Boolean lhsSuspectedMalicious; lhsSuspectedMalicious = this.isSuspectedMalicious(); Boolean rhsSuspectedMalicious; rhsSuspectedMalicious = that.isSuspectedMalicious(); if (!strategy.equals(LocatorUtils.property(thisLocator, "suspectedMalicious", lhsSuspectedMalicious), LocatorUtils .property(thatLocator, "suspectedMalicious", rhsSuspectedMalicious), lhsSuspectedMalicious, rhsSuspectedMalicious)) { 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); { HashListType theHashes; theHashes = this.getHashes(); currentHashCode = strategy.hashCode( LocatorUtils.property(locator, "hashes", theHashes), currentHashCode, theHashes); } { PackagingType thePackaging; thePackaging = this.getPackaging(); currentHashCode = strategy.hashCode( LocatorUtils.property(locator, "packaging", thePackaging), currentHashCode, thePackaging); } { String theRawArtifactReference; theRawArtifactReference = this.getRawArtifactReference(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "rawArtifactReference", theRawArtifactReference), currentHashCode, theRawArtifactReference); } { RawArtifactType theRawArtifact; theRawArtifact = this.getRawArtifact(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "rawArtifact", theRawArtifact), currentHashCode, theRawArtifact); } { ArtifactTypeEnum theType; theType = this.getType(); currentHashCode = strategy.hashCode( LocatorUtils.property(locator, "type", theType), currentHashCode, theType); } { String theContentType; theContentType = this.getContentType(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "contentType", theContentType), currentHashCode, theContentType); } { String theContentTypeVersion; theContentTypeVersion = this.getContentTypeVersion(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "contentTypeVersion", theContentTypeVersion), currentHashCode, theContentTypeVersion); } { Boolean theSuspectedMalicious; theSuspectedMalicious = this.isSuspectedMalicious(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "suspectedMalicious", theSuspectedMalicious), currentHashCode, theSuspectedMalicious); } return currentHashCode; } public int hashCode() { final HashCodeStrategy strategy = JAXBHashCodeStrategy.INSTANCE; return this.hashCode(null, strategy); } public Artifact withHashes(HashListType value) { setHashes(value); return this; } public Artifact withPackaging(PackagingType value) { setPackaging(value); return this; } public Artifact withRawArtifactReference(String value) { setRawArtifactReference(value); return this; } public Artifact withRawArtifact(RawArtifactType value) { setRawArtifact(value); return this; } public Artifact withType(ArtifactTypeEnum value) { setType(value); return this; } public Artifact withContentType(String value) { setContentType(value); return this; } public Artifact withContentTypeVersion(String value) { setContentTypeVersion(value); return this; } public Artifact withSuspectedMalicious(Boolean value) { setSuspectedMalicious(value); return this; } @Override public Artifact withCustomProperties(CustomPropertiesType value) { setCustomProperties(value); return this; } @Override public Artifact 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); { HashListType theHashes; theHashes = this.getHashes(); strategy.appendField(locator, this, "hashes", buffer, theHashes); } { PackagingType thePackaging; thePackaging = this.getPackaging(); strategy.appendField(locator, this, "packaging", buffer, thePackaging); } { String theRawArtifactReference; theRawArtifactReference = this.getRawArtifactReference(); strategy.appendField(locator, this, "rawArtifactReference", buffer, theRawArtifactReference); } { RawArtifactType theRawArtifact; theRawArtifact = this.getRawArtifact(); strategy.appendField(locator, this, "rawArtifact", buffer, theRawArtifact); } { ArtifactTypeEnum theType; theType = this.getType(); strategy.appendField(locator, this, "type", buffer, theType); } { String theContentType; theContentType = this.getContentType(); strategy.appendField(locator, this, "contentType", buffer, theContentType); } { String theContentTypeVersion; theContentTypeVersion = this.getContentTypeVersion(); strategy.appendField(locator, this, "contentTypeVersion", buffer, theContentTypeVersion); } { Boolean theSuspectedMalicious; theSuspectedMalicious = this.isSuspectedMalicious(); strategy.appendField(locator, this, "suspectedMalicious", buffer, theSuspectedMalicious); } 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, Artifact.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 Artifact instance for XML String * * @param text * XML String for the document * @return The Artifact instance for the passed XML String */ public static Artifact fromXMLString(String text) { JAXBContext jaxbContext; try { jaxbContext = JAXBContext.newInstance(Artifact.class.getPackage() .getName()); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); unmarshaller.setSchema(STIXSchema.getInstance().getSchema()); unmarshaller.setEventHandler(new ValidationEventHandler()); StreamSource streamSource = new StreamSource(new StringReader(text)); return (Artifact) unmarshaller.unmarshal(streamSource); } catch (JAXBException e) { throw new RuntimeException(e); } } /** * Validates the XML representation of this Artifact 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