# 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)`
  `java.io.InputStream`
  `getData(String id)`
  Returns the data resource from the file
  `byte[]`
  `getDataByteArray(String id)`
  `boolean`
  `isModified()`
  `static MutableResource`
  `open(java.io.InputStream resource)`
  Opens a mutable resource from an input stream.
  `void`
  `save(java.io.OutputStream out)`
  `protected void`
  `saveL10N(java.io.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, java.lang.Object value)`
  `void`
  `setTimeline(String name, Timeline timeline)`
  `void`
  `setUi(String name, byte[] data)`
  `protected void`
  `writeImage(java.io.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 java.lang.Object

  `clone, equals, finalize, 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(java.io.InputStream resource) throws java.io.IOException
    Opens a mutable resource from an input stream.
    Parameters:
      `resource` - source stream.
    Returns:
      loaded mutable resource.
    Throws:
      `java.io.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, java.lang.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(java.io.OutputStream out) throws java.io.IOException
    Throws:
      `java.io.IOException`

  - ### writeImage

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

  - ### saveL10N

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

  - ### getData

    public java.io.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`