Interface MediumEditorValue<T extends BinaryMedium>

All Superinterfaces:
EditorValue<T>
All Known Subinterfaces:
FileEditorValue, ImageMapEditorValue, PictureEditorValue

public interface MediumEditorValue<T extends BinaryMedium> extends EditorValue<T>
Tag for editors working on binary media.
Since:
4.0.17
Example:
How to store and get a GraphicalMedium from a PictureEditorValue
import de.espirit.firstspirit.access.editor.*;

import de.espirit.firstspirit.access.Language;
import de.espirit.firstspirit.access.editor.value.GraphicalMedium;
import de.espirit.firstspirit.access.editor.value.InvalidValueException;
import de.espirit.firstspirit.access.store.mediastore.Media;

import org.jetbrains.annotations.NotNull;


/**
 * Example how to store a picture (GraphicalMedium) into a PictureEditorValue
 *
 * @since 4.2.34
 */
public class PictureEditorValueExample {

	/**
	 * Stores given media as language specific value (specified by the given language) for the given editor
	 *
	 * @since 4.2.34
	 */
	public PictureEditorValue setValueForLanguage(final PictureEditorValue editor, @NotNull final Media media, final Language language) {
		// 1. check if language is provided if editor is language dependent ("useLanguages='yes'" in gom syntax)
		if (editor.isLanguageDependent() && (language == null)) {
			throw new NullPointerException("Language is missing!");
		}

		// 2. check if given media is of type PICTURE
		if (media.getType() != Media.PICTURE) {
			throw new IllegalArgumentException("only media of type PICTURE allowed for PictureEditorValue");
		}

		// 3. get the editor data container for the given language
		final GraphicalMedium graphicalMedium = editor.get(language);

		// 4. store the given media in data container
		graphicalMedium.setMedium(media);

		// 5. return the instance for further processing
		return editor;

	}


	/**
	 * Gets the language specific value (GraphicalMedium) for the given language and picture editor
	 *
	 * @since 4.2.34
	 */
	public GraphicalMedium getValueForLanguage(final PictureEditorValue editor, final Language language) throws InvalidValueException {

		// 1. get the stored instance in the editor value
		final GraphicalMedium medium = editor.get(language);

		// 2. and return the reference container for further processing
		return medium;
	}
}
How to store and get a BinaryMedium from a FileEditorValue
import de.espirit.firstspirit.access.editor.*;

import de.espirit.firstspirit.access.Language;
import de.espirit.firstspirit.access.editor.value.BinaryMedium;
import de.espirit.firstspirit.access.editor.value.InvalidValueException;


/**
 * Example how to store a file (BinaryMedium) into a FileEditorValue.
 *
 * @since 4.2.34
 */
public class FileEditorValueExample {

	/**
	 * Stores given binary object as language specific value (specified by the given language) for the given editor.
	 *
	 * @since 4.2.34
	 */
	public FileEditorValue setValueForLanguage(final FileEditorValue editor, final BinaryMedium object, final Language language) throws InvalidValueException {

		// 1. check if language is provided if editor is language dependent ("useLanguages='yes'" in gom syntax)
		if (editor.isLanguageDependent() && (language == null)) {
			throw new NullPointerException("Language is missing!");
		}

		// 2. store this instance in the editor value
		editor.set(language, object);

		// 3. and return the instance for further processing
		return editor;
	}


	/**
	 * Gets the language specific value (BinaryMedium) for the given language and file editor.
	 *
	 * @since 4.2.34
	 */
	public BinaryMedium getValueForLanguage(final FileEditorValue editor, final Language language) throws InvalidValueException {

		// 1. get the stored instance in the editor value
		final BinaryMedium medium = editor.get(language);

		// 2. and return the reference container for further processing
		return medium;
	}
}
  • Field Details

  • Method Details

    • getForm

      GomFile getForm()
      Covariant return of concrete form container.
      Specified by:
      getForm in interface EditorValue<T extends BinaryMedium>
      Returns:
      The form definition.
      Since:
      4.0.17