Package org.jibx.binding.def
Class PropertyDefinition
- java.lang.Object
-
- org.jibx.binding.def.PropertyDefinition
-
public class PropertyDefinition extends 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
-
-
Constructor Summary
Constructors Constructor Description PropertyDefinition(String type, IContextObj obj, boolean opt)Constructor for implicit object reference.PropertyDefinition(IContainer parent, IContextObj obj, String type, boolean isthis, boolean opt, String fname, String test, String flag, String get, String set)Constructor.PropertyDefinition(IContextObj obj, boolean opt)Constructor for "this" object reference.PropertyDefinition(PropertyDefinition original)Copy constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidgenFlag(MethodBuilder mb)Generate code to call flag method with value on stack.voidgenLoad(ContextMethodBuilder mb)Generate code to load property value to stack.voidgenStore(MethodBuilder mb)Generate code to store property value from stack.BranchWrappergenTest(ContextMethodBuilder mb)Generate code to test if property is present.StringgetGetValueType()Get value type as fully qualified name for loaded property value.StringgetName()Get property name.StringgetSetValueType()Get value type as fully qualified name for stored property value.StringgetTypeName()Get declared type fully qualified name.booleanhasFlag()Check if property has flag method.booleanhasTest()Check if property has presence test.booleanisFlagOnly()Check if property is flag only.booleanisImplicit()Check if property is implicit value from collection.booleanisLoadable()Check if the value can be loaded.booleanisOptional()Check if property is optional.booleanisTestOnly()Check if property is test only.booleanisThis()Check if property is "this" reference for object.voidsetOptional(boolean opt)Set flag for an optional property.voidswitchProperty()Switch property from "this" to "implicit".StringtoString()
-
-
-
Constructor Detail
-
PropertyDefinition
public PropertyDefinition(IContainer parent, IContextObj obj, String type, boolean isthis, boolean opt, String fname, String test, String flag, String get, String set) throws org.jibx.runtime.JiBXException
Constructor.- Parameters:
parent- containing binding definition structureobj- containing object contexttype- fully qualified name of typeisthis- "this" object reference flagopt- optional property flagfname- containing object field name for property (may benull)test- containing object method to test for property present (may benull)flag- containing object method to flag property present (may benull)get- containing object method to get property value (may benull)set- containing object method to set property value (may benull)- Throws:
org.jibx.runtime.JiBXException- if configuration error
-
PropertyDefinition
public PropertyDefinition(IContextObj obj, boolean opt)
Constructor for "this" object reference.- Parameters:
obj- containing object contextopt- optional property flag
-
PropertyDefinition
public PropertyDefinition(String type, IContextObj obj, boolean opt)
Constructor for implicit object reference.- Parameters:
type- object type suppliedobj- containing object contextopt- optional property flag
-
PropertyDefinition
public PropertyDefinition(PropertyDefinition original)
Copy constructor.- Parameters:
original- Property Definition
-
-
Method Detail
-
isThis
public boolean isThis()
Check if property is "this" reference for object.- Returns:
trueif reference to "this",falseif not
-
isImplicit
public boolean isImplicit()
Check if property is implicit value from collection.- Returns:
trueif implicit,falseif not
-
switchProperty
public void switchProperty()
Switch property from "this" to "implicit".
-
isOptional
public boolean isOptional()
Check if property is optional.- Returns:
trueif optional,falseif required
-
setOptional
public void setOptional(boolean opt)
Set flag for an optional property.- Parameters:
opt-trueif optional property,falseif not
-
isLoadable
public boolean isLoadable()
Check if the value can be loaded.- Returns:
trueif loadable,falseif not
-
getName
public 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 String getTypeName()
Get declared type fully qualified name.- Returns:
- fully qualified class name of declared type
-
getGetValueType
public String getGetValueType()
Get value type as fully qualified name for loaded property value.- Returns:
- fully qualified class name of value type
-
getSetValueType
public 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:
trueif presence test needed,falseif not
-
isTestOnly
public boolean isTestOnly()
Check if property is test only.- Returns:
trueif test-only property,falseif not
-
hasFlag
public boolean hasFlag()
Check if property has flag method.- Returns:
trueif flag method defined,falseif not
-
isFlagOnly
public boolean isFlagOnly()
Check if property is flag only.- Returns:
trueif flag-only property,falseif not
-
genTest
public BranchWrapper genTest(ContextMethodBuilder mb) throws org.jibx.runtime.JiBXException
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
- Throws:
org.jibx.runtime.JiBXException- If error
-
genFlag
public void genFlag(MethodBuilder mb) throws org.jibx.runtime.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:
org.jibx.runtime.JiBXException- if configuration error
-
genLoad
public void genLoad(ContextMethodBuilder mb) throws org.jibx.runtime.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:
org.jibx.runtime.JiBXException- if configuration error
-
genStore
public void genStore(MethodBuilder mb) throws org.jibx.runtime.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:
org.jibx.runtime.JiBXException- if configuration error
-
-