LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.misc
Class LyEnvironment

java.lang.Object
  extended by leon.misc.LyEnvironment

public final class LyEnvironment
extends java.lang.Object

This class describes an execution environment. It gives an access to all properties like language, debug mode, strings, colors, fonts and also to the type of view manager used. An environment is linked to a session or an application. This means that several applications may be launched in the same Java Virtual Machine using different resources. It also means that each user session may have its own environment: this allows multi-lingualism in servlet mode. Each time a new http client connects itself on the servlet, a new session is created using a new environment if needed (to change the language for example).

An environment is described by:

See Also:
LyApplication, LySession

Nested Class Summary
static class LyEnvironment.ResourceType
          Resource types.
 
Field Summary
static java.lang.String __VERSION
           
 java.text.DateFormat[] _dateFormatTable
          Optimization: keep dateFormat array association between TYPE_xxx and format.
 java.io.PrintStream _oldSystemErr
          When the environment is closed, may restore former System.err.
 java.io.PrintStream _oldSystemOut
          When the environment is closed, may restore former System.out.
 java.lang.String[] _stringDateFormatTable
          Optimization: keep dateFormat array association between TYPE_xxx (e.g.
 java.lang.Throwable _throwable
           
static int DEBUG_ALL
          Debug level: All = Writes information of the following levels: DEBUG_ERROR DEBUG_WARNING DEBUG_INFO or DEBUG_LOG DEBUG_TRACE DEBUG_DBMS DEBUG_BUS DEBUG_XML
static int DEBUG_BUS
          Debug level: BUS = Writes information about the logical bus (messages between applications).
static int DEBUG_DBMS
          Debug level: DBMS = Writes information about DBMS connection and requests.
static int DEBUG_DUMP_HTML
          Debug level: DUMP HTML = Dump HTML pages to log directory.
static int DEBUG_ERROR
          Debug level: Error = writes only occurred errors.
static int DEBUG_GRAPHICS
          Debug level: GRAPHICS = Shows debug information about graphics (e.g. clipping area).
static int DEBUG_HELP_FILES
          Debug level: HELP FILES = Dump Help Files that the application is seeking.
static int DEBUG_INFO
          Debug level: Info = writes only information, i.e. normal operations such as saving a file.
static int DEBUG_LOCKS
          Debug level: LOCKS = Writes information about session locks.
static int DEBUG_LOG
          Debug level: Log = Debug level: Info.
static int DEBUG_NONE
          Debug level: None = No debug.
static int DEBUG_PEER
          Debug level: PEER = Writes information about peer layer.
static int DEBUG_PERF
          Debug level: PERF = Writes informations about performance.
static int DEBUG_PRINT_PDF
          Debug level: PRINT PDF = Writes information about generation of PDF files for printing.
static int DEBUG_TRACE
          Debug level: Trace = writes only Traces.
static int DEBUG_TRANSACTION
          Debug level: TRANSACTION = Writes information about generic hooks on transactions.
static int DEBUG_WARNING
          Debug level: Warning = writes only occurred warning.
static int DEBUG_XML
          Debug level: XML = Write information about XML (generation of views XML files).
static java.lang.String DEFAULT_SKIN
          Default skin name.
static java.lang.String DELIMITERS
          Delimiters : separators that may be encountered when translating keys used to split given key in sub-keys.
 java.io.PrintStream err
          Output stream to display errors.
static java.lang.String HOSTING_TEMPSPACE
          Context key for JNDI temp dir
static java.lang.String INTERNAL_DATE_FORMAT
          Internal date format to store dates in ids or peer values default is in LyDateFormatter and is EEE MMM dd HH:mm:ss zzz yyyy.
static java.lang.String NAMING_CONTEXT
          Context key for JNDI Resources
static short OS_AIX
          AIX Os.
static short OS_HPUX
          HP-UX Os.
static short OS_LINUX
          Linux Os.
static short OS_MACOS
          Mac OS.
static short OS_SOLARIS
          Solaris Os.
static short OS_UNIX
          Unix Os : so far OS_UNIX = OS_SOLARIS || OS_LINUX || OS_HPUX || OS_AIX.
static short OS_WINDOWS
          Windows OS.
 java.io.PrintStream out
          Output stream to display informations.
static boolean TEST_MODE
          Boolean indicating if the application is in test mode (record or replay).
static boolean TEST_MODE_AUTO
          Boolean indicating if the application is in automatic test mode (record or replay).
static short TYPE_DATE
          Date type : date (day+month+year).
static short TYPE_DATE_HOUR_MIN
          Date type : date (day+month+year) and hour (hour+min).
static short TYPE_DATE_TIME
          Date type : date (day+month+year) and time (hour+min+seconds).
static short TYPE_HOUR_MIN
          Date type : hour (hour+min).
static short TYPE_TIME
          Date type : time (hour+min+seconds).
 
Constructor Summary
LyEnvironment(LyEnvironment parent)
          Constructor with a given parent environment.
LyEnvironment(java.lang.String id, LyEnvironment parent, boolean hasViewManager)
          Constructor with a given identifier, parent environment and indication about view manager building.
LyEnvironment(java.lang.String id, LyEnvironment parent, boolean hasViewManager, boolean isMobile)
          Constructor with a given identifier, parent environment and indications about view manager building and type of platform used.
 
Method Summary
 void beep()
          Emits a brief sound signal.
 java.util.Calendar calendarFactory()
          Creates a new Calendar instance for the specified or default timeZone Set the time zone parameter in .ini file with the user.timezone key.
 boolean checkEnv()
          Checks all initialization environment parameters (data directories, images, files...)
 boolean checkFile(java.lang.String key, boolean fatalError, boolean required)
          Checks if the specified path exists.
 boolean checkImage(java.lang.String key)
          Checks if given key image corresponds to a known image.
 boolean checkPath(java.lang.String key, java.lang.String extraPath, boolean fatalError, boolean required)
          Checks if the specified directory exists.
 boolean checkResource(LyEnvironment.ResourceType type, java.lang.String key, boolean checkAll)
          Check the existence of a resource in the resources bundles
 void clearResourceBundleCaches()
          Clears all the resource bundle caches for this environment.
 java.text.DateFormat dateFormatFactory(int type)
          Creates a new DateFormat instance of the given type.
 void execGui(java.lang.Runnable runnable)
          Calls the #execGui(runnable, false) method of the given runnable to be invoked by the user-interface thread asynchronously.
 void execGui(java.lang.Runnable runnable, boolean synchronous)
          If the view manager exist calls the view manager execGui(runnable, synchronous) method.
 void executeCommand(java.lang.String[] command, boolean waiting)
          Execute the given command in a separate process, capture its output and redirect it to the standard output.
 void executeCommand(java.lang.String command, boolean waiting)
          Execute the given command in a separate process, capture its output and redirect it to the standard output.
 void free()
          Frees all resources used by this environment.
static void freeRootEnvironment()
          Free root environment.
 java.lang.String getCharset(java.lang.String lang, boolean nullIfNotFound)
          Gets the charset for the given language.
 java.lang.ClassLoader getClassLoader()
          Gets the default class loader of this environment.
 java.lang.Object getColor(java.lang.String key)
          Retrieves a Color from the application environment.
 java.util.Vector<java.lang.String> getColorCodes()
          Gets the color codes list of the color_codes properties file.
static LyEnvironment getCurrentEnvironment()
          Gets environment for current thread.
 java.lang.String getDateLanguage()
          Gets the environment date language.
 java.util.Locale getDateLocale()
          Gets the default date locale for current context and current environment.
static java.lang.Character getDecimalSeparator()
          Gets the decimal separator for all environment.
 java.lang.String getDisabledImageUrl(java.lang.String key)
          Retrieves a disabled image url from the application environment.
 java.text.DateFormat getDisplayDateFormat(java.lang.String pattern)
          Gets the date format associated to the given pattern.
 java.lang.String getEnv(java.lang.String key)
          Retrieves a value from the contextual environment.
 java.lang.String getFile(java.lang.String key)
          Retrieves a File path from the application environment.
 java.lang.Object getFont(java.lang.String key)
          Retrieves a Font from the application environment.
static java.lang.Character getGroupingSeparator()
          Gets the grouping separator for all environment.
 java.lang.String getHelpFile(java.lang.String actionId, java.lang.String rootActionId, java.lang.String classId)
          Gets the help file for the specified context, or null if help file could not be found.
 java.lang.String getId()
          Gets the environment identifier.
 java.lang.Object getImage(java.lang.String key)
          Retrieves an image from the Application environment.
 java.lang.Object getImage(java.lang.String key, java.lang.String sizeCode)
          Retrieves an image from the Application environment.
 java.lang.Object getImage(java.lang.String key, java.lang.String sizeCode, boolean defaultImage)
          Retrieves an image from the Application environment.
 java.lang.String getImageFileName(java.lang.String key)
          Gets the image file name corresponding to the given key.
 java.lang.String getImagePath(java.lang.String key)
          Retrieves an image path from the application environment.
 LyImages getImages()
          Gets the Images bundle associated to this environment.
 int[] getImageSize(java.lang.String path)
          Checks if a size is given in the path.
 int[] getImageSize(java.lang.String path, boolean enableLoadImage)
          Checks if a size is given in the path.
 java.lang.String getImageSizeInfo(int width, int height)
          Builds an image size description info (as a string).
 java.lang.String getImageUrl(java.lang.String key)
          Retrieves an image url from the application environment.
 java.lang.String getImageUrl(java.lang.String key, boolean disabled, boolean defaultImage)
          Gets the image url corresponding to the given key.
 java.io.InputStream getInputStream(java.lang.String path)
          Retrieves an inputStream from a local address.
 java.io.InputStream getInputStream(java.lang.String path, boolean showError)
          Retrieves an inputStream from a local address.
 int getIntResource(java.lang.String key)
          Retrieves an integer resource from the application environment.
 java.lang.String getLanguage()
          Gets the environment language.
 java.lang.String getLeonDocExternalUrl()
          Gets the path of the external leonardi documentation if exists (LY_LEON_EXTERNAL_URL), the Leonardi dicumentation otherwise (LY_LEON_DOC).
 java.util.Locale getLocale()
          Gets the default locale for current context and current environment.
 LyLogger getLogger()
          Gets the environment logger used to log application messages.
 LyColor getLyColor(java.lang.String key)
          Retrieves a Color from the application environment.
 LyFont getLyFont(java.lang.String key)
          Retrieves a Font from the application environment.
 int[] getMaxScreenSize()
          Retrieves the viewport size available on the computer.
 java.lang.String getMessage(java.lang.String key)
          Convenient routine to get a formated message without argument.
 java.lang.String getMessage(java.lang.String key, java.lang.Object argument)
          Convenient routine to get a formated message with only one argument.
 java.lang.String getMessage(java.lang.String key, java.lang.Object[] arguments)
          Constructs a message from a key and an array of arguments.
 java.lang.String getMessage(java.lang.String key, java.lang.Object argument1, java.lang.Object argument2)
          Convenient routine to get a formated message with two arguments.
 java.lang.String getMessage(java.lang.String key, java.lang.Object argument1, java.lang.Object argument2, java.lang.Object argument3)
          Convenient routine to get a formated message with three arguments.
 java.lang.Character getMnemonic(java.lang.String key)
          Gets the mnemonic for the string corresponding to the given key.
 java.text.NumberFormat getNumberFormat(java.lang.String pattern)
          Gets the deciaml format associated to the given pattern.
 java.io.OutputStream getOutputStream(java.lang.String path, boolean showError)
          Retrieves an outputStream from a local address.
 java.lang.String getPathWithoutSize(java.lang.String path)
          Retrieves the path of an image without the information about its size.
 LyPerfLogger getPerfLogger()
          Gets the perfomance logger used to log perf messages.
 LyPlayer getPlayer()
          Gets demand player.
 java.util.Properties getPropertiesFromContext(java.lang.String prefix)
          Accessor to the properties file or parameter if specified in constructor.
 java.lang.String getResource(LyEnvironment.ResourceType type, java.lang.String key)
          Gets the resource identified with the given key and type.
 java.lang.String getResource(java.lang.String key)
          Retrieves a resource from the application environment.
 java.io.InputStream getResourceAsStream(java.lang.String name, java.lang.ClassLoader classLoader)
          Retrieves an inputStream from a local address.
 java.util.HashMap<java.lang.String,java.lang.String> getResources(LyEnvironment.ResourceType type)
          Gets resources identified with the given type.
 int[] getScreenSize(java.lang.Object component)
          Retrieves the screen size.
 java.lang.String getSkin()
          Gest the environment skin.
 LyString getString()
          Retrieves the instance of LyString associated to this environment.
 java.lang.String getString(java.lang.String key)
          Convenient routine to get a formated string without argument.
 java.lang.String getString(java.lang.String key, java.lang.Object argument)
          Convenient routine to get a formated string with one argument.
 java.lang.String getString(java.lang.String key, java.lang.Object[] arguments)
          Constructs a string from a key and an array of arguments.
 java.lang.String getStringDateFormat(int type)
          Returns the string representing the date format of the given type.
 java.util.TimeZone getTimeZone()
          Gets the default timezone for current context and current environment.
 java.lang.String getUrl(java.lang.String key)
          Retrieves an url from the application environment.
 java.lang.String getViewAttValue(java.lang.String key)
          Retrieves a value from this environment.
 LyViewManagerInterface getViewManager()
          Retrieves the environment view manager.
 LyViewManagerInterface getViewManager(boolean isMobile)
          Retrieves the environment view manager.
 boolean hasResource(LyEnvironment.ResourceType type, java.lang.String key)
          Checks if a resource if found for given key.
 void initResources()
          Initialize the environment.
 boolean isDebugLevel(int level)
          Checks if a debug level is set or not.
 boolean isImageAnimated(java.lang.String key)
          Indicates if an image is animated.
 boolean isImageCached(java.lang.Object image)
          Indicates whether given image may be cached.
static boolean isOperatingSystem(short osType)
          Checks the current Operating System.
 boolean isResourceDefined(java.lang.String key)
          Test if the given key is declared in a resource file
 boolean isRoot()
          Checks if this environment is the root environment.
 void load(java.lang.String applicationId)
          Adds to the current environment resources of properties files corresponding to the given application id.
 void load(java.lang.String applicationId, java.lang.ClassLoader classLoader)
          Adds to the current environment resources of properties files corresponding to the given application id.
 void load(java.lang.String applicationId, java.lang.ClassLoader classLoader, boolean checkParentForBundle)
          Adds to the current environment resources of properties files corresponding to the given application id.
 boolean loadEnv(java.lang.String path)
          Loads the environment from the ".ini" file.
 boolean loadEnv(java.lang.String path, java.lang.ClassLoader classLoader)
          Deprecated. use loadEnv(String path, ClassLoader classLoader, true) instead of this one
 boolean loadEnv(java.lang.String path, java.lang.ClassLoader classLoader, boolean initialize)
          Loads the environment from ini file.
 boolean loadEnv(java.lang.String path, java.lang.ClassLoader classLoader, boolean initialize, java.lang.String lyAppDir)
          Loads the environment from ini file.
 void loadInParentBundles(java.lang.String applicationId, java.lang.ClassLoader classLoader)
          Adds to the current environment resources of properties files corresponding to the given application id.
 void logErr(java.lang.String message)
          This method logs error messages.
 void logError(java.lang.String message)
          This method logs errors.
 void logFatal(java.lang.String message)
          This method logs fatal errors.
 void logInfo(java.lang.String message)
          This method logs info.
 void logOut(java.lang.String message)
          This method logs output messages.
 void logTrace(java.lang.String message)
          This method logs traces.
 void logWarning(java.lang.String message)
          This method logs warnings.
 void parseEnv()
          Gets general configuration parameters from property file (".ini" file).
 void putColor(java.lang.String key, java.lang.String string)
          Adds a specific color in this environment.
 java.lang.Object putEnv(java.lang.String key, java.lang.Object value)
          Adds a value in the contextual environment.
 void putFile(java.lang.String key, java.lang.String string)
          Adds a specific file in this environment.
 void putFont(java.lang.String key, java.lang.String string)
          Adds a specific font in this environment.
 void putImage(java.lang.String key, java.lang.String string)
          Adds a specific image in this environment.
 void putMessage(java.lang.String key, java.lang.String string)
          Adds a specific message in this environment.
 void putResource(LyEnvironment.ResourceType type, java.lang.String key, java.lang.String value)
          Adds a non-persistent resource with the given type, key and value in this environment.
 void putResource(LyEnvironment.ResourceType type, java.lang.String key, java.lang.String value, boolean persistent)
          Adds a resource with the given type, key and value in this environment.
 void putResource(java.lang.String key, java.lang.String string)
          Adds a specific resource in this environment.
 void putString(java.lang.String key, java.lang.String string)
          Adds a string to the table of specific strings defined for one session.
 void raiseError(java.lang.String message)
          Raises a warning message to the end-user.
 void removeResource(LyEnvironment.ResourceType type, java.lang.String key)
          Removes a resource with the given type and key from this environment.
 boolean repostGuiEvents()
          Checks if events on data need to be reposted in GUI event queue.
 void setClassLoader(java.lang.ClassLoader loader)
          Sets the default class loader for this environment.
static LyEnvironment setCurrentEnvironment(LyEnvironment environment)
          Sets environment for current thread.
 void setDateLanguage(java.lang.String language)
          Sets the date language for this environment.
 void setDebugLevel(int level)
          Sets current debug level for this environment.
 void setDebugLevel(int level, boolean status)
          Sets current debug level for this environment.
static void setDecimalSeparator(java.lang.Character decimalSeparator)
          Sets the decimal separator for all environment.
 void setErrorStream(java.io.PrintStream error)
          Set the stream used to display errors.
static void setGroupingSeparator(java.lang.Character groupingSeparator)
          Set the grouping separator for all environment.
 void setLanguage(java.lang.String language)
          Sets the language for this environment.
 void setLogger(LyLogger logger)
          Sets environment logger.
 void setMobile(boolean isMobile)
           
 void setOutputStream(java.io.PrintStream output)
          Sets the stream used to display information.
 void setPlayer(LyPlayer player)
          Sets the demand player.
 void setSkin(java.lang.String skin)
          Set the skin for current environment.
 void setSkinAndLanguage(java.lang.String skin, java.lang.String language)
          Sets the skin and language for this environment.
 void setViewManager(LyViewManagerInterface viewManager)
          Sets the application view manager.
 boolean testEnv(java.lang.String key)
          Checks if an environment parameter is set.
 boolean testResource(java.lang.String key)
          Checks if a resource is set to true or 1.
 java.lang.String translate(java.lang.String key)
          Translates the given key to a String that may be shown to the user.
 void writeException(java.lang.Throwable t)
          Writes an exception to the error stream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

__VERSION

public static final java.lang.String __VERSION
See Also:
Constant Field Values

DEBUG_NONE

public static final int DEBUG_NONE
Debug level: None = No debug.

See Also:
Constant Field Values

DEBUG_ALL

public static final int DEBUG_ALL
Debug level: All = Writes information of the following levels:

See Also:
Constant Field Values

DEBUG_ERROR

public static final int DEBUG_ERROR
Debug level: Error = writes only occurred errors.
An error means that an operation did not complete successfully and/or that the current result might be inaccurate.

See Also:
Constant Field Values

DEBUG_WARNING

public static final int DEBUG_WARNING
Debug level: Warning = writes only occurred warning.
A warning occurres when an error or an unexpected result was found but the current operation may continue without any trouble.

See Also:
Constant Field Values

DEBUG_INFO

public static final int DEBUG_INFO
Debug level: Info = writes only information, i.e. normal operations such as saving a file.

See Also:
Constant Field Values

DEBUG_LOG

public static final int DEBUG_LOG
Debug level: Log = Debug level: Info.

See Also:
Constant Field Values

DEBUG_TRACE

public static final int DEBUG_TRACE
Debug level: Trace = writes only Traces.
A trace is an information about method calls or stacks traces.

See Also:
Constant Field Values

DEBUG_DBMS

public static final int DEBUG_DBMS
Debug level: DBMS = Writes information about DBMS connection and requests.

See Also:
Constant Field Values

DEBUG_BUS

public static final int DEBUG_BUS
Debug level: BUS = Writes information about the logical bus (messages between applications).

See Also:
Constant Field Values

DEBUG_XML

public static final int DEBUG_XML
Debug level: XML = Write information about XML (generation of views XML files).

See Also:
Constant Field Values

DEBUG_PERF

public static final int DEBUG_PERF
Debug level: PERF = Writes informations about performance.

See Also:
Constant Field Values

DEBUG_GRAPHICS

public static final int DEBUG_GRAPHICS
Debug level: GRAPHICS = Shows debug information about graphics (e.g. clipping area).

See Also:
Constant Field Values

DEBUG_PEER

public static final int DEBUG_PEER
Debug level: PEER = Writes information about peer layer.

See Also:
Constant Field Values

DEBUG_DUMP_HTML

public static final int DEBUG_DUMP_HTML
Debug level: DUMP HTML = Dump HTML pages to log directory.

See Also:
Constant Field Values

DEBUG_HELP_FILES

public static final int DEBUG_HELP_FILES
Debug level: HELP FILES = Dump Help Files that the application is seeking.

See Also:
Constant Field Values

DEBUG_TRANSACTION

public static final int DEBUG_TRANSACTION
Debug level: TRANSACTION = Writes information about generic hooks on transactions.

See Also:
Constant Field Values

DEBUG_PRINT_PDF

public static final int DEBUG_PRINT_PDF
Debug level: PRINT PDF = Writes information about generation of PDF files for printing.

See Also:
Constant Field Values

DEBUG_LOCKS

public static final int DEBUG_LOCKS
Debug level: LOCKS = Writes information about session locks.

See Also:
Constant Field Values

OS_WINDOWS

public static final short OS_WINDOWS
Windows OS.

See Also:
Constant Field Values

OS_UNIX

public static final short OS_UNIX
Unix Os : so far OS_UNIX = OS_SOLARIS || OS_LINUX || OS_HPUX || OS_AIX.

See Also:
Constant Field Values

OS_SOLARIS

public static final short OS_SOLARIS
Solaris Os.

See Also:
Constant Field Values

OS_LINUX

public static final short OS_LINUX
Linux Os.

See Also:
Constant Field Values

OS_HPUX

public static final short OS_HPUX
HP-UX Os.

See Also:
Constant Field Values

OS_AIX

public static final short OS_AIX
AIX Os.

See Also:
Constant Field Values

OS_MACOS

public static final short OS_MACOS
Mac OS.

See Also:
Constant Field Values

INTERNAL_DATE_FORMAT

public static java.lang.String INTERNAL_DATE_FORMAT
Internal date format to store dates in ids or peer values default is in LyDateFormatter and is EEE MMM dd HH:mm:ss zzz yyyy.


DELIMITERS

public static final java.lang.String DELIMITERS
Delimiters : separators that may be encountered when translating keys used to split given key in sub-keys.

See Also:
Constant Field Values

TEST_MODE

public static boolean TEST_MODE
Boolean indicating if the application is in test mode (record or replay).


TEST_MODE_AUTO

public static boolean TEST_MODE_AUTO
Boolean indicating if the application is in automatic test mode (record or replay).


TYPE_DATE_TIME

public static final short TYPE_DATE_TIME
Date type : date (day+month+year) and time (hour+min+seconds).

See Also:
Constant Field Values

TYPE_DATE_HOUR_MIN

public static final short TYPE_DATE_HOUR_MIN
Date type : date (day+month+year) and hour (hour+min).

See Also:
Constant Field Values

TYPE_DATE

public static final short TYPE_DATE
Date type : date (day+month+year).

See Also:
Constant Field Values

TYPE_TIME

public static final short TYPE_TIME
Date type : time (hour+min+seconds).

See Also:
Constant Field Values

TYPE_HOUR_MIN

public static final short TYPE_HOUR_MIN
Date type : hour (hour+min).

See Also:
Constant Field Values

NAMING_CONTEXT

public static final java.lang.String NAMING_CONTEXT
Context key for JNDI Resources

See Also:
Constant Field Values

HOSTING_TEMPSPACE

public static final java.lang.String HOSTING_TEMPSPACE
Context key for JNDI temp dir

See Also:
Constant Field Values

DEFAULT_SKIN

public static java.lang.String DEFAULT_SKIN
Default skin name.


out

public java.io.PrintStream out
Output stream to display informations. Default is System.out.


err

public java.io.PrintStream err
Output stream to display errors. Default is System.err.


_stringDateFormatTable

public java.lang.String[] _stringDateFormatTable
Optimization: keep dateFormat array association between TYPE_xxx (e.g. TYPE_DATE_TIME) and format. May be set by the application to specify its own date formats.


_dateFormatTable

public java.text.DateFormat[] _dateFormatTable
Optimization: keep dateFormat array association between TYPE_xxx and format. May be set by the application to specify its own date formats.


_oldSystemOut

public java.io.PrintStream _oldSystemOut
When the environment is closed, may restore former System.out.


_oldSystemErr

public java.io.PrintStream _oldSystemErr
When the environment is closed, may restore former System.err.


_throwable

public java.lang.Throwable _throwable
Constructor Detail

LyEnvironment

public LyEnvironment(java.lang.String id,
                     LyEnvironment parent,
                     boolean hasViewManager)
Constructor with a given identifier, parent environment and indication about view manager building.

Parameters:
id - The environment identifier.
parent - The parent environment.
hasViewManager - Indicates whether this environment may build a view manager or not.

LyEnvironment

public LyEnvironment(java.lang.String id,
                     LyEnvironment parent,
                     boolean hasViewManager,
                     boolean isMobile)
Constructor with a given identifier, parent environment and indications about view manager building and type of platform used.

Parameters:
id - The environment identifier.
parent - The parent environment.
hasViewManager - Indicates whether this environment may build a view manager or not.
isMobile - Indicates if the platform used is a mobile of not.

LyEnvironment

public LyEnvironment(LyEnvironment parent)
Constructor with a given parent environment.

Parameters:
parent - The parent environment.
Method Detail

getCurrentEnvironment

public static LyEnvironment getCurrentEnvironment()
Gets environment for current thread.

Returns:
Current environment if set, null otherwise.

setCurrentEnvironment

public static LyEnvironment setCurrentEnvironment(LyEnvironment environment)
Sets environment for current thread.

Parameters:
environment - Current environment, null to unset.

freeRootEnvironment

public static void freeRootEnvironment()
Free root environment.


isOperatingSystem

public static boolean isOperatingSystem(short osType)
Checks the current Operating System.

Parameters:
osType - One of the OS_XXX defines.
Returns:
true If os characteristics are found.

setDecimalSeparator

public static void setDecimalSeparator(java.lang.Character decimalSeparator)
Sets the decimal separator for all environment.

Parameters:
decimalSeparator - the new decimal separator.

setGroupingSeparator

public static void setGroupingSeparator(java.lang.Character groupingSeparator)
Set the grouping separator for all environment.

Parameters:
groupingSeparator - the new grouping separator.

getDecimalSeparator

public static java.lang.Character getDecimalSeparator()
Gets the decimal separator for all environment.

Returns:
the decimal separator, null if it was not surcharged.

getGroupingSeparator

public static java.lang.Character getGroupingSeparator()
Gets the grouping separator for all environment.

Returns:
the grouping separator, null if it was not surcharged.

free

public void free()
Frees all resources used by this environment.


isRoot

public boolean isRoot()
Checks if this environment is the root environment.

Returns:
true if this environment is the root environment, false otherwise

setOutputStream

public void setOutputStream(java.io.PrintStream output)
Sets the stream used to display information.

Parameters:
output - The new output stream

setErrorStream

public void setErrorStream(java.io.PrintStream error)
Set the stream used to display errors.

Parameters:
error - The new error stream

putResource

public void putResource(LyEnvironment.ResourceType type,
                        java.lang.String key,
                        java.lang.String value,
                        boolean persistent)
Adds a resource with the given type, key and value in this environment.

Parameters:
type - Type of the resource.
key - Key of the resource.
value - Value of the resource.
persistent - Indicates that resource survives to environment reload (language or skin changes).

putResource

public final void putResource(LyEnvironment.ResourceType type,
                              java.lang.String key,
                              java.lang.String value)
Adds a non-persistent resource with the given type, key and value in this environment.


removeResource

public void removeResource(LyEnvironment.ResourceType type,
                           java.lang.String key)
Removes a resource with the given type and key from this environment.

Parameters:
type - Type of the removed resource.
key - Key of the removed resource.

checkResource

public boolean checkResource(LyEnvironment.ResourceType type,
                             java.lang.String key,
                             boolean checkAll)
Check the existence of a resource in the resources bundles

Parameters:
type - type of the resource
key - the key
checkAll - if true, we check the existence in the application and in the AE properties. If false we only look in the application
Returns:
true if we found the resource

getResource

public java.lang.String getResource(LyEnvironment.ResourceType type,
                                    java.lang.String key)
Gets the resource identified with the given key and type.

Parameters:
type - Type of the resource.
key - Key of the resource.
Returns:
Value of the resource if it exists, null otherwise.

getResources

public java.util.HashMap<java.lang.String,java.lang.String> getResources(LyEnvironment.ResourceType type)
Gets resources identified with the given type.

Parameters:
type - Type of the resources.
Returns:
Value of the resources if it exists, null otherwise.

translate

public java.lang.String translate(java.lang.String key)
Translates the given key to a String that may be shown to the user. Strings are found in the strings_XXX.properties files (see LyResourceBundle for more details). This method only call translate(key, true)

Parameters:
key - The key to translate.
Returns:
The translated key if found in local dictionary, the key is returned 'as is' otherwise.
See Also:
LyStrings, translate(String, boolean)

getString

public java.lang.String getString(java.lang.String key)
Convenient routine to get a formated string without argument.

Parameters:
key - the string to find
Returns:
the found message
See Also:
getString(String, Object[])

getString

public java.lang.String getString(java.lang.String key,
                                  java.lang.Object argument)
Convenient routine to get a formated string with one argument.

Parameters:
key - the string key
argument - the message argument
Returns:
the found message
See Also:
getString(String, Object[])

getString

public java.lang.String getString(java.lang.String key,
                                  java.lang.Object[] arguments)
Constructs a string from a key and an array of arguments. Used instead of the translate method when arguments are needed.

Parameters:
key - the string key.
arguments - the array of arguments used to build the string.
Returns:
the string formated with the arguments. If not found, the key is returned followed by the string representation of the arguments.
See Also:
LyStrings.getString(String,Object[])

getMnemonic

public java.lang.Character getMnemonic(java.lang.String key)
Gets the mnemonic for the string corresponding to the given key.

Parameters:
key - The key of the string.
Returns:
The mnemonic for the string corresponding to the given key or null if not found.

putString

public void putString(java.lang.String key,
                      java.lang.String string)
Adds a string to the table of specific strings defined for one session. Allows adding a specific string during the session execution. If the key defines an existing string in the session environment, it is overidden.

Parameters:
key - The key that defines the string.
string - The translated string as it appears in views.

getMessage

public java.lang.String getMessage(java.lang.String key)
Convenient routine to get a formated message without argument.

Parameters:
key - the message key
Returns:
The message formated. If not found, the key is returned.
See Also:
getMessage(String, Object[])

getMessage

public java.lang.String getMessage(java.lang.String key,
                                   java.lang.Object argument)
Convenient routine to get a formated message with only one argument.

Parameters:
key - the message key
argument - the message argument
Returns:
The message formated with the argument. If not found, the key is returned followed by the string representation of the arguments.
See Also:
getMessage(String, Object[])

getMessage

public java.lang.String getMessage(java.lang.String key,
                                   java.lang.Object argument1,
                                   java.lang.Object argument2)
Convenient routine to get a formated message with two arguments.

Parameters:
key - the message key
argument1 - the first argument
argument2 - the second argument
Returns:
The message formated with the arguments. If not found, the key is returned followed by the string representation of the arguments.
See Also:
getMessage(String, Object[])

getMessage

public java.lang.String getMessage(java.lang.String key,
                                   java.lang.Object argument1,
                                   java.lang.Object argument2,
                                   java.lang.Object argument3)
Convenient routine to get a formated message with three arguments.

Parameters:
key - the message key
argument1 - the first argument
argument2 - the second argument
argument3 - the third argument
Returns:
The message formated with the arguments. If not found, the key is returned followed by the string representation of the arguments.
See Also:
getMessage(String, Object[])

getMessage

public java.lang.String getMessage(java.lang.String key,
                                   java.lang.Object[] arguments)
Constructs a message from a key and an array of arguments. Strings are found in the messages_XXX.properties files (see LyResourceBundle for more details).

Parameters:
key - The key of the message.
arguments - The array of arguments used to construct the message.
Returns:
The message formated with the arguments. If not found, the key is returned followed by the string representation of the arguments.
See Also:
LyStrings.getString(String,Object[]), LyStrings

putMessage

public void putMessage(java.lang.String key,
                       java.lang.String string)
Adds a specific message in this environment.

Parameters:
key - The key that defines the message.
string - The message content

getImageFileName

public java.lang.String getImageFileName(java.lang.String key)
Gets the image file name corresponding to the given key.

Parameters:
key - the image resource key
Returns:
The image file name corresponding to the given key if found, null otherwise

getImagePath

public java.lang.String getImagePath(java.lang.String key)
Retrieves an image path from the application environment.

Parameters:
key - The resource name (key) of the image.
Returns:
The image path, or null if it could not be found.
See Also:
LyImages.getImagePath(String)

getImageUrl

public final java.lang.String getImageUrl(java.lang.String key)
Retrieves an image url from the application environment.

Parameters:
key - The resource name (key) of the image.
Returns:
The image url, or the key if it could not be found.
See Also:
LyImages.getImageUrl(String)

getDisabledImageUrl

public final java.lang.String getDisabledImageUrl(java.lang.String key)
Retrieves a disabled image url from the application environment.

Parameters:
key - The resource name (key) of the image.
Returns:
The disabled image url, or the key if it could not be found.
See Also:
LyImages.getDisabledImageUrl(String)

getImageUrl

public java.lang.String getImageUrl(java.lang.String key,
                                    boolean disabled,
                                    boolean defaultImage)
Gets the image url corresponding to the given key.

Parameters:
key - the image resource key
disabled - Indicates if disabled image should be searched.
defaultImage - If true, return default image if the URL is not found.
Returns:
The image url corresponding to the given key, the default image url if not found and defaultImage parameter is set to true, null otherwise.

getImage

public java.lang.Object getImage(java.lang.String key)
Retrieves an image from the Application environment.

Parameters:
key - The resource name (key) of the image.
Returns:
A reference to the image object, or null if it could not be found.
See Also:
getImage(String,String), LyImages

getImage

public java.lang.Object getImage(java.lang.String key,
                                 java.lang.String sizeCode)
Retrieves an image from the Application environment.

Parameters:
key - The resource name (key) of the image
sizeCode - The size code of the image (see LyImages.loadImage())
Returns:
a reference to the image object, or null if it could not be found.
See Also:
getImage(String,String,boolean)

getImage

public java.lang.Object getImage(java.lang.String key,
                                 java.lang.String sizeCode,
                                 boolean defaultImage)
Retrieves an image from the Application environment.

Parameters:
key - The resource name (key) of the image
sizeCode - The size code of the image (see LyImages.loadImage())
defaultImage - If true, return default image if not found.
Returns:
a reference to the image object, or null if it could not be found.
See Also:
LyImages.loadImage(Object,String), getImageSizeInfo(int,int)

checkImage

public boolean checkImage(java.lang.String key)
Checks if given key image corresponds to a known image.

Parameters:
key - The resource name (key) of the image
Returns:
True if found, false otherwise.

isImageCached

public boolean isImageCached(java.lang.Object image)
Indicates whether given image may be cached.

Parameters:
image - The image that may be cached.
Returns:
true if image may be cached, false otherwise

isImageAnimated

public boolean isImageAnimated(java.lang.String key)
Indicates if an image is animated.

Parameters:
key - The resource name (key) of the image
Returns:
True if the image is animated, false otherwise.

getImageSizeInfo

public java.lang.String getImageSizeInfo(int width,
                                         int height)
Builds an image size description info (as a string). The syntax is : [VISIBLE_SEP3 + width + VISIBLE_SEP2 + height + VISIBLE_SEP3_BIS].

Parameters:
width - The desired width for the image.
height - The desired height for the image.
Returns:
The image info.
See Also:
LyImages.getImageSizeInfo(int,int)

getImageSize

public int[] getImageSize(java.lang.String path)
Checks if a size is given in the path. This method does *not* attempt to load the image.

Parameters:
path - The path to check.
Returns:
An array of two integers (width, height) describing the size of the image or null if no size is given.
See Also:
LyImages.getImageSize(String, boolean)

getImageSize

public int[] getImageSize(java.lang.String path,
                          boolean enableLoadImage)
Checks if a size is given in the path.

Parameters:
path - The path to check.
enableLoadImage - indicates wether the application is allowed to load the image
Returns:
An array of two integers (width, height) describing the size of the image or null if no size is given.
See Also:
LyImages.getImageSize(String, boolean)

getPathWithoutSize

public java.lang.String getPathWithoutSize(java.lang.String path)
Retrieves the path of an image without the information about its size.

Parameters:
path - The path of the image.
Returns:
The path of the image without the size information.
See Also:
LyImages.getPathWithoutSize(String)

putImage

public void putImage(java.lang.String key,
                     java.lang.String string)
Adds a specific image in this environment.

Parameters:
key - The key that defines the image.
string - The specific image path.

getLeonDocExternalUrl

public java.lang.String getLeonDocExternalUrl()
Gets the path of the external leonardi documentation if exists (LY_LEON_EXTERNAL_URL), the Leonardi dicumentation otherwise (LY_LEON_DOC).

Returns:
the path to the documentation
See Also:
getEnv(String)

getLyFont

public LyFont getLyFont(java.lang.String key)
Retrieves a Font from the application environment.

Parameters:
key - The resource name (key) of the font.
Returns:
A reference to the requested Font, or a default font if it could not be found.
See Also:
LyFonts

getFont

public java.lang.Object getFont(java.lang.String key)
Retrieves a Font from the application environment.

Parameters:
key - The resource name (key) of the font.
Returns:
A reference to the requested Font, or a default font if it could not be found.
See Also:
LyFonts

putFont

public void putFont(java.lang.String key,
                    java.lang.String string)
Adds a specific font in this environment.

Parameters:
key - The key that defines the font.
string - The specific font.

getLyColor

public LyColor getLyColor(java.lang.String key)
Retrieves a Color from the application environment.

Parameters:
key - The resource name (key) of the Color.
Returns:
A reference to the requested Color, or null if it could not be found.
See Also:
LyColors

getColor

public java.lang.Object getColor(java.lang.String key)
Retrieves a Color from the application environment.

Parameters:
key - The resource name (key) of the Color.
Returns:
A reference to the requested Color, or null if it could not be found.
See Also:
LyColors

getColorCodes

public java.util.Vector<java.lang.String> getColorCodes()
Gets the color codes list of the color_codes properties file.

Returns:
the color codes list as a Vector

putColor

public void putColor(java.lang.String key,
                     java.lang.String string)
Adds a specific color in this environment.

Parameters:
key - The key that defines the color.
string - The specific color.

getFile

public java.lang.String getFile(java.lang.String key)
Retrieves a File path from the application environment.

Parameters:
key - The resource name (key) of the File
Returns:
A reference to the requested Path, or null if it could not be found.
See Also:
LyFiles

getUrl

public java.lang.String getUrl(java.lang.String key)
Retrieves an url from the application environment.

Parameters:
key - The resource name (key) of the url
Returns:
A reference to the requested url, or null if it could not be found.
See Also:
LyFiles

putFile

public void putFile(java.lang.String key,
                    java.lang.String string)
Adds a specific file in this environment.

Parameters:
key - The key that defines the file.
string - The specific file.

isResourceDefined

public boolean isResourceDefined(java.lang.String key)
Test if the given key is declared in a resource file

Parameters:
key - a key
Returns:
true if the key is declared in a resource file.

getResource

public java.lang.String getResource(java.lang.String key)
Retrieves a resource from the application environment.

Parameters:
key - The resource name (key).
Returns:
The value of the requested resource, or null if it could not be found.
See Also:
LyResources

hasResource

public boolean hasResource(LyEnvironment.ResourceType type,
                           java.lang.String key)
Checks if a resource if found for given key.

Parameters:
key - Resource key.
Returns:
True if found, false otherwise.

testResource

public boolean testResource(java.lang.String key)
Checks if a resource is set to true or 1.

Parameters:
key - The resource name (key).
Returns:
True if the resource exits and is set to ttrue or 1, false otherwise.
See Also:
getResource(String)

putResource

public void putResource(java.lang.String key,
                        java.lang.String string)
Adds a specific resource in this environment.

Parameters:
key - The key that defines the resource.
string - The specific resource.

getIntResource

public int getIntResource(java.lang.String key)
Retrieves an integer resource from the application environment.

Parameters:
key - The resource name (key).
Returns:
The value of the requested resource, or -1 if it could not be found.
See Also:
LyResources

getEnv

public java.lang.String getEnv(java.lang.String key)
Retrieves a value from the contextual environment. Seeks in the local property table (_properties), and if not found a second search is done in the global environment (System or applet). Properties may be added using the putEnv method or may be read in the ini file of the application.

Parameters:
key - The key associated with the environment parameter.
Returns:
The environment variable or null if the value could not be found.
See Also:
putEnv(String,Object)

putEnv

public java.lang.Object putEnv(java.lang.String key,
                               java.lang.Object value)
Adds a value in the contextual environment. Both key and values should be not null.

Parameters:
key - The Id of the added property.
value - The value added in the environnment.
Returns:
the previous value of the specified key in the environnment, or null if it did not have one.
See Also:
getEnv(String)

testEnv

public boolean testEnv(java.lang.String key)
Checks if an environment parameter is set. A parameter is set when the key is in the application environment properties and when the value is true or 1.

Parameters:
key - The key that defines the parameter.
Returns:
true if the environment is set.
See Also:
putEnv(String,Object)

getViewAttValue

public java.lang.String getViewAttValue(java.lang.String key)
Retrieves a value from this environment.

Parameters:
key - The resource name (key).
Returns:
The value corresponding to the given key, or null if it could not be found.
See Also:
LyResources

initResources

public void initResources()
Initialize the environment.


loadEnv

public boolean loadEnv(java.lang.String path)
Loads the environment from the ".ini" file. Default file is found in system property LY_INI_FILE.

Parameters:
path - The full path to the environment file.
Returns:
true if the file was successfully read, false otherwise.
See Also:
loadEnv(String, ClassLoader, boolean)

loadEnv

public boolean loadEnv(java.lang.String path,
                       java.lang.ClassLoader classLoader)
Deprecated. use loadEnv(String path, ClassLoader classLoader, true) instead of this one

Loads the environment from ".ini" file. Default file is found in system property LY_INI_FILE.

Parameters:
path - The full path to the environment file.
classLoader - optional classloader to look in CLASSPATH
Returns:
true if the file was successfully read, false otherwise.

loadEnv

public boolean loadEnv(java.lang.String path,
                       java.lang.ClassLoader classLoader,
                       boolean initialize)
Loads the environment from ini file. Default file is found in system property LY_INI_FILE.

Parameters:
path - The full path to the environment file.
classLoader - optional classloader to look in CLASSPATH
initialize - indicates if we call the endInitialize method (true) or just read ini file (false)
Returns:
true if the file was successfully read, false otherwise.

loadEnv

public boolean loadEnv(java.lang.String path,
                       java.lang.ClassLoader classLoader,
                       boolean initialize,
                       java.lang.String lyAppDir)
Loads the environment from ini file. Default file is found in system property LY_INI_FILE.

Parameters:
path - The full path to the environment file.
classLoader - optional classloader to look in CLASSPATH
initialize - indicates if we call the endInitialize method (true) or just read ini file (false)
lyAppDir - new value of the LY_APP_DIR variable
Returns:
true if the file was successfully read, false otherwise.

checkEnv

public boolean checkEnv()
Checks all initialization environment parameters (data directories, images, files...) This method shall generate warning messages if some resources are missing.

Returns:
true
See Also:
checkPath(String, String, boolean, boolean)

checkPath

public boolean checkPath(java.lang.String key,
                         java.lang.String extraPath,
                         boolean fatalError,
                         boolean required)
Checks if the specified directory exists. If the file does not exists and error message is raised. The fatalError parameter indicates if the application can start after this error or not. FatalError throws an exception, otherwise a warning is printed to the console.

Parameters:
key - the key associated to the path we want to check
extraPath - additional path checked at the end of specified path
fatalError - if an error occured, shall we log the error to the console or stop the execution of the application (Exception).
required - indicates that the resource MUST be set.
Returns:
current status (true if everything is fine), false otherwise.

checkFile

public boolean checkFile(java.lang.String key,
                         boolean fatalError,
                         boolean required)
Checks if the specified path exists. If the file does not exists and error message is raised. The fatalError parameter indicates if the application can start after this error or not. FatalError throws an exception, otherwise a warning is printed to the console.

Parameters:
key - the key associated to the path we want to check
fatalError - if an error occured, shall we log the error to the console or stop the execution of the application (Exception).
required - indicates that the resource MUST be set.
Returns:
current status (true if everything is fine), false otherwise.

getTimeZone

public java.util.TimeZone getTimeZone()
Gets the default timezone for current context and current environment.

Returns:
Default timezone.

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String name,
                                               java.lang.ClassLoader classLoader)
