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

xml.metadatasharing.ClassificationObject 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 xml.metadatasharing;

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.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.datatype.XMLGregorianCalendar;
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.stix.DocumentUtilities;
import org.mitre.stix.STIXSchema;
import org.mitre.stix.ValidationEventHandler;
import org.xml.sax.SAXException;

/**
 * 
 *        Classification object, used to hold names or classifications of objects. The most common use case for this is detection
 *        names for files from av scanners. However, this object could be used for general classification. The globally unique id (attribute)
 *        should be created from "Company name:internal classification name", e.g. "Mcafee:Generic.DX". The other required attribute is the
 *        type of classification, e.g. clean, dirty, unknown. 
 *        
 *        There are elements to capture the category of the classification. The category should be entered in the same way to the
 *        classification name, e.g. company name:category name, e..g Mcafee:Trojan.
 *        
 *       
 * 
 * 

Java class for classificationObject complex type. * *

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

 * <complexType name="classificationObject">
 *   <complexContent>
 *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       <sequence>
 *         <element name="classificationName" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *         <element name="companyName" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *         <element name="category" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         <element name="classificationDetails" minOccurs="0">
 *           <complexType>
 *             <complexContent>
 *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *                 <sequence>
 *                   <element name="definitionVersion" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *                   <element name="detectionAddedTimeStamp" type="{http://www.w3.org/2001/XMLSchema}dateTime" minOccurs="0"/>
 *                   <element name="detectionShippedTimeStamp" type="{http://www.w3.org/2001/XMLSchema}dateTime" minOccurs="0"/>
 *                   <element name="product" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *                   <element name="productVersion" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *                 </sequence>
 *               </restriction>
 *             </complexContent>
 *           </complexType>
 *         </element>
 *       </sequence>
 *       <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
 *       <attribute name="type" use="required" type="{http://xml/metadataSharing.xsd}ClassificationTypeEnum" />
 *     </restriction>
 *   </complexContent>
 * </complexType>
 * 
* * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "classificationObject", propOrder = { "classificationName", "companyName", "category", "classificationDetails" }) public class ClassificationObject implements Equals, HashCode, ToString { @XmlElement(required = true) protected String classificationName; @XmlElement(required = true) protected String companyName; protected String category; protected ClassificationObject.ClassificationDetails classificationDetails; @XmlAttribute(name = "id", required = true) protected String id; @XmlAttribute(name = "type", required = true) protected ClassificationTypeEnum type; /** * Default no-arg constructor * */ public ClassificationObject() { super(); } /** * Fully-initialising value constructor * */ public ClassificationObject( final String classificationName, final String companyName, final String category, final ClassificationObject.ClassificationDetails classificationDetails, final String id, final ClassificationTypeEnum type) { this.classificationName = classificationName; this.companyName = companyName; this.category = category; this.classificationDetails = classificationDetails; this.id = id; this.type = type; } /** * Gets the value of the classificationName property. * * @return * possible object is * {@link String } * */ public String getClassificationName() { return classificationName; } /** * Sets the value of the classificationName property. * * @param value * allowed object is * {@link String } * */ public void setClassificationName(String value) { this.classificationName = value; } /** * Gets the value of the companyName property. * * @return * possible object is * {@link String } * */ public String getCompanyName() { return companyName; } /** * Sets the value of the companyName property. * * @param value * allowed object is * {@link String } * */ public void setCompanyName(String value) { this.companyName = value; } /** * Gets the value of the category property. * * @return * possible object is * {@link String } * */ public String getCategory() { return category; } /** * Sets the value of the category property. * * @param value * allowed object is * {@link String } * */ public void setCategory(String value) { this.category = value; } /** * Gets the value of the classificationDetails property. * * @return * possible object is * {@link ClassificationObject.ClassificationDetails } * */ public ClassificationObject.ClassificationDetails getClassificationDetails() { return classificationDetails; } /** * Sets the value of the classificationDetails property. * * @param value * allowed object is * {@link ClassificationObject.ClassificationDetails } * */ public void setClassificationDetails( ClassificationObject.ClassificationDetails value) { this.classificationDetails = value; } /** * Gets the value of the id property. * * @return * possible object is * {@link String } * */ public String getId() { return id; } /** * Sets the value of the id property. * * @param value * allowed object is * {@link String } * */ public void setId(String value) { this.id = value; } /** * Gets the value of the type property. * * @return * possible object is * {@link ClassificationTypeEnum } * */ public ClassificationTypeEnum getType() { return type; } /** * Sets the value of the type property. * * @param value * allowed object is * {@link ClassificationTypeEnum } * */ public void setType(ClassificationTypeEnum value) { this.type = value; } public boolean equals(ObjectLocator thisLocator, ObjectLocator thatLocator, Object object, EqualsStrategy strategy) { if (!(object instanceof ClassificationObject)) { return false; } if (this == object) { return true; } final ClassificationObject that = ((ClassificationObject) object); { String lhsClassificationName; lhsClassificationName = this.getClassificationName(); String rhsClassificationName; rhsClassificationName = that.getClassificationName(); if (!strategy.equals(LocatorUtils.property(thisLocator, "classificationName", lhsClassificationName), LocatorUtils .property(thatLocator, "classificationName", rhsClassificationName), lhsClassificationName, rhsClassificationName)) { return false; } } { String lhsCompanyName; lhsCompanyName = this.getCompanyName(); String rhsCompanyName; rhsCompanyName = that.getCompanyName(); if (!strategy.equals(LocatorUtils.property(thisLocator, "companyName", lhsCompanyName), LocatorUtils.property( thatLocator, "companyName", rhsCompanyName), lhsCompanyName, rhsCompanyName)) { return false; } } { String lhsCategory; lhsCategory = this.getCategory(); String rhsCategory; rhsCategory = that.getCategory(); if (!strategy .equals(LocatorUtils.property(thisLocator, "category", lhsCategory), LocatorUtils.property(thatLocator, "category", rhsCategory), lhsCategory, rhsCategory)) { return false; } } { ClassificationObject.ClassificationDetails lhsClassificationDetails; lhsClassificationDetails = this.getClassificationDetails(); ClassificationObject.ClassificationDetails rhsClassificationDetails; rhsClassificationDetails = that.getClassificationDetails(); if (!strategy.equals(LocatorUtils.property(thisLocator, "classificationDetails", lhsClassificationDetails), LocatorUtils.property(thatLocator, "classificationDetails", rhsClassificationDetails), lhsClassificationDetails, rhsClassificationDetails)) { return false; } } { String lhsId; lhsId = this.getId(); String rhsId; rhsId = that.getId(); if (!strategy.equals( LocatorUtils.property(thisLocator, "id", lhsId), LocatorUtils.property(thatLocator, "id", rhsId), lhsId, rhsId)) { return false; } } { ClassificationTypeEnum lhsType; lhsType = this.getType(); ClassificationTypeEnum rhsType; rhsType = that.getType(); if (!strategy.equals( LocatorUtils.property(thisLocator, "type", lhsType), LocatorUtils.property(thatLocator, "type", rhsType), lhsType, rhsType)) { 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 = 1; { String theClassificationName; theClassificationName = this.getClassificationName(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "classificationName", theClassificationName), currentHashCode, theClassificationName); } { String theCompanyName; theCompanyName = this.getCompanyName(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "companyName", theCompanyName), currentHashCode, theCompanyName); } { String theCategory; theCategory = this.getCategory(); currentHashCode = strategy.hashCode( LocatorUtils.property(locator, "category", theCategory), currentHashCode, theCategory); } { ClassificationObject.ClassificationDetails theClassificationDetails; theClassificationDetails = this.getClassificationDetails(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "classificationDetails", theClassificationDetails), currentHashCode, theClassificationDetails); } { String theId; theId = this.getId(); currentHashCode = strategy.hashCode( LocatorUtils.property(locator, "id", theId), currentHashCode, theId); } { ClassificationTypeEnum theType; theType = this.getType(); currentHashCode = strategy.hashCode( LocatorUtils.property(locator, "type", theType), currentHashCode, theType); } return currentHashCode; } public int hashCode() { final HashCodeStrategy strategy = JAXBHashCodeStrategy.INSTANCE; return this.hashCode(null, strategy); } public ClassificationObject withClassificationName(String value) { setClassificationName(value); return this; } public ClassificationObject withCompanyName(String value) { setCompanyName(value); return this; } public ClassificationObject withCategory(String value) { setCategory(value); return this; } public ClassificationObject withClassificationDetails( ClassificationObject.ClassificationDetails value) { setClassificationDetails(value); return this; } public ClassificationObject withId(String value) { setId(value); return this; } public ClassificationObject withType(ClassificationTypeEnum value) { setType(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) { { String theClassificationName; theClassificationName = this.getClassificationName(); strategy.appendField(locator, this, "classificationName", buffer, theClassificationName); } { String theCompanyName; theCompanyName = this.getCompanyName(); strategy.appendField(locator, this, "companyName", buffer, theCompanyName); } { String theCategory; theCategory = this.getCategory(); strategy.appendField(locator, this, "category", buffer, theCategory); } { ClassificationObject.ClassificationDetails theClassificationDetails; theClassificationDetails = this.getClassificationDetails(); strategy.appendField(locator, this, "classificationDetails", buffer, theClassificationDetails); } { String theId; theId = this.getId(); strategy.appendField(locator, this, "id", buffer, theId); } { ClassificationTypeEnum theType; theType = this.getType(); strategy.appendField(locator, this, "type", buffer, theType); } return buffer; } /** *

Java class for anonymous complex type. * *

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

	 * <complexType>
	 *   <complexContent>
	 *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
	 *       <sequence>
	 *         <element name="definitionVersion" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
	 *         <element name="detectionAddedTimeStamp" type="{http://www.w3.org/2001/XMLSchema}dateTime" minOccurs="0"/>
	 *         <element name="detectionShippedTimeStamp" type="{http://www.w3.org/2001/XMLSchema}dateTime" minOccurs="0"/>
	 *         <element name="product" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
	 *         <element name="productVersion" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
	 *       </sequence>
	 *     </restriction>
	 *   </complexContent>
	 * </complexType>
	 * 
* * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { "definitionVersion", "detectionAddedTimeStamp", "detectionShippedTimeStamp", "product", "productVersion" }) public static class ClassificationDetails implements Equals, HashCode, ToString { protected String definitionVersion; @XmlSchemaType(name = "dateTime") protected XMLGregorianCalendar detectionAddedTimeStamp; @XmlSchemaType(name = "dateTime") protected XMLGregorianCalendar detectionShippedTimeStamp; protected String product; protected String productVersion; /** * Default no-arg constructor * */ public ClassificationDetails() { super(); } /** * Fully-initialising value constructor * */ public ClassificationDetails(final String definitionVersion, final XMLGregorianCalendar detectionAddedTimeStamp, final XMLGregorianCalendar detectionShippedTimeStamp, final String product, final String productVersion) { this.definitionVersion = definitionVersion; this.detectionAddedTimeStamp = detectionAddedTimeStamp; this.detectionShippedTimeStamp = detectionShippedTimeStamp; this.product = product; this.productVersion = productVersion; } /** * Gets the value of the definitionVersion property. * * @return * possible object is * {@link String } * */ public String getDefinitionVersion() { return definitionVersion; } /** * Sets the value of the definitionVersion property. * * @param value * allowed object is * {@link String } * */ public void setDefinitionVersion(String value) { this.definitionVersion = value; } /** * Gets the value of the detectionAddedTimeStamp property. * * @return * possible object is * {@link XMLGregorianCalendar } * */ public XMLGregorianCalendar getDetectionAddedTimeStamp() { return detectionAddedTimeStamp; } /** * Sets the value of the detectionAddedTimeStamp property. * * @param value * allowed object is * {@link XMLGregorianCalendar } * */ public void setDetectionAddedTimeStamp(XMLGregorianCalendar value) { this.detectionAddedTimeStamp = value; } /** * Gets the value of the detectionShippedTimeStamp property. * * @return * possible object is * {@link XMLGregorianCalendar } * */ public XMLGregorianCalendar getDetectionShippedTimeStamp() { return detectionShippedTimeStamp; } /** * Sets the value of the detectionShippedTimeStamp property. * * @param value * allowed object is * {@link XMLGregorianCalendar } * */ public void setDetectionShippedTimeStamp(XMLGregorianCalendar value) { this.detectionShippedTimeStamp = value; } /** * Gets the value of the product property. * * @return * possible object is * {@link String } * */ public String getProduct() { return product; } /** * Sets the value of the product property. * * @param value * allowed object is * {@link String } * */ public void setProduct(String value) { this.product = value; } /** * Gets the value of the productVersion property. * * @return * possible object is * {@link String } * */ public String getProductVersion() { return productVersion; } /** * Sets the value of the productVersion property. * * @param value * allowed object is * {@link String } * */ public void setProductVersion(String value) { this.productVersion = value; } public boolean equals(ObjectLocator thisLocator, ObjectLocator thatLocator, Object object, EqualsStrategy strategy) { if (!(object instanceof ClassificationObject.ClassificationDetails)) { return false; } if (this == object) { return true; } final ClassificationObject.ClassificationDetails that = ((ClassificationObject.ClassificationDetails) object); { String lhsDefinitionVersion; lhsDefinitionVersion = this.getDefinitionVersion(); String rhsDefinitionVersion; rhsDefinitionVersion = that.getDefinitionVersion(); if (!strategy.equals(LocatorUtils.property(thisLocator, "definitionVersion", lhsDefinitionVersion), LocatorUtils.property(thatLocator, "definitionVersion", rhsDefinitionVersion), lhsDefinitionVersion, rhsDefinitionVersion)) { return false; } } { XMLGregorianCalendar lhsDetectionAddedTimeStamp; lhsDetectionAddedTimeStamp = this.getDetectionAddedTimeStamp(); XMLGregorianCalendar rhsDetectionAddedTimeStamp; rhsDetectionAddedTimeStamp = that.getDetectionAddedTimeStamp(); if (!strategy.equals(LocatorUtils.property(thisLocator, "detectionAddedTimeStamp", lhsDetectionAddedTimeStamp), LocatorUtils.property(thatLocator, "detectionAddedTimeStamp", rhsDetectionAddedTimeStamp), lhsDetectionAddedTimeStamp, rhsDetectionAddedTimeStamp)) { return false; } } { XMLGregorianCalendar lhsDetectionShippedTimeStamp; lhsDetectionShippedTimeStamp = this .getDetectionShippedTimeStamp(); XMLGregorianCalendar rhsDetectionShippedTimeStamp; rhsDetectionShippedTimeStamp = that .getDetectionShippedTimeStamp(); if (!strategy.equals(LocatorUtils.property(thisLocator, "detectionShippedTimeStamp", lhsDetectionShippedTimeStamp), LocatorUtils.property( thatLocator, "detectionShippedTimeStamp", rhsDetectionShippedTimeStamp), lhsDetectionShippedTimeStamp, rhsDetectionShippedTimeStamp)) { return false; } } { String lhsProduct; lhsProduct = this.getProduct(); String rhsProduct; rhsProduct = that.getProduct(); if (!strategy.equals(LocatorUtils.property(thisLocator, "product", lhsProduct), LocatorUtils.property( thatLocator, "product", rhsProduct), lhsProduct, rhsProduct)) { return false; } } { String lhsProductVersion; lhsProductVersion = this.getProductVersion(); String rhsProductVersion; rhsProductVersion = that.getProductVersion(); if (!strategy.equals(LocatorUtils.property(thisLocator, "productVersion", lhsProductVersion), LocatorUtils .property(thatLocator, "productVersion", rhsProductVersion), lhsProductVersion, rhsProductVersion)) { 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 = 1; { String theDefinitionVersion; theDefinitionVersion = this.getDefinitionVersion(); currentHashCode = strategy.hashCode(LocatorUtils.property( locator, "definitionVersion", theDefinitionVersion), currentHashCode, theDefinitionVersion); } { XMLGregorianCalendar theDetectionAddedTimeStamp; theDetectionAddedTimeStamp = this.getDetectionAddedTimeStamp(); currentHashCode = strategy.hashCode(LocatorUtils.property( locator, "detectionAddedTimeStamp", theDetectionAddedTimeStamp), currentHashCode, theDetectionAddedTimeStamp); } { XMLGregorianCalendar theDetectionShippedTimeStamp; theDetectionShippedTimeStamp = this .getDetectionShippedTimeStamp(); currentHashCode = strategy.hashCode(LocatorUtils.property( locator, "detectionShippedTimeStamp", theDetectionShippedTimeStamp), currentHashCode, theDetectionShippedTimeStamp); } { String theProduct; theProduct = this.getProduct(); currentHashCode = strategy.hashCode( LocatorUtils.property(locator, "product", theProduct), currentHashCode, theProduct); } { String theProductVersion; theProductVersion = this.getProductVersion(); currentHashCode = strategy.hashCode(LocatorUtils.property( locator, "productVersion", theProductVersion), currentHashCode, theProductVersion); } return currentHashCode; } public int hashCode() { final HashCodeStrategy strategy = JAXBHashCodeStrategy.INSTANCE; return this.hashCode(null, strategy); } public ClassificationObject.ClassificationDetails withDefinitionVersion( String value) { setDefinitionVersion(value); return this; } public ClassificationObject.ClassificationDetails withDetectionAddedTimeStamp( XMLGregorianCalendar value) { setDetectionAddedTimeStamp(value); return this; } public ClassificationObject.ClassificationDetails withDetectionShippedTimeStamp( XMLGregorianCalendar value) { setDetectionShippedTimeStamp(value); return this; } public ClassificationObject.ClassificationDetails withProduct( String value) { setProduct(value); return this; } public ClassificationObject.ClassificationDetails withProductVersion( String value) { setProductVersion(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) { { String theDefinitionVersion; theDefinitionVersion = this.getDefinitionVersion(); strategy.appendField(locator, this, "definitionVersion", buffer, theDefinitionVersion); } { XMLGregorianCalendar theDetectionAddedTimeStamp; theDetectionAddedTimeStamp = this.getDetectionAddedTimeStamp(); strategy.appendField(locator, this, "detectionAddedTimeStamp", buffer, theDetectionAddedTimeStamp); } { XMLGregorianCalendar theDetectionShippedTimeStamp; theDetectionShippedTimeStamp = this .getDetectionShippedTimeStamp(); strategy.appendField(locator, this, "detectionShippedTimeStamp", buffer, theDetectionShippedTimeStamp); } { String theProduct; theProduct = this.getProduct(); strategy.appendField(locator, this, "product", buffer, theProduct); } { String theProductVersion; theProductVersion = this.getProductVersion(); strategy.appendField(locator, this, "productVersion", buffer, theProductVersion); } 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, ClassificationObject.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 ClassificationObject instance for XML String * * @param text * XML String for the document * @return The ClassificationObject instance for the passed XML String */ public static ClassificationObject fromXMLString(String text) { JAXBContext jaxbContext; try { jaxbContext = JAXBContext.newInstance(ClassificationObject.class .getPackage().getName()); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); unmarshaller.setSchema(STIXSchema.getInstance().getSchema()); unmarshaller.setEventHandler(new ValidationEventHandler()); StreamSource streamSource = new StreamSource(new StringReader(text)); return (ClassificationObject) unmarshaller.unmarshal(streamSource); } catch (JAXBException e) { throw new RuntimeException(e); } } /** * Validates the XML representation of this ClassificationObject 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