Class EnvProps
- All Implemented Interfaces:
EventListener
,IGProp<GProp<?>[]>
,IPropCnr
,Cloneable
The property also handles the capabilities of the client.
The environment has at least the following properties:
- $client - StringMapProp
- $server - StringMapProp
- $geo - GeoProps
- ...other capabilities such as Speech...
- Author:
- Christopher Mindus
Nested Class Summary
Field Summary
Modifier and TypeFieldDescriptionprotected StringMapProp
The client environment properties.protected GeoProps
The Geolocation properties.protected StringMapProp
The server environment properties.Fields inherited from class com.iizix.prop.PropCnr
EMPTY, EMPTY_CLASSES, EMPTY_CNRS, EXTENDS_FRAMEWORK_ERROR_ID
Fields inherited from class com.iizix.prop.GProp
GPDEBUG, PROP_ATTR_STRING_EDITOR_PROP, PROP_ATTR_STRING_ERRORED_NAME, PROP_ATTR_STRING_EXTENDS, PROP_ATTR_STRING_EXTENDS_FINAL, PROP_ATTR_STRING_EXTENDS_PRIVATE, PROP_ATTR_STRING_NULLABLE, PROP_ATTR_STRING_PRIVATE, PROP_ATTR_STRING_PRIVATE_CHANGE_EVENT, PROP_ATTR_STRING_READ_ONLY, PROP_USER_1, PROP_USER_2
Fields inherited from interface com.iizix.prop.IGProp
EQC_ERROR_IGNORE_ALL, EQC_ERROR_IGNORE_REFERENCES, EQC_IGNORE_ARRAY, EQC_IGNORE_VOLATILE_OR_EDITOR, EQC_INCLUDE_PRIVATE, EQC_SAVE_FILE, EXT_CONTAINER_EXTENDS, EXT_CONTAINER_EXTENDS_VALID, EXT_EXTENDED, EXT_FINAL, EXT_OVERRIDES, EXT_OVERRIDES_FINAL_ERR, EXT_PRIVATE
Constructor Summary
Method Summary
Modifier and TypeMethodDescriptionprotected void
Adds the predefined properties for this container.boolean
Adds a screen orientation listener for the client session.boolean
addScreenSizeListener
(IScreenSizeListener listener) Adds a screen size listener for the client session.boolean
addStatusBarTapListener
(IStatusBarTapListener listener) Adds a status bar tap listener for the client session.clone()
Clones the environment properties.boolean
configureStatusBar
(StatusBarConfig config) Sets the client sessions status bar to the configuration specified.<TYPE> TYPE
getCachedValue
(String name, Class<TYPE> valueClass) Gets a cached property of a certain type.Gets the client environment properties.Gets the client session gyro instance.io.github.mngsk.devicedetector.Detection
Gets the cached device detection instance based on the parsed user agent.Gets the device UUID.getDeviceUUID
(boolean mustBeValid) Gets the device UUID.double
getDPR()
The device pixel ratio of the client.Gets the Geolocation properties.Gets the language code to use.Gets the client local info class instance.ua_parser.Client
Gets the parsed user agent instance.protected void
Gets potential references to predefined properties for this container.int
Gets the current screen height.Gets the current screen orientation.Gets the current screen size.int
Gets the current screen width.Gets the server environment properties.Gets the speech recognition instance.Gets the speech synthesis instance.boolean
hasClientCapabilities
(EnvProps.ClientCapability capability) Checks if a client has the specified capabilities.boolean
Checks if iiziRun is present.boolean
Checks if screen orientation locking is supported or not.void
onEventSelf
(GEvent event) Called when a property event is send to this property.void
onRemoteEvent
(RemoteEvent event) Called when a remote property event should be processed by this property.registerSession
(IClientSessionGyro clientGyro, IRemoteSessionControlListener listener) Assigns the application session control listener.boolean
Removes a screen orientation listener for the client session.boolean
removeScreenSizeListener
(IScreenSizeListener listener) Removes a screen size listener for the client session.boolean
Removes a status bar tap listener for the client session.void
setCachedValue
(String name, Object value) Sets a cached property by name.setLocale
(LocaleInfo locale) Changes or sets the LocaleInfo for the environment.boolean
setScreenOrientation
(ScreenOrientation orientation) Locks the screen orientation.protected boolean
shouldSerializeToXML
(int programType) The EnvProps are never written to XML.boolean
Unlocks the screen orientation.Methods inherited from class com.iizix.prop.PropCnr
__transferChildProps, addProp, addProp, addProp2, addProp2, appendPropValue, canRequestFocus, completeVirtualize, containsProp, containsProp, convertLoadedProp, couldRequestFocusIfVirtualized, createCopyOfAtom, createUniqueAtom, createUniqueAtom, createUniqueAtom, createVSReference, doPropEqualsArrayValues, enablePropCommunication, enablePropHashMap, equalsTree, equalsTree, getAllProps, getAllProps, getAllProps, getAllProps, getAllProps, getAllProps, getAllProps, getAllProps, getBool, getBool, getBool, getBool, getChildPropError, getChildPropError, getChildPropErrorSeverity, getChildPropErrorSeverity, getErrorsProp, getExtendsContainer, getExtendsError, getExtendsName, getExtendsOverride, getExtendsPossibleClasses, getFirstProp, getFirstProp, getFocusEngine, getInt, getInt, getInt, getInt, getLong, getLong, getLong, getLong, getNumber, getNumber, getNumber, getNumber, getPossibleChildren, getProp, getProp, getProp, getProp, getProp, getProp, getProp, getProp, getProp, getProp, getProp, getPropBaseReference, getPropCnr, getPropCount, getPropCount, getPropIndex, getPropIndex, getPropIndexes, getProps, getProps, getPropValue, getPropValue, getPropValue, getPropValue, getPropValue, getPropValue, getPropValue, getPropValue0, getRetargetedVerifyContainer, getString, getString, getString, getString, getValueClasses, getVSReference, hasFocus, hasSendData, initializeElement, initializeExtendsFramework, initializeProp, initializeValue, initPropCnr, insertProp, insertProp2, isChild, isExtendsOverriden, isExtendsPropertyValid, isExtendsRoot, isPropAddRemoveAllowed, isPropCommunicating, isPropExtended, list, list, logPropNotFound, maybeAddProp, onInsertProp, onPropDispose, onPropRemoved, onPropTreeInitialized, onReferenceEvent, onVirtualContainerCreated, onVirtualizationCompleted, paramString, prepare, removeAllProps, removeAllProps2, removeProp, removeProp, removeProp, removeProp, removeProp, removeProp, removeProp, removeProp2, removeProp2, removeProp2, removeProp2, removeProp2, removeProp2, removeProp2, reorderProps, replaceProps, requestFocus, requestFocus, requestFocusEx, requestFocusEx, resolveReferences, resolveRuntimeReferences, setBool, setBool, setBool, setBool, setCreateRequiredProp, setExtendsName, setExtendsOverride, setInt, setInt, setInt, setLong, setLong, setLong, setLong, setNumber, setNumber, setNumber, setNumber, setProp, setProp, setProp, setProp2, setProp2, setPropValue, setPropValue, setPropValue, setPropValue, setPropValue, setPropValue, setString, setString, setString, setString, shouldCreateProps, shouldSerializeToXML, toElementString, toNativeValue0, usePropHashMap, usesPropIndex, validateChildPropInValue, validateClassInstances, validatePropType, validatePropValue, verify, verifyInternalUseOnly, verifyTree, virtualize
Methods inherited from class com.iizix.prop.GProp
addPropError, addPropListener, appendProp, convertPropError, dispose, equals, equals, equalsErrors, equalsObj, equalsPropValue, equalValues, finalize, fine, fine, finer, finer, finest, finest, fromElementString, getAliasName, getAppSessionGyro, getAppWorker, getAtomPath, getAttribute, getChildReferencePropName, getClientWorker, getConstraints, getEnvironment, getErroredPropItems, getErroredProps, getErrorsProp, getExtendsRootContainer, getFullPropName, getFullPropName, getFullPropNameDebug, getFullPropNameDebug, getListeners, getModuleFolder, getModuleFolder, getParent, getParent, getProjectName, getPropAtom, getPropError, getPropError, getPropErroredName, getPropErrorSeverity, getPropExtendsFlags, getPropFromPath, getPropFromPath, getPropFromReference, getPropFromReference, getPropIndex, getPropName, getPropPath, getPropPath, getPropReferenceTarget, getPropRootPropMgr, getPropTreeErrorSeverity, getPropValue, getPropValue, getPropValueObject, getReferencePropName, getReferencePropNameNoAssert, getRelativePropName, getRootFromName, getRootName, getRootParent, getRootParentNoAssert, getTreeLock, hasChanged, hasCircularReferencesError, hasPrivateChangeEventProp, hasPropError, hasPropTreeError, info, info, initializeGElement, initializeGProp, isDisposed, isPropChildOf, isPropClientCreated, isPropCreateRequired, isPropExtended, isPropExtendsFinal, isPropExtendsPrivate, isPropExtendsPrivateInRoot, isPropExtendsPrivateInRoot, isPropFile, isPropFolder, isPropForEditor, isPropNullable, isPropPrivate, isPropPrivateAtCreation, isPropReadOnly, isPropReferenceTreeValid, isPropRoot, isPropRootLoading, isPropRootTreeModificationsAllowed, isPropUSER, isPropValueTreeLockNeeded, isPropVirtualized, isPropVirtualizing, isPropVolatile, isPropVolatileOrEditorOnly, isProxied, isSibling, list, list, list, mapAliasToReference, mapAliasToReference, mapReferenceToAlias, mapReferenceToAlias, mapReferenceToProjectRelative, modifyPropValue, moveProp, moveProp, moveProp, onEvent, onPrepare, onPropInvalidateCache, onPropParentChanged, onPropValueSet, paramString, paramValue, post, post, removePropError, removePropListener, removePropUSER, renameProp, renameProp2, resetChangedTree, setChanged, setConstraints, setConstraints, setParent, setPrivateChangeEventProp, setPrivateCreateRequiredProp, setPropError, setPropErroredName, setPropExtended, setPropExtendsFinal, setPropExtendsPrivate, setPropForEditor, setPropNullable, setPropPrivate, setPropReadOnly, setPropUSER, setPropValue, setPropValue, setPropValue, setPropValueIncognito, setPropVolatile, severe, severe, severe, throwIfReadOnly, toNativeValue, toString, toString, triggerRemoteEvent, triggerRemoteEvent, validateProp, warning, warning, warning
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.iizix.prop.IGProp
addPropError, addPropListener, dispose, equals, fine, fine, finer, finer, finest, finest, fromElementString, getAppSessionGyro, getAtomPath, getConstraints, getEnvironment, getErroredPropItems, getErroredProps, getErrorsProp, getExtendsRootContainer, getFullPropName, getFullPropNameDebug, getModuleFolder, getModuleFolder, getParent, getParent, getPropAtom, getPropError, getPropError, getPropErrorSeverity, getPropExtendsFlags, getPropFromPath, getPropFromReference, getPropIndex, getPropName, getPropPath, getPropPath, getPropRootPropMgr, getPropTreeErrorSeverity, getPropValue, getPropValue, getReferencePropName, getRelativePropName, getRootParent, getTreeLock, hasChanged, hasCircularReferencesError, hasPrivateChangeEventProp, hasPropError, hasPropTreeError, info, info, initializeGElement, initializeGProp, isDisposed, isPropChildOf, isPropClientCreated, isPropCreateRequired, isPropExtended, isPropExtendsFinal, isPropExtendsPrivate, isPropExtendsPrivateInRoot, isPropExtendsPrivateInRoot, isPropFile, isPropFolder, isPropNullable, isPropPrivate, isPropReadOnly, isPropReferenceTreeValid, isPropRoot, isPropVirtualized, isSibling, list, list, list, mapAliasToReference, mapReferenceToAlias, mapReferenceToProjectRelative, moveProp, moveProp, moveProp, onEvent, removePropError, removePropListener, renameProp, setChanged, setConstraints, setConstraints, setParent, setPrivateChangeEventProp, setPropError, setPropExtendsFinal, setPropExtendsPrivate, setPropNullable, setPropPrivate, setPropReadOnly, setPropValue, setPropValue, severe, severe, severe, toNativeValue, triggerRemoteEvent, triggerRemoteEvent, validateProp, warning, warning, warning
Methods inherited from interface com.iizix.prop.IPropCnr
canRequestFocus, canRequestFocus, couldRequestFocusIfVirtualized, couldRequestFocusIfVirtualized
Field Details
clientEnv
The client environment properties.geoProps
The Geolocation properties.serverEnv
The server environment properties.
Constructor Details
EnvProps
protected EnvProps()Creates the environment properties without a name.EnvProps
Creates the environment properties with a name.- Parameters:
atom
- The atom name.
Method Details
getClientSessionGyro
Gets the client session gyro instance.- Specified by:
getClientSessionGyro
in interfaceIGProp<GProp<?>[]>
- Overrides:
getClientSessionGyro
in classGProp<GProp<?>[]>
- Returns:
- The instance, or null if not found.
shouldSerializeToXML
protected boolean shouldSerializeToXML(int programType) The EnvProps are never written to XML.- Overrides:
shouldSerializeToXML
in classGProp<GProp<?>[]>
- Parameters:
programType
- From PropFactory.getProgramType(): 0=PropFactory.CLIENT
, 1=PropFactory.SERVER
or 2=PropFactory.EDITOR
.- Returns:
- true (default if not VOLATILE) to save to XML, false to avoid writing the property to XML.
addPredefinedProps
Adds the predefined properties for this container. This method is called once just after construction of the property container.Properties added:
- client environment StringMapProp Atom.A_CLIENT - server environment StringMapProp Atom.A_SERVER
- Overrides:
addPredefinedProps
in classPropCnr
- Throws:
PropException
- for property exceptions.
getPredefinedProps
protected void getPredefinedProps()Gets potential references to predefined properties for this container. This method is called once just after cloning of the property container.The method should get reference to using the
getProp(...)
methods. This allows the subclass to be able to retrieve the new instances to the properties created duringaddPredefinedProps()
if stored in instance variables.- Overrides:
getPredefinedProps
in classPropCnr
clone
Clones the environment properties.getServerEnv
Gets the server environment properties.- Returns:
- StringMapProp for the server environment.
getClientEnv
Gets the client environment properties.- Returns:
- StringMapProp for the client environment.
iiziRunPresent
public boolean iiziRunPresent()Checks if iiziRun is present.- Returns:
- true if present, false otherwise.
getGeolocation
Gets the Geolocation properties.getSpeechSynthesis
Gets the speech synthesis instance.- Returns:
- The instance, or null if not supported.
getSpeechRecognition
Gets the speech recognition instance.- Returns:
- The instance, or null if not supported.
getLocale
Gets the client local info class instance.- Returns:
- The client locale info class instance when the client environment has been set, otherwise the default client locale info instance specified for the server.
setLocale
Changes or sets the LocaleInfo for the environment. This method is intended to be used to change the language setting of a client session.Note that this change does not fire any refresh to the client property tree, use the
instead.IClientSessionGyro.setLocale(LocaleInfo)
- Parameters:
locale
- localeInfo The locale information to use.- Returns:
- The old LocaleInfo, or null if not set.
- Throws:
PropTypeException
- If the property is read-only.
getDPR
public double getDPR()The device pixel ratio of the client.- Returns:
- The Device Pixel Ratio, or 1.0 if not found.
getLanguageCode
Gets the language code to use.- Returns:
- The language code, or null for default (not defined by the client).
setCachedValue
Sets a cached property by name. This is set for this instance only.- Parameters:
name
- The name.value
- An object.
getCachedValue
Gets a cached property of a certain type.- Parameters:
name
- The name.valueClass
- The value class to retrieve.- Returns:
- The cached value, or null if not found or class mismatch.
hasClientCapabilities
Checks if a client has the specified capabilities. It is important to use the appropriate EnvProps instance, i.e. the client session EnvProps and not e.g. the server's.- Parameters:
capability
- The capability to query.- Returns:
- true for support, false when client doesn't have the capability.
getParsedUserAgent
Gets the parsed user agent instance.- Returns:
- The parsed user agent for the client, a cached value (i.e. parsed once only).
- Throws:
Exception
- An exception due to failure in performing the test, with a message why it failed.
getDeviceDetectionFromUserAgent
Gets the cached device detection instance based on the parsed user agent.- Returns:
- The cached device detection instance based on the parsed user agent (i.e. parsed once only).
- Throws:
Exception
- An exception due to failure in performing the test, with a message why it failed.
registerSession
public IRemoteSessionControl registerSession(IClientSessionGyro clientGyro, IRemoteSessionControlListener listener) Assigns the application session control listener.This method is only intended for the framework and will throw an error if called.
- Parameters:
clientGyro
- The client gyro instance.listener
- The control listener.- Throws:
IllegalStateException
- If not called from the framework.
onRemoteEvent
Called when a remote property event should be processed by this property.A subclass can override this method to perform appropriate processing and is not required to call
super.onRemoteEvent(e)
.The onRemoteEvent is NOT called when in a proxied property container, but rather the normal onEventSelf method.
- Specified by:
onRemoteEvent
in interfaceIGProp<GProp<?>[]>
- Overrides:
onRemoteEvent
in classGProp<GProp<?>[]>
- Parameters:
event
- The remote event.
onEventSelf
Called when a property event is send to this property.A subclass can override this method to perform appropriate processing and is not required to call
super.onEventSelf(e)
.- Specified by:
onEventSelf
in interfaceIGProp<GProp<?>[]>
- Overrides:
onEventSelf
in classGProp<GProp<?>[]>
- Parameters:
event
- The property event.
addScreenSizeListener
Adds a screen size listener for the client session. Calling this method multiple times with the same listener will have no effect (but to return false).- Parameters:
listener
- The listener to add.- Returns:
- true if the listener was added, false otherwise.
- Throws:
NullPointerException
- If the listener isnull
.
removeScreenSizeListener
Removes a screen size listener for the client session.- Parameters:
listener
- The listener to remove.- Returns:
- true if listener is successfully removed, false otherwise.
getScreenWidth
public int getScreenWidth()Gets the current screen width.- Returns:
- The current screen width, or zero if not initialized.
getScreenHeight
public int getScreenHeight()Gets the current screen height.- Returns:
- The current screen height, or zero if not initialized.
getScreenSize
Gets the current screen size.- Returns:
- The current screen size, or zero width and/or height if not initialized.
addScreenOrientationListener
Adds a screen orientation listener for the client session. Calling this method multiple times with the same listener will have no effect (but to return false).- Parameters:
listener
- The listener to add.- Returns:
- true if the listener was added, false otherwise.
- Throws:
NullPointerException
- If the listener isnull
.
removeScreenOrientationListener
Removes a screen orientation listener for the client session.- Parameters:
listener
- The listener to remove.- Returns:
- true if listener is successfully removed, false otherwise.
isScreenOrientationLockSupported
public boolean isScreenOrientationLockSupported()Checks if screen orientation locking is supported or not.- Returns:
- true if the functions to lock or unlock screen orientation are supported, false otherwise.
getScreenOrientation
Gets the current screen orientation.- Returns:
- The orientation,
ScreenOrientation.unknown
if not supported.
setScreenOrientation
Locks the screen orientation.Note that there may be a delay in the orientation change after calling this method. This could be due to slow client connection, disconnected client or just due to device lag.
- Parameters:
orientation
- The orientation.- Returns:
- true for success, false for not supported.
- Throws:
IllegalArgumentException
- Iforientation
isScreenOrientation.unknown
.
unlockScreenOrientation
public boolean unlockScreenOrientation()Unlocks the screen orientation.Note that there may be a delay in the orientation change after calling this method. This could be due to slow client connection, disconnected client or just due to device lag.
- Returns:
- true for success, false for not supported.
getDeviceUUID
Gets the device UUID.- Returns:
- The device's UUID if iiziRun is used and has been initialized,
unknown
otherwise. It is always "browser" for browsers.
getDeviceUUID
Gets the device UUID.- Parameters:
mustBeValid
- Flag requiring device UUID to be from a valid device, otherwise null is returned. When flag is false,- Returns:
- The device's UUID if iiziRun is used and has been initialized, when
mustBeValid
is falseunknown
otherwise. It is always "browser" for browsers whenmustBeValid
is false. WhenmustBeValid
is true, null is returned.
configureStatusBar
Sets the client sessions status bar to the configuration specified.Note: this only works on devices using iiziRun.
- Parameters:
config
- The configuration.- Returns:
- true for ch
addStatusBarTapListener
Adds a status bar tap listener for the client session. Calling this method multiple times with the same listener will have no effect (but to return false).Status bar tap events are only fired for devices using iiziRun with status bars available, using iOS devices.
- Parameters:
listener
- The listener to add.- Returns:
- true if the listener was added, false otherwise.
- Throws:
NullPointerException
- If the listener isnull
.
removeStatusBarTapListener
Removes a status bar tap listener for the client session.- Parameters:
listener
- The listener to remove.- Returns:
- true if listener is successfully removed, false otherwise.