Retrieves an inputStream from a local address.

Parameters:
name - the address of the input stream to retrieve
classLoader - the class loader that may retrieves the InputStream
Returns:
The inputStream if found, null otherwise

getInputStream

public java.io.InputStream getInputStream(java.lang.String path)
Retrieves an inputStream from a local address.

Parameters:
path - The path may be the access to a file or an URL.
Returns:
The inputStream or null if the stream does not exists.

getInputStream

public java.io.InputStream getInputStream(java.lang.String path,
                                          boolean showError)
Retrieves an inputStream from a local address.

Parameters:
path - The path may be the access to a file or an URL.
showError - indicates if an error may be shown to the user
Returns:
The inputStream or null if the stream does not exists.

getOutputStream

public java.io.OutputStream getOutputStream(java.lang.String path,
                                            boolean showError)
Retrieves an outputStream from a local address.

Parameters:
path - The path may be the access to a file or an URL.
showError - indicates if an error may be shown to the user
Returns:
The outputStream or null if the stream does not exists.

parseEnv

public void parseEnv()
Gets general configuration parameters from property file (".ini" file). They represents Lyria "kernel" properties such as LY_DEBUG_LEVEL.

See Also:
loadEnv(String)

calendarFactory

public java.util.Calendar calendarFactory()
Creates a new Calendar instance for the specified or default timeZone Set the time zone parameter in .ini file with the user.timezone key. If no timeZone is set, the default timeZone is ECT.

