Top Description Inners Fields Constructors Methods
com.sun.star.uno

public Class UnoRuntime

extends Object
Class Inheritance
Imports
java.io.IOException, java.lang.reflect.Array, .Constructor, java.util.ArrayList, .Iterator, .UUID, .WeakHashMap, com.sun.star.lib.uno.typedesc.FieldDescription, .TypeDescription, com.sun.star.lib.util.WeakMap

The central class needed for implementing or using UNO components in Java.

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.

See Also
com.sun.star.uno.IBridge, com.sun.star.uno.IEnvironment, com.sun.star.uno.IQueryInterface

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
UnoRuntime.BridgeTurner

References Deprecated IBridge is deprecated or references (maybe indirectly) at least one deprecated element.
private static class
UnoRuntime.MappingWrapper

References Deprecated IMapping is deprecated or references (maybe indirectly) at least one deprecated element.

Field Summary

Modifier and TypeField and Description
private static final WeakMap<String, IBridge>
private static final ThreadLocal<com.sun.star.uno.XCurrentContext>
public static final boolean
DEBUG

Deprecated As of UDK 3.2.0, do not use this internal field.
private static final WeakMap<String, IEnvironment>
private static final WeakHashMap<Object, String>
private static final String
private static long
private static final String
private static final Object
private static long

Constructor Summary

AccessConstructor and Description
public
UnoRuntime()
Deprecated As of UDK 3.2.0, do not create instances of this class.

Method Summary

Modifier and TypeMethod and Description
public static boolean

Returns:

true if and only if the two arguments represent equal UNO values.
areSame
(Object
a Java value representing a UNO ANY value.
any1
,
Object
a Java value representing a UNO ANY value.
any2
)

Tests two UNO ANY values for equality.

public static final Object

Returns:

the given value, or the neutral value of the given type, if the given value was an invalid null value.
completeValue
(Type
a non-void, non-exception UNO type.
type
,
Object
a Java value representing a UNO value of the given UNO type, or null.
value
)

Complete a UNO value (make sure it is no invalid null value).

public static String

Returns:

the generated OID
generateOid
(Object
any object for which an OID shall be generated; must not be null
object
)

Generates a worldwide unique object identifier (OID) for the given Java object.

public static IBridge

Returns:

the requested bridge
getBridge
(IEnvironment
the source environment
from
,
IEnvironment
the target environment
to
,
Object[]
the initial arguments for the bridge
args
)
Deprecated As of UDK 3.2.0, this method is deprecated, without offering a replacement.

Gets a bridge from environment from to environment to.

public static IBridge

Returns:

the requested bridge
getBridgeByName
(String
the name of the source environment
from
,
Object
the context for the source environment
fromContext
,
String
the name of the target environment
to
,
Object
the context for the target environment
toContext
,
Object[]
the initial arguments for the bridge
args
)
Deprecated As of UDK 3.2.0, this method is deprecated, without offering a replacement.

Gets a bridge from environment from to environment to.

public static IBridge[]

Returns:

an array of IBridge objects
getBridges
()
Deprecated As of UDK 3.2.0, this method is deprecated, without offering a replacement.

Returns an array of all active bridges.

public static com.sun.star.uno.XCurrentContext

Returns:

the current context of the current thread, or null if no context has been set for the current thread
getCurrentContext
()

Gets the current context of the current thread, or null if no context has been set for the current thread.

public static IEnvironment

Returns:

an environment.
getEnvironment
(String
the name of the environment
name
,
Object
the context of the environment
context
)
Deprecated As of UDK 3.2.0, this method is deprecated, without offering a replacement.

Retrieves an environment of type name with context context.

public static IMapping

Returns:

the requested mapping
getMapping
(IEnvironment
the source environment
from
,
IEnvironment
the target environment
to
)
Deprecated As of UDK 3.2.0, this method is deprecated, without offering a replacement.

Gets a mapping from environment from to environment to.

public static IMapping

Returns:

the requested mapping
getMappingByName
(String
the name of the source environment
from
,
String
the name of the target environment
to
)
Deprecated As of UDK 3.2.0, this method is deprecated, without offering a replacement.

Gets a mapping from environment from to environment to.

public static String

Returns:

a unique String
getUniqueKey
()

Generates a worldwide unique identifier string.

public static Object

Returns:

a reference to the requested UNO interface type if available, otherwise null
queryInterface
(Type
the requested UNO interface type; must be a Type object representing a UNO interface type
type
,
Object
a reference to any Java object representing (a facet of) a UNO object; may be null
object
)

