com.legstar.coxb.common
Class CComplexBinding

java.lang.Object
  extended by com.legstar.coxb.common.CBinding
      extended by com.legstar.coxb.common.CComplexBinding
All Implemented Interfaces:
ICobolBinding, ICobolComplexBinding, ICobolElement

public abstract class CComplexBinding
extends CBinding
implements ICobolComplexBinding

This class is a superclass of all other complex element types implementing binding between a java type and cobol.

Author:
Fady Moussallam

Constructor Summary
CComplexBinding(String bindingName, String jaxbName, Class<?> jaxbType, CobolElement cobolAnnotations, ICobolComplexBinding parentBinding)
          Constructor for a cobol complex element to java binding.
 
Method Summary
 void accept(CobolElementVisitor cev)
          Visitor pattern accept method.
 int calcByteLength()
          The method calculates the exact host byte length for this Cobol binding.
 void createJaxbObject()
          Deprecated.  
 void createValueObject()
          This method is meant to be overridden.
 List<ICobolBinding> getChildrenList()
          Request a list of children from this complex binding.
 ICobolNumericBinding getCounter(String cobolName)
          Get a specific counter either from us or one of our ancestors.
protected  ICobolNumericBinding getCounterInChildren(List<ICobolBinding> children, String cobolName)
          Descend the children of a complex or choice element looking for a counter with the corresponding COBOL name.
 int getCounterValue(String cobolName)
          Get the value of a specific counter either from us or one of our ancestors.
 int getDynamicCountersCount()
           
 String getValueObjectClassName()
          Complex bindings can be bound to JAXB objects or arbitrary POJOs jointly referred to as value objects.
 String getValueObjectsFactoryClassName()
          Optional factory class name used to create bound value objects.
 void setChildrenList(List<ICobolBinding> children)
           
 void setCounterValue(String cobolName, int count)
          When a list size is known, this method updates the corresponding counter (if any).
 void setJaxbPropertyValue(int index)
          Deprecated.  
 void setPropertyValue(int index)
          This method is meant to be overridden.
 void setValueObjectClassName(String valueObjectClassName)
          
 void setValueObjectsFactoryClassName(String valueObjectsFactoryClassName)
          
 void storeCounter(ICobolBinding counter)
          
 void storeCounter(ICobolNumericBinding counter)
          Store a new counter as a child of the root complex element.
 
Methods inherited from class com.legstar.coxb.common.CBinding
cast, getBindingName, getByteLength, getCobolName, getCobolType, getDefaultValue, getDependingOn, getFractionDigits, getJaxbName, getJaxbType, getLevelNumber, getMarshalChoiceStrategyClassName, getMaxOccurs, getMinOccurs, getParentBinding, getPicture, getRedefines, getSrceLine, getTotalDigits, getUnmarshalChoiceStrategyClassName, getUsage, isBound, isCustomVariable, isGeneratedBinding, isJustifiedRight, isODOObject, isRedefined, isSigned, isSignLeading, isSignSeparate, setBindingName, setByteLength, setCobolName, setCobolType, setDefaultValue, setDependingOn, setFractionDigits, setIsCustomVariable, setIsJustifiedRight, setIsODOObject, setIsRedefined, setIsSigned, setIsSignLeading, setIsSignSeparate, setJaxbName, setJaxbType, setLevelNumber, setMarshalChoiceStrategyClassName, setMaxOccurs, setMinOccurs, setParentBinding, setPicture, setRedefines, setSrceLine, setTotalDigits, setUnmarshalChoiceStrategyClassName, setUsage, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.legstar.coxb.ICobolComplexBinding
getObjectFactory, setChildrenValues, setObjectFactory
 
Methods inherited from interface com.legstar.coxb.ICobolBinding
getBindingName, getJaxbName, getJaxbType, getObjectValue, getParentBinding, isBound, isSet, setObjectValue
 
Methods inherited from interface com.legstar.coxb.ICobolElement
getByteLength, getCobolName, getCobolType, getDefaultValue, getDependingOn, getFractionDigits, getLevelNumber, getMarshalChoiceStrategyClassName, getMaxOccurs, getMinOccurs, getPicture, getRedefines, getSrceLine, getTotalDigits, getUnmarshalChoiceStrategyClassName, getUsage, isCustomVariable, isJustifiedRight, isODOObject, isRedefined, isSigned, isSignLeading, isSignSeparate, setByteLength, setCobolName, setCobolType, setDefaultValue, setDependingOn, setFractionDigits, setIsCustomVariable, setIsJustifiedRight, setIsODOObject, setIsRedefined, setIsSigned, setIsSignLeading, setIsSignSeparate, setLevelNumber, setMarshalChoiceStrategyClassName, setMaxOccurs, setMinOccurs, setPicture, setRedefines, setSrceLine, setTotalDigits, setUnmarshalChoiceStrategyClassName, setUsage
 

Constructor Detail

CComplexBinding

public CComplexBinding(String bindingName,
                       String jaxbName,
                       Class<?> jaxbType,
                       CobolElement cobolAnnotations,
                       ICobolComplexBinding parentBinding)
Constructor for a cobol complex element to java binding.

Parameters:
bindingName - the identifier for this binding
jaxbName - the name of the bound java property
jaxbType - the type of the bound java property
cobolAnnotations - the cobol annotations for this element
parentBinding - a reference to the parent binding if any
Method Detail

accept

public void accept(CobolElementVisitor cev)
            throws HostException
Visitor pattern accept method.

Specified by:
accept in interface ICobolBinding
Parameters:
cev - The visitor
Throws:
HostException - visitor request cannot be accepted