Returns:
A new Calendar instance for the environment timezone.

getStringDateFormat

public java.lang.String getStringDateFormat(int type)
Returns the string representing the date format of the given type. Strings format table is set as association table type-format in _stringDateFormatTable.

Parameters:
type - The date type (use LyDateFieldInfo types constants).
Returns:
a string representing the format.
See Also:
LyDateFieldInfo, dateFormatFactory(int)

dateFormatFactory

public java.text.DateFormat dateFormatFactory(int type)
Creates a new DateFormat instance of the given type. Format table is set as association table type-pattern in _dateFormatTable.

Parameters:
type - The type of date (use LyDateFieldInfo types constants).
Returns:
a new DateFormat instance.
See Also:
LyDateFieldInfo, getStringDateFormat(int)

getDisplayDateFormat

public java.text.DateFormat getDisplayDateFormat(java.lang.String pattern)
Gets the date format associated to the given pattern.

Parameters:
pattern - The pattern used for the requested format.
Returns:
The date format associated to the given pattern.

getNumberFormat

public java.text.NumberFormat getNumberFormat(java.lang.String pattern)
Gets the deciaml format associated to the given pattern.

Parameters:
pattern - The pattern used for the requested format.
Returns:
The decimal format associated to the given pattern.

getHelpFile

