Exemple #1
0
 /**
  * Add an extension - this changes the data to reflect an extension for this sub type.
  *
  * @param extension
  */
 public void addExtension(SubTypeExtension extension) throws DuplicateNameException {
   if (getExtension(extension.getName()) != null) {
     throw new DuplicateNameException(
         "Subtype extension for subtype " + this + " with name already exists",
         extension.getName());
   }
   extension.setSubType(this);
   extension.setMimeType(
       getTopMediaType().getName() + SubTypeExtension.MIME_TYPE_SEPERATOR + getName());
   extensions.add(extension);
 }
Exemple #2
0
  /**
   * Returns the extension if the extension name exists otherwise returns null
   *
   * @param extensionName
   * @return the found extension or null if it is not found
   */
  public SubTypeExtension getExtension(String extensionName) {
    SubTypeExtension ext = null;

    for (SubTypeExtension e : extensions) {
      if (e.getName().equals(extensionName)) {
        ext = e;
      }
    }

    return ext;
  }