Class EnvProps
- java.lang.Object
- com.iizix.prop.GProp<GProp<?>[]>
- com.iizix.prop.PropCnr
- com.iizix.prop.EnvProps
- All Implemented Interfaces:
EventListener
,IGProp<GProp<?>[]>
,IPropCnr
,java.lang.Cloneable
public class EnvProps extends PropCnr
This client property is a container that holds everything a client/server needs in order to establish communication with the other party, and information about themselves (such as environment).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
Nested Classes Modifier and Type Class Description static class
EnvProps.ClientCapability
Capabilities of a Client.
Field Summary
Fields Modifier and Type Field Description protected StringMapProp
clientEnv
The client environment properties.protected GeoProps
geoProps
The Geolocation properties.protected StringMapProp
serverEnv
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_PRIVATE, EQC_SAVE_FILE, EXT_CONTAINER_EXTENDS, EXT_CONTAINER_EXTENDS_VALID, EXT_EXTENDED, EXT_FINAL, EXT_OVERRIDES, EXT_OVERRIDES_FINAL_ERR, EXT_PRIVATE
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addPredefinedProps()
Adds the predefined properties for this container.boolean
addScreenOrientationListener(IScreenOrientationListener listener)
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.EnvProps
clone()
Clones the environment properties.boolean
configureStatusBar(StatusBarConfig config)
Sets the client sessions status bar to the configuration specified.<TYPE> TYPE
getCachedValue(java.lang.String name, java.lang.Class<TYPE> valueClass)
Gets a cached property of a certain type.StringMapProp
getClientEnv()
Gets the client environment properties.IClientSessionGyro
getClientSessionGyro()
Gets the client session gyro instance.io.github.mngsk.devicedetector.Detection
getDeviceDetectionFromUserAgent()
Gets the cached device detection instance based on the parsed user agent.java.lang.String
getDeviceUUID()
Gets the device UUID.java.lang.String
getDeviceUUID(boolean mustBeValid)
Gets the device UUID.double
getDPR()
The device pixel ratio of the client.GeoProps
getGeolocation()
Gets the Geolocation properties.java.lang.String
getLanguageCode()
Gets the language code to use.LocaleInfo
getLocale()
Gets the client local info class instance.ua_parser.Client
getParsedUserAgent()
Gets the parsed user agent instance.protected void
getPredefinedProps()
Gets potential references to predefined properties for this container.int
getScreenHeight()
Gets the current screen height.ScreenOrientation
getScreenOrientation()
Gets the current screen orientation.Size
getScreenSize()
Gets the current screen size.int
getScreenWidth()
Gets the current screen width.StringMapProp
getServerEnv()
Gets the server environment properties.SpeechRecognitionProp
getSpeechRecognition()
Gets the speech recognition instance.SpeechSynthesisProp
getSpeechSynthesis()
Gets the speech synthesis instance.boolean
hasClientCapabilities(EnvProps.ClientCapability capability)
Checks if a client has the specified capabilities.boolean
iiziRunPresent()
Checks if iiziRun is present.boolean
isScreenOrientationLockSupported()
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.IRemoteSessionControl
registerSession(IClientSessionGyro clientGyro, IRemoteSessionControlListener listener)
Assigns the application session control listener.boolean
removeScreenOrientationListener(IScreenOrientationListener listener)
Removes a screen orientation listener for the client session.boolean
removeScreenSizeListener(IScreenSizeListener listener)
Removes a screen size listener for the client session.boolean
removeStatusBarTapListener(IStatusBarTapListener listener)
Removes a status bar tap listener for the client session.void
setCachedValue(java.lang.String name, java.lang.Object value)
Sets a cached property by name.LocaleInfo
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
unlockScreenOrientation()
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, doVirtualizePropCnr, 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, getReferences, getRetargetedVerifyContainer, getString, getString, getString, getString, getValueClasses, getVSReference, hasFocus, hasSendData, initializeElement, initializeExtendsFramework, initializeProp, initializeValue, initPropCnr, insertProp, insertProp2, isChild, isExtendsOverriden, isExtendsPropertyValid, isExtendsRoot, isPropAddRemoveAllowed, isPropCommunicating, isPropExtended, isSibling, list, list, logPropNotFound, maybeAddProp, onInsertProp, onPropDispose, onPropRemoved, onPropTreeInitialized, onReferenceEvent, 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, convertPropError, dispose, equals, equals, equalsErrors, equalsObj, equalsPropValue, equalValues, extendsClone, 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, getRelativePropName, getRootFromName, getRootName, getRootParent, getRootParent, getTreeLock, hasChanged, 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, isPropUSER, isPropValueTreeLockNeeded, isPropVirtualized, isPropVirtualizing, isPropVolatile, isPropVolatileOrEditorOnly, isProxied, list, list, list, mapAliasToReference, mapAliasToReference, mapReferenceToAlias, mapReferenceToAlias, mapReferenceToProjectRelative, modifyPropValue, moveProp, moveProp, moveProp, onEvent, onPrepare, onPropInvalidateCache, onPropParentChanged, onPropValueSet, onVirtualizationCompleted, onVirtualized, 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, verifyHasPropertyItem, 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, hasPrivateChangeEventProp, hasPropError, hasPropTreeError, info, info, initializeGElement, initializeGProp, isDisposed, isPropChildOf, isPropClientCreated, isPropCreateRequired, isPropExtended, isPropExtendsFinal, isPropExtendsPrivate, isPropExtendsPrivateInRoot, isPropExtendsPrivateInRoot, isPropFile, isPropFolder, isPropNullable, isPropPrivate, isPropReadOnly, isPropReferenceTreeValid, isPropRoot, isPropVirtualized, 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, verifyHasPropertyItem, warning, warning, warning
Methods inherited from interface com.iizix.prop.IPropCnr
canRequestFocus, canRequestFocus, couldRequestFocusIfVirtualized, couldRequestFocusIfVirtualized
Field Detail
clientEnv
protected StringMapProp clientEnv
The client environment properties.
geoProps
protected GeoProps geoProps
The Geolocation properties.
serverEnv
protected StringMapProp serverEnv
The server environment properties.
Constructor Detail
EnvProps
protected EnvProps()
Creates the environment properties without a name.
EnvProps
public EnvProps(Atom atom)
Creates the environment properties with a name.- Parameters:
atom
- The atom name.
Method Detail
getClientSessionGyro
public IClientSessionGyro 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
protected void addPredefinedProps() throws PropException
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
getServerEnv
public StringMapProp getServerEnv()
Gets the server environment properties.- Returns:
- StringMapProp for the server environment.
getClientEnv
public StringMapProp 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
public GeoProps getGeolocation()
Gets the Geolocation properties.
getSpeechSynthesis
public SpeechSynthesisProp getSpeechSynthesis()
Gets the speech synthesis instance.- Returns:
- The instance, or null if not supported.
getSpeechRecognition
public SpeechRecognitionProp getSpeechRecognition()
Gets the speech recognition instance.- Returns:
- The instance, or null if not supported.
getLocale
public LocaleInfo 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
public LocaleInfo setLocale(LocaleInfo locale) throws PropTypeException
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
public java.lang.String getLanguageCode()
Gets the language code to use.- Returns:
- The language code, or null for default (not defined by the client).
setCachedValue
public void setCachedValue(java.lang.String name, java.lang.Object value)
Sets a cached property by name. This is set for this instance only.- Parameters:
name
- The name.value
- An object.
getCachedValue
public <TYPE> TYPE getCachedValue(java.lang.String name, java.lang.Class<TYPE> valueClass)
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
public boolean hasClientCapabilities(EnvProps.ClientCapability capability)
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
public ua_parser.Client getParsedUserAgent() throws java.lang.Exception
Gets the parsed user agent instance.- Returns:
- The parsed user agent for the client, a cached value (i.e. parsed once only).
- Throws:
java.lang.Exception
- An exception due to failure in performing the test, with a message why it failed.
getDeviceDetectionFromUserAgent
public io.github.mngsk.devicedetector.Detection getDeviceDetectionFromUserAgent() throws java.lang.Exception
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:
java.lang.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:
java.lang.IllegalStateException
- If not called from the framework.
onRemoteEvent
public void onRemoteEvent(RemoteEvent event)
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
public void onEventSelf(GEvent event)
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
public boolean addScreenSizeListener(IScreenSizeListener listener)
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:
java.lang.NullPointerException
- If the listener isnull
.
removeScreenSizeListener
public boolean removeScreenSizeListener(IScreenSizeListener listener)
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
public Size getScreenSize()
Gets the current screen size.- Returns:
- The current screen size, or zero width and/or height if not initialized.
addScreenOrientationListener
public boolean addScreenOrientationListener(IScreenOrientationListener listener)
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:
java.lang.NullPointerException
- If the listener isnull
.
removeScreenOrientationListener
public boolean removeScreenOrientationListener(IScreenOrientationListener listener)
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
public ScreenOrientation getScreenOrientation()
Gets the current screen orientation.- Returns:
- The orientation,
ScreenOrientation.unknown
if not supported.
setScreenOrientation
public boolean setScreenOrientation(ScreenOrientation orientation)
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:
java.lang.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
public java.lang.String 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
public java.lang.String getDeviceUUID(boolean mustBeValid)
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
public boolean configureStatusBar(StatusBarConfig config)
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
public boolean addStatusBarTapListener(IStatusBarTapListener listener)
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:
java.lang.NullPointerException
- If the listener isnull
.
removeStatusBarTapListener
public boolean removeStatusBarTapListener(IStatusBarTapListener listener)
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.