public java.lang.String getHelpFile(java.lang.String actionId,
                                    java.lang.String rootActionId,
                                    java.lang.String classId)
Gets the help file for the specified context, or null if help file could not be found. Programs attempts to find in help directory : help/classId/actionId_XX.html then help/classId/rootActionId_XX.html then help/actionId_XX.html then help/rootActionId_XX.html which is the default leonardi file.

Parameters:
actionId - Current action identifier (attempt to get help for the specific action)
rootActionId - Root action identifier
classId - Class id identifier.
Returns:
The help file path if it is found, null otherwise.
See Also:
LyHelpFiles

getScreenSize

public int[] getScreenSize(java.lang.Object component)
Retrieves the screen size.

Parameters:
component - The component used to retrieve the screen size.
Returns:
The dimension of the screen used to display views.
See Also:
LyViewManager.getScreenSize(Object)

getMaxScreenSize

public int[] getMaxScreenSize()
Retrieves the viewport size available on the computer.

Returns:
The addition of all screen sizes.

getId

public java.lang.String getId()
Gets the environment identifier.

Returns:
the environment identifier

getLanguage

public java.lang.String getLanguage()
Gets the environment language. Default values are defined in LANGUAGE_xxx constants.

Returns:
Current environment language if has been defined, null otherwise
See Also:
setLanguage(String)

