public class RgfReflectUNO
extends java.lang.Object
------------------------ Apache Version 2.0 license ------------------------- Copyright (C) 2006-2011 Rony G. Flatscher Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -----------------------------------------------------------------------------
Modifier and Type | Field and Description |
---|---|
static boolean |
bDebug
Controls issuing some debug messages, if set to
true . |
static java.lang.String |
version
Version string indicating version of this class (majorVersion*100+minorVersion
concatenated with a dot and the sorted date of last change.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.Object |
findInterfaceWithMember(java.lang.Object o,
java.lang.String needle,
boolean bReturnString,
int howMany,
boolean bExtendSearch)
Looks for the interface in a service object (
o ) containing a member
(a method or attribute) of the given name . |
static com.sun.star.uno.XComponentContext |
getContext()
Returns the value of the current XComponentObject in use, or null, if not set yet.
|
static java.lang.String |
getDefinition(java.lang.Object o)
Returns a blank delimited string containing the UNOIDL definitions of
an UNO object (or a string denoting the fully qualified UNOIDL name).
|
static java.lang.String |
getInterfaceNamesViaReflection(java.lang.Object o)
Returns a blank delimited String of the interface names that are defined in UNOIDL
for the service object.
|
static java.lang.String |
getProperties(java.lang.Object o)
Creates and returns a blank delimited string of property definitions available for the
service object
o . |
static java.lang.String |
getServiceNamesViaReflection(java.lang.Object o)
Returns a blank delimited String of service names that are defined in UNOIDL
for the service object.
|
static java.lang.String |
getTypeName(java.lang.Object o)
Returns string indicating the type of the supplied UNO object.
|
static java.lang.String |
getXTypeProviderTypeNames(java.lang.Object o)
Returns a blank delimited string of names of the provided interface types.
|
static java.lang.String |
queryInterfaceName(java.lang.Object o,
java.lang.String name,
boolean bExtendSearch)
Looks up a (partially qualified) given interface name case-insensitively and returns the
fully-qualified mixed case interface name.
|
static java.lang.Object |
queryInterfaceObjectByName(java.lang.Object o,
java.lang.String name,
boolean bExtendSearch)
Looks up a (partially qualified) given interface name case-insensitively, carries out
the appropriate
UnoRuntime.queryInterface() and returns its result. |
static java.lang.String |
queryServiceName(java.lang.Object o,
java.lang.String name)
Looks up a (partially qualified) given service name case-insensitively and returns the
fully-qualified mixed case service name.
|
static com.sun.star.uno.XComponentContext |
setContext(com.sun.star.uno.XComponentContext ctxt)
Sets the component context and gets singletons and type descriptions from it.
|
public static java.lang.String version
public static boolean bDebug
true
. Default value:
false
.public static com.sun.star.uno.XComponentContext getContext()
null
, if not set.public static com.sun.star.uno.XComponentContext setContext(com.sun.star.uno.XComponentContext ctxt)
"setUpPropertyAttributesHashTable()"
.)ctxt
- component context object to be used for this class, if null
, then
a default component context is created using "com.sun.star.comp.helper.Bootstrap.bootstrap()".public static java.lang.String getTypeName(java.lang.Object o)
getDefinition(Object o)
("…strings representing UNO-Types…").o
- UNO object or fully qualified string referring to an UNOIDL definitionpublic static java.lang.String getDefinition(java.lang.Object o)
TypeClass | Encoding |
---|---|
UNO_CONSTANTS |
UNO_CONSTANTS|fully-qualified-name|datatype member-name|value…
"datatype" s are allowed for constants:
|
UNO_ENUM |
UNO_ENUM|fully-qualified-name|default-value member-name|value…
Remark: this is always of UNO type |
UNO_EXCEPTION |
UNO_EXCEPTION|fully-qualified-name member-name|fullDatatype…
|
UNO_INTERFACE |
UNO_INTERFACE|fully-qualified-name member-name|member-definition…
|
UNO_MODULE |
UNO_MODULE|fully-qualified-name fully-qualified-member-name|UNO-Type…
|
UNO_SERVICE |
UNO_SERVICE|fully-qualified-name|[implementationName] member-name|member-definition…
Remark: if a service object is reflected that implements more than one service definition, than the "fully-qualified-name" of that compound service is created by concatenating all service names with the plus sign (+). Each of these constituting service definitions (if available via reflection) is then used to create the entire definition of that "compound service" object in hand, documenting all defined interfaces, services and properties.
Remark ad |
UNO_SINGLETON |
UNO_SINGLETON|fully-qualified-name|[old-style-servicename]
Remark: old-style-servicename or empty string if an instance of an interface |
UNO_STRUCT |
UNO_STRUCT|fully-qualified-name member-name|fullDatatype…
|
UNO_TYPEDEF |
UNO_TYPEDEF|fully-qualified-name referenced-type|UNO-Type
|
"fullDatatype"
is encoded as follows:
fully-qualified-datatype-name:UNO-TypeClass:[referenced-type]:[UNO-TypeClass]
If a datatype is of type UNO_TYPEDEF
, then its
"referenced-type-name" is given together with its
respective UNO-TypeClass.
"UNO_ANY", "UNO_ARRAY", "UNO_BOOLEAN", "UNO_BYTE", "UNO_CHAR",
"UNO_CONSTANT", "UNO_CONSTANTS", "UNO_DOUBLE", "UNO_ENUM", "UNO_EXCEPTION",
"UNO_FLOAT", "UNO_HYPER", "UNO_INTERFACE", "UNO_INTERFACE_ATTRIBUTE"
"UNO_INTERFACE_METHOD", "UNO_LONG", "UNO_MODULE", "UNO_PROPERTY",
"UNO_SEQUENCE", "UNO_SERVICE", "UNO_SHORT", "UNO_SINGLETON",
"UNO_STRING", "UNO_STRUCT", "UNO_TYPE", "UNO_TYPEDEF",
"UNO_UNION", "UNO_UNKNOWN", "UNO_UNSIGNED_HYPER", "UNO_UNSIGNED_LONG",
"UNO_UNSIGNED_SHORT", "UNO_VOID"
.
Remark: The UNO "TypeClass
" constant names use
the respective names above, but without the lead-in string
"UNO_
" (this makes the type information from methods of this
class unambiguous).
UNO Datatype | Java Datatype |
---|---|
UNO_ANY | com.sun.star.uno.Any or java.lang.Object
|
UNO_VOID | void
|
UNO_BOOLEAN | boolean
|
UNO_BYTE (8-bit) | byte
|
UNO_CHAR (16-bit) | char
|
UNO_SHORT (16-bit) | short
|
UNO_UNSIGNED_SHORT (16-bit) | short
|
UNO_LONG (32-bit) | int
|
UNO_UNSIGNED_LONG (32-bit) | int
|
UNO_HYPER (64-bit) | long
|
UNO_UNSIGNED_HYPER (64-bit) | long
|
UNO_FLOAT | float
|
UNO_DOUBLE | double
|
o
- UNO service object or string fully qualifying a service definition in an UNOIDL modulepublic static java.lang.String getXTypeProviderTypeNames(java.lang.Object o)
com.sun.star.lang.XTypeProvider
interface which is applied to the
service object o
.o
- a service object which gets queried of its provided interface types using
the XTypeProvider interfacepublic static java.lang.Object queryInterfaceObjectByName(java.lang.Object o, java.lang.String name, boolean bExtendSearch)
UnoRuntime.queryInterface()
and returns its result.name
- which may qualify the desired interface fully or partly, case
does not matter either. If name
denotes an existing Java class, that
class is used to carry out the UnoRuntime.queryInterface(...). Otherwise an interface
class is searched at runtime using XTypeProvider
and possibly reflection.o
- is the object from which the interface should be queried frombExtendSearch
- true
: if interface cannot be found in the
XTypeProvider
list, then extend search using full
reflection; it could be the case that XTypeProvider
does not provide all available interfaces! (as of OOo 2.0, 2005-12-20)null
elsepublic static java.lang.String getInterfaceNamesViaReflection(java.lang.Object o)
o
- service object to analyzepublic static java.lang.String getServiceNamesViaReflection(java.lang.Object o)
o
- service object to analyzepublic static java.lang.String getProperties(java.lang.Object o)
o
.
To find out about all available interfaces in a service object at runtime use
getXTypeProviderTypeNames(Object o)
,
to find the interface in which a member (a method or an attribute) got defined at runtime
use findInterfaceWithMember(Object o, String needle, boolean bReturnString, int howMany, boolean bExtendSearch)
.o
- a service objectproperty-name|full-datatype-name:UNO-TypeClass:[referenced-type]:[UNTO-TypeClass]
.public static java.lang.Object findInterfaceWithMember(java.lang.Object o, java.lang.String needle, boolean bReturnString, int howMany, boolean bExtendSearch)
o
) containing a member
(a method or attribute) of the given name
. This method uses the
XTypeProvider
interface to search the available interfaces at runtime.
To find out about all properties of a
service object at runtime use getProperties(Object o)
.o
- service object to analyzeneedle
- denotes the name to look for case-independentlybReturnString
- if true
then the string encoded INTERFACE
information
(cf. getDefinition(Object o)
)
is returned having the denoted member(s), otherwise the queried
interface object is returned, which can be immediately addressed to invoke
the member method or access the member attribute.howMany
- determines how many members matching needle
should be searched
and returned. Only relevant, if bReturnString
is true
.
interfaces that contain the sought for member should
be returned. A number less than 1 indicates to return all matching
interface definitions (separated by a newline character 0x0A).bExtendSearch
- true
: if interface cannot be found in the
XTYpeProvider
list, then extend search using full
reflection; it could be the case that XTYpeProvider
does not provide all available interfaces! (as of OOo 2.0, 2005-12-20)bReturnString==true
, can be empty, if no definitions
were found) or the desired interface object (bReturnString==false
,
can be null null
) depending on the value of parameterpublic static java.lang.String queryInterfaceName(java.lang.Object o, java.lang.String name, boolean bExtendSearch)
o
- service object to analyzename
- denotes the name to look for case-independentlybExtendSearch
- true
: if interface cannot be found in the
XTYpeProvider
list, then extend search using full
reflection; it could be the case that XTYpeProvider
does not provide all available interfaces! (as of OOo 2.0, 2005-12-20)public static java.lang.String queryServiceName(java.lang.Object o, java.lang.String name)
o
- service object to analyzename
- denotes the name to look for case-independently