|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.ops4j.pax.reflector.impl.ReflectorImpl
public final class ReflectorImpl
The Reflector Implementation is capable of digging through any Java application that is added as a root object.
| Method Summary | |
|---|---|
void |
addRootObject(java.lang.String name,
java.lang.Object obj)
Adds a Root Object to the Reflector instance. |
void |
addTypeHandler(TypeHandler handler)
Adds a TypeHandler. |
java.lang.String |
append(java.lang.Object container,
java.lang.String containerpart,
java.lang.String namepart)
Appends the name to the container name. |
void |
dispose()
|
java.lang.String |
extractContainerPart(java.lang.String objectname)
Returns the container part of the objectname. |
java.lang.String |
extractNamePart(java.lang.String objectname)
Returns the Name part of the objectname. |
java.lang.String[] |
getAllRootNames()
|
java.lang.String |
getMember(java.lang.String object)
Returns the human readable form of the object instance traversed from the objectname argument. |
java.lang.Class |
getMemberClass(java.lang.Object container,
java.lang.String memberName)
Returns the Class of the member identified by the membername in the provided
container. |
java.lang.Class |
getMemberClass(java.lang.String name)
Returns the Class of the member identified by the membername argument. |
java.lang.String |
getMemberClassName(java.lang.Object container,
java.lang.String memberName)
Returns the name of the Class of the member identified by the membername in the provided
container. |
java.lang.String |
getMemberClassName(java.lang.String name)
Returns the name of the Class of the member identified by the objectname argument. |
java.lang.String[] |
getMemberNames(java.lang.Object container)
Returns all the membernames found in the object. |
java.lang.String[] |
getMemberNames(java.lang.String object)
Returns all the membernames found in the member identified by membername argument. |
java.lang.Object |
getMemberObject(java.lang.Object container,
java.lang.String memberName)
Returns the object of the member by the given membername, starting at the provided container. |
java.lang.Object |
getMemberObject(java.lang.String object)
Returns the object of the member by the given membername. |
java.lang.Object |
getRootObject(java.lang.String name)
|
java.util.Map |
getRootObjects()
|
java.util.List<TypeHandler> |
getTypeHandlers()
|
boolean |
isMemberSettable(java.lang.Object container,
java.lang.String memberName)
Checks with the member of the given membername can be set to a value. |
boolean |
isMemberSettable(java.lang.String name)
Checks with the member of the given objectname can be set to a value. |
static ReflectorImpl |
newInstance()
|
void |
removeRootObject(java.lang.String name)
Removes the root object with registered under the provided name. |
void |
removeTypeHandler(TypeHandler handler)
Removes a TypeHandler from the ReflectorProvider. |
void |
setMember(java.lang.String object,
java.lang.String value)
Assigns the value to the member identified by the membername argument. |
void |
setMemberObject(java.lang.Object container,
java.lang.String member,
java.lang.Object value)
Assigns the value to the member identified by the membername starting at the
container object. |
void |
setMemberObject(java.lang.String objectname,
java.lang.Object object)
Assigns the value to the member identified by the membername argument. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static ReflectorImpl newInstance()
public java.util.List<TypeHandler> getTypeHandlers()
public void addTypeHandler(TypeHandler handler)
ReflectorProviderTypeHandlers must be added in the priority order with the least high priority first, such as the default ObjectTypeHandler, and highly specialized type handlers last.
There is no support for adding a lower priority TypeHandler after a higher priority one.
addTypeHandler in interface ReflectorProviderhandler - The TypeHandler to be added.public void removeTypeHandler(TypeHandler handler)
ReflectorProvider
removeTypeHandler in interface ReflectorProviderhandler - The TypeHandler instance to be removed.
public void addRootObject(java.lang.String name,
java.lang.Object obj)
ReflectorServiceThe name must also be unique and no other root object may have been registered with the same name. The ReflectorService will hold on to the root objects with a hard reference, so it is imperative that objects are removed explicitly with a removeRootObject() method call.
addRootObject in interface ReflectorServicename - The name of the Root Object. The name may only contain valid Java characters, as
reported by Character.isJavaIdentifierPart(char ch).obj - The object instance to be registered at the provided name.public void removeRootObject(java.lang.String name)
ReflectorServiceIf there is no root object registered under the provided name, this method will simply return.
removeRootObject in interface ReflectorServicename - The name under which the root object was previously registered.public java.lang.Object getRootObject(java.lang.String name)
public java.util.Map getRootObjects()
public java.lang.String[] getAllRootNames()
public java.lang.String[] getMemberNames(java.lang.String object)
throws ReflectionException
ReflectorServicemembername argument.
If the membername is an empty string, all root object names are returned.
getMemberNames in interface ReflectorServiceobject - The name of the member to query for its members.
membername.
ReflectionException - If the member identified by the membername does not exist.public java.lang.String[] getMemberNames(java.lang.Object container)
ReflectorServiceobject.
getMemberNames in interface ReflectorServicecontainer - The Java instance to query for its members.
object.
public java.lang.String getMember(java.lang.String object)
throws ReflectionException
ReflectorServiceobjectname argument.
getMember in interface ReflectorServiceobject - The name of the object of interested.
ReflectionException - if the member does not exist.
public void setMember(java.lang.String object,
java.lang.String value)
throws ReflectionException
ReflectorServicevalue to the member identified by the membername argument.
setMember in interface ReflectorServiceobject - The name of the member to be assigned a value.value - The value to be assigned to the member. For primitives, the value is converted according to
normal Java rules, but additionally a fully-qualified classname can be given, in which case
the reflector will try to instantiate such class through the default constructor, and if
successful assign the instance to the member.
ReflectionException - If the value is not assignable to the member type or the member does not exist.
public java.lang.Object getMemberObject(java.lang.String object)
throws ReflectionException
ReflectorService
getMemberObject in interface ReflectorServiceobject - The name of the object to traverse to and return.
ReflectionException - if the member does not exist.
public java.lang.Object getMemberObject(java.lang.Object container,
java.lang.String memberName)
throws ReflectionException
ReflectorService
getMemberObject in interface ReflectorServicecontainer - The object which has a member of the memberName.memberName - The name of the object to traverse to and return.
ReflectionException - if the member does not exist.
public void setMemberObject(java.lang.String objectname,
java.lang.Object object)
throws ReflectionException
ReflectorServicevalue to the member identified by the membername argument.
setMemberObject in interface ReflectorServiceobjectname - The name of the member to be assigned a value.object - The value to be assigned to the member.
ReflectionException - If the value is not assignable to the member type.
public void setMemberObject(java.lang.Object container,
java.lang.String member,
java.lang.Object value)
throws ReflectionException
ReflectorServicevalue to the member identified by the membername starting at the
container object.
setMemberObject in interface ReflectorServicecontainer - The object which has a member of the memberName.member - The name of the member to be assigned a value.value - The value to be assigned to the member.
ReflectionException - If the value is not assignable to the member type.public java.lang.String extractContainerPart(java.lang.String objectname)
ReflectorServiceThis method must correctly return the container part of the full objectname. For instance; getContainerPart( "someRoot.Abc.Def" ), must return "someRoot.Abc", getContainerPart( "someRoot.Abc['Def']" ), must return "someRoot.Abc", and getContainerPart( "someRoot.Abc['Def'].Rst" ), must return "someRoot.Abc['Def']".
extractContainerPart in interface ReflectorServiceobjectname - The objectname to be worked upon.
objectname.public java.lang.String extractNamePart(java.lang.String objectname)
ReflectorServiceThis method must correctly return the Name part of the full objectname. For instance; getContainerPart( "someRoot.Abc.Def" ), must return "Def", getContainerPart( "someRoot.Abc['Def']" ), must return "['Def']", and getContainerPart( "someRoot.Abc['Def'].Rst" ), must return "Rst".
extractNamePart in interface ReflectorServiceobjectname - The objectname to be worked upon.
objectname.
public java.lang.String append(java.lang.Object container,
java.lang.String containerpart,
java.lang.String namepart)
ReflectorService
append in interface ReflectorServicecontainer - The actual container so that the type can be determined.containerpart - The name of the container.namepart - The name part to append to the containerpart.
public java.lang.String getMemberClassName(java.lang.String name)
throws ReflectionException
ReflectorServiceobjectname argument.
getMemberClassName in interface ReflectorServicename - The name of the member to query for its Class.
ReflectionException - if the named object does not exist.
public java.lang.String getMemberClassName(java.lang.Object container,
java.lang.String memberName)
throws ReflectionException
ReflectorServicemembername in the provided
container.
getMemberClassName in interface ReflectorServicecontainer - The object which has a member of the memberName.memberName - The name of the member of the container to query for its Class.
objectname in the container.
ReflectionException - if the objectname does not exist as a member in the container.
public java.lang.Class getMemberClass(java.lang.String name)
throws ReflectionException
ReflectorServicemembername argument.
getMemberClass in interface ReflectorServicename - The name of the object to query for its Class.
ReflectionException - if the named object does not exist.
public java.lang.Class getMemberClass(java.lang.Object container,
java.lang.String memberName)
throws ReflectionException
ReflectorServicemembername in the provided
container.
getMemberClass in interface ReflectorServicecontainer - The object which has a member of the memberName.memberName - The name of the member of the container to query for its Class.
ReflectionException - if the named object does not exist.
public boolean isMemberSettable(java.lang.String name)
throws ReflectionException
ReflectorService
isMemberSettable in interface ReflectorServicename - The member to be tested if it can be set by a setMemberObject() method call.
objectname can be set.
ReflectionException - if the objectname does not identify an existing object reference.
public boolean isMemberSettable(java.lang.Object container,
java.lang.String memberName)
throws ReflectionException
ReflectorService
isMemberSettable in interface ReflectorServicecontainer - The container from where we should test if a member can be set to a value, by calling the
setMemberObject() method.memberName - The member in the provided container to be tested if it can be set by a setMemberObject()
method call.
membername can be set in the container.
ReflectionException - if the membername does not exist as a member in the container.public void dispose()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||