public class Devices
extends java.lang.Object
Device
).Modifier and Type | Method and Description |
---|---|
static void |
add(Element config)
Adds a device based on the XML declaration.
|
static java.lang.String |
add(java.lang.String deviceType,
java.lang.Class cls)
Adds a device type.
|
static java.lang.String |
add(java.lang.String deviceType,
java.lang.String clsnm)
Adds a device type.
|
static void |
addEmbedded(java.lang.String deviceType,
java.lang.String content)
Adds the content that shall be added to the output generated and
sent to the client, when rending a desktop.
|
static boolean |
exists(java.lang.String deviceType)
Tests whether the device for the specified type exists.
|
static Device |
getDevice(java.lang.String deviceType)
Returns the device for the specified desktop type.
|
static Device |
getDeviceByClient(java.lang.String userAgent)
Returns the device for the specified client.
|
java.lang.String |
getEmbedded(java.lang.String deviceType)
Returns the content that shall be embedded to the output being
generated to the client, or null if no embedded content.
|
static java.lang.String |
getServerPushClass(java.lang.String deviceType)
Returns the class name that implements the server push feature.
|
static java.lang.String |
getUnavailableMessage(java.lang.String deviceType)
Returns the unavailable message for the specified device type.
|
static java.lang.String |
loadFileContentAsString(Execution exec,
java.lang.String path)
Loads the content of a file as a String.
|
static java.lang.String |
loadJavaScript(Execution exec,
java.lang.String path)
Loads the content of a javascript file as a String.
|
static java.lang.Object[] |
matches(java.lang.String userAgent)
Returns the name and version of the client if the given user agent
matches any of the devices, or null if not matched or it is a standard
browser request.
|
static java.lang.String |
setServerPushClass(java.lang.String deviceType,
java.lang.Class cls)
Sets the class that implements the server-push feature.
|
static java.lang.String |
setServerPushClass(java.lang.String deviceType,
java.lang.String clsnm)
Sets the name of the class that implements the server-push feature.
|
static java.lang.String |
setUnavailableMessage(java.lang.String deviceType,
java.lang.String msg)
Sets the unavailable message for the specified device type.
|
public static final Device getDevice(java.lang.String deviceType) throws DeviceNotFoundException
deviceType
- the device type, such as ajax, xml and mil.DeviceNotFoundException
- if not found.public static final Device getDeviceByClient(java.lang.String userAgent) throws DeviceNotFoundException
Device.isCompatible(java.lang.String)
to return the correct device.
If all devices returns null (means unknown), one of the devices returning
null is returned. If all devices returns Boolean.FALSE,
DeviceNotFoundException is thrown.userAgent
- represents a client.
It is the user-agent header for HTTP-base client.DeviceNotFoundException
- if not found.Execution.getUserAgent()
public static final boolean exists(java.lang.String deviceType)
deviceType
- the device type, say, ajax.public static final void add(Element config)
<device-config>
<device-type>superajax</device-type>
<device-class>my.MyDevice</device-class>
<unavailable-message>error message</unavailable-message>
<server-push-class>my.MyServerPush</server-push-class>
</device-config>
config
- the XML element called zscript-configpublic static final java.lang.String add(java.lang.String deviceType, java.lang.String clsnm)
deviceType
- the device type (a.k.a., the device name).clsnm
- the device class namepublic static final java.lang.String add(java.lang.String deviceType, java.lang.Class cls)
deviceType
- the device type (a.k.a., the device name).cls
- the device classpublic static final java.lang.String getUnavailableMessage(java.lang.String deviceType)
The result is the same as the invocation of Device.getUnavailableMessage()
against getDevice(java.lang.String)
, but this method will not load the device
if it is not loaded yet.
Device
,
Device.getUnavailableMessage()
public static final java.lang.String setUnavailableMessage(java.lang.String deviceType, java.lang.String msg)
Device
,
Device.setUnavailableMessage(java.lang.String)
public java.lang.String getEmbedded(java.lang.String deviceType)
public static void addEmbedded(java.lang.String deviceType, java.lang.String content)
As the method name suggests, the embedded contents are accumulated and all generated to the output.
public static final java.lang.String getServerPushClass(java.lang.String deviceType)
Default: null (the server-push feature is not available).
The result is the same as the invocation of Device.getServerPushClass()
against getDevice(java.lang.String)
, but this method will not load the device
if it is not loaded yet.
public static final java.lang.String setServerPushClass(java.lang.String deviceType, java.lang.String clsnm)
clsnm
- the class name that implements the server push.
If null, it means no server push is available.public static final java.lang.String setServerPushClass(java.lang.String deviceType, java.lang.Class cls)
cls
- the class that implements the server push.
If null, it means no server push is available.public static final java.lang.Object[] matches(java.lang.String userAgent)
It iterates all devices and invokes Device.matches(java.lang.String)
one-by-one,
then returns the first non-null return, if any.
userAgent
- represents a client (i.e., HTTP's user-agent).public static java.lang.String loadJavaScript(Execution exec, java.lang.String path) throws java.io.IOException
java.io.IOException
public static java.lang.String loadFileContentAsString(Execution exec, java.lang.String path) throws java.io.IOException
java.io.IOException
Copyright © 2005-2023 Potix Corporation. All Rights Reserved.