org.jibx.binding.def
Class PropertyDefinition

java.lang.Object
  extended by org.jibx.binding.def.PropertyDefinition

public class PropertyDefinition
extends java.lang.Object

Property definition from binding. This organizes shared information for bindings linked to fields or get/set methods of an object, and provides methods for related code generation.

Author:
Dennis M. Sosnoski

Field Summary
private static java.lang.String[] FLAG_METHOD_SIGNATURES
           
private static java.lang.String[] GET_METHOD_SIGNATURES
           
private  ClassItem m_fieldItem
          Information for field (if given, may be null).
private  ClassItem m_flagMethod
          Information for flag method (if given, may be null).
private  ClassItem m_getMethod
          Information for get method (if given, may be null).
private  java.lang.String m_getValueType
          Fully qualified name of declared type of value loaded.
private  boolean m_isImplicit
          Reference to implicit value from collection.
private  boolean m_isOptional
          Optional item flag.
private  boolean m_isThis
          Reference to "this" property of object flag.
private  IContextObj m_objContext
          Containing object context.
private  ClassItem m_setMethod
          Information for set method (if given, may be null).
private  java.lang.String m_setValueType
          Fully qualified name of declared type of value stored.
private  ClassItem m_testMethod
          Information for test method (if given, may be null).
private  java.lang.String m_typeName
          Fully qualified name of actual type of value.
private static java.lang.String[] TEST_METHOD_SIGNATURES
           
 
Constructor Summary
PropertyDefinition(IContainer parent, IContextObj obj, java.lang.String type, boolean isthis, boolean opt, java.lang.String fname, java.lang.String test, java.lang.String flag, java.lang.String get, java.lang.String set)
          Constructor.
PropertyDefinition(IContextObj obj, boolean opt)
          Constructor for "this" object reference.
PropertyDefinition(PropertyDefinition original)
          Copy constructor.
PropertyDefinition(java.lang.String type, IContextObj obj, boolean opt)
          Constructor for implicit object reference.
 
Method Summary
private  void discardValue(MethodBuilder mb)
          Append instruction to pop the value from the stack.
private  void duplicateValue(MethodBuilder mb)
          Append instruction to duplicate the value on the stack.
 void genFlag(MethodBuilder mb)
          Generate code to call flag method with value on stack.
 void genLoad(ContextMethodBuilder mb)
          Generate code to load property value to stack.
 void genStore(MethodBuilder mb)
          Generate code to store property value from stack.
 BranchWrapper genTest(ContextMethodBuilder mb)
          Generate code to test if property is present.
 java.lang.String getGetValueType()
          Get value type as fully qualified name for loaded property value.
 java.lang.String getName()
          Get property name.
 java.lang.String getSetValueType()
          Get value type as fully qualified name for stored property value.
 java.lang.String getTypeName()
          Get declared type fully qualified name.
 boolean hasFlag()
          Check if property has flag method.
 boolean hasTest()
          Check if property has presence test.
 boolean isFlagOnly()
          Check if property is flag only.
 boolean isImplicit()
          Check if property is implicit value from collection.
 boolean isLoadable()
          Check if the value can be loaded.
 boolean isOptional()
          Check if property is optional.
 boolean isTestOnly()
          Check if property is test only.
 boolean isThis()
          Check if property is "this" reference for object.
 void setOptional(boolean opt)
          Set flag for an optional property.
 void switchProperty()
          Switch property from "this" to "implicit".
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TEST_METHOD_SIGNATURES

private static final java.lang.String[] TEST_METHOD_SIGNATURES

GET_METHOD_SIGNATURES

private static final java.lang.String[] GET_METHOD_SIGNATURES

FLAG_METHOD_SIGNATURES

private static final java.lang.String[] FLAG_METHOD_SIGNATURES

m_isThis

private boolean m_isThis
Reference to "this" property of object flag.


m_isImplicit

private boolean m_isImplicit
Reference to implicit value from collection.


m_isOptional

private boolean m_isOptional
Optional item flag.


m_objContext

private final IContextObj m_objContext
Containing object context.


m_typeName

private final java.lang.String m_typeName
Fully qualified name of actual type of value.


m_getValueType

private final java.lang.String m_getValueType
Fully qualified name of declared type of value loaded.


m_setValueType

private final java.lang.String m_setValueType
Fully qualified name of declared type of value stored.


m_fieldItem

private final ClassItem m_fieldItem
Information for field (if given, may be null).


m_testMethod

private final ClassItem m_testMethod
Information for test method (if given, may be null).


m_flagMethod

private final ClassItem m_flagMethod
Information for flag method (if given, may be null).


m_getMethod

private final ClassItem m_getMethod
Information for get method (if given, may be null).


m_setMethod

private final ClassItem m_setMethod
Information for set method (if given, may be null).

Constructor Detail

PropertyDefinition

