UDK 3.1.0 Java API Reference

com.sun.star.uno
クラス UnoRuntime

java.lang.Object
  |
  +--com.sun.star.uno.UnoRuntime

public class UnoRuntime
extends Object

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.

導入されたバージョン:
UDK1.0
関連項目:
IEnvironment, IQueryInterface, IBridge

フィールドの概要
protected static com.sun.star.lib.util.WeakTable __bridges
           
protected static com.sun.star.lib.util.WeakTable __environments
           
static boolean DEBUG
           
 
コンストラクタの概要
UnoRuntime()
           
 
メソッドの概要
static boolean areSame(Object object1, Object object2)
          Tests if the given objects are interfaces of the same underlying object.
static String generateOid(Object object)
          Generates a worldwide unique object identifier (oid) for the given object.
static IBridge getBridge(IEnvironment from, IEnvironment to, Object[] args)
          Gets a bridge from environment from to environment to.
static IBridge getBridgeByName(String from, Object from_context, String to, Object to_context, 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(String name, 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(String from, String to)
          Gets the desired mapping from from to to.
static String getUniqueKey()
          returns a world wide unique string.
static Object queryInterface(Class zInterface, Object object)
          queries the given object for the given java class (which must represent a UNO interface).
static Object queryInterface(Type type, 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.
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

DEBUG

public static final boolean DEBUG
関連項目:
定数フィールド値

__environments

protected static com.sun.star.lib.util.WeakTable __environments

__bridges

protected static com.sun.star.lib.util.WeakTable __bridges
コンストラクタの詳細

UnoRuntime

public UnoRuntime()
メソッドの詳細

getUniqueKey

public static String getUniqueKey()
returns a world wide unique string. 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.

戻り値:
a unique String

generateOid

public static String generateOid(Object object)
Generates a worldwide unique object identifier (oid) for the given object. It is guaranteed, that subsequent calls to the method with the same object will give the same id.

パラメータ:
object - the object for which a Oid should be generated.
戻り値:
the generated oid.

getCurrentContext

public static XCurrentContext getCurrentContext()
Gets the current context of current thread or null if no context has been set for the current thread. The current context is threadlocal, meaning that this method returns the current context, that was last set during this thread.

戻り値:
current context of current thread or null if no context was set.

setCurrentContext

public static void setCurrentContext(XCurrentContext context)
Sets the current context of current thread. You have to manually call setCurrentContext( null ) before terminating the current thread. The current context is threadlocal, meaning that upper callstack layers can retrieve the current context, which has been set before. Every function, that sets the current context, should reset the context to the original value when exiting (e.g. within a finally block).

パラメータ:
context - context to be set (if null, a previously set context will be removed)

queryInterface

public static Object queryInterface(Type type,
                                    Object object)
queries the given object for the given type.

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.
戻り値:
the desired interface if available, otherwise null.
関連項目:
IQueryInterface

queryInterface

public static Object queryInterface(Class zInterface,
                                    Object object)
queries the given object for the given java class (which must represent a UNO interface).

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.
戻り値:
the desired interface if available, otherwise null.
関連項目:
IQueryInterface

areSame

public static boolean areSame(Object object1,
                              Object object2)
Tests if the given objects are interfaces of the same underlying object.

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.
戻り値:
true, if the underlying object is the same, otherwise false.

getEnvironment

public static IEnvironment getEnvironment(String name,
                                          Object context)
                                   throws Exception
retrieves an environment of type 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.
Exception
関連項目:
IEnvironment

getBridge

public static IBridge getBridge(IEnvironment from,
                                IEnvironment to,
                                Object[] args)
                         throws Exception
Gets a bridge from environment 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
戻り値:
the desired bridge.
Exception
関連項目:
IEnvironment, IBridge, getBridgeByName(java.lang.String, java.lang.Object, java.lang.String, java.lang.Object, java.lang.Object[])

getBridgeByName

public static IBridge getBridgeByName(String from,
                                      Object from_context,
                                      String to,
                                      Object to_context,
                                      Object[] args)
                               throws Exception
Gets a bridge from environment 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 environment
to - the name of the target environment.
to_context - the context for the source environment
args - the initial arguments for the bridge
戻り値:
the desired bridge.
Exception
関連項目:
IEnvironment, IBridge, getBridge(com.sun.star.uno.IEnvironment, com.sun.star.uno.IEnvironment, java.lang.Object[]), getEnvironment(java.lang.String, java.lang.Object)

getBridges

public static IBridge[] getBridges()
Gives an array of all active bridges.

戻り値:
an array of IBridge objects.
関連項目:
IBridge

getMapping

public static IMapping getMapping(IEnvironment from,
                                  IEnvironment to)
                           throws Exception
Gets the desired mapping from 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.
戻り値:
the desired bridge.
Exception
関連項目:
IMapping, getMapping(com.sun.star.uno.IEnvironment, com.sun.star.uno.IEnvironment), getEnvironment(java.lang.String, java.lang.Object), IEnvironment

getMappingByName

public static IMapping getMappingByName(String from,
                                        String to)
                                 throws Exception
Gets the desired mapping from from to to. Retrieves the environments via UnoRuntime#getEnvironment.

パラメータ:
from - the name of the source environment.
to - the name of the target environment.
戻り値:
the desired bridge.
Exception
関連項目:
IMapping, getMapping(com.sun.star.uno.IEnvironment, com.sun.star.uno.IEnvironment), getEnvironment(java.lang.String, java.lang.Object)

reset

public static boolean reset()
Resets the UnoRuntime to its initial state. Releases all references to bridges and environments.

関連項目:
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)

UDK 3.1.0 Java API Reference