Class MutableResource
java.lang.Object
com.codename1.ui.util.Resources
com.codename1.ui.util.MutableResource
- Direct Known Subclasses:
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()booleancontainsResource(String name) Returns the data resource from the filebyte[]booleanstatic MutableResourceopen(InputStream resource) Opens a mutable resource from an input stream.voidsave(OutputStream out) protected voidsaveL10N(DataOutputStream output, Hashtable l10n) voidvoidvoidsetIndexedImage(String name, Image image) voidvoidvoidvoidsetThemeProperty(String themeName, String key, Object value) voidsetTimeline(String name, Timeline timeline) voidprotected voidwriteImage(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, setEnableMediaQueries, setFailOnMissingTruetype, setGlobalResources, setPassword, setRuntimeMultiImageEnabledModifier and TypeMethodDescriptionString[]Returns the names of the data resources within this bundleReturns the font resource from the fileString[]Returns the names of the fonts within this bundlestatic ResourcesGlobal resources are used by new GUI builder apps to keep track of the applications resourcesReturns the image resource from the fileString[]Returns the names of the images within this bundleReturns a hashmap containing localized String key/value pairs for the given locale nameString[]Returns the names of the localization bundles within this bundleintReturns the version number for this resource file.String[]Returns optional meta-data associated with the resource fileintReturns the minor version number for this resource file This value relates to the value from the header defined by the resource file specification.String[]Returns the names of the resources within this bundlestatic ResourcesGets the system resource which can be located /CN1Images.res.Returns the theme resource from the fileString[]Returns the names of the images within this bundleString[]Returns the names of the ui resources within this bundlebooleanisAnimation(String name) Returns true if this is an animation resourcebooleanReturns true if this is a data resourcestatic booleanstatic booleanReturns
booleanReturns true if this is a font resourcebooleanReturns true if this is an image resourcebooleanReturns true if this is a generic data resourcebooleanReturns true if this is a theme resourcebooleanReturns true if this is a UI resourcel10NLocaleSet(String id) Returns a collection of the l10 locale namesReturns an enumration of the locales supported by this resource idstatic Resourcesopen(InputStream resource, int dpi) Creates a resource object from the given input streamstatic ResourcesCreates a resource object from the local JAR resource identifierstatic ResourcesCreates a resource object from the local JAR resource identifierstatic ResourcesopenLayered(String resource) Opens a multi-layer resource file that supports overriding features on a specific platform.static ResourcesopenLayered(String resource, int dpi) Opens a multi-layer resource file that supports overriding features on a specific platform.voidoverride(InputStream input) This method allows overriding the data of a resource file with another resource file thus replacing or enhancing existing content with platform specific content.static voidsetEnableMediaQueries(boolean enable) static voidsetFailOnMissingTruetype(boolean aFailOnMissingTruetype) Parameters
static voidGlobal resources are used by new GUI builder apps to keep track of the applications resourcesstatic voidsetPassword(String password) Sets the password to use for password protected resource filesstatic voidsetRuntimeMultiImageEnabled(boolean b) This flag should be off and it is off by default, some special case implementations for development e.g.Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()booleanIndicates whether some other object is "equal to" this one.final ClassgetClass()Returns the runtime class of an object.inthashCode()Returns a hash code value for the object.final voidnotify()Wakes up a single thread that is waiting on this object's monitor.final voidWakes up all threads that are waiting on this object's monitor.toString()Returns a string representation of the object.final voidwait()Causes current thread to wait until another thread invokes the method or the method for this object.final voidwait(long timeout) Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.final voidwait(long timeout, int nanos) Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
-
Constructor Details
-
MutableResource
public MutableResource()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
-
setTheme
-
setThemeProperty
-
setL10N
-
getDataByteArray
-
containsResource
-
isModified
public boolean isModified() -
setUi
-
setTimeline
-
setIndexedImage
-
setSVG
-
clear
public void clear() -
save
- Throws:
IOException
-
writeImage
- Throws:
IOException
-
saveL10N
- Throws:
IOException
-
getData
Description copied from class:ResourcesReturns 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
-