org.mitre.cybox.objects.CodeObject Maven / Gradle / Ivy
Show all versions of stix Show documentation
/**
* 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 java.util.ArrayList;
import java.util.Collection;
import java.util.List;
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.DigitalSignaturesType;
import org.mitre.cybox.common_2.ExtractedFeaturesType;
import org.mitre.cybox.common_2.HexBinaryObjectPropertyType;
import org.mitre.cybox.common_2.MeasureSourceType;
import org.mitre.cybox.common_2.ObjectPropertiesType;
import org.mitre.cybox.common_2.StringObjectPropertyType;
import org.mitre.cybox.common_2.StructuredTextType;
import org.mitre.stix.DocumentUtilities;
import org.mitre.stix.STIXSchema;
import org.mitre.stix.ValidationEventHandler;
import org.xml.sax.SAXException;
/**
* The CodeObjectType type is intended to characterize a body of computer code.
*
* Java class for CodeObjectType complex type.
*
*
The following schema fragment specifies the expected content contained within this class.
*
*
* <complexType name="CodeObjectType">
* <complexContent>
* <extension base="{http://cybox.mitre.org/common-2}ObjectPropertiesType">
* <sequence>
* <element name="Description" type="{http://cybox.mitre.org/common-2}StructuredTextType" minOccurs="0"/>
* <element name="Type" type="{http://cybox.mitre.org/objects#CodeObject-2}CodeTypeType" minOccurs="0"/>
* <element name="Purpose" type="{http://cybox.mitre.org/objects#CodeObject-2}CodePurposeType" minOccurs="0"/>
* <element name="Code_Language" type="{http://cybox.mitre.org/objects#CodeObject-2}CodeLanguageType" minOccurs="0"/>
* <element name="Targeted_Platforms" type="{http://cybox.mitre.org/objects#CodeObject-2}TargetedPlatformsType" minOccurs="0"/>
* <element name="Processor_Family" type="{http://cybox.mitre.org/objects#CodeObject-2}ProcessorTypeType" maxOccurs="unbounded" minOccurs="0"/>
* <element name="Discovery_Method" type="{http://cybox.mitre.org/common-2}MeasureSourceType" minOccurs="0"/>
* <element name="Start_Address" type="{http://cybox.mitre.org/common-2}HexBinaryObjectPropertyType" minOccurs="0"/>
* <element name="Code_Segment" type="{http://cybox.mitre.org/common-2}StringObjectPropertyType" minOccurs="0"/>
* <element name="Code_Segment_XOR" type="{http://cybox.mitre.org/objects#CodeObject-2}CodeSegmentXORType" minOccurs="0" form="qualified"/>
* <element name="Digital_Signatures" type="{http://cybox.mitre.org/common-2}DigitalSignaturesType" minOccurs="0"/>
* <element name="Extracted_Features" type="{http://cybox.mitre.org/common-2}ExtractedFeaturesType" minOccurs="0"/>
* </sequence>
* </extension>
* </complexContent>
* </complexType>
*
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CodeObjectType", namespace = "http://cybox.mitre.org/objects#CodeObject-2", propOrder = {
"description", "type", "purpose", "codeLanguage", "targetedPlatforms",
"processorFamilies", "discoveryMethod", "startAddress", "codeSegment",
"codeSegmentXOR", "digitalSignatures", "extractedFeatures" })
@XmlRootElement(name = "Code_Object", namespace = "http://cybox.mitre.org/objects#CodeObject-2")
public class CodeObject extends ObjectPropertiesType implements Equals,
HashCode, ToString {
@XmlElement(name = "Description")
protected StructuredTextType description;
@XmlElement(name = "Type")
protected CodeTypeType type;
@XmlElement(name = "Purpose")
protected CodePurposeType purpose;
@XmlElement(name = "Code_Language")
protected CodeLanguageType codeLanguage;
@XmlElement(name = "Targeted_Platforms")
protected TargetedPlatformsType targetedPlatforms;
@XmlElement(name = "Processor_Family")
protected List processorFamilies;
@XmlElement(name = "Discovery_Method")
protected MeasureSourceType discoveryMethod;
@XmlElement(name = "Start_Address")
protected HexBinaryObjectPropertyType startAddress;
@XmlElement(name = "Code_Segment")
protected StringObjectPropertyType codeSegment;
@XmlElement(name = "Code_Segment_XOR")
protected CodeSegmentXORType codeSegmentXOR;
@XmlElement(name = "Digital_Signatures")
protected DigitalSignaturesType digitalSignatures;
@XmlElement(name = "Extracted_Features")
protected ExtractedFeaturesType extractedFeatures;
/**
* Default no-arg constructor
*
*/
public CodeObject() {
super();
}
/**
* Fully-initialising value constructor
*
*/
public CodeObject(final CustomPropertiesType customProperties,
final QName objectReference, final StructuredTextType description,
final CodeTypeType type, final CodePurposeType purpose,
final CodeLanguageType codeLanguage,
final TargetedPlatformsType targetedPlatforms,
final List processorFamilies,
final MeasureSourceType discoveryMethod,
final HexBinaryObjectPropertyType startAddress,
final StringObjectPropertyType codeSegment,
final CodeSegmentXORType codeSegmentXOR,
final DigitalSignaturesType digitalSignatures,
final ExtractedFeaturesType extractedFeatures) {
super(customProperties, objectReference);
this.description = description;
this.type = type;
this.purpose = purpose;
this.codeLanguage = codeLanguage;
this.targetedPlatforms = targetedPlatforms;
this.processorFamilies = processorFamilies;
this.discoveryMethod = discoveryMethod;
this.startAddress = startAddress;
this.codeSegment = codeSegment;
this.codeSegmentXOR = codeSegmentXOR;
this.digitalSignatures = digitalSignatures;
this.extractedFeatures = extractedFeatures;
}
/**
* Gets the value of the description property.
*
* @return
* possible object is
* {@link StructuredTextType }
*
*/
public StructuredTextType getDescription() {
return description;
}
/**
* Sets the value of the description property.
*
* @param value
* allowed object is
* {@link StructuredTextType }
*
*/
public void setDescription(StructuredTextType value) {
this.description = value;
}
/**
* Gets the value of the type property.
*
* @return
* possible object is
* {@link CodeTypeType }
*
*/
public CodeTypeType getType() {
return type;
}
/**
* Sets the value of the type property.
*
* @param value
* allowed object is
* {@link CodeTypeType }
*
*/
public void setType(CodeTypeType value) {
this.type = value;
}
/**
* Gets the value of the purpose property.
*
* @return
* possible object is
* {@link CodePurposeType }
*
*/
public CodePurposeType getPurpose() {
return purpose;
}
/**
* Sets the value of the purpose property.
*
* @param value
* allowed object is
* {@link CodePurposeType }
*
*/
public void setPurpose(CodePurposeType value) {
this.purpose = value;
}
/**
* Gets the value of the codeLanguage property.
*
* @return
* possible object is
* {@link CodeLanguageType }
*
*/
public CodeLanguageType getCodeLanguage() {
return codeLanguage;
}
/**
* Sets the value of the codeLanguage property.
*
* @param value
* allowed object is
* {@link CodeLanguageType }
*
*/
public void setCodeLanguage(CodeLanguageType value) {
this.codeLanguage = value;
}
/**
* Gets the value of the targetedPlatforms property.
*
* @return
* possible object is
* {@link TargetedPlatformsType }
*
*/
public TargetedPlatformsType getTargetedPlatforms() {
return targetedPlatforms;
}
/**
* Sets the value of the targetedPlatforms property.
*
* @param value
* allowed object is
* {@link TargetedPlatformsType }
*
*/
public void setTargetedPlatforms(TargetedPlatformsType value) {
this.targetedPlatforms = value;
}
/**
* Gets the value of the processorFamilies property.
*
*
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a set
method for the processorFamilies property.
*
*
* For example, to add a new item, do as follows:
*
* getProcessorFamilies().add(newItem);
*
*
*
*
* Objects of the following type(s) are allowed in the list
* {@link ProcessorTypeType }
*
*
*/
public List getProcessorFamilies() {
if (processorFamilies == null) {
processorFamilies = new ArrayList();
}
return this.processorFamilies;
}
/**
* Gets the value of the discoveryMethod property.
*
* @return
* possible object is
* {@link MeasureSourceType }
*
*/
public MeasureSourceType getDiscoveryMethod() {
return discoveryMethod;
}
/**
* Sets the value of the discoveryMethod property.
*
* @param value
* allowed object is
* {@link MeasureSourceType }
*
*/
public void setDiscoveryMethod(MeasureSourceType value) {
this.discoveryMethod = value;
}
/**
* Gets the value of the startAddress property.
*
* @return
* possible object is
* {@link HexBinaryObjectPropertyType }
*
*/
public HexBinaryObjectPropertyType getStartAddress() {
return startAddress;
}
/**
* Sets the value of the startAddress property.
*
* @param value
* allowed object is
* {@link HexBinaryObjectPropertyType }
*
*/
public void setStartAddress(HexBinaryObjectPropertyType value) {
this.startAddress = value;
}
/**
* Gets the value of the codeSegment property.
*
* @return
* possible object is
* {@link StringObjectPropertyType }
*
*/
public StringObjectPropertyType getCodeSegment() {
return codeSegment;
}
/**
* Sets the value of the codeSegment property.
*
* @param value
* allowed object is
* {@link StringObjectPropertyType }
*
*/
public void setCodeSegment(StringObjectPropertyType value) {
this.codeSegment = value;
}
/**
* Gets the value of the codeSegmentXOR property.
*
* @return
* possible object is
* {@link CodeSegmentXORType }
*
*/
public CodeSegmentXORType getCodeSegmentXOR() {
return codeSegmentXOR;
}
/**
* Sets the value of the codeSegmentXOR property.
*
* @param value
* allowed object is
* {@link CodeSegmentXORType }
*
*/
public void setCodeSegmentXOR(CodeSegmentXORType value) {
this.codeSegmentXOR = value;
}
/**
* Gets the value of the digitalSignatures property.
*
* @return
* possible object is
* {@link DigitalSignaturesType }
*
*/
public DigitalSignaturesType getDigitalSignatures() {
return digitalSignatures;
}
/**
* Sets the value of the digitalSignatures property.
*
* @param value
* allowed object is
* {@link DigitalSignaturesType }
*
*/
public void setDigitalSignatures(DigitalSignaturesType value) {
this.digitalSignatures = value;
}
/**
* Gets the value of the extractedFeatures property.
*
* @return
* possible object is
* {@link ExtractedFeaturesType }
*
*/
public ExtractedFeaturesType getExtractedFeatures() {
return extractedFeatures;
}
/**
* Sets the value of the extractedFeatures property.
*
* @param value
* allowed object is
* {@link ExtractedFeaturesType }
*
*/
public void setExtractedFeatures(ExtractedFeaturesType value) {
this.extractedFeatures = value;
}
public boolean equals(ObjectLocator thisLocator, ObjectLocator thatLocator,
Object object, EqualsStrategy strategy) {
if (!(object instanceof CodeObject)) {
return false;
}
if (this == object) {
return true;
}
if (!super.equals(thisLocator, thatLocator, object, strategy)) {
return false;
}
final CodeObject that = ((CodeObject) object);
{
StructuredTextType lhsDescription;
lhsDescription = this.getDescription();
StructuredTextType rhsDescription;
rhsDescription = that.getDescription();
if (!strategy.equals(LocatorUtils.property(thisLocator,
"description", lhsDescription), LocatorUtils.property(
thatLocator, "description", rhsDescription),
lhsDescription, rhsDescription)) {
return false;
}
}
{
CodeTypeType lhsType;
lhsType = this.getType();
CodeTypeType rhsType;
rhsType = that.getType();
if (!strategy.equals(
LocatorUtils.property(thisLocator, "type", lhsType),
LocatorUtils.property(thatLocator, "type", rhsType),
lhsType, rhsType)) {
return false;
}
}
{
CodePurposeType lhsPurpose;
lhsPurpose = this.getPurpose();
CodePurposeType rhsPurpose;
rhsPurpose = that.getPurpose();
if (!strategy.equals(
LocatorUtils.property(thisLocator, "purpose", lhsPurpose),
LocatorUtils.property(thatLocator, "purpose", rhsPurpose),
lhsPurpose, rhsPurpose)) {
return false;
}
}
{
CodeLanguageType lhsCodeLanguage;
lhsCodeLanguage = this.getCodeLanguage();
CodeLanguageType rhsCodeLanguage;
rhsCodeLanguage = that.getCodeLanguage();
if (!strategy.equals(LocatorUtils.property(thisLocator,
"codeLanguage", lhsCodeLanguage), LocatorUtils.property(
thatLocator, "codeLanguage", rhsCodeLanguage),
lhsCodeLanguage, rhsCodeLanguage)) {
return false;
}
}
{
TargetedPlatformsType lhsTargetedPlatforms;
lhsTargetedPlatforms = this.getTargetedPlatforms();
TargetedPlatformsType rhsTargetedPlatforms;
rhsTargetedPlatforms = that.getTargetedPlatforms();
if (!strategy.equals(LocatorUtils.property(thisLocator,
"targetedPlatforms", lhsTargetedPlatforms), LocatorUtils
.property(thatLocator, "targetedPlatforms",
rhsTargetedPlatforms), lhsTargetedPlatforms,
rhsTargetedPlatforms)) {
return false;
}
}
{
List lhsProcessorFamilies;
lhsProcessorFamilies = (((this.processorFamilies != null) && (!this.processorFamilies
.isEmpty())) ? this.getProcessorFamilies() : null);
List rhsProcessorFamilies;
rhsProcessorFamilies = (((that.processorFamilies != null) && (!that.processorFamilies
.isEmpty())) ? that.getProcessorFamilies() : null);
if (!strategy.equals(LocatorUtils.property(thisLocator,
"processorFamilies", lhsProcessorFamilies), LocatorUtils
.property(thatLocator, "processorFamilies",
rhsProcessorFamilies), lhsProcessorFamilies,
rhsProcessorFamilies)) {
return false;
}
}
{
MeasureSourceType lhsDiscoveryMethod;
lhsDiscoveryMethod = this.getDiscoveryMethod();
MeasureSourceType rhsDiscoveryMethod;
rhsDiscoveryMethod = that.getDiscoveryMethod();
if (!strategy.equals(LocatorUtils.property(thisLocator,
"discoveryMethod", lhsDiscoveryMethod), LocatorUtils
.property(thatLocator, "discoveryMethod",
rhsDiscoveryMethod), lhsDiscoveryMethod,
rhsDiscoveryMethod)) {
return false;
}
}
{
HexBinaryObjectPropertyType lhsStartAddress;
lhsStartAddress = this.getStartAddress();
HexBinaryObjectPropertyType rhsStartAddress;
rhsStartAddress = that.getStartAddress();
if (!strategy.equals(LocatorUtils.property(thisLocator,
"startAddress", lhsStartAddress), LocatorUtils.property(
thatLocator, "startAddress", rhsStartAddress),
lhsStartAddress, rhsStartAddress)) {
return false;
}
}
{
StringObjectPropertyType lhsCodeSegment;
lhsCodeSegment = this.getCodeSegment();
StringObjectPropertyType rhsCodeSegment;
rhsCodeSegment = that.getCodeSegment();
if (!strategy.equals(LocatorUtils.property(thisLocator,
"codeSegment", lhsCodeSegment), LocatorUtils.property(
thatLocator, "codeSegment", rhsCodeSegment),
lhsCodeSegment, rhsCodeSegment)) {
return false;
}
}
{
CodeSegmentXORType lhsCodeSegmentXOR;
lhsCodeSegmentXOR = this.getCodeSegmentXOR();
CodeSegmentXORType rhsCodeSegmentXOR;
rhsCodeSegmentXOR = that.getCodeSegmentXOR();
if (!strategy.equals(LocatorUtils.property(thisLocator,
"codeSegmentXOR", lhsCodeSegmentXOR),
LocatorUtils.property(thatLocator, "codeSegmentXOR",
rhsCodeSegmentXOR), lhsCodeSegmentXOR,
rhsCodeSegmentXOR)) {
return false;
}
}
{
DigitalSignaturesType lhsDigitalSignatures;
lhsDigitalSignatures = this.getDigitalSignatures();
DigitalSignaturesType rhsDigitalSignatures;
rhsDigitalSignatures = that.getDigitalSignatures();
if (!strategy.equals(LocatorUtils.property(thisLocator,
"digitalSignatures", lhsDigitalSignatures), LocatorUtils
.property(thatLocator, "digitalSignatures",
rhsDigitalSignatures), lhsDigitalSignatures,
rhsDigitalSignatures)) {
return false;
}
}
{
ExtractedFeaturesType lhsExtractedFeatures;
lhsExtractedFeatures = this.getExtractedFeatures();
ExtractedFeaturesType rhsExtractedFeatures;
rhsExtractedFeatures = that.getExtractedFeatures();
if (!strategy.equals(LocatorUtils.property(thisLocator,
"extractedFeatures", lhsExtractedFeatures), LocatorUtils
.property(thatLocator, "extractedFeatures",
rhsExtractedFeatures), lhsExtractedFeatures,
rhsExtractedFeatures)) {
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);
{
StructuredTextType theDescription;
theDescription = this.getDescription();
currentHashCode = strategy.hashCode(LocatorUtils.property(locator,
"description", theDescription), currentHashCode,
theDescription);
}
{
CodeTypeType theType;
theType = this.getType();
currentHashCode = strategy.hashCode(
LocatorUtils.property(locator, "type", theType),
currentHashCode, theType);
}
{
CodePurposeType thePurpose;
thePurpose = this.getPurpose();
currentHashCode = strategy.hashCode(
LocatorUtils.property(locator, "purpose", thePurpose),
currentHashCode, thePurpose);
}
{
CodeLanguageType theCodeLanguage;
theCodeLanguage = this.getCodeLanguage();
currentHashCode = strategy.hashCode(LocatorUtils.property(locator,
"codeLanguage", theCodeLanguage), currentHashCode,
theCodeLanguage);
}
{
TargetedPlatformsType theTargetedPlatforms;
theTargetedPlatforms = this.getTargetedPlatforms();
currentHashCode = strategy.hashCode(LocatorUtils.property(locator,
"targetedPlatforms", theTargetedPlatforms),
currentHashCode, theTargetedPlatforms);
}
{
List theProcessorFamilies;
theProcessorFamilies = (((this.processorFamilies != null) && (!this.processorFamilies
.isEmpty())) ? this.getProcessorFamilies() : null);
currentHashCode = strategy.hashCode(LocatorUtils.property(locator,
"processorFamilies", theProcessorFamilies),
currentHashCode, theProcessorFamilies);
}
{
MeasureSourceType theDiscoveryMethod;
theDiscoveryMethod = this.getDiscoveryMethod();
currentHashCode = strategy.hashCode(LocatorUtils.property(locator,
"discoveryMethod", theDiscoveryMethod), currentHashCode,
theDiscoveryMethod);
}
{
HexBinaryObjectPropertyType theStartAddress;
theStartAddress = this.getStartAddress();
currentHashCode = strategy.hashCode(LocatorUtils.property(locator,
"startAddress", theStartAddress), currentHashCode,
theStartAddress);
}
{
StringObjectPropertyType theCodeSegment;
theCodeSegment = this.getCodeSegment();
currentHashCode = strategy.hashCode(LocatorUtils.property(locator,
"codeSegment", theCodeSegment), currentHashCode,
theCodeSegment);
}
{
CodeSegmentXORType theCodeSegmentXOR;
theCodeSegmentXOR = this.getCodeSegmentXOR();
currentHashCode = strategy.hashCode(LocatorUtils.property(locator,
"codeSegmentXOR", theCodeSegmentXOR), currentHashCode,
theCodeSegmentXOR);
}
{
DigitalSignaturesType theDigitalSignatures;
theDigitalSignatures = this.getDigitalSignatures();
currentHashCode = strategy.hashCode(LocatorUtils.property(locator,
"digitalSignatures", theDigitalSignatures),
currentHashCode, theDigitalSignatures);
}
{
ExtractedFeaturesType theExtractedFeatures;
theExtractedFeatures = this.getExtractedFeatures();
currentHashCode = strategy.hashCode(LocatorUtils.property(locator,
"extractedFeatures", theExtractedFeatures),
currentHashCode, theExtractedFeatures);
}
return currentHashCode;
}
public int hashCode() {
final HashCodeStrategy strategy = JAXBHashCodeStrategy.INSTANCE;
return this.hashCode(null, strategy);
}
public CodeObject withDescription(StructuredTextType value) {
setDescription(value);
return this;
}
public CodeObject withType(CodeTypeType value) {
setType(value);
return this;
}
public CodeObject withPurpose(CodePurposeType value) {
setPurpose(value);
return this;
}
public CodeObject withCodeLanguage(CodeLanguageType value) {
setCodeLanguage(value);
return this;
}
public CodeObject withTargetedPlatforms(TargetedPlatformsType value) {
setTargetedPlatforms(value);
return this;
}
public CodeObject withProcessorFamilies(ProcessorTypeType... values) {
if (values != null) {
for (ProcessorTypeType value : values) {
getProcessorFamilies().add(value);
}
}
return this;
}
public CodeObject withProcessorFamilies(Collection values) {
if (values != null) {
getProcessorFamilies().addAll(values);
}
return this;
}
public CodeObject withDiscoveryMethod(MeasureSourceType value) {
setDiscoveryMethod(value);
return this;
}
public CodeObject withStartAddress(HexBinaryObjectPropertyType value) {
setStartAddress(value);
return this;
}
public CodeObject withCodeSegment(StringObjectPropertyType value) {
setCodeSegment(value);
return this;
}
public CodeObject withCodeSegmentXOR(CodeSegmentXORType value) {
setCodeSegmentXOR(value);
return this;
}
public CodeObject withDigitalSignatures(DigitalSignaturesType value) {
setDigitalSignatures(value);
return this;
}
public CodeObject withExtractedFeatures(ExtractedFeaturesType value) {
setExtractedFeatures(value);
return this;
}
@Override
public CodeObject withCustomProperties(CustomPropertiesType value) {
setCustomProperties(value);
return this;
}
@Override
public CodeObject 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);
{
StructuredTextType theDescription;
theDescription = this.getDescription();
strategy.appendField(locator, this, "description", buffer,
theDescription);
}
{
CodeTypeType theType;
theType = this.getType();
strategy.appendField(locator, this, "type", buffer, theType);
}
{
CodePurposeType thePurpose;
thePurpose = this.getPurpose();
strategy.appendField(locator, this, "purpose", buffer, thePurpose);
}
{
CodeLanguageType theCodeLanguage;
theCodeLanguage = this.getCodeLanguage();
strategy.appendField(locator, this, "codeLanguage", buffer,
theCodeLanguage);
}
{
TargetedPlatformsType theTargetedPlatforms;
theTargetedPlatforms = this.getTargetedPlatforms();
strategy.appendField(locator, this, "targetedPlatforms", buffer,
theTargetedPlatforms);
}
{
List theProcessorFamilies;
theProcessorFamilies = (((this.processorFamilies != null) && (!this.processorFamilies
.isEmpty())) ? this.getProcessorFamilies() : null);
strategy.appendField(locator, this, "processorFamilies", buffer,
theProcessorFamilies);
}
{
MeasureSourceType theDiscoveryMethod;
theDiscoveryMethod = this.getDiscoveryMethod();
strategy.appendField(locator, this, "discoveryMethod", buffer,
theDiscoveryMethod);
}
{
HexBinaryObjectPropertyType theStartAddress;
theStartAddress = this.getStartAddress();
strategy.appendField(locator, this, "startAddress", buffer,
theStartAddress);
}
{
StringObjectPropertyType theCodeSegment;
theCodeSegment = this.getCodeSegment();
strategy.appendField(locator, this, "codeSegment", buffer,
theCodeSegment);
}
{
CodeSegmentXORType theCodeSegmentXOR;
theCodeSegmentXOR = this.getCodeSegmentXOR();
strategy.appendField(locator, this, "codeSegmentXOR", buffer,
theCodeSegmentXOR);
}
{
DigitalSignaturesType theDigitalSignatures;
theDigitalSignatures = this.getDigitalSignatures();
strategy.appendField(locator, this, "digitalSignatures", buffer,
theDigitalSignatures);
}
{
ExtractedFeaturesType theExtractedFeatures;
theExtractedFeatures = this.getExtractedFeatures();
strategy.appendField(locator, this, "extractedFeatures", buffer,
theExtractedFeatures);
}
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, CodeObject.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 CodeObject instance for XML String
*
* @param text
* XML String for the document
* @return The CodeObject instance for the passed XML String
*/
public static CodeObject fromXMLString(String text) {
JAXBContext jaxbContext;
try {
jaxbContext = JAXBContext.newInstance(CodeObject.class.getPackage()
.getName());
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
unmarshaller.setSchema(STIXSchema.getInstance().getSchema());
unmarshaller.setEventHandler(new ValidationEventHandler());
StreamSource streamSource = new StreamSource(new StringReader(text));
return (CodeObject) unmarshaller.unmarshal(streamSource);
} catch (JAXBException e) {
throw new RuntimeException(e);
}
}
/**
* Validates the XML representation of this CodeObject 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());
}
}