# Class MutableResouce

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

public class MutableResouce 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
  `MutableResouce()`
  Creates an empty mutable resource container.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `clear()`
  Clears all resources and resets the modified flag.
  `boolean`
  `containsResource(String name)`
  Checks whether any resource exists for a given id.
  `InputStream`
  `getData(String id)`
  Returns the data resource as a new input stream.
  `byte[]`
  `getDataByteArray(String id)`
  Returns raw bytes for a named data resource.
  `boolean`
  `isModified()`
  Indicates whether this resource set has pending edits.
  `static MutableResouce`
  `open(InputStream resource)`
  Opens a mutable resource from an input stream.
  `void`
  `save(OutputStream out)`
  Serializes the current resources into a `.res` stream.
  `protected void`
  `saveL10N(DataOutputStream output, Hashtable l10n)`
  Writes an L10N map in resource-file format.
  `void`
  `setData(String name, byte[] data)`
  Stores or removes raw data resource bytes.
  `void`
  `setImage(String name, Image value)`
  Stores or removes an image resource.
  `void`
  `setIndexedImage(String name, Image image)`
  Unsupported indexed image setter.
  `void`
  `setL10N(String name, Hashtable l10n)`
  Stores or replaces an L10N resource bundle.
  `void`
  `setSVG(String name, Image image)`
  Unsupported SVG setter.
  `void`
  `setTheme(String name, Hashtable theme)`
  Stores or replaces a theme resource.
  `void`
  `setThemeProperty(String themeName, String key, Object value)`
  Sets or removes a single property inside a named theme.
  `void`
  `setTimeline(String name, Timeline timeline)`
  Unsupported timeline setter.
  `void`
  `setUi(String name, byte[] data)`
  Unsupported GUI builder setter.
  `protected void`
  `writeImage(DataOutputStream output, Image image)`
  Writes an encoded image entry.

  ### 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, setEnableMediaQueries, setFailOnMissingTruetype, setGlobalResources, setPassword, setRuntimeMultiImageEnabled`

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### MutableResouce

    public MutableResouce()
    Creates an empty mutable resource container.

- ## Method Details

  - ### open

    public static MutableResouce 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)
    Stores or removes an image resource.
    Parameters:
      `name` - resource id.
      `value` - image value, or `null` to remove.

  - ### setData

    public void setData(String name, byte[] data)
    Stores or removes raw data resource bytes.
    Parameters:
      `name` - resource id.
      `data` - payload bytes, or `null` to remove.

  - ### setTheme

    public void setTheme(String name, Hashtable theme)
    Stores or replaces a theme resource.
    Parameters:
      `name` - theme resource id.
      `theme` - theme properties map.

  - ### setThemeProperty

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

    Sets or removes a single property inside a named theme.

    If the theme does not exist, a new map is created. Passing `null` value removes the property.

    Parameters:
      `themeName` - theme resource id.
      `key` - theme property key.
      `value` - theme property value or `null` to remove.

  - ### setL10N

    public void setL10N(String name, Hashtable l10n)
    Stores or replaces an L10N resource bundle.
    Parameters:
      `name` - l10n resource id.
      `l10n` - locale->translation map.

  - ### getDataByteArray

    public byte[] getDataByteArray(String id)
    Returns raw bytes for a named data resource.
    Parameters:
      `id` - resource id.
    Returns:
      data bytes, or `null` if missing.

  - ### containsResource

    public boolean containsResource(String name)
    Checks whether any resource exists for a given id.
    Parameters:
      `name` - resource id.
    Returns:
      `true` when an entry exists.

  - ### isModified

    public boolean isModified()
    Indicates whether this resource set has pending edits.
    Returns:
      `true` if modified.

  - ### setUi

    public void setUi(String name, byte[] data)
    Unsupported GUI builder setter.
    Parameters:
      `name` - ignored.
      `data` - ignored.

  - ### setTimeline

    public void setTimeline(String name, Timeline timeline)
    Unsupported timeline setter.
    Parameters:
      `name` - ignored.
      `timeline` - ignored.

  - ### setIndexedImage

    public void setIndexedImage(String name, Image image)
    Unsupported indexed image setter.
    Parameters:
      `name` - ignored.
      `image` - ignored.

  - ### setSVG

    public void setSVG(String name, Image image)
    Unsupported SVG setter.
    Parameters:
      `name` - ignored.
      `image` - ignored.

  - ### clear

    public void clear()
    Clears all resources and resets the modified flag.

  - ### save

    public void save(OutputStream out) throws IOException

    Serializes the current resources into a `.res` stream.

    Entries are written in deterministic sorted order by id.

    Parameters:
      `out` - output stream.
    Throws:
      `IOException` - if writing fails.

  - ### writeImage

    protected void writeImage(DataOutputStream output, Image image) throws IOException
    Writes an encoded image entry.
    Parameters:
      `output` - output stream.
      `image` - image value.
    Throws:
      `IOException` - if writing fails.

  - ### saveL10N

    protected void saveL10N(DataOutputStream output, Hashtable l10n) throws IOException
    Writes an L10N map in resource-file format.
    Parameters:
      `output` - output stream.
      `l10n` - locale map.
    Throws:
      `IOException` - if writing fails.

  - ### getData

    public InputStream getData(String id)
    Returns the data resource as a new input stream.
    Overrides:
      `getData` in class `Resources`
    Parameters:
      `id` - resource id.
    Returns:
      data stream or `null`.