public PropertyDefinition(IContainer parent,
                          IContextObj obj,
                          java.lang.String type,
                          boolean isthis,
                          boolean opt,
                          java.lang.String fname,
                          java.lang.String test,
                          java.lang.String flag,
                          java.lang.String get,
                          java.lang.String set)
                   throws JiBXException
Constructor.

Parameters:
parent - containing binding definition structure
obj - containing object context
type - fully qualified name of type
isthis - "this" object reference flag
opt - optional property flag
fname - containing object field name for property (may be null)
test - containing object method to test for property present (may be null)
flag - containing object method to flag property present (may be null)
get - containing object method to get property value (may be null)
set - containing object method to set property value (may be null)
Throws:
JiBXException - if configuration error

PropertyDefinition

public PropertyDefinition(IContextObj obj,
                          boolean opt)
Constructor for "this" object reference.

Parameters:
obj - containing object context
opt - optional property flag

PropertyDefinition

public PropertyDefinition(java.lang.String type,
                          IContextObj obj,
                          boolean opt)
Constructor for implicit object reference.

Parameters:
type - object type supplied
obj - containing object context
opt - optional property flag

PropertyDefinition

public PropertyDefinition(PropertyDefinition original)
Copy constructor.

Parameters:
original -
Method Detail

isThis

public boolean isThis()
Check if property is "this" reference for object.

Returns:
true if reference to "this", false if not

isImplicit

public boolean isImplicit()
Check if property is implicit value from collection.

Returns:
true if implicit, false if not

switchProperty

public void switchProperty()
Switch property from "this" to "implicit".


isOptional

public boolean isOptional()
Check if property is optional.

Returns:
true if optional, false if required

setOptional

public void setOptional(boolean opt)
Set flag for an optional property.

Parameters:
opt - true if optional property, false if not

isLoadable

public boolean isLoadable()
Check if the value can be loaded.

Returns:
true if loadable, false if not

getName

public java.lang.String getName()
Get property name. If a field is defined this is the same as the field; otherwise it is either the get method name (with leading "get" stripped, if present) or the set method (with leading "set" stripped, if present), whichever is found.

Returns:
name for this property

getTypeName

public java.lang.String getTypeName()
Get declared type fully qualified name.

Returns:
fully qualified class name of declared type

getGetValueType

public java.lang.String getGetValueType()
Get value type as fully qualified name for loaded property value.

Returns:
fully qualified class name of value type

getSetValueType

public java.lang.String getSetValueType()
Get value type as fully qualified name for stored property value.

Returns:
fully qualified class name of value type

hasTest

public boolean hasTest()
Check if property has presence test. Code needs to be generated to check for the presence of the property if it is optional and either a test method is defined or the value is an object reference.

Returns:
true if presence test needed, false if not

isTestOnly

public boolean isTestOnly()
Check if property is test only.

Returns:
true if test-only property, false if not

hasFlag

public boolean hasFlag()
Check if property has flag method.

Returns:
true if flag method defined, false if not

isFlagOnly

public boolean isFlagOnly()
Check if property is flag only.

Returns:
true if flag-only property, false if not

duplicateValue

private void duplicateValue(MethodBuilder mb)
Append instruction to duplicate the value on the stack. This will use the appropriate instruction for the size of the value.

Parameters:
mb -

discardValue

private void discardValue(MethodBuilder mb)
Append instruction to pop the value from the stack. This will use the appropriate instruction for the size of the value.

Parameters:
mb -

genTest

public BranchWrapper genTest(ContextMethodBuilder mb)
Generate code to test if property is present. The generated code assumes that the top of the stack is the reference for the containing object, and consumes this value for the test. The target for the returned branch instruction must be set by the caller.

Parameters:
mb - method builder
Returns:
wrapper for branch instruction taken when property is missing

genFlag

public void genFlag(MethodBuilder mb)
             throws JiBXException
Generate code to call flag method with value on stack. The generated code assumes that the reference to the containing object and the value to be stored have already been pushed on the stack. It consumes these, leaving nothing. If the property value is not directly accessible from the context of the method being generated this automatically constructs an access method and uses that method.

Parameters:
mb - method builder
Throws:
JiBXException - if configuration error

genLoad

public void genLoad(ContextMethodBuilder mb)
             throws JiBXException
Generate code to load property value to stack. The generated code assumes that the top of the stack is the reference for the containing object. It consumes this and leaves the actual value on the stack. If the property value is not directly accessible from the context of the method being generated this automatically constructs an access method and uses that method.

Parameters:
mb - method builder
Throws:
JiBXException - if configuration error

genStore

public void genStore(MethodBuilder mb)
              throws JiBXException
Generate code to store property value from stack. The generated code assumes that the reference to the containing object and the value to be stored have already been pushed on the stack. It consumes these, leaving nothing. If the property value is not directly accessible from the context of the method being generated this automatically constructs an access method and uses that method.

Parameters:
mb - method builder
Throws:
JiBXException - if configuration error

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Project Web Site