Queries the given UNO object for the given UNO interface type.

public static <
the requested UNO interface type.
T
>
T

Returns:

a reference to the requested UNO interface type if available, otherwise null
queryInterface
(Class<T>
a Java class representing a UNO interface type
zInterface
,
Object
a reference to any Java object representing (a facet of) a UNO object; may be null
object
)

Queries the given UNO object for the given Java class (which must represent a UNO interface type).

public static boolean

Returns:

true if another thread didn't re-insert some bridge or environment before the method returns. Why that information would be useful is anybody's guess.
reset
()
Deprecated As of UDK 3.2.0, this method is deprecated, without offering a replacement.

Resets this UnoRuntime to its initial state.

public static void
setCurrentContext(com.sun.star.uno.XCurrentContext
the context to be set; if null, any previously set context will be removed
context
)

Sets the current context for the current thread.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bridgesback to summary
private static final WeakMap<String, IBridge> bridges
currentContextback to summary
private static final ThreadLocal<com.sun.star.uno.XCurrentContext> currentContext
DEBUGback to summary
public static final boolean DEBUG

Deprecated

As of UDK 3.2.0, do not use this internal field.

Annotations
@Deprecated
environmentsback to summary
private static final WeakMap<String, IEnvironment> environments
oidMapback to summary
private static final WeakHashMap<Object, String> oidMap
oidSuffixback to summary
private static final String oidSuffix
uniqueKeyCountback to summary
private static long uniqueKeyCount
uniqueKeyHostPrefixback to summary
private static final String uniqueKeyHostPrefix
uniqueKeyLockback to summary
private static final Object uniqueKeyLock
uniqueKeyTimeback to summary
private static long uniqueKeyTime

Constructor Detail

UnoRuntimeback to summary
public 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.

Annotations
@Deprecated

Method Detail

areSameback to summary
public static boolean areSame(Object any1, Object any2)

Tests two UNO 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:

  • If t is a primitive type, then both values must denote the same element of the set of values of t.
  • If t is a structured type, then both values must recursively contain corresponding values that are equal.
  • If t is an interface type, then the two values must be either both null references, or both references to the same UNO object.
Parameters
any1:Object

a Java value representing a UNO ANY value.

any2:Object

a Java value representing a UNO ANY value.

Returns:boolean

true if and only if the two arguments represent equal UNO values.

completeValueback to summary
public static final Object completeValue(Type type, Object value)

Complete a UNO value (make sure it is no invalid 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).

Parameters
type:Type

a non-void, non-exception UNO type.

value:Object

a Java value representing a UNO value of the given UNO type, or null.

Returns:Object

the given value, or the neutral value of the given type, if the given value was an invalid null value.

Since
UDK 3.2.3
generateOidback to summary
public static String generateOid(Object object)

Generates a worldwide unique object identifier (OID) for the given Java 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.

Parameters
object:Object

any object for which an OID shall be generated; must not be null

Returns:String

the generated OID

See Also
com.sun.star.uno.IQueryInterface#getOid
getBridgeback to summary
public static IBridge getBridge(IEnvironment from, IEnvironment to, Object[] args) throws Exception

Deprecated

As of UDK 3.2.0, this method is deprecated, without offering a replacement.

Gets a bridge from environment 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.

Parameters
from:IEnvironment

the source environment

to:IEnvironment

the target environment

args:Object[]

the initial arguments for the bridge

Returns:IBridge

the requested bridge

Annotations
@Deprecated
Exceptions
Exception:
if something goes awry.
See Also
getBridgeByName, com.sun.star.uno.IBridge, com.sun.star.uno.IEnvironment
getBridgeByNameback to summary
public static IBridge getBridgeByName(String from, Object fromContext, String to, Object toContext, Object[] args) throws Exception

Deprecated

As of UDK 3.2.0, this method is deprecated, without offering a replacement.

Gets a bridge from environment 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.

Parameters
from:String

the name of the source environment

fromContext:Object

the context for the source environment

to:String

the name of the target environment

toContext:Object

the context for the target environment

args:Object[]

the initial arguments for the bridge

Returns:IBridge

the requested bridge

Annotations
@Deprecated
Exceptions
Exception:
if something goes awry.
See Also
getBridge, getEnvironment, com.sun.star.uno.IBridge, com.sun.star.uno.IEnvironment
getBridgesback to summary
public static IBridge[] getBridges()

Deprecated

As of UDK 3.2.0, this method is deprecated, without offering a replacement.

Returns an array of all active bridges.