calcByteLength

public int calcByteLength()
The method calculates the exact host byte length for this Cobol binding.

If length exceed Integer.MAX_VALUE, returns Integer.MAX_VALUE.

Specified by:
calcByteLength in interface ICobolBinding
Returns:
the host byte length of this binding

getChildrenList

public List<ICobolBinding> getChildrenList()
Request a list of children from this complex binding.

Specified by:
getChildrenList in interface ICobolComplexBinding
Returns:
Ordered list of children

setChildrenList

public void setChildrenList(List<ICobolBinding> children)
Parameters:
children - the children list to set

storeCounter

public void storeCounter(ICobolNumericBinding counter)
Store a new counter as a child of the root complex element. If this complex element is root (has no parent), the counter is inserted at the beginning of the children list in order to ensure that it is not variably located in the corresponding Cobol layout. If this is not a root element, the request is propagated up to parent.

Specified by:
storeCounter in interface ICobolComplexBinding
Parameters:
counter - the counter to add to children list

storeCounter

public void storeCounter(ICobolBinding counter)

Specified by:
storeCounter in interface ICobolComplexBinding
Parameters:
counter - the counter to add to children list

setCounterValue

public void setCounterValue(String cobolName,
                            int count)
                     throws HostException
When a list size is known, this method updates the corresponding counter (if any). Counters are kept at the root level so if this complex binding is not root (has a parent), the request is propagated up.

Specified by:
setCounterValue in interface ICobolComplexBinding
Parameters:
cobolName - cobol name of the counter
count - the array or list size
Throws:
HostException - if counter cannot be updated

getCounterValue

public int getCounterValue(String cobolName)
                    throws HostException
Get the value of a specific counter either from us or one of our ancestors.

Specified by:
getCounterValue in interface ICobolComplexBinding
Parameters:
cobolName - cobol name of the counter
Returns:
the array or list size
Throws:
HostException - if counter cannot be queried

getCounter

public ICobolNumericBinding getCounter(String cobolName)
                                throws HostException
Get a specific counter either from us or one of our ancestors.

Specified by:
getCounter in interface ICobolComplexBinding
Parameters:
cobolName - cobol name of the counter
Returns:
the counter binding element
Throws:
HostException - if counter cannot be queried

getCounterInChildren

protected ICobolNumericBinding getCounterInChildren(List<ICobolBinding> children,
                                                    String cobolName)
                                             throws HostException
Descend the children of a complex or choice element looking for a counter with the corresponding COBOL name.

First lookup numeric children for the requested counter. If not found, give a chance to complex and choice children for finding the counter within their children.

Parameters:
children - the list of children element to search
cobolName - the COBOL name we are looking for
Returns:
the element mapping the COBOL counter or null if not found
Throws:
HostException

getDynamicCountersCount

public int getDynamicCountersCount()
Specified by:
getDynamicCountersCount in interface ICobolComplexBinding
Returns:
the number of dynamic counters this complex element is handling

createValueObject

public void createValueObject()
                       throws HostException
This method is meant to be overridden. If it is not, then we are dealing with an previous version of a binding object which did not implement this method. For backward compatibility, we route the call to the now deprecated createJaxbObject Requests complex binding to create an instance of its bound object.

Specified by:
createValueObject in interface ICobolComplexBinding
Throws:
HostException - if initialization fails

setPropertyValue

public void setPropertyValue(int index)
                      throws HostException
This method is meant to be overridden. If it is not, then we are dealing with an previous version of a binding object which did not implement this method. For backward compatibility, we route the call to the now deprecated setJaxbPropertyValue Request complex binding to set a property of the bound value object to the value of a corresponding child.

Specified by:
setPropertyValue in interface ICobolComplexBinding
Parameters:
index - the position of the child in the complex element child list
Throws:
HostException - if bound object values cannot be set

createJaxbObject

public void createJaxbObject()
                      throws HostException
Deprecated. 

Specified by:
createJaxbObject in interface ICobolComplexBinding
Throws:
HostException - if initialization fails

setJaxbPropertyValue

public void setJaxbPropertyValue(int index)
                          throws HostException
Deprecated. 

Specified by:
setJaxbPropertyValue in interface ICobolComplexBinding
Parameters:
index - the position of the child in the complex element child list
Throws:
HostException - if bound object values cannot be set

getValueObjectClassName

public String getValueObjectClassName()
Complex bindings can be bound to JAXB objects or arbitrary POJOs jointly referred to as value objects. This property is the fully qualified java class name of the bound value object.

Specified by:
getValueObjectClassName in interface ICobolComplexBinding
Returns:
the fully qualified bound value object class name

setValueObjectClassName

public void setValueObjectClassName(String valueObjectClassName)

Specified by:
setValueObjectClassName in interface ICobolComplexBinding
Parameters:
valueObjectClassName - the fully qualified bound value object class name to set

getValueObjectsFactoryClassName

public String getValueObjectsFactoryClassName()
Optional factory class name used to create bound value objects. If null, value objects are assumed to have a no-argument constructor.

Specified by:
getValueObjectsFactoryClassName in interface ICobolComplexBinding
Returns:
the factory class name used to create bound value objects

setValueObjectsFactoryClassName

public void setValueObjectsFactoryClassName(String valueObjectsFactoryClassName)

Specified by:
setValueObjectsFactoryClassName in interface ICobolComplexBinding
Parameters:
valueObjectsFactoryClassName - the factory class name used to create bound value objects to set


Copyright © 2015 LegSem. All Rights Reserved.