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 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