getSkin

public java.lang.String getSkin()
Gest the environment skin.

Returns:
Current environment skin if it has been defined, otherwise returns the parent one or null if no parent.
See Also:
setSkin(String)

getDateLanguage

public java.lang.String getDateLanguage()
Gets the environment date language. Default values are defined in LANGUAGE_xxx constants.

Returns:
Current environment date language if has been defined, null otherwise
See Also:
setDateLanguage(String)

isDebugLevel

public boolean isDebugLevel(int level)
Checks if a debug level is set or not. Default values are defined in DEBUG_xxx constants.

Parameters:
level - The level that must be checked.
Returns:
true if the level is set, false otherwise.
See Also:
setDebugLevel(int,boolean)

getViewManager

public LyViewManagerInterface getViewManager()
Retrieves the environment view manager. If the environment does not have its own view manager (_hasViewManager is false) the view manager of the parent is returned.

Returns:
A reference to the LyViewManager instance or to the view manager of the parent.
See Also:
LyViewManager

getViewManager

public LyViewManagerInterface getViewManager(boolean isMobile)
Retrieves the environment view manager. If the environment does not have its own view manager (_hasViewManager is false) the view manager of the parent is returned.

Returns:
A reference to the LyViewManager instance or to the view manager of the parent.
See Also:
LyViewManager

