|
20080913, rgf | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.oorexx.uno.RgfReflectUNO
This class allows reflecting UNO objects and types using the type descriptions and usually returns results as strings only (to facilitate interaction with scripting languages); originally devised for Open Object Rexx (cf. http://www.ooRexx.org).
------------------------ Apache Version 2.0 license ------------------------- Copyright (C) 2006-2007 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. -----------------------------------------------------------------------------
Field Summary | |
(package private) static boolean |
bDebug
Controls issuing some debug messages, if set to true . |
(package private) static com.sun.star.uno.XComponentContext |
context
|
(package private) static int |
GET_INTERFACES_AS_ARRAY
|
(package private) static int |
GET_INTERFACES_AS_STRING
|
(package private) static int |
GET_SERVICES_AS_ARRAY
|
(package private) static int |
GET_SERVICES_AS_STRING
|
(package private) static java.util.Hashtable |
ht
|
(package private) static java.util.Hashtable |
ht2j
|
(package private) static java.util.Hashtable |
ht2j_prop
|
(package private) static boolean |
isContextAvailable
|
(package private) static java.util.Hashtable |
pa
|
(package private) static int |
QUERY_INTERFACE_NAME
|
(package private) static int |
QUERY_INTERFACE_OBJECT_BY_NAME
Analyzes all implemented services and processes found interfaces or services. |
(package private) static int |
SERVICE_NUMBERING
|
(package private) static com.sun.star.reflection.XIdlReflection |
theCoreReflection
|
(package private) static com.sun.star.lang.XMultiComponentFactory |
theServiceManager
|
(package private) static com.sun.star.container.XHierarchicalNameAccess |
theTypeDescriptionManager
|
(package private) static int |
USE_VECTOR
|
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. |
(package private) static com.sun.star.lang.XMultiComponentFactory |
xmcf
|
Method Summary | |
(package private) static java.lang.String |
check4reflection(java.lang.String name)
2005-12-20: turns out that OOo 2.0 and 1.5 have the module name "com.sun.star.text.TextField. |
(package private) static boolean |
compareRelaxed(java.lang.String endName,
java.lang.String haystack)
Compares two strings in a "relaxed" manner, i.e. |
(package private) static java.lang.Object[] |
determineTypeClass(java.lang.Object o)
Determines the XIdlClass/XTypeDescription and TypeClass of the supplied UNO object/UNOIDL string. |
(package private) static void |
encode4InterfaceXIMTD(java.lang.StringBuffer sb,
com.sun.star.reflection.XInterfaceMemberTypeDescription ximtd,
char delimiter)
|
(package private) static java.lang.Object |
extendSearch(java.lang.Object o,
java.lang.String needle,
int kind)
|
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 . |
(package private) static java.lang.Object |
fIWM_worker(java.lang.Object o,
java.lang.String needle,
java.lang.String interfaceName,
boolean bReturnString,
java.lang.StringBuffer sb,
int countFound,
int howMany)
|
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. |
(package private) static java.lang.String |
getUnqualifiedName(java.lang.String s)
Returns unqualified name (string after the last dot) from dotted string or string itself, if no dot in string. |
(package private) static com.sun.star.reflection.XTypeDescription |
getXTypeDescription(com.sun.star.reflection.XIdlClass xic)
Returns a XTypeDescription object representing the received XIdlClass object. |
static java.lang.String |
getXTypeProviderTypeNames(java.lang.Object o)
Returns a blank delimited string of names of the provided interface types. |
(package private) static java.lang.String |
pp(java.lang.Object o)
Convenience method, returns argument enclosed in angle brackets, allows null as well. |
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. |
(package private) static void |
say(java.lang.String s)
Convenience method, will print received string to System.err . |
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. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static java.lang.String version
static boolean bDebug
true
. Default value:
false
.
static com.sun.star.uno.XComponentContext context
static boolean isContextAvailable
static com.sun.star.lang.XMultiComponentFactory xmcf
static com.sun.star.reflection.XIdlReflection theCoreReflection
static com.sun.star.lang.XMultiComponentFactory theServiceManager
static com.sun.star.container.XHierarchicalNameAccess theTypeDescriptionManager
static java.util.Hashtable ht
static java.util.Hashtable ht2j
static java.util.Hashtable ht2j_prop
static java.util.Hashtable pa
static final int QUERY_INTERFACE_OBJECT_BY_NAME
static final int QUERY_INTERFACE_NAME
static final int USE_VECTOR
static final int GET_INTERFACES_AS_STRING
static final int GET_INTERFACES_AS_ARRAY
static final int SERVICE_NUMBERING
static final int GET_SERVICES_AS_STRING
static final int GET_SERVICES_AS_ARRAY
Method Detail |
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()".
static java.lang.Object[] determineTypeClass(java.lang.Object o)
o
- UNO object or String fully qualifying the module name
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 definition
public 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 module
static com.sun.star.reflection.XTypeDescription getXTypeDescription(com.sun.star.reflection.XIdlClass xic)
xic
- an XIdlClass object.
static void encode4InterfaceXIMTD(java.lang.StringBuffer sb, com.sun.star.reflection.XInterfaceMemberTypeDescription ximtd, char delimiter)
public 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 interface
public 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 analyze
public static java.lang.String getServiceNamesViaReflection(java.lang.Object o)
o
- service object to analyze
static java.lang.Object extendSearch(java.lang.Object o, java.lang.String needle, int kind)
public 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 object
property-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 parameterstatic java.lang.Object fIWM_worker(java.lang.Object o, java.lang.String needle, java.lang.String interfaceName, boolean bReturnString, java.lang.StringBuffer sb, int countFound, int howMany)
public 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
static boolean compareRelaxed(java.lang.String endName, java.lang.String haystack)
haystack
ends with the first argument endName
string.
endName
- the string which should end haystack
haystack
- the string to test endName
against
true
, if haystack
ends with the
string endName
(comparison carried out case-insensitively),
false
elsestatic void say(java.lang.String s)
System.err
.
static java.lang.String pp(java.lang.Object o)
null
as well.
static java.lang.String getUnqualifiedName(java.lang.String s)
s
- String to extract unqualified name
static java.lang.String check4reflection(java.lang.String name)
"com.sun.star.text.TextField."
spelled wrongly, ".TextField"
should be spelled in lowercase: ".textfield."
.
|
20080913, rgf | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |