org.mitre.capec.capec_2.AlternateTerms 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.06.23 at 10:59:44 AM EDT
//
package org.mitre.capec.capec_2;
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.stix.DocumentUtilities;
import org.mitre.stix.STIXSchema;
import org.mitre.stix.ValidationEventHandler;
/**
* 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="Alternate_Term" maxOccurs="unbounded">
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="Term" type="{http://www.w3.org/2001/XMLSchema}string"/>
* <element name="Alternate_Term_Description" type="{http://capec.mitre.org/capec-2}Structured_Text_Type" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </element>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
*
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = { "alternateTerms" })
@XmlRootElement(name = "Alternate_Terms")
public class AlternateTerms implements Equals, HashCode, ToString {
@XmlElement(name = "Alternate_Term", required = true)
protected List alternateTerms;
/**
* Default no-arg constructor
*
*/
public AlternateTerms() {
super();
}
/**
* Fully-initialising value constructor
*
*/
public AlternateTerms(
final List alternateTerms) {
this.alternateTerms = alternateTerms;
}
/**
* Gets the value of the alternateTerms 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 alternateTerms property.
*
*
* For example, to add a new item, do as follows:
*
* getAlternateTerms().add(newItem);
*
*
*
*
* Objects of the following type(s) are allowed in the list
* {@link AlternateTerms.AlternateTerm }
*
*
*/
public List getAlternateTerms() {
if (alternateTerms == null) {
alternateTerms = new ArrayList();
}
return this.alternateTerms;
}
public boolean equals(ObjectLocator thisLocator, ObjectLocator thatLocator,
Object object, EqualsStrategy strategy) {
if (!(object instanceof AlternateTerms)) {
return false;
}
if (this == object) {
return true;
}
final AlternateTerms that = ((AlternateTerms) object);
{
List lhsAlternateTerms;
lhsAlternateTerms = (((this.alternateTerms != null) && (!this.alternateTerms
.isEmpty())) ? this.getAlternateTerms() : null);
List rhsAlternateTerms;
rhsAlternateTerms = (((that.alternateTerms != null) && (!that.alternateTerms
.isEmpty())) ? that.getAlternateTerms() : null);
if (!strategy.equals(LocatorUtils.property(thisLocator,
"alternateTerms", lhsAlternateTerms),
LocatorUtils.property(thatLocator, "alternateTerms",
rhsAlternateTerms), lhsAlternateTerms,
rhsAlternateTerms)) {
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;
{
List theAlternateTerms;
theAlternateTerms = (((this.alternateTerms != null) && (!this.alternateTerms
.isEmpty())) ? this.getAlternateTerms() : null);
currentHashCode = strategy.hashCode(LocatorUtils.property(locator,
"alternateTerms", theAlternateTerms), currentHashCode,
theAlternateTerms);
}
return currentHashCode;
}
public int hashCode() {
final HashCodeStrategy strategy = JAXBHashCodeStrategy.INSTANCE;
return this.hashCode(null, strategy);
}
public AlternateTerms withAlternateTerms(
AlternateTerms.AlternateTerm... values) {
if (values != null) {
for (AlternateTerms.AlternateTerm value : values) {
getAlternateTerms().add(value);
}
}
return this;
}
public AlternateTerms withAlternateTerms(
Collection values) {
if (values != null) {
getAlternateTerms().addAll(values);
}
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) {
{
List theAlternateTerms;
theAlternateTerms = (((this.alternateTerms != null) && (!this.alternateTerms
.isEmpty())) ? this.getAlternateTerms() : null);
strategy.appendField(locator, this, "alternateTerms", buffer,
theAlternateTerms);
}
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="Term" type="{http://www.w3.org/2001/XMLSchema}string"/>
* <element name="Alternate_Term_Description" type="{http://capec.mitre.org/capec-2}Structured_Text_Type" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
*
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = { "term", "alternateTermDescription" })
public static class AlternateTerm implements Equals, HashCode, ToString {
@XmlElement(name = "Term", required = true)
protected String term;
@XmlElement(name = "Alternate_Term_Description")
protected StructuredTextType alternateTermDescription;
/**
* Default no-arg constructor
*
*/
public AlternateTerm() {
super();
}
/**
* Fully-initialising value constructor
*
*/
public AlternateTerm(final String term,
final StructuredTextType alternateTermDescription) {
this.term = term;
this.alternateTermDescription = alternateTermDescription;
}
/**
* Gets the value of the term property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getTerm() {
return term;
}
/**
* Sets the value of the term property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setTerm(String value) {
this.term = value;
}
/**
* Gets the value of the alternateTermDescription property.
*
* @return
* possible object is
* {@link StructuredTextType }
*
*/
public StructuredTextType getAlternateTermDescription() {
return alternateTermDescription;
}
/**
* Sets the value of the alternateTermDescription property.
*
* @param value
* allowed object is
* {@link StructuredTextType }
*
*/
public void setAlternateTermDescription(StructuredTextType value) {
this.alternateTermDescription = value;
}
public boolean equals(ObjectLocator thisLocator,
ObjectLocator thatLocator, Object object,
EqualsStrategy strategy) {
if (!(object instanceof AlternateTerms.AlternateTerm)) {
return false;
}
if (this == object) {
return true;
}
final AlternateTerms.AlternateTerm that = ((AlternateTerms.AlternateTerm) object);
{
String lhsTerm;
lhsTerm = this.getTerm();
String rhsTerm;
rhsTerm = that.getTerm();
if (!strategy.equals(
LocatorUtils.property(thisLocator, "term", lhsTerm),
LocatorUtils.property(thatLocator, "term", rhsTerm),
lhsTerm, rhsTerm)) {
return false;
}
}
{
StructuredTextType lhsAlternateTermDescription;
lhsAlternateTermDescription = this
.getAlternateTermDescription();
StructuredTextType rhsAlternateTermDescription;
rhsAlternateTermDescription = that
.getAlternateTermDescription();
if (!strategy.equals(LocatorUtils
.property(thisLocator, "alternateTermDescription",
lhsAlternateTermDescription), LocatorUtils
.property(thatLocator, "alternateTermDescription",
rhsAlternateTermDescription),
lhsAlternateTermDescription,
rhsAlternateTermDescription)) {
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 theTerm;
theTerm = this.getTerm();
currentHashCode = strategy.hashCode(
LocatorUtils.property(locator, "term", theTerm),
currentHashCode, theTerm);
}
{
StructuredTextType theAlternateTermDescription;
theAlternateTermDescription = this
.getAlternateTermDescription();
currentHashCode = strategy.hashCode(LocatorUtils.property(
locator, "alternateTermDescription",
theAlternateTermDescription), currentHashCode,
theAlternateTermDescription);
}
return currentHashCode;
}
public int hashCode() {
final HashCodeStrategy strategy = JAXBHashCodeStrategy.INSTANCE;
return this.hashCode(null, strategy);
}
public AlternateTerms.AlternateTerm withTerm(String value) {
setTerm(value);
return this;
}
public AlternateTerms.AlternateTerm withAlternateTermDescription(
StructuredTextType value) {
setAlternateTermDescription(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 theTerm;
theTerm = this.getTerm();
strategy.appendField(locator, this, "term", buffer, theTerm);
}
{
StructuredTextType theAlternateTermDescription;
theAlternateTermDescription = this
.getAlternateTermDescription();
strategy.appendField(locator, this, "alternateTermDescription",
buffer, theAlternateTermDescription);
}
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, AlternateTerms.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 AlternateTerms instance for XML String
*
* @param text
* XML String for the document
* @return The AlternateTerms instance for the passed XML String
*/
public static AlternateTerms fromXMLString(String text) {
JAXBContext jaxbContext;
try {
jaxbContext = JAXBContext.newInstance(AlternateTerms.class
.getPackage().getName());
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
unmarshaller.setSchema(STIXSchema.getInstance().getSchema());
unmarshaller.setEventHandler(new ValidationEventHandler());
StreamSource streamSource = new StreamSource(new StringReader(text));
return (AlternateTerms) unmarshaller.unmarshal(streamSource);
} catch (JAXBException e) {
throw new RuntimeException(e);
}
}
/**
* Validates the XML representation of this AlternateTerms instance
* Returning true indicating a successful validation, false if not.
*
* @return boolean
*/
public boolean validate() {
return STIXSchema.getInstance().validate(toXMLString());
}
}