setViewManager

public void setViewManager(LyViewManagerInterface viewManager)
Sets the application view manager. This method should be used with caution and only if the application needs to have the control on the view component instances that are created.

Parameters:
viewManager - a reference to the LyViewManager instance or to the view manager of the parent.
See Also:
LyViewManager

getLocale

public java.util.Locale getLocale()
Gets the default locale for current context and current environment.

Returns:
The locale corresponding to the language of the environment if it is set, the locale corresponding to the LY_LANGUAGE configuration parameter otherwise.

getDateLocale

public java.util.Locale getDateLocale()
Gets the default date locale for current context and current environment.

Returns:
The locale corresponding to the date language of the environment if it is set, the locale corresponding to the LY_LANGUAGE configuration parameter otherwise.

getCharset

public java.lang.String getCharset(java.lang.String lang,
                                   boolean nullIfNotFound)
Gets the charset for the given language. Language values are the language abreviations (such as fr, en , etc.) as defined in the ISO 639-1 languages codes. If the resource with the given language is not found, searches in the resource without language.

Parameters:
lang - the language whose charset is required
nullIfNotFound - if true, return null if the charset is not found, else return the default charset
Returns:
the charset if found, or null or the default charset (depending on parameter nullIfNotFound)

getString

public LyString getString()
Retrieves the instance of LyString associated to this environment.

