com.legstar.coxb.common
Class CChoiceBinding

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

public abstract class CChoiceBinding
extends CBinding
implements ICobolChoiceBinding

Represents a choice between 2 or more elements. A choice results from a cobol REDEFINES clause exposed as an xs:choice in the corresponding XML schema

Author:
Fady Moussallam

Constructor Summary
CChoiceBinding(String bindingName, CobolElement cobolAnnotations, ICobolComplexBinding parentBinding)
          A choice element gets created when a redefined item is encountered.
 
Method Summary
 void accept(CobolElementVisitor cev)
          Visitor pattern accept method.
 void addAlternative(ICobolBinding ce)
          When alternatives are discovered dynamically, this method allows other classes to participate in the alternative list buildup.
 int calcByteLength()
          The method calculates the exact host byte length for this Cobol binding.
 ICobolBinding getAlternativeByCobolName(String cobolName)
          Retrieves an alternative identified by its cobol field name.
 ICobolBinding getAlternativeByName(String name)
          Retrieves an alternative identified by its name.
 List<ICobolBinding> getAlternativesList()
          Returns the current list of alternatives for this choice element.
 ICobolMarshalChoiceStrategy getMarshalChoiceStrategy()
          Gets an instance of a class providing additional logic to select an alternative within a choice element at marshaling (Java to Host) time.
 Object getParentJaxbObject()
          Deprecated.  
 Object getParentValueObject()
          This method is meant to be overridden.
 ICobolUnmarshalChoiceStrategy getUnmarshalChoiceStrategy()
          Gets an instance of a class providing additional logic to select an alternative within a choice element at unmarshaling (Host to Java) time.
 void setJaxbPropertyValue(int index)
          Deprecated.  
 void setMarshalChoiceStrategy(ICobolMarshalChoiceStrategy strategy)
          Sets a instance of a class providing additional logic to select an alternative within a choice element at marshaling (Java to Host) time.
 void setPropertyValue(int index)
          This method is meant to be overridden.
 void setUnmarshalChoiceStrategy(ICobolUnmarshalChoiceStrategy strategy)
          Sets a instance of a class providing additional logic to select an alternative within a choice element at unmarshaling (Host to Java) time.
 
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.ICobolChoiceBinding
getParentBinding, setAlternativesValues
 
Methods inherited from interface com.legstar.coxb.ICobolBinding
getBindingName, getJaxbName, getJaxbType, getObjectValue, 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

CChoiceBinding

public CChoiceBinding(String bindingName,
                      CobolElement cobolAnnotations,
                      ICobolComplexBinding parentBinding)
A choice element gets created when a redefined item is encountered.

Parameters:
bindingName - the identifier for this binding
cobolAnnotations - the cobol annotations for the first alternative
parentBinding - a reference to the parent binding if any
Method Detail

addAlternative

public void addAlternative(ICobolBinding ce)
When alternatives are discovered dynamically, this method allows other classes to participate in the alternative list buildup.

Specified by:
addAlternative in interface ICobolChoiceBinding
Parameters:
ce - redefined or redefining cobol element description

getAlternativesList

public List<ICobolBinding> getAlternativesList()
Returns the current list of alternatives for this choice element.

Specified by:
getAlternativesList in interface ICobolChoiceBinding
Returns:
Ordered list of alternatives

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.

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

getAlternativeByName

public ICobolBinding getAlternativeByName(String name)
Retrieves an alternative identified by its name.

Specified by:
getAlternativeByName in interface ICobolChoiceBinding
Parameters:
name - the alternative name
Returns:
corresponding alternative or null if not found

getAlternativeByCobolName

public ICobolBinding getAlternativeByCobolName(String cobolName)
Retrieves an alternative identified by its cobol field name.

Specified by:
getAlternativeByCobolName in interface ICobolChoiceBinding
Parameters:
cobolName - the field name
Returns:
corresponding alternative or null if not found

getMarshalChoiceStrategy

public ICobolMarshalChoiceStrategy getMarshalChoiceStrategy()
                                                     throws HostException
Gets an instance of a class providing additional logic to select an alternative within a choice element at marshaling (Java to Host) time.

Specified by:
getMarshalChoiceStrategy in interface ICobolChoiceBinding
Returns:
a choice strategy implementation
Throws:
HostException - if strategy cannot be loaded

setMarshalChoiceStrategy

public void setMarshalChoiceStrategy(ICobolMarshalChoiceStrategy strategy)
Sets a instance of a class providing additional logic to select an alternative within a choice element at marshaling (Java to Host) time.

Specified by:
setMarshalChoiceStrategy in interface ICobolChoiceBinding
Parameters:
strategy - a choice strategy implementation

getUnmarshalChoiceStrategy

public ICobolUnmarshalChoiceStrategy getUnmarshalChoiceStrategy()
                                                         throws HostException
Gets an instance of a class providing additional logic to select an alternative within a choice element at unmarshaling (Host to Java) time.

Specified by:
getUnmarshalChoiceStrategy in interface ICobolChoiceBinding
Returns:
a choice strategy implementation
Throws:
HostException - if strategy cannot be loaded

setUnmarshalChoiceStrategy

public void setUnmarshalChoiceStrategy(ICobolUnmarshalChoiceStrategy strategy)
Sets a instance of a class providing additional logic to select an alternative within a choice element at unmarshaling (Host to Java) time.

Specified by:
setUnmarshalChoiceStrategy in interface ICobolChoiceBinding
Parameters:
strategy - a choice strategy implementation

getParentJaxbObject

public Object getParentJaxbObject()
                           throws HostException
Deprecated. 

Specified by:
getParentJaxbObject in interface ICobolChoiceBinding
Returns:
the parent bound jaxb object
Throws:
HostException - if parent jaxb object cannot be retrieved

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 choice binding to set to set a property of the bound value object to the value of a corresponding alternative. child value.

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

setJaxbPropertyValue

public void setJaxbPropertyValue(int index)
                          throws HostException
Deprecated. 

This method is deprecated, it is replaced by setPropertyValue.

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

getParentValueObject

public Object getParentValueObject()
                            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 getParentJaxbObject Retrieves the parent's value object. Choice bindings are not directly bound to a value object themselves but they are always children of a complex binding.

Specified by:
getParentValueObject in interface ICobolChoiceBinding
Returns:
the parent's bound value object
Throws:
HostException - if parent's value object cannot be retrieved


Copyright © 2015 LegSem. All Rights Reserved.