|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.partnersoft.data.PathedIntrospector
public class PathedIntrospector
A tool that simplifies the use of Java Introspection to get and put object properties and run methods.
This is a very useful tool, but embodies some complex abstract concepts, so was hard to name and a bit hard to explain. On the other hand, using it is pretty simple.
A common problem when building configuration-driven interfaces and reports is retrieving objects from within a complex Object graph using named paths. Straight Java or script code tends to be fragile when confronted with nulls anywhere along the path of retrieval. Also, datatype conversion is so common that it helps to build that in as well and reduce the amount of code required.
This was originally solved at Partner using the original 3.x Cog, but Cog has gone on to be more of a generic data structure and serialization framework and has drifted from this task.
PathedIntrospector is designed specifically to allow you to put and get properties and run methods using Path (or path Strings), while insulating the developer as much as possible from dealing with nulls and datatype conversion. This is a "fuzzy" approach, designed to be robust rather than correct. Properties that are missing will always return some kind of valid default value rather than breaking with a NullPointerException or similar error. The downside of this approach is that you lose both compiler-level and runtime checking and so it may not be obvious when something is misconfigured or broken.
Copyright 2009 Partner Software, Inc.
| Constructor Summary | |
|---|---|
PathedIntrospector(java.lang.Object root)
Creates a new PathedIntrospector using the given root object. |
|
| Method Summary | |
|---|---|
void |
copy(java.lang.String originalPropertyName,
java.lang.String newPropertyName)
Copies a property value to a new name. |
boolean |
getBoolean(java.lang.String propertyPath)
|
double |
getDouble(java.lang.String propertyPath)
|
float |
getFloat(java.lang.String propertyPath)
|
int |
getInt(java.lang.String propertyPath)
|
long |
getLong(java.lang.String propertyPath)
|
java.lang.Object |
getObject(Path propertyPath)
|
java.lang.Object |
getObject(java.lang.String propertyPath)
|
java.lang.Object |
getRoot()
|
java.lang.String |
getString(Path propertyPath)
|
java.lang.String |
getString(java.lang.String... propertyPaths)
|
java.lang.String |
getString(java.lang.String propertyPath)
|
void |
move(java.lang.String originalPropertyName,
java.lang.String newPropertyName)
Changes the name of a property, "moving" its value. |
void |
putBoolean(java.lang.String propertyPath,
boolean value)
|
void |
putDouble(java.lang.String propertyPath,
double newValue)
|
void |
putFloat(java.lang.String propertyPath,
float newValue)
|
void |
putInt(java.lang.String propertyPath,
int newValue)
|
void |
putLong(java.lang.String propertyPath,
long newValue)
|
void |
putObject(Path propertyPath,
java.lang.Object newValue)
|
void |
putObject(java.lang.String propertyPath,
java.lang.Object newValue)
|
void |
putString(java.lang.String propertyPath,
java.lang.String newValue)
|
void |
remove(java.lang.String propertyName)
Removes a property by putting its value to null. |
void |
setRoot(java.lang.Object newRoot)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public PathedIntrospector(java.lang.Object root)
| Method Detail |
|---|
public java.lang.Object getObject(java.lang.String propertyPath)
public java.lang.Object getObject(Path propertyPath)
public void putObject(java.lang.String propertyPath,
java.lang.Object newValue)
public void putObject(Path propertyPath,
java.lang.Object newValue)
public int getInt(java.lang.String propertyPath)
public void putInt(java.lang.String propertyPath,
int newValue)
public long getLong(java.lang.String propertyPath)
public void putLong(java.lang.String propertyPath,
long newValue)
public float getFloat(java.lang.String propertyPath)
public void putFloat(java.lang.String propertyPath,
float newValue)
public double getDouble(java.lang.String propertyPath)
public void putDouble(java.lang.String propertyPath,
double newValue)
public java.lang.String getString(java.lang.String propertyPath)
public java.lang.String getString(java.lang.String... propertyPaths)
public java.lang.String getString(Path propertyPath)
public void putString(java.lang.String propertyPath,
java.lang.String newValue)
public boolean getBoolean(java.lang.String propertyPath)
public void putBoolean(java.lang.String propertyPath,
boolean value)
public void move(java.lang.String originalPropertyName,
java.lang.String newPropertyName)
public void copy(java.lang.String originalPropertyName,
java.lang.String newPropertyName)
public void remove(java.lang.String propertyName)
public java.lang.Object getRoot()
public void setRoot(java.lang.Object newRoot)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||