Package org.zkoss.zk.device
Class GenericDevice
- java.lang.Object
-
- org.zkoss.zk.device.GenericDevice
-
- All Implemented Interfaces:
Device
- Direct Known Subclasses:
AjaxDevice
public abstract class GenericDevice extends java.lang.Object implements Device
A skeletal implementation ofDevice.- Since:
- 3.0.0
- Author:
- tomyeh
-
-
Constructor Summary
Constructors Constructor Description GenericDevice()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEmbedded(java.lang.String content)Adds the content that shall be added to the output generated and sent to the client, when rending a desktop.java.lang.StringgetDocType()Returns null to indicate not to generate <!java.lang.StringgetEmbedded()Returns the content that shall be embedded to the output being generated to the client, or null if no embedded content.java.lang.ClassgetServerPushClass()Returns the class that implements the server-push feature (ServerPush) for this device, or null if the default is used.java.lang.StringgetType()Returns the device type.java.lang.StringgetUnavailableMessage()Returns the unavailable message that is shown to the client if the client doesn't support this device.voidinit(java.lang.String type, DeviceConfig config)Initializes the device.booleanisCacheable()Return true to indicate it is cacheable.java.lang.BooleanisCompatible(java.lang.String userAgent)Returns null to indicate unknown.booleanisSupported(int func)Returns whether the specified function is supported.java.lang.Object[]matches(java.lang.String userAgent)Returns the name and version of the client if the given user agent matches this client, or null if not matched or it is a standard browser request.java.lang.StringpackageToPath(java.lang.String pkg)Converts a package to an absolute path that can be accessible by the class loader (classpath).voidreloadMessages(java.util.Locale locale)Reloads the client-side messages in the specified locale.voidsessionDidActivate(Desktop desktop)Notification that the desktop, which owns this device, has just been activated (a.k.a., deserialized) by the Web container.voidsessionWillPassivate(Desktop desktop)Notification that the desktop, which owns this device, is about to be passivated (a.k.a., serialized) by the Web container.java.lang.ClasssetServerPushClass(java.lang.Class cls)Sets the class that implements the server-push feature (ServerPush) for this device, or null to use the default.java.lang.StringsetUnavailableMessage(java.lang.String msg)Sets the unavailable message that is shown to the client if the client doesn't support this device.java.lang.StringtoAbsolutePath(java.lang.String path)Converts a relative path to an absolute path that can be accessible by the class loader (classpath).-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.zkoss.zk.device.Device
getContentType
-
-
-
-
Method Detail
-
isSupported
public boolean isSupported(int func)
Description copied from interface:DeviceReturns whether the specified function is supported.- Specified by:
isSupportedin interfaceDevice- Parameters:
func- the function.
-
getType
public java.lang.String getType()
Description copied from interface:DeviceReturns the device type.
-
isCacheable
public boolean isCacheable()
Return true to indicate it is cacheable.- Specified by:
isCacheablein interfaceDevice
-
isCompatible
public java.lang.Boolean isCompatible(java.lang.String userAgent)
Returns null to indicate unknown. Deriving should override it to provide more precise information.- Specified by:
isCompatiblein interfaceDevice- Parameters:
userAgent- represents a client. For HTTP clients, It is the user-agent header.- Returns:
- Boolean.TRUE if this device supports the specified client, Boolean.FALSE if cannot, or null if unknown.
- See Also:
Execution.getUserAgent(),Devices.getDeviceByClient(java.lang.String)
-
getUnavailableMessage
public java.lang.String getUnavailableMessage()
Description copied from interface:DeviceReturns the unavailable message that is shown to the client if the client doesn't support this device.- Specified by:
getUnavailableMessagein interfaceDevice- Returns:
- the unavailable message, or null if no such message
-
setUnavailableMessage
public java.lang.String setUnavailableMessage(java.lang.String msg)
Description copied from interface:DeviceSets the unavailable message that is shown to the client if the client doesn't support this device.- Specified by:
setUnavailableMessagein interfaceDevice- Parameters:
msg- the unavailable message.- Returns:
- the previous unavailable message, or null if not such message
-
setServerPushClass
public java.lang.Class setServerPushClass(java.lang.Class cls)
Description copied from interface:DeviceSets the class that implements the server-push feature (ServerPush) for this device, or null to use the default.Default:
PollingServerPush.If ZK EE (with zkmax.jar) is loaded, the COMET-based server push (
CometServerPush) is the default.- Specified by:
setServerPushClassin interfaceDevice- Returns:
- the previous class, or null if not available.
-
getServerPushClass
public java.lang.Class getServerPushClass()
Description copied from interface:DeviceReturns the class that implements the server-push feature (ServerPush) for this device, or null if the default is used.- Specified by:
getServerPushClassin interfaceDevice
-
getDocType
public java.lang.String getDocType()
Returns null to indicate not to generate <!DOCTYPE> at all.- Specified by:
getDocTypein interfaceDevice
-
addEmbedded
public void addEmbedded(java.lang.String content)
Description copied from interface:DeviceAdds the content that shall be added to the output generated and sent to the client, when rending a desktop. What content can be embedded depends on the device. For Ajax devices, it can be anything that can be placed inside HTML HEAD, such as JavaScript codes.As the method name suggests, the embedded contents are accumulated and all generated to the output.
- Specified by:
addEmbeddedin interfaceDevice
-
getEmbedded
public java.lang.String getEmbedded()
Description copied from interface:DeviceReturns the content that shall be embedded to the output being generated to the client, or null if no embedded content.- Specified by:
getEmbeddedin interfaceDevice
-
matches
public java.lang.Object[] matches(java.lang.String userAgent)
Returns the name and version of the client if the given user agent matches this client, or null if not matched or it is a standard browser request.This implementation always returns null. That is, it assumes the client is a standard browser.
-
reloadMessages
public void reloadMessages(java.util.Locale locale) throws java.io.IOExceptionReloads the client-side messages in the specified locale.Default: throw UnsupportedOperationException.
- Specified by:
reloadMessagesin interfaceDevice- Parameters:
locale- the locale. If null,Locales.getCurrent()is assumed.- Throws:
java.io.IOException- Since:
- 5.0.4
-
packageToPath
public java.lang.String packageToPath(java.lang.String pkg)
Converts a package to an absolute path that can be accessible by the class loader (classpath).Default: throw UnsupportedOperationException.
- Specified by:
packageToPathin interfaceDevice- Since:
- 5.0.4
-
toAbsolutePath
public java.lang.String toAbsolutePath(java.lang.String path)
Converts a relative path to an absolute path that can be accessible by the class loader (classpath).Default: throw UnsupportedOperationException.
- Specified by:
toAbsolutePathin interfaceDevice- Parameters:
path- the path (never null). It is assumed to be a relative path if not starting with '/' or '~'.- Since:
- 5.0.4
-
init
public void init(java.lang.String type, DeviceConfig config)Description copied from interface:DeviceInitializes the device. A device is created for each desktop, and this method is called when it is associated to the desktop.
-
sessionWillPassivate
public void sessionWillPassivate(Desktop desktop)
Description copied from interface:DeviceNotification that the desktop, which owns this device, is about to be passivated (a.k.a., serialized) by the Web container.- Specified by:
sessionWillPassivatein interfaceDevice
-
sessionDidActivate
public void sessionDidActivate(Desktop desktop)
Description copied from interface:DeviceNotification that the desktop, which owns this device, has just been activated (a.k.a., deserialized) by the Web container.- Specified by:
sessionDidActivatein interfaceDevice
-
-