Returns:
A reference to the LyString instance.
See Also:
LyString

beep

public void beep()
Emits a brief sound signal.


getImages

public LyImages getImages()
Gets the Images bundle associated to this environment.

Returns:
A reference to the LyImages instance.
See Also:
LyImages

clearResourceBundleCaches

public void clearResourceBundleCaches()
Clears all the resource bundle caches for this environment.


getPlayer

public LyPlayer getPlayer()
Gets demand player.

Returns:
the demand player

setPlayer

public void setPlayer(LyPlayer player)
Sets the demand player.

Parameters:
player - new demand player value

getClassLoader

public java.lang.ClassLoader getClassLoader()
Gets the default class loader of this environment.

Returns:
The default class loader for this environment or null if the system class loader is used.

getLogger

public LyLogger getLogger()
Gets the environment logger used to log application messages.

Returns:
the environment logger.

getPerfLogger

public LyPerfLogger getPerfLogger()
Gets the perfomance logger used to log perf messages.

Returns:
the performance logge if any.

setClassLoader

public void setClassLoader(java.lang.ClassLoader loader)
Sets the default class loader for this environment. All resources loaded before changing the class loader are NOT unload.

Parameters:
loader - The new default class loader.

setLogger

public void setLogger(LyLogger logger)
Sets environment logger.