Returns:IBridge[]

an array of IBridge objects

Annotations
@Deprecated
See Also
com.sun.star.uno.IBridge
getCurrentContextback to summary
public static com.sun.star.uno.XCurrentContext getCurrentContext()

Gets the current context of the current thread, or 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.

Returns:com.sun.star.uno.XCurrentContext

the current context of the current thread, or null if no context has been set for the current thread

getEnvironmentback to summary
public static IEnvironment getEnvironment(String name, Object context) throws Exception

Deprecated

As of UDK 3.2.0, this method is deprecated, without offering a replacement.

Retrieves an environment of type 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.

Parameters
name:String

the name of the environment

context:Object

the context of the environment

Returns:IEnvironment

an environment.

Annotations
@Deprecated
Exceptions
Exception:
if something goes awry.
See Also
com.sun.star.uno.IEnvironment
getMappingback to summary
public static IMapping getMapping(IEnvironment from, IEnvironment to) throws Exception

Deprecated

As of UDK 3.2.0, this method is deprecated, without offering a replacement.

Gets a mapping from environment 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.

Parameters
from:IEnvironment

the source environment

to:IEnvironment

the target environment

Returns:IMapping

the requested mapping

Annotations
@Deprecated
Exceptions
Exception:
if something goes awry.
See Also
com.sun.star.uno.IEnvironment, com.sun.star.uno.IMapping
getMappingByNameback to summary
public static IMapping getMappingByName(String from, String to) throws Exception

Deprecated

As of UDK 3.2.0, this method is deprecated, without offering a replacement.

Gets a mapping from environment from to environment to.

The used environments are retrieved through getEnvironment.

Parameters
from:String

the name of the source environment

to:String

the name of the target environment

Returns:IMapping

the requested mapping

Annotations
@Deprecated
Exceptions
Exception:
if something goes awry.
See Also
getEnvironment, getMapping, com.sun.star.uno.IMapping
getUniqueKeyback to summary
public static String getUniqueKey()

Generates a worldwide unique identifier string.

It is guaranteed that every invocation of this method generates a new ID, which is unique within the VM. The quality of “worldwide unique” will depend on the actual implementation, you should look at the source to determine if it meets your requirements.

Returns:String

a unique String

queryInterfaceback to summary
public static Object queryInterface(Type type, Object object)

Queries the given UNO object for the given UNO interface type.

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.

Parameters
type:Type

the requested UNO interface type; must be a Type object representing a UNO interface type

object:Object

a reference to any Java object representing (a facet of) a UNO object; may be null

Returns:Object

a reference to the requested UNO interface type if available, otherwise null

See Also
com.sun.star.uno.IQueryInterface#queryInterface
queryInterfaceback to summary
public static <T> T queryInterface(Class<T> zInterface, Object object)

Queries the given UNO object for the given Java class (which must represent a UNO interface type).

Parameters
<T>
the requested UNO interface type.
zInterface:Class<T>

a Java class representing a UNO interface type

object:Object

a reference to any Java object representing (a facet of) a UNO object; may be null

Returns:T

a reference to the requested UNO interface type if available, otherwise null

Annotations
@SuppressWarnings:unchecked
See Also
queryInterface(Type, Object)
resetback to summary
public static boolean reset()

Deprecated

As of UDK 3.2.0, this method is deprecated, without offering a replacement.

Resets this UnoRuntime to its initial state.

Releases all references to bridges and environments.

Returns:boolean

true if another thread didn't re-insert some bridge or environment before the method returns. Why that information would be useful is anybody's guess.

Annotations
@Deprecated
setCurrentContextback to summary
public static void setCurrentContext(com.sun.star.uno.XCurrentContext context)

Sets the current context for the current thread.

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).

Parameters
context:com.sun.star.uno.XCurrentContext

the context to be set; if null, any previously set context will be removed

com.sun.star.uno back to summary

private final Class UnoRuntime.BridgeTurner

extends Object
implements IBridge
Class Inheritance
All Implemented Interfaces
com.sun.star.uno.IBridge

References Deprecated

IBridge is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Field Summary

Modifier and TypeField and Description
private final IBridge
bridge

References Deprecated IBridge is deprecated or references (maybe indirectly) at least one deprecated element.

Constructor Summary

AccessConstructor and Description
public
BridgeTurner(IBridge bridge)
References Deprecated IBridge is deprecated or references (maybe indirectly) at least one deprecated element.

Method Summary

Modifier and TypeMethod and Description
public void
acquire()

