public class UnoRuntime
extends java.lang.Object
The methods queryInterface
and areSame
delegate
calls to the implementing objects and are used instead of casts,
instanceof
, ==
, and equals
.
For historic reasons, this class is not final
, and has a
public
constructor. These artifacts are considered mistakes,
which might be corrected in a future version of this class, so client code
should not rely on them.
IBridge
,
IEnvironment
,
IQueryInterface
Modifier and Type | Field and Description |
---|---|
static boolean |
DEBUG
Deprecated.
As of UDK 3.2.0, do not use this internal field.
|
Constructor and Description |
---|
UnoRuntime()
Deprecated.
As of UDK 3.2.0, do not create instances of this class.
It is considered a historic mistake to have a
public
constructor for this class, which only has static members.
Also, this class might be changed to become final in a
future version. |
Modifier and Type | Method and Description |
---|---|
static boolean |
areSame(java.lang.Object any1,
java.lang.Object any2)
Tests two UNO
ANY values for equality. |
static java.lang.Object |
completeValue(Type type,
java.lang.Object value)
Complete a UNO value (make sure it is no invalid
null
value). |
static java.lang.String |
generateOid(java.lang.Object object)
Generates a world wide unique object identifier (OID) for the given
Java object.
|
static IBridge |
getBridge(IEnvironment from,
IEnvironment to,
java.lang.Object[] args)
Deprecated.
As of UDK 3.2.0, this method is deprecated, without
offering a replacement.
|
static IBridge |
getBridgeByName(java.lang.String from,
java.lang.Object fromContext,
java.lang.String to,
java.lang.Object toContext,
java.lang.Object[] args)
Deprecated.
As of UDK 3.2.0, this method is deprecated, without
offering a replacement.
|
static IBridge[] |
getBridges()
Deprecated.
As of UDK 3.2.0, this method is deprecated, without
offering a replacement.
|
static XCurrentContext |
getCurrentContext()
Gets the current context of the current thread, or
null if
no context has been set for the current thread. |
static IEnvironment |
getEnvironment(java.lang.String name,
java.lang.Object context)
Deprecated.
As of UDK 3.2.0, this method is deprecated, without
offering a replacement.
|
static IMapping |
getMapping(IEnvironment from,
IEnvironment to)
Deprecated.
As of UDK 3.2.0, this method is deprecated, without
offering a replacement.
|
static IMapping |
getMappingByName(java.lang.String from,
java.lang.String to)
Deprecated.
As of UDK 3.2.0, this method is deprecated, without
offering a replacement.
|
static java.lang.String |
getUniqueKey()
Generates a world wide unique identifier string.
|
static <T> T |
queryInterface(java.lang.Class<T> zInterface,
java.lang.Object object)
Queries the given UNO object for the given Java class (which must
represent a UNO interface type).
|
static java.lang.Object |
queryInterface(Type type,
java.lang.Object object)
Queries the given UNO object for the given UNO interface type.
|
static boolean |
reset()
Deprecated.
As of UDK 3.2.0, this method is deprecated, without
offering a replacement.
|
static void |
setCurrentContext(XCurrentContext context)
Sets the current context for the current thread.
|
public static final boolean DEBUG
public UnoRuntime()
public
constructor for this class, which only has static
members.
Also, this class might be changed to become final
in a
future version.public static java.lang.String getUniqueKey()
It is guaranteed that every invocation of this method generates a new ID, which is unique within the VM. The quality of “world wide unique” will depend on the actual implementation, you should look at the source to determine if it meets your requirements.
String
public static java.lang.String generateOid(java.lang.Object object)
It is guaranteed that subsequent calls to this method with the same Java object will give the same ID.
This method is generally of little use for client code. It should be considered a mistake that this method is published at all.
object
- any object for which a OID shall be generated; must not be
null
IQueryInterface.getOid()
public static java.lang.Object queryInterface(Type type, java.lang.Object object)
This method returns null
in case the given UNO object
does not support the given UNO interface type (or is itself
null
). Otherwise, a reference to a Java object implementing
the Java interface type corresponding to the given UNO interface is
returned. In the latter case, it is unspecified whether the returned
Java object is the same as the given object, or is another facet of that
UNO object.
type
- the requested UNO interface type; must be a Type
object representing a UNO interface typeobject
- a reference to any Java object representing (a facet of) a
UNO object; may be null
null
IQueryInterface.queryInterface(com.sun.star.uno.Type)
public static <T> T queryInterface(java.lang.Class<T> zInterface, java.lang.Object object)
zInterface
- a Java class representing a UNO interface typeobject
- a reference to any Java object representing (a facet of) a
UNO object; may be null
null
queryInterface(Type, Object)
public static boolean areSame(java.lang.Object any1, java.lang.Object any2)
ANY
values for equality.
Two UNO values are equal if and only if they are of the same UNO type t, and they meet the following condition, depending on t:
any1
- a Java value representing a UNO ANY
value.any2
- a Java value representing a UNO ANY
value.true
if and only if the two arguments represent
equal UNO values.public static final java.lang.Object completeValue(Type type, java.lang.Object value)
null
value).
This is useful for members of parameterized type of instantiated
polymorphic struct types, as null
is a valid value there
(and only there, for all types except ANY
and interface
types).
type
- a non-void, non-exception UNO type.value
- a Java value representing a UNO value of the given UNO type,
or null
.null
value.public static XCurrentContext getCurrentContext()
null
if
no context has been set for the current thread.
The current context is thread local, which means that this method returns the context that was last set for this thread.
null
if no context has been set for the current threadpublic static void setCurrentContext(XCurrentContext context)
The current context is thread local. To support a stacking behaviour,
every function that sets the current context should reset it to the
original value when exiting (for example, within a finally
block).
context
- the context to be set; if null
, any
previously set context will be removedpublic static IEnvironment getEnvironment(java.lang.String name, java.lang.Object context) throws java.lang.Exception
name
with context
context
.
Environments are held weakly by this class. If the requested
environment already exists, this methods simply returns it. Otherwise,
this method looks for it under
com.sun.star.lib.uno.environments.name.name_environment
.
name
- the name of the environmentcontext
- the context of the environmentjava.lang.Exception
IEnvironment
public static IBridge getBridge(IEnvironment from, IEnvironment to, java.lang.Object[] args) throws java.lang.Exception
from
to environment
to
.
Creates a new bridge, if the requested bridge does not yet exist, and hands the arguments to the bridge.
If the requested bridge does not exist, it is searched for in package
com.sun.star.lib.uno.bridges.from_to;
and the root classpath as
from_to_bridge
.
from
- the source environmentto
- the target environmentargs
- the initial arguments for the bridgejava.lang.Exception
getBridgeByName(java.lang.String, java.lang.Object, java.lang.String, java.lang.Object, java.lang.Object[])
,
IBridge
,
IEnvironment
public static IBridge getBridgeByName(java.lang.String from, java.lang.Object fromContext, java.lang.String to, java.lang.Object toContext, java.lang.Object[] args) throws java.lang.Exception
from
to environment
to
.
Creates a new bridge, if the requested bridge does not yet exist, and hands the arguments to the bridge.
If the requested bridge does not exist, it is searched for in package
com.sun.star.lib.uno.bridges.from_to;
and the root classpath as
from_to_bridge
. The used environments
are retrieved through getEnvironment
.
from
- the name of the source environmentfromContext
- the context for the source environmentto
- the name of the target environmenttoContext
- the context for the target environmentargs
- the initial arguments for the bridgejava.lang.Exception
getBridge(com.sun.star.uno.IEnvironment, com.sun.star.uno.IEnvironment, java.lang.Object[])
,
getEnvironment(java.lang.String, java.lang.Object)
,
IBridge
,
IEnvironment
public static IBridge[] getBridges()
IBridge
objectsIBridge
public static IMapping getMapping(IEnvironment from, IEnvironment to) throws java.lang.Exception
from
to environment
to
.
Mappings are like bridges, except that with mappings one can only map in one direction. Mappings are here for compatibility with the binary UNO API. Mappings are implemented as wrappers around bridges.
from
- the source environmentto
- the target environmentjava.lang.Exception
IEnvironment
,
IMapping
public static IMapping getMappingByName(java.lang.String from, java.lang.String to) throws java.lang.Exception
from
to environment
to
.
The used environments are retrieved through
getEnvironment
.
from
- the name of the source environmentto
- the name of the target environmentjava.lang.Exception
getEnvironment(java.lang.String, java.lang.Object)
,
getMapping(com.sun.star.uno.IEnvironment, com.sun.star.uno.IEnvironment)
,
IMapping
public static boolean reset()
UnoRuntime
to its initial state.
Releases all references to bridges and environments.