Parameters:
logger - The logger used to log application messages.

setSkinAndLanguage

public void setSkinAndLanguage(java.lang.String skin,
                               java.lang.String language)
Sets the skin and language for this environment.

Parameters:
skin - The new skin.
language - The new language.
See Also:
LyEnvironment#setLanguage(), setSkin(String)

setLanguage

public void setLanguage(java.lang.String language)
Sets the language for this environment. Default values are defined in LANGUAGE_xxx constants.

Parameters:
language - The new language.
See Also:
getLanguage()

setSkin

public void setSkin(java.lang.String skin)
Set the skin for current environment.

Parameters:
skin - the name of the skin to be used.
initialization - indicates if we are in the initialization process.

setDateLanguage

public void setDateLanguage(java.lang.String language)
Sets the date language for this environment. Default values are defined in LANGUAGE_xxx constants.

Parameters:
language - The new date language.
See Also:
getLanguage()

setDebugLevel

public void setDebugLevel(int level)
Sets current debug level for this environment. Default values are defined in DEBUG_xxx constants.

Parameters:
level - The debug level that must be set.
See Also:
setDebugLevel(int,boolean)

setDebugLevel

public void setDebugLevel(int level,
                          boolean status)
Sets current debug level for this environment. Default values are defined in DEBUG_xxx constants.

Parameters:
level - The debug level that must be set.
status - true if the debugLevel is added, false if removed.
See Also:
setDebugLevel(int)

executeCommand

public void executeCommand(java.lang.String command,
                           boolean waiting)
Execute the given command in a separate process, capture its output and redirect it to the standard output.

Parameters:
command - system script that should be executed
waiting - indicates whether the call is waiting for process completion
See Also:
LyProcessViewer

executeCommand

public void executeCommand(java.lang.String[] command,
                           boolean waiting)
Execute the given command in a separate process, capture its output and redirect it to the standard output.

Parameters:
commands - command list which should be executed.
waiting - indicates whether the call is waiting for process completion
See Also:
LyProcessViewer

logFatal

public void logFatal(java.lang.String message)
This method logs fatal errors.

Parameters:
message - Message to log.

logError

public void logError(java.lang.String message)
This method logs errors.

Parameters:
message - Message to log.

logWarning

public void logWarning(java.lang.String message)
This method logs warnings.

Parameters:
message - Message to log.

logInfo

public void logInfo(java.lang.String message)
This method logs info.

Parameters:
message - Message to log.

logTrace

public void logTrace(java.lang.String message)
This method logs traces.

Parameters:
message - Message to log.

logErr

public void logErr(java.lang.String message)
This method logs error messages.

Parameters:
message - Message to log.

logOut

public void logOut(java.lang.String message)
This method logs output messages.

Parameters:
message - Message to log.

writeException

public void writeException(java.lang.Throwable t)
Writes an exception to the error stream. DEBUG_ERROR level must be set to produce the stack trace.


load

public void load(java.lang.String applicationId)
Adds to the current environment resources of properties files corresponding to the given application id.

Parameters:
applicationId - The application id.

load

public void load(java.lang.String applicationId,
                 java.lang.ClassLoader classLoader)
Adds to the current environment resources of properties files corresponding to the given application id.

Parameters:
applicationId - The application id.
classLoader - The environment classLoader.

load

public void load(java.lang.String applicationId,
                 java.lang.ClassLoader classLoader,
                 boolean checkParentForBundle)
Adds to the current environment resources of properties files corresponding to the given application id.

Parameters:
applicationId - The application id.
classLoader - The environment classLoader.
checkParentForBundle - indicates if parent bundles must be used during properties merge

loadInParentBundles

public void loadInParentBundles(java.lang.String applicationId,
                                java.lang.ClassLoader classLoader)
Adds to the current environment resources of properties files corresponding to the given application id.

Parameters:
applicationId - The application id.
classLoader - The environment classLoader.

repostGuiEvents

public boolean repostGuiEvents()
Checks if events on data need to be reposted in GUI event queue.

Returns:
True if the event need to be reposted, false otherwise.

raiseError

public void raiseError(java.lang.String message)
Raises a warning message to the end-user.

Parameters:
message - error message

execGui

public void execGui(java.lang.Runnable runnable)
Calls the #execGui(runnable, false) method of the given runnable to be invoked by the user-interface thread asynchronously. The caller of this method continues to run in parallel, and is not notified when the runnable has completed.

Parameters:
runnable - Code to run on the user-interface thread.

execGui

public void execGui(java.lang.Runnable runnable,
                    boolean synchronous)
If the view manager exist calls the view manager execGui(runnable, synchronous) method. Else, calls the given runnable Runnable.run() method to be invoked by the user-interface thread either synchronously or asynchronously. If asynchronous, the caller of this method continues to run in parallel, and is not notified when the runnable has completed. Otherwise, the thread which calls this method is suspended until the runnable completes.

Parameters:
runnable - Code to run on the user-interface thread.
synchronous - True is synchronous, false if asynchronous.

getPropertiesFromContext

public java.util.Properties getPropertiesFromContext(java.lang.String prefix)
Accessor to the properties file or parameter if specified in constructor.

Parameters:
prefix - Prefix used for properties files name.
Returns:
the properties.

setMobile

public void setMobile(boolean isMobile)

(c) January 2013 - W4 S.A.

Website: W4 S.A., contact us: support@w4global.com