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

org.mitre.cybox.objects.Address 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.IntegerObjectPropertyType;
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 AddressObjectType is intended to characterize cyber addresses.
 * 
 * 

Java class for AddressObjectType complex type. * *

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

 * <complexType name="AddressObjectType">
 *   <complexContent>
 *     <extension base="{http://cybox.mitre.org/common-2}ObjectPropertiesType">
 *       <sequence>
 *         <element name="Address_Value" type="{http://cybox.mitre.org/common-2}StringObjectPropertyType" minOccurs="0"/>
 *         <element name="VLAN_Name" type="{http://cybox.mitre.org/common-2}StringObjectPropertyType" minOccurs="0"/>
 *         <element name="VLAN_Num" type="{http://cybox.mitre.org/common-2}IntegerObjectPropertyType" minOccurs="0"/>
 *       </sequence>
 *       <attribute name="category" type="{http://cybox.mitre.org/objects#AddressObject-2}CategoryTypeEnum" default="ipv4-addr" />
 *       <attribute name="is_source" type="{http://www.w3.org/2001/XMLSchema}boolean" />
 *       <attribute name="is_destination" type="{http://www.w3.org/2001/XMLSchema}boolean" />
 *       <attribute name="is_spoofed" type="{http://www.w3.org/2001/XMLSchema}boolean" />
 *     </extension>
 *   </complexContent>
 * </complexType>
 * 
* * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "AddressObjectType", namespace = "http://cybox.mitre.org/objects#AddressObject-2", propOrder = { "addressValue", "vlanName", "vlanNum" }) @XmlRootElement(name = "Address", namespace = "http://cybox.mitre.org/objects#AddressObject-2") public class Address extends ObjectPropertiesType implements Equals, HashCode, ToString { @XmlElement(name = "Address_Value") protected StringObjectPropertyType addressValue; @XmlElement(name = "VLAN_Name") protected StringObjectPropertyType vlanName; @XmlElement(name = "VLAN_Num") protected IntegerObjectPropertyType vlanNum; @XmlAttribute(name = "category") protected CategoryTypeEnum category; @XmlAttribute(name = "is_source") protected Boolean isSource; @XmlAttribute(name = "is_destination") protected Boolean isDestination; @XmlAttribute(name = "is_spoofed") protected Boolean isSpoofed; /** * Default no-arg constructor * */ public Address() { super(); } /** * Fully-initialising value constructor * */ public Address(final CustomPropertiesType customProperties, final QName objectReference, final StringObjectPropertyType addressValue, final StringObjectPropertyType vlanName, final IntegerObjectPropertyType vlanNum, final CategoryTypeEnum category, final Boolean isSource, final Boolean isDestination, final Boolean isSpoofed) { super(customProperties, objectReference); this.addressValue = addressValue; this.vlanName = vlanName; this.vlanNum = vlanNum; this.category = category; this.isSource = isSource; this.isDestination = isDestination; this.isSpoofed = isSpoofed; } /** * Gets the value of the addressValue property. * * @return * possible object is * {@link StringObjectPropertyType } * */ public StringObjectPropertyType getAddressValue() { return addressValue; } /** * Sets the value of the addressValue property. * * @param value * allowed object is * {@link StringObjectPropertyType } * */ public void setAddressValue(StringObjectPropertyType value) { this.addressValue = value; } /** * Gets the value of the vlanName property. * * @return * possible object is * {@link StringObjectPropertyType } * */ public StringObjectPropertyType getVLANName() { return vlanName; } /** * Sets the value of the vlanName property. * * @param value * allowed object is * {@link StringObjectPropertyType } * */ public void setVLANName(StringObjectPropertyType value) { this.vlanName = value; } /** * Gets the value of the vlanNum property. * * @return * possible object is * {@link IntegerObjectPropertyType } * */ public IntegerObjectPropertyType getVLANNum() { return vlanNum; } /** * Sets the value of the vlanNum property. * * @param value * allowed object is * {@link IntegerObjectPropertyType } * */ public void setVLANNum(IntegerObjectPropertyType value) { this.vlanNum = value; } /** * Gets the value of the category property. * * @return * possible object is * {@link CategoryTypeEnum } * */ public CategoryTypeEnum getCategory() { if (category == null) { return CategoryTypeEnum.IPV_4_ADDR; } else { return category; } } /** * Sets the value of the category property. * * @param value * allowed object is * {@link CategoryTypeEnum } * */ public void setCategory(CategoryTypeEnum value) { this.category = value; } /** * Gets the value of the isSource property. * * @return * possible object is * {@link Boolean } * */ public Boolean isIsSource() { return isSource; } /** * Sets the value of the isSource property. * * @param value * allowed object is * {@link Boolean } * */ public void setIsSource(Boolean value) { this.isSource = value; } /** * Gets the value of the isDestination property. * * @return * possible object is * {@link Boolean } * */ public Boolean isIsDestination() { return isDestination; } /** * Sets the value of the isDestination property. * * @param value * allowed object is * {@link Boolean } * */ public void setIsDestination(Boolean value) { this.isDestination = value; } /** * Gets the value of the isSpoofed property. * * @return * possible object is * {@link Boolean } * */ public Boolean isIsSpoofed() { return isSpoofed; } /** * Sets the value of the isSpoofed property. * * @param value * allowed object is * {@link Boolean } * */ public void setIsSpoofed(Boolean value) { this.isSpoofed = value; } public boolean equals(ObjectLocator thisLocator, ObjectLocator thatLocator, Object object, EqualsStrategy strategy) { if (!(object instanceof Address)) { return false; } if (this == object) { return true; } if (!super.equals(thisLocator, thatLocator, object, strategy)) { return false; } final Address that = ((Address) object); { StringObjectPropertyType lhsAddressValue; lhsAddressValue = this.getAddressValue(); StringObjectPropertyType rhsAddressValue; rhsAddressValue = that.getAddressValue(); if (!strategy.equals(LocatorUtils.property(thisLocator, "addressValue", lhsAddressValue), LocatorUtils.property( thatLocator, "addressValue", rhsAddressValue), lhsAddressValue, rhsAddressValue)) { return false; } } { StringObjectPropertyType lhsVLANName; lhsVLANName = this.getVLANName(); StringObjectPropertyType rhsVLANName; rhsVLANName = that.getVLANName(); if (!strategy .equals(LocatorUtils.property(thisLocator, "vlanName", lhsVLANName), LocatorUtils.property(thatLocator, "vlanName", rhsVLANName), lhsVLANName, rhsVLANName)) { return false; } } { IntegerObjectPropertyType lhsVLANNum; lhsVLANNum = this.getVLANNum(); IntegerObjectPropertyType rhsVLANNum; rhsVLANNum = that.getVLANNum(); if (!strategy.equals( LocatorUtils.property(thisLocator, "vlanNum", lhsVLANNum), LocatorUtils.property(thatLocator, "vlanNum", rhsVLANNum), lhsVLANNum, rhsVLANNum)) { return false; } } { CategoryTypeEnum lhsCategory; lhsCategory = this.getCategory(); CategoryTypeEnum rhsCategory; rhsCategory = that.getCategory(); if (!strategy .equals(LocatorUtils.property(thisLocator, "category", lhsCategory), LocatorUtils.property(thatLocator, "category", rhsCategory), lhsCategory, rhsCategory)) { return false; } } { Boolean lhsIsSource; lhsIsSource = this.isIsSource(); Boolean rhsIsSource; rhsIsSource = that.isIsSource(); if (!strategy .equals(LocatorUtils.property(thisLocator, "isSource", lhsIsSource), LocatorUtils.property(thatLocator, "isSource", rhsIsSource), lhsIsSource, rhsIsSource)) { return false; } } { Boolean lhsIsDestination; lhsIsDestination = this.isIsDestination(); Boolean rhsIsDestination; rhsIsDestination = that.isIsDestination(); if (!strategy.equals(LocatorUtils.property(thisLocator, "isDestination", lhsIsDestination), LocatorUtils.property( thatLocator, "isDestination", rhsIsDestination), lhsIsDestination, rhsIsDestination)) { return false; } } { Boolean lhsIsSpoofed; lhsIsSpoofed = this.isIsSpoofed(); Boolean rhsIsSpoofed; rhsIsSpoofed = that.isIsSpoofed(); if (!strategy.equals(LocatorUtils.property(thisLocator, "isSpoofed", lhsIsSpoofed), LocatorUtils.property( thatLocator, "isSpoofed", rhsIsSpoofed), lhsIsSpoofed, rhsIsSpoofed)) { 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); { StringObjectPropertyType theAddressValue; theAddressValue = this.getAddressValue(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "addressValue", theAddressValue), currentHashCode, theAddressValue); } { StringObjectPropertyType theVLANName; theVLANName = this.getVLANName(); currentHashCode = strategy.hashCode( LocatorUtils.property(locator, "vlanName", theVLANName), currentHashCode, theVLANName); } { IntegerObjectPropertyType theVLANNum; theVLANNum = this.getVLANNum(); currentHashCode = strategy.hashCode( LocatorUtils.property(locator, "vlanNum", theVLANNum), currentHashCode, theVLANNum); } { CategoryTypeEnum theCategory; theCategory = this.getCategory(); currentHashCode = strategy.hashCode( LocatorUtils.property(locator, "category", theCategory), currentHashCode, theCategory); } { Boolean theIsSource; theIsSource = this.isIsSource(); currentHashCode = strategy.hashCode( LocatorUtils.property(locator, "isSource", theIsSource), currentHashCode, theIsSource); } { Boolean theIsDestination; theIsDestination = this.isIsDestination(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "isDestination", theIsDestination), currentHashCode, theIsDestination); } { Boolean theIsSpoofed; theIsSpoofed = this.isIsSpoofed(); currentHashCode = strategy.hashCode( LocatorUtils.property(locator, "isSpoofed", theIsSpoofed), currentHashCode, theIsSpoofed); } return currentHashCode; } public int hashCode() { final HashCodeStrategy strategy = JAXBHashCodeStrategy.INSTANCE; return this.hashCode(null, strategy); } public Address withAddressValue(StringObjectPropertyType value) { setAddressValue(value); return this; } public Address withVLANName(StringObjectPropertyType value) { setVLANName(value); return this; } public Address withVLANNum(IntegerObjectPropertyType value) { setVLANNum(value); return this; } public Address withCategory(CategoryTypeEnum value) { setCategory(value); return this; } public Address withIsSource(Boolean value) { setIsSource(value); return this; } public Address withIsDestination(Boolean value) { setIsDestination(value); return this; } public Address withIsSpoofed(Boolean value) { setIsSpoofed(value); return this; } @Override public Address withCustomProperties(CustomPropertiesType value) { setCustomProperties(value); return this; } @Override public Address 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); { StringObjectPropertyType theAddressValue; theAddressValue = this.getAddressValue(); strategy.appendField(locator, this, "addressValue", buffer, theAddressValue); } { StringObjectPropertyType theVLANName; theVLANName = this.getVLANName(); strategy.appendField(locator, this, "vlanName", buffer, theVLANName); } { IntegerObjectPropertyType theVLANNum; theVLANNum = this.getVLANNum(); strategy.appendField(locator, this, "vlanNum", buffer, theVLANNum); } { CategoryTypeEnum theCategory; theCategory = this.getCategory(); strategy.appendField(locator, this, "category", buffer, theCategory); } { Boolean theIsSource; theIsSource = this.isIsSource(); strategy.appendField(locator, this, "isSource", buffer, theIsSource); } { Boolean theIsDestination; theIsDestination = this.isIsDestination(); strategy.appendField(locator, this, "isDestination", buffer, theIsDestination); } { Boolean theIsSpoofed; theIsSpoofed = this.isIsSpoofed(); strategy.appendField(locator, this, "isSpoofed", buffer, theIsSpoofed); } 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, Address.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 Address instance for XML String * * @param text * XML String for the document * @return The Address instance for the passed XML String */ public static Address fromXMLString(String text) { JAXBContext jaxbContext; try { jaxbContext = JAXBContext.newInstance(Address.class.getPackage() .getName()); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); unmarshaller.setSchema(STIXSchema.getInstance().getSchema()); unmarshaller.setEventHandler(new ValidationEventHandler()); StreamSource streamSource = new StreamSource(new StringReader(text)); return (Address) unmarshaller.unmarshal(streamSource); } catch (JAXBException e) { throw new RuntimeException(e); } } /** * Validates the XML representation of this Address 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