org.ccsds.moims.mo.mal.structures.File Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of api-mal Show documentation
Show all versions of api-mal Show documentation
An implementation of the Java API for the CCSDS MAL
package org.ccsds.moims.mo.mal.structures;
/**
* The File structure represents a File and holds details about a File. It can also,
* optionally, hold a BLOB of the file data. The file type is denoted using the internet
* MIME media types, the list of official MIME types is held at http://www.iana.org/assignments/media-types/index.html.
*/
public final class File implements org.ccsds.moims.mo.mal.structures.Composite {
/**
* Short form for type.
*/
public static final Integer TYPE_SHORT_FORM = 1007;
/**
* Short form for area.
*/
public static final org.ccsds.moims.mo.mal.structures.UShort AREA_SHORT_FORM = new org.ccsds.moims.mo.mal.structures.UShort(1);
/**
* Version for area.
*/
public static final org.ccsds.moims.mo.mal.structures.UOctet AREA_VERSION = new org.ccsds.moims.mo.mal.structures.UOctet((short) 1);
/**
* Short form for service.
*/
public static final org.ccsds.moims.mo.mal.structures.UShort SERVICE_SHORT_FORM = new org.ccsds.moims.mo.mal.structures.UShort(0);
/**
* Absolute short form for type.
*/
public static final Long SHORT_FORM = 281474993488879L;
private static final long serialVersionUID = 281474993488879L;
/**
* The file name.
*/
private String name;
/**
* The MIME type of the file, NULL if not known.
*/
private String mimeType;
/**
* The creation timestamp of the file, NULL if not known.
*/
private org.ccsds.moims.mo.mal.structures.Time creationDate;
/**
* The last modification timestamp of the file, NULL if not known.
*/
private org.ccsds.moims.mo.mal.structures.Time modificationDate;
/**
* The size of the file in Octets, NULL if not known.
*/
private org.ccsds.moims.mo.mal.structures.ULong size;
/**
* The contents of the file, NULL if not supplied.
*/
private org.ccsds.moims.mo.mal.structures.Blob content;
/**
* A list of extra metadata for the file.
*/
private org.ccsds.moims.mo.mal.structures.NamedValueList metaData;
/**
* Default constructor for File.
*/
/**
*
*/
public File() {
}
/**
* Constructor that initialises the values of the structure.
*
* @param name The file name.
* @param mimeType The MIME type of the file, NULL if not known.
* @param creationDate The creation timestamp of the file, NULL if not known.
* @param modificationDate The last modification timestamp of the file, NULL if not
* known.
* @param size The size of the file in Octets, NULL if not known.
* @param content The contents of the file, NULL if not supplied.
* @param metaData A list of extra metadata for the file.
*/
public File(String name, String mimeType, org.ccsds.moims.mo.mal.structures.Time creationDate, org.ccsds.moims.mo.mal.structures.Time modificationDate, org.ccsds.moims.mo.mal.structures.ULong size, org.ccsds.moims.mo.mal.structures.Blob content, org.ccsds.moims.mo.mal.structures.NamedValueList metaData) {
this.name = name;
this.mimeType = mimeType;
this.creationDate = creationDate;
this.modificationDate = modificationDate;
this.size = size;
this.content = content;
this.metaData = metaData;
}
/**
* Constructor that initialises the non-nullable values of the structure.
*
* @param name The file name.
*/
public File(String name) {
this.name = name;
this.mimeType = null;
this.creationDate = null;
this.modificationDate = null;
this.size = null;
this.content = null;
this.metaData = null;
}
/**
* 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.mal.structures.File();
}
/**
* Returns the field name.
*
* @return The field name.
*/
public String getName() {
return name;
}
/**
* Sets the field name.
*
* @param __newValue __newValue The new value.
*/
public void setName(String __newValue) {
name = __newValue;
}
/**
* Returns the field mimeType.
*
* @return The field mimeType.
*/
public String getMimeType() {
return mimeType;
}
/**
* Sets the field mimeType.
*
* @param __newValue __newValue The new value.
*/
public void setMimeType(String __newValue) {
mimeType = __newValue;
}
/**
* Returns the field creationDate.
*
* @return The field creationDate.
*/
public org.ccsds.moims.mo.mal.structures.Time getCreationDate() {
return creationDate;
}
/**
* Sets the field creationDate.
*
* @param __newValue __newValue The new value.
*/
public void setCreationDate(org.ccsds.moims.mo.mal.structures.Time __newValue) {
creationDate = __newValue;
}
/**
* Returns the field modificationDate.
*
* @return The field modificationDate.
*/
public org.ccsds.moims.mo.mal.structures.Time getModificationDate() {
return modificationDate;
}
/**
* Sets the field modificationDate.
*
* @param __newValue __newValue The new value.
*/
public void setModificationDate(org.ccsds.moims.mo.mal.structures.Time __newValue) {
modificationDate = __newValue;
}
/**
* Returns the field size.
*
* @return The field size.
*/
public org.ccsds.moims.mo.mal.structures.ULong getSize() {
return size;
}
/**
* Sets the field size.
*
* @param __newValue __newValue The new value.
*/
public void setSize(org.ccsds.moims.mo.mal.structures.ULong __newValue) {
size = __newValue;
}
/**
* Returns the field content.
*
* @return The field content.
*/
public org.ccsds.moims.mo.mal.structures.Blob getContent() {
return content;
}
/**
* Sets the field content.
*
* @param __newValue __newValue The new value.
*/
public void setContent(org.ccsds.moims.mo.mal.structures.Blob __newValue) {
content = __newValue;
}
/**
* Returns the field metaData.
*
* @return The field metaData.
*/
public org.ccsds.moims.mo.mal.structures.NamedValueList getMetaData() {
return metaData;
}
/**
* Sets the field metaData.
*
* @param __newValue __newValue The new value.
*/
public void setMetaData(org.ccsds.moims.mo.mal.structures.NamedValueList __newValue) {
metaData = __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 obj the object to compare with.
* @return true if the objects are the same; false otherwise.
*/
public boolean equals(Object obj) {
if (obj instanceof File) {
File other = (File) obj;
if (name == null) {
if (other.name != null) {
return false;
}
} else {
if (! name.equals(other.name)) {
return false;
}
}
if (mimeType == null) {
if (other.mimeType != null) {
return false;
}
} else {
if (! mimeType.equals(other.mimeType)) {
return false;
}
}
if (creationDate == null) {
if (other.creationDate != null) {
return false;
}
} else {
if (! creationDate.equals(other.creationDate)) {
return false;
}
}
if (modificationDate == null) {
if (other.modificationDate != null) {
return false;
}
} else {
if (! modificationDate.equals(other.modificationDate)) {
return false;
}
}
if (size == null) {
if (other.size != null) {
return false;
}
} else {
if (! size.equals(other.size)) {
return false;
}
}
if (content == null) {
if (other.content != null) {
return false;
}
} else {
if (! content.equals(other.content)) {
return false;
}
}
if (metaData == null) {
if (other.metaData != null) {
return false;
}
} else {
if (! metaData.equals(other.metaData)) {
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 = 7;
hash = 83 * hash + (name != null ? name.hashCode() : 0);
hash = 83 * hash + (mimeType != null ? mimeType.hashCode() : 0);
hash = 83 * hash + (creationDate != null ? creationDate.hashCode() : 0);
hash = 83 * hash + (modificationDate != null ? modificationDate.hashCode() : 0);
hash = 83 * hash + (size != null ? size.hashCode() : 0);
hash = 83 * hash + (content != null ? content.hashCode() : 0);
hash = 83 * hash + (metaData != null ? metaData.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('(');
buf.append("name=");
buf.append(name);
buf.append(", mimeType=");
buf.append(mimeType);
buf.append(", creationDate=");
buf.append(creationDate);
buf.append(", modificationDate=");
buf.append(modificationDate);
buf.append(", size=");
buf.append(size);
buf.append(", content=");
buf.append(content);
buf.append(", metaData=");
buf.append(metaData);
buf.append(')');
return buf.toString();
}
/**
* Encodes the value of this object using the provided MALEncoder.
*
* @param encoder 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 {
encoder.encodeString(name);
encoder.encodeNullableString(mimeType);
encoder.encodeNullableTime(creationDate);
encoder.encodeNullableTime(modificationDate);
encoder.encodeNullableULong(size);
encoder.encodeNullableBlob(content);
encoder.encodeNullableElement(metaData);
}
/**
* Decodes the value of this object using the provided MALDecoder.
*
* @param decoder 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 {
name = decoder.decodeString();
mimeType = decoder.decodeNullableString();
creationDate = decoder.decodeNullableTime();
modificationDate = decoder.decodeNullableTime();
size = decoder.decodeNullableULong();
content = decoder.decodeNullableBlob();
metaData = (org.ccsds.moims.mo.mal.structures.NamedValueList) decoder.decodeNullableElement(new org.ccsds.moims.mo.mal.structures.NamedValueList());
return this;
}
/**
* Returns the absolute short form of this type.
*
* @return The absolute short form of this type.
*/
public Long getShortForm() {
return SHORT_FORM;
}
/**
* Returns the type short form of this type which is unique to the area/service it is
* defined in but not unique across all types.
*
* @return The type short form of this type.
*/
public Integer getTypeShortForm() {
return TYPE_SHORT_FORM;
}
/**
* Returns the area number of this type.
*
* @return The area number of this type.
*/
public org.ccsds.moims.mo.mal.structures.UShort getAreaNumber() {
return AREA_SHORT_FORM;
}
/**
* Returns the area version of this type.
*
* @return The area number of this type.
*/
public org.ccsds.moims.mo.mal.structures.UOctet getAreaVersion() {
return AREA_VERSION;
}
/**
* Returns the service number of this type.
*
* @return The service number of this type.
*/
public org.ccsds.moims.mo.mal.structures.UShort getServiceNumber() {
return SERVICE_SHORT_FORM;
}
}