com.sun.tools.xjc.reader.xmlschema
Class ClassSelector

java.lang.Object
  extended by com.sun.tools.xjc.reader.xmlschema.BindingComponent
      extended by com.sun.tools.xjc.reader.xmlschema.ClassSelector

public final class ClassSelector
extends BindingComponent

Manages association between XSComponents and generated CTypeInfos.

This class determines which component is mapped to (or is not mapped to) what types.


Field Summary
(package private)  Map<XSComponent,CElementInfo> boundElements
          UGLY HACK.
 
Constructor Summary
ClassSelector()
           
 
Method Summary
(package private)  CTypeInfo _bindToClass(XSComponent sc, XSComponent referer, boolean cannotBeDelayed)
          The real meat of the "bindToType" code.
 CClass bindToType(XSComplexType t, XSComponent referer, boolean cannotBeDelayed)
           
 CTypeInfo bindToType(XSComponent sc, XSComponent referer)
          Checks if the given component is being mapped to a type.
 CElement bindToType(XSElementDecl e, XSComponent referer)
           
 TypeUse bindToType(XSType t, XSComponent referer)
           
 void executeTasks()
          Runs all the pending build tasks.
 CClassInfoParent getClassScope()
          Gets the current class scope.
 CClassInfo getCurrentBean()
           
 XSComponent getCurrentRoot()
           
 com.sun.codemodel.JPackage getPackage(String targetNamespace)
          Gets the Java package to which classes from this namespace should go.
 CElement isBound(XSElementDecl x, XSComponent referer)
          Checks if the given component is bound to a class.
 void popClassScope()
           
 void pushClassScope(CClassInfoParent clsFctry)
           
 void queueBuild(XSComponent sc, CElement bean)
           
 
Methods inherited from class com.sun.tools.xjc.reader.xmlschema.BindingComponent
getClassSelector, getErrorReporter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

boundElements

final Map<XSComponent,CElementInfo> boundElements
UGLY HACK.

To avoid cyclic dependency between binding elements and types, we need additional markers that tell which elements are definitely not bound to a class.

the cyclic dependency is as follows: elements need to bind its types first, because otherwise it can't determine T of JAXBElement. OTOH, types need to know whether its parent is bound to a class to decide which class name to use.

Constructor Detail

ClassSelector

public ClassSelector()
Method Detail

getClassScope

public final CClassInfoParent getClassScope()
Gets the current class scope.


pushClassScope

public final void pushClassScope(CClassInfoParent clsFctry)

popClassScope

public final void popClassScope()

getCurrentRoot

public XSComponent getCurrentRoot()

getCurrentBean

public CClassInfo getCurrentBean()

isBound

public final CElement isBound(XSElementDecl x,
                              XSComponent referer)
Checks if the given component is bound to a class.


bindToType

public CTypeInfo bindToType(XSComponent sc,
                            XSComponent referer)
Checks if the given component is being mapped to a type. If so, build that type and return that object. If it is not being mapped to a type item, return null.


bindToType

public CElement bindToType(XSElementDecl e,
                           XSComponent referer)

bindToType

public CClass bindToType(XSComplexType t,
                         XSComponent referer,
                         boolean cannotBeDelayed)

bindToType

public TypeUse bindToType(XSType t,
                          XSComponent referer)

_bindToClass

CTypeInfo _bindToClass(@NotNull
                       XSComponent sc,
                       XSComponent referer,
                       boolean cannotBeDelayed)
The real meat of the "bindToType" code.

Parameters:
cannotBeDelayed - if the binding of the body of the class cannot be defered and needs to be done immediately. If the flag is false, the binding of the body will be done later, to avoid cyclic binding problem.
referer - The component that refers to sc. This can be null, if figuring out the referer is too hard, in which case the error message might be less user friendly.

executeTasks

public void executeTasks()
Runs all the pending build tasks.


queueBuild

public void queueBuild(XSComponent sc,
                       CElement bean)

getPackage

public com.sun.codemodel.JPackage getPackage(String targetNamespace)
Gets the Java package to which classes from this namespace should go.

Usually, the getOuterClass method should be used to determine where to put a class.