# Class MutableResource

java.lang.Object
com.codename1.ui.util.Resources
com.codename1.ui.util.MutableResource

Direct Known Subclasses:
  `MutableResouce`

public class MutableResource extends Resources

Mutable variant of `Resources` intended for non-designer environments.

This class provides a minimal API for programmatically editing resource files inside Codename One core code where JavaSE/Swing designer classes are not available.

### Supported resource categories

- `IMAGE`
- `DATA`
- `L10N`
- `THEME` (in-memory editing only; save serialization is intentionally limited)

### Explicitly unsupported categories

The following are intentionally rejected with `UnsupportedOperationException` when read or written:

- Timeline
- Indexed images
- SVG
- GUI Builder UI resources

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MutableResource()`
  Creates an empty mutable resource container.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `clear()`
  `boolean`
  `containsResource(String name)`
  `InputStream`
  `getData(String id)`
  Returns the data resource from the file
  `byte[]`
  `getDataByteArray(String id)`
  `boolean`
  `isModified()`
  `static MutableResource`
  `open(InputStream resource)`
  Opens a mutable resource from an input stream.
  `void`
  `save(OutputStream out)`
  `protected void`
  `saveL10N(DataOutputStream output, Hashtable l10n)`
  `void`
  `setData(String name, byte[] data)`
  `void`
  `setImage(String name, Image value)`
  Install an `Image` into this resources bundle under the given name so a subsequent `Resources.getImage(String)` returns it.
  `void`
  `setIndexedImage(String name, Image image)`
  `void`
  `setL10N(String name, Hashtable l10n)`
  `void`
  `setSVG(String name, Image image)`
  `void`
  `setTheme(String name, Hashtable theme)`
  `void`
  `setThemeProperty(String themeName, String key, Object value)`
  `void`
  `setTimeline(String name, Timeline timeline)`
  `void`
  `setUi(String name, byte[] data)`
  `protected void`
  `writeImage(DataOutputStream output, Image image)`

  ### Methods inherited from class Resources

  `getDataResourceNames, getFont, getFontResourceNames, getGlobalResources, getImage, getImageResourceNames, getL10N, getL10NResourceNames, getMajorVersion, getMetaData, getMinorVersion, getResourceNames, getSystemResource, getTheme, getThemeResourceNames, getUIResourceNames, isAnimation, isData, isEnableMediaQueries, isFailOnMissingTruetype, isFont, isImage, isL10N, isTheme, isUI, l10NLocaleSet, listL10NLocales, open, open, open, openLayered, openLayered, override, registerGeneratedImage, setEnableMediaQueries, setFailOnMissingTruetype, setGlobalResources, setPassword, setRuntimeMultiImageEnabled`

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### MutableResource

    public MutableResource()
    Creates an empty mutable resource container.

- ## Method Details

  - ### open

    public static MutableResource open(InputStream resource) throws IOException
    Opens a mutable resource from an input stream.
    Parameters:
      `resource` - source stream.
    Returns:
      loaded mutable resource.
    Throws:
      `IOException` - if parsing fails.

  - ### setImage

    public void setImage(String name, Image value)
    Description copied from class: `Resources`
    Install an `Image` into this resources bundle under the given name so a subsequent `Resources.getImage(String)` returns it. Used by the build-time SVG transcoder registry to inject generated images alongside the resources loaded from the `.res` file.
    Overrides:
      `setImage` in class `Resources`

  - ### setData

    public void setData(String name, byte[] data)

  - ### setTheme

    public void setTheme(String name, Hashtable theme)

  - ### setThemeProperty

    public void setThemeProperty(String themeName, String key, Object value)

  - ### setL10N

    public void setL10N(String name, Hashtable l10n)

  - ### getDataByteArray

    public byte[] getDataByteArray(String id)

  - ### containsResource

    public boolean containsResource(String name)

  - ### isModified

    public boolean isModified()

  - ### setUi

    public void setUi(String name, byte[] data)

  - ### setTimeline

    public void setTimeline(String name, Timeline timeline)

  - ### setIndexedImage

    public void setIndexedImage(String name, Image image)

  - ### setSVG

    public void setSVG(String name, Image image)

  - ### clear

    public void clear()

  - ### save

    public void save(OutputStream out) throws IOException
    Throws:
      `IOException`

  - ### writeImage

    protected void writeImage(DataOutputStream output, Image image) throws IOException
    Throws:
      `IOException`

  - ### saveL10N

    protected void saveL10N(DataOutputStream output, Hashtable l10n) throws IOException
    Throws:
      `IOException`

  - ### getData

    public InputStream getData(String id)
    Description copied from class: `Resources`

    Returns the data resource from the file

    ###### Parameters

    - `id`: name of the data resource

    ###### Returns

    newly created input stream that allows reading the data of the resource

    Overrides:
      `getData` in class `Resources`