org.ccsds.moims.mo.mpd.structures.StringPattern Maven / Gradle / Ivy
The newest version!
package org.ccsds.moims.mo.mpd.structures;
/**
* A StringPattern is a concrete subtype of ParameterFilter that allows the
* specification of a regular expression (or match pattern) to be searched
* for in the value of a text type metadata parameter.
*/
public final class StringPattern extends org.ccsds.moims.mo.mpd.structures.ParameterFilter {
private static final long serialVersionUID = 2533274807173125L;
/**
* The TypeId of this Element as a long.
*/
public static final Long SHORT_FORM = 2533274807173125L;
/**
* The TypeId of this Element.
*/
public static final org.ccsds.moims.mo.mal.TypeId TYPE_ID = new org.ccsds.moims.mo.mal.TypeId(SHORT_FORM);
/**
* Regular expression - a sequence of characters that specifies a match pattern
* to be searched for in a text type metadata parameter (Sting, Identifier
* or URI).
*/
private String regex;
/**
* Default constructor for StringPattern.
*
*/
public StringPattern() {
}
/**
* Constructor that initialises the values of the structure.
*
* @param name References the name of a defined metadata parameter.
* @param include Indicates whether the filter is to include [TRUE] or exclude
* [FALSE] parameter values that match the filter.
* @param regex Regular expression - a sequence of characters that specifies
* a match pattern to be searched for in a text type metadata parameter (Sting,
* Identifier or URI).
*/
public StringPattern(org.ccsds.moims.mo.mal.structures.Identifier name,
Boolean include,
String regex) {
super(name,
include);
this.regex = regex;
}
/**
* Creates an instance of this type using the default constructor. It is a
* generic factory method.
*
* @return A new instance of this type with default field values.
*/
public org.ccsds.moims.mo.mal.structures.Element createElement() {
return new org.ccsds.moims.mo.mpd.structures.StringPattern();
}
/**
* Returns the field regex.
*
* @return The field regex.
*/
public String getRegex() {
return regex;
}
/**
* Sets the field regex.
*
* @param __newValue The new value.
*/
@Deprecated
public void setRegex(String __newValue) {
regex = __newValue;
}
/**
* Compares this object to the specified object. The result is true if and
* only if the argument is not null and is the same type that contains the
* same value as this object.
*
* @param obj The object to compare with.
* @return true if the objects are the same; false otherwise.
*/
public boolean equals(Object obj) {
if (obj instanceof StringPattern) {
if (! super.equals(obj)) {
return false;
}
StringPattern other = (StringPattern) obj;
if (regex == null) {
if (other.regex != null) {
return false;
}
} else {
if (! regex.equals(other.regex)) {
return false;
}
}
return true;
}
return false;
}
/**
* Returns a hash code for this object.
*
* @return a hash code value for this object.
*/
public int hashCode() {
int hash = super.hashCode();
hash = 83 * hash + (regex != null ? regex.hashCode() : 0);
return hash;
}
/**
* Returns a String object representing this type"s value.
*
* @return a string representation of the value of this object.
*/
public String toString() {
StringBuilder buf = new StringBuilder();
buf.append("(StringPattern: ");
buf.append(super.toString());
buf.append(", regex=");
buf.append(regex);
buf.append(')');
return buf.toString();
}
/**
* Encodes the value of this object using the provided MALEncoder.
*
* @param encoder The encoder to use for encoding.
* @throws org.ccsds.moims.mo.mal.MALException if any encoding errors are
* detected.
*/
public void encode(org.ccsds.moims.mo.mal.MALEncoder encoder) throws org.ccsds.moims.mo.mal.MALException {
super.encode(encoder);
if (regex == null) {
throw new org.ccsds.moims.mo.mal.MALException("The field 'regex' cannot be null!");
}
encoder.encodeString(regex);
}
/**
* Decodes the value of this object using the provided MALDecoder.
*
* @param decoder The decoder to use for decoding.
* @return Returns this object.
* @throws org.ccsds.moims.mo.mal.MALException if any decoding errors are
* detected.
*/
public org.ccsds.moims.mo.mal.structures.Element decode(org.ccsds.moims.mo.mal.MALDecoder decoder) throws org.ccsds.moims.mo.mal.MALException {
super.decode(decoder);
regex = decoder.decodeString();
return this;
}
/**
* Returns the TypeId of this element.
*
* @return The TypeId of this element.
*/
public org.ccsds.moims.mo.mal.TypeId getTypeId() {
return TYPE_ID;
}
}