Пример #1
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;
  }
Пример #2
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);
 }
Пример #3
0
  /**
   * Returns the extension if the id exists otherwise returns null - null is always returned if the
   * id is 0
   *
   * @param extensionName
   * @return the found extension or null if it is not found
   */
  public SubTypeExtension getExtension(Long id) {
    SubTypeExtension ext = null;

    if (id == 0) {
      return ext;
    }

    for (SubTypeExtension e : extensions) {
      if (e.getId().equals(id)) {
        ext = e;
      }
    }

    return ext;
  }
Пример #4
0
 /**
  * Remove an extension from this subtype
  *
  * @param extension to remove
  * @return true if the extension is removed
  */
 private boolean removeExtension(SubTypeExtension extension) {
   extension.setSubType(null);
   return extensions.remove(extension);
 }