Implements com.sun.star.uno.IBridge.acquire.

Increases the life count.

public void
dispose()

Implements com.sun.star.uno.IBridge.dispose.

Disposes the bridge.

public IEnvironment
getSourceEnvironment()

Implements com.sun.star.uno.IBridge.getSourceEnvironment.

References Deprecated IEnvironment is deprecated or references (maybe indirectly) at least one deprecated element.

Returns the source environment.

public IEnvironment
getTargetEnvironment()

Implements com.sun.star.uno.IBridge.getTargetEnvironment.

References Deprecated IEnvironment is deprecated or references (maybe indirectly) at least one deprecated element.

Returns the destination environment.

public Object
mapInterfaceFrom(Object object, Type type)

Implements com.sun.star.uno.IBridge.mapInterfaceFrom.

Maps an object from the destination environment to the source environment.

public Object
mapInterfaceTo(Object object, Type type)

Implements com.sun.star.uno.IBridge.mapInterfaceTo.

Maps an object from the source environment to the destination environment.

public void
release()

Implements com.sun.star.uno.IBridge.release.

Decreases the life count.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bridgeback to summary
private final IBridge bridge

References Deprecated

IBridge is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Constructor Detail

BridgeTurnerback to summary
public BridgeTurner(IBridge bridge)

References Deprecated

IBridge is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Method Detail

acquireback to summary
public void acquire()

Implements com.sun.star.uno.IBridge.acquire.

Doc from com.sun.star.uno.IBridge.acquire.

Increases the life count.

disposeback to summary
public void dispose() throws InterruptedException, IOException

Implements com.sun.star.uno.IBridge.dispose.

Doc from com.sun.star.uno.IBridge.dispose.

Disposes the bridge.

Sends involved threads an InterruptedException. Releases mapped objects.

Exceptions
InterruptedException:
it's deprecated so who cares.
IOException:
it's deprecated so who cares.
getSourceEnvironmentback to summary
public IEnvironment getSourceEnvironment()

Implements com.sun.star.uno.IBridge.getSourceEnvironment.

Doc from com.sun.star.uno.IBridge.getSourceEnvironment.

References Deprecated

IEnvironment is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Returns the source environment.

getTargetEnvironmentback to summary
public IEnvironment getTargetEnvironment()

Implements com.sun.star.uno.IBridge.getTargetEnvironment.

Doc from com.sun.star.uno.IBridge.getTargetEnvironment.

References Deprecated

IEnvironment is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Returns the destination environment.

mapInterfaceFromback to summary
public Object mapInterfaceFrom(Object object, Type type)

Implements com.sun.star.uno.IBridge.mapInterfaceFrom.

Doc from com.sun.star.uno.IBridge.mapInterfaceFrom.

Maps an object from the destination environment to the source environment.

mapInterfaceToback to summary
public Object mapInterfaceTo(Object object, Type type)

Implements com.sun.star.uno.IBridge.mapInterfaceTo.

Doc from com.sun.star.uno.IBridge.mapInterfaceTo.

Maps an object from the source environment to the destination environment.

releaseback to summary
public void release()

Implements com.sun.star.uno.IBridge.release.

Doc from com.sun.star.uno.IBridge.release.

Decreases the life count.

If the life count drops to zero, the bridge disposes itself.

com.sun.star.uno back to summary

private final Class UnoRuntime.MappingWrapper

extends Object
implements IMapping
Class Inheritance
All Implemented Interfaces
com.sun.star.uno.IMapping

References Deprecated

IMapping is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Field Summary

Modifier and TypeField and Description
private final IBridge
bridge

References Deprecated IBridge is deprecated or references (maybe indirectly) at least one deprecated element.

Constructor Summary

AccessConstructor and Description
public
MappingWrapper(IBridge bridge)
References Deprecated IBridge is deprecated or references (maybe indirectly) at least one deprecated element.

Method Summary

Modifier and TypeMethod and Description
public Object
mapInterface(Object object, Type type)

Implements com.sun.star.uno.IMapping.mapInterface.

Maps an interface from one environment to another.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bridgeback to summary
private final IBridge bridge

References Deprecated

IBridge is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Constructor Detail

MappingWrapperback to summary
public MappingWrapper(IBridge bridge)

References Deprecated

IBridge is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Method Detail

mapInterfaceback to summary
public Object mapInterface(Object object, Type type)

Implements com.sun.star.uno.IMapping.mapInterface.

Doc from com.sun.star.uno.IMapping.mapInterface.

Maps an interface from one environment to another.