public class MutableResource

  1. Object
  2. Resources
  3. MutableResource

Known subtypesMutableResouce

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

Constructors

public MutableResource()Creates an empty mutable resource container.

Methods

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

Inherited methods

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 InputStream
source stream.

Returns

loaded mutable resource.

Throws

IOException
if parsing fails.

setImage

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

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

writeImage

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

saveL10N

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

getData

public InputStream getData(String id)
Returns the data resource from the file

Parameters

id String
name of the data resource

Returns

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