Class MutableResouce
java.lang.Object
com.codename1.ui.util.Resources
com.codename1.ui.util.MutableResouce
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
IMAGEDATAL10NTHEME(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 -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears all resources and resets the modified flag.booleancontainsResource(String name) Checks whether any resource exists for a given id.Returns the data resource as a new input stream.byte[]Returns raw bytes for a named data resource.booleanIndicates whether this resource set has pending edits.static MutableResouceopen(InputStream resource) Opens a mutable resource from an input stream.voidsave(OutputStream out) Serializes the current resources into a.resstream.protected voidsaveL10N(DataOutputStream output, Hashtable l10n) Writes an L10N map in resource-file format.voidStores or removes raw data resource bytes.voidStores or removes an image resource.voidsetIndexedImage(String name, Image image) Unsupported indexed image setter.voidStores or replaces an L10N resource bundle.voidUnsupported SVG setter.voidStores or replaces a theme resource.voidsetThemeProperty(String themeName, String key, Object value) Sets or removes a single property inside a named theme.voidsetTimeline(String name, Timeline timeline) Unsupported timeline setter.voidUnsupported GUI builder setter.protected voidwriteImage(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
-
Constructor Details
-
MutableResouce
public MutableResouce()Creates an empty mutable resource container.
-
-
Method Details
-
open
Opens a mutable resource from an input stream.- Parameters:
resource- source stream.- Returns:
- loaded mutable resource.
- Throws:
IOException- if parsing fails.
-
setImage
-
setData
Stores or removes raw data resource bytes.- Parameters:
name- resource id.data- payload bytes, ornullto remove.
-
setTheme
-
setThemeProperty
Sets or removes a single property inside a named theme.
If the theme does not exist, a new map is created. Passing
nullvalue removes the property.- Parameters:
themeName- theme resource id.key- theme property key.value- theme property value ornullto remove.
-
setL10N
-
getDataByteArray
Returns raw bytes for a named data resource.- Parameters:
id- resource id.- Returns:
- data bytes, or
nullif missing.
-
containsResource
Checks whether any resource exists for a given id.- Parameters:
name- resource id.- Returns:
truewhen an entry exists.
-
isModified
public boolean isModified()Indicates whether this resource set has pending edits.- Returns:
trueif modified.
-
setUi
Unsupported GUI builder setter.- Parameters:
name- ignored.data- ignored.
-
setTimeline
-
setIndexedImage
-
setSVG
-
clear
public void clear()Clears all resources and resets the modified flag. -
save
Serializes the current resources into a
.resstream.Entries are written in deterministic sorted order by id.
- Parameters:
out- output stream.- Throws:
IOException- if writing fails.
-
writeImage
Writes an encoded image entry.- Parameters:
output- output stream.image- image value.- Throws:
IOException- if writing fails.
-
saveL10N
Writes an L10N map in resource-file format.- Parameters:
output- output stream.l10n- locale map.- Throws:
IOException- if writing fails.
-
getData
Returns the data resource as a new input stream.
-