|
UNO Java Runtime | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sun.star.uno.UnoRuntime
The UnoRuntime
class is the central class needed for
implementing or using UNO components in Java.
The Methods queryInterface
and isSame
delegate
calls to the implementing objects and are used instead of casts
and identity comparisons.
The other methods are used for managing bridges, which enable a user to map objects out to or into java.
IEnvironment
,
IQueryInterface
,
IBridge
Field Summary | |
protected static com.sun.star.lib.util.WeakTable |
__bridges
|
protected static com.sun.star.lib.util.WeakTable |
__environments
|
static boolean |
DEBUG
|
Constructor Summary | |
UnoRuntime()
|
Method Summary | |
static boolean |
areSame(java.lang.Object object1,
java.lang.Object object2)
Tests if the given objects are interfaces of the same underlying object. |
static java.lang.String |
generateOid(java.lang.Object object)
Generates a worldwide unique object identifier (oid) for the given object. |
static IBridge |
getBridge(IEnvironment from,
IEnvironment to,
java.lang.Object[] args)
Gets a bridge from environment from to environment to . |
static IBridge |
getBridgeByName(java.lang.String from,
java.lang.Object from_context,
java.lang.String to,
java.lang.Object to_context,
java.lang.Object[] args)
Gets a bridge from environment from to environment to . |
static IBridge[] |
getBridges()
Gives an array of all active bridges. |
static XCurrentContext |
getCurrentContext()
Gets the current context of 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)
retrieves an environment of type name with context context . |
static IMapping |
getMapping(IEnvironment from,
IEnvironment to)
Gets the desired mapping from from to to . |
static IMapping |
getMappingByName(java.lang.String from,
java.lang.String to)
Gets the desired mapping from from to to . |
static java.lang.String |
getUniqueKey()
returns a world wide unique string. |
static java.lang.Object |
queryInterface(java.lang.Class zInterface,
java.lang.Object object)
queries the given object for the given java class (which must represent a UNO interface). |
static java.lang.Object |
queryInterface(Type type,
java.lang.Object object)
queries the given object for the given type. |
static boolean |
reset()
Resets the UnoRuntime to its initial state. |
static void |
setCurrentContext(XCurrentContext context)
Sets the current context of current thread. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final boolean DEBUG
protected static com.sun.star.lib.util.WeakTable __environments
protected static com.sun.star.lib.util.WeakTable __bridges
Constructor Detail |
public UnoRuntime()
Method Detail |
public static java.lang.String getUniqueKey()
public static java.lang.String generateOid(java.lang.Object object)
object
- the object for which a Oid should be generated.
public static XCurrentContext getCurrentContext()
public static void setCurrentContext(XCurrentContext context)
context
- context to be set (if null, a previously set context will be removed)public static java.lang.Object queryInterface(Type type, java.lang.Object object)
It returns null in case the object doesn't support this interface,
othewise a reference to the desired interface.
If the given object already implements the desired interface,
it is passed back immediatly. Otherwise it is checked if the given
object implments the delegator interface IQueryInterface
and
the request is delegated to queryInterface
of IQueryInterface
.
type
- the class of the desired interface.object
- the object to ask for it.
IQueryInterface
public static java.lang.Object queryInterface(java.lang.Class zInterface, java.lang.Object object)
It returns null in case the object doesn't support this interface,
othewise a reference to the desired interface.
If the given object already implements the desired interface,
it is passed back immediatly. Otherwise it is checked if the given
object implments the delegator interface IQueryInterface
and
the request is delegated to queryInterface
of IQueryInterface
.
zInterface
- the class of the desired interface.object
- the object to ask for it.
IQueryInterface
public static boolean areSame(java.lang.Object object1, java.lang.Object object2)
For UNO objects, it is not suffient to check object identity with a simple ==, because there may be multiple proxies for the same object (in general implementing different interfaces.
object1
- an object representing an interface.object2
- an object representing an interface.
public static IEnvironment getEnvironment(java.lang.String name, java.lang.Object context) throws java.lang.Exception
name
with context context
.
Environments are hold weak at the UnoRuntime. If the desired environment already
exists, this methods gives it back.
If the desired environement does not exist, this method looks for it under
com.sun.star.lib.uno.environments.<name>.<name>_environment
.
name
- the name of the environment.context
- the context of the environment.
java.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 desired bridge does not exist yet and handles the arguments
to the bridge.
If the desired bridge does not exist, is it searched in com.sun.star.lib.uno.bridges.<from>_<to>.<
and the root classpath as from>_<to>_bridge
.
from
- the source environment.to
- the target environment.args
- the initial arguments for the bridge
java.lang.Exception
IEnvironment
,
IBridge
,
getBridgeByName(java.lang.String, java.lang.Object, java.lang.String, java.lang.Object, java.lang.Object[])
public static IBridge getBridgeByName(java.lang.String from, java.lang.Object from_context, java.lang.String to, java.lang.Object to_context, java.lang.Object[] args) throws java.lang.Exception
from
to environment to
.
Creates a new bridge, if the desired bridge does not exist yet and handles the arguments
to the bridge.
If the desired bridge does not exist, is it searched in com.sun.star.lib.uno.bridges.<from>_<to>.<
and the root classpath as from>_<to>_bridge
.
The needed environments are retrieved through UnoRuntime#getEnvironment
.
from
- the name of the source environment.from_context
- the context for the source environmentto
- the name of the target environment.to_context
- the context for the source environmentargs
- the initial arguments for the bridge
java.lang.Exception
IEnvironment
,
IBridge
,
getBridge(com.sun.star.uno.IEnvironment, com.sun.star.uno.IEnvironment, java.lang.Object[])
,
getEnvironment(java.lang.String, java.lang.Object)
public static IBridge[] getBridges()
array
of all active bridges.
IBridge
public static IMapping getMapping(IEnvironment from, IEnvironment to) throws java.lang.Exception
from
to to
.
Mappings are like bridges, except that with mappings one can only map in one direction.
Mappings are here for api
compatibility reasons the binary UNO runtime.
Mappings are implemented as wrappers around bridges.
from
- the source environment.to
- the target environment.
java.lang.Exception
com.sun.star.uno.Mapping
,
getMapping(com.sun.star.uno.IEnvironment, com.sun.star.uno.IEnvironment)
,
getEnvironment(java.lang.String, java.lang.Object)
,
IEnvironment
public static IMapping getMappingByName(java.lang.String from, java.lang.String to) throws java.lang.Exception
from
to to
.
Retrieves the environments via UnoRuntime#getEnvironment
.
from
- the name of the source environment.to
- the name of the target environment.
java.lang.Exception
com.sun.star.uno.Mapping
,
getMapping(com.sun.star.uno.IEnvironment, com.sun.star.uno.IEnvironment)
,
getEnvironment(java.lang.String, java.lang.Object)
public static boolean reset()
getBridge(com.sun.star.uno.IEnvironment, com.sun.star.uno.IEnvironment, java.lang.Object[])
,
getBridgeByName(java.lang.String, java.lang.Object, java.lang.String, java.lang.Object, java.lang.Object[])
,
getEnvironment(java.lang.String, java.lang.Object)
,
getMapping(com.sun.star.uno.IEnvironment, com.sun.star.uno.IEnvironment)
,
getMappingByName(java.lang.String, java.lang.String)
|
UNO Java Runtime | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |