com.sun.tools.xjc.model
Class CElementInfo

java.lang.Object
  extended by com.sun.tools.xjc.model.AbstractCTypeInfoImpl
      extended by com.sun.tools.xjc.model.AbstractCElement
          extended by com.sun.tools.xjc.model.CElementInfo
All Implemented Interfaces:
CClassInfoParent, CCustomizable, CElement, CTypeInfo, NType, Locatable, Element<NType,NClass>, ElementInfo<NType,NClass>, TypeInfo<NType,NClass>

public final class CElementInfo
extends AbstractCElement
implements ElementInfo<NType,NClass>, NType, CClassInfoParent

ElementInfo implementation for the compile-time model.

As an NType, it represents the Java representation of this element (either JAXBElement<T> or Foo).


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.sun.tools.xjc.model.CClassInfoParent
CClassInfoParent.Package, CClassInfoParent.Visitor<T>
 
Field Summary
 CClassInfoParent parent
          If this element is global, the element info is considered to be package-level, and this points to the package in which this element lives in.
 
Constructor Summary
CElementInfo(Model model, QName tagName, CClassInfoParent parent, String className, CCustomizations customizations, Locator location)
          Creates an element with a class in the given parent.
CElementInfo(Model model, QName tagName, CClassInfoParent parent, TypeUse contentType, XmlString defaultValue, XSElementDecl source, CCustomizations customizations, Locator location)
          Creates an element in the given parent.
 
Method Summary
 com.sun.codemodel.JPackage _package()
           
<T> T
accept(CClassInfoParent.Visitor<T> visitor)
           
 String fullName()
          Human readable name of this type.
 NType getContentInMemoryType()
          T of JAXBElement<T>.
 CNonElement getContentType()
          Short for getProperty().ref().get(0).
 String getDefaultValue()
           
 QName getElementName()
          Gets the element name of the class.
 com.sun.codemodel.JPackage getOwnerPackage()
          Gets the nearest JPackage.
 CElementPropertyInfo getProperty()
          Gets the object that represents the value property.
 CClassInfo getScope()
          If non-null, this element is only active inside the given scope.
 String getSqueezedName()
          Returns the "squeezed name" of this element.
 CElementInfo getSubstitutionHead()
          If this element can substitute another element, return that element.
 Collection<CElementInfo> getSubstitutionMembers()
          All the ElementInfos whose ElementInfo.getSubstitutionHead() points to this object.
 NType getType()
          Deprecated. why are you calling a method that returns this?
 boolean hasClass()
          True if this element has its own class (as opposed to be represented as an instance of JAXBElement.
 void initContentType(TypeUse contentType, XSElementDecl source, XmlString defaultValue)
           
 boolean isBoxedType()
          Returns true iff this type represents a class that has a unboxed form.
 void setSubstitutionHead(CElementInfo substitutionHead)
           
 String shortName()
           
 com.sun.codemodel.JType toType(Outline o, Aspect aspect)
          Returns the representation of this type in code model.
 
Methods inherited from class com.sun.tools.xjc.model.AbstractCElement
getLocator, isAbstract, setAbstract
 
Methods inherited from class com.sun.tools.xjc.model.AbstractCTypeInfoImpl
canBeReferencedByIDREF, createConstant, getAdapterUse, getCustomizations, getExpectedMimeType, getLocation, getSchemaComponent, getUpstream, idUse, isCollection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sun.xml.bind.v2.model.core.TypeInfo
canBeReferencedByIDREF
 
Methods inherited from interface com.sun.xml.bind.v2.model.annotation.Locatable
getLocation, getUpstream
 
Methods inherited from interface com.sun.tools.xjc.model.CCustomizable
getCustomizations, getSchemaComponent
 

Field Detail

parent

public final CClassInfoParent parent
If this element is global, the element info is considered to be package-level, and this points to the package in which this element lives in.

For local elements, this points to the parent CClassInfo.

Constructor Detail

CElementInfo

public CElementInfo(Model model,
                    QName tagName,
                    CClassInfoParent parent,
                    TypeUse contentType,
                    XmlString defaultValue,
                    XSElementDecl source,
                    CCustomizations customizations,
                    Locator location)
Creates an element in the given parent.

When using this construction, initContentType(TypeUse, XSElementDecl, XmlString) must not be invoked.


CElementInfo

public CElementInfo(Model model,
                    QName tagName,
                    CClassInfoParent parent,
                    String className,
                    CCustomizations customizations,
                    Locator location)
Creates an element with a class in the given parent.

When using this construction, the caller must use initContentType(TypeUse, XSElementDecl, XmlString) to fill in the content type later. This is to avoid a circular model construction dependency between buidling a type inside an element and element itself. To build a content type, you need to have CElementInfo for a parent, so we can't take it as a constructor parameter.

Method Detail

initContentType

public void initContentType(TypeUse contentType,
                            @Nullable
                            XSElementDecl source,
                            XmlString defaultValue)

getDefaultValue

public final String getDefaultValue()

_package

public final com.sun.codemodel.JPackage _package()

getContentType

public CNonElement getContentType()
Description copied from interface: ElementInfo
Short for getProperty().ref().get(0). The type of the value this element holds. Normally, this is the T of JAXBElement<T>. But if the property is adapted, this is the on-the-wire type. Or if the element has a list of values, then this field represents the type of the individual item.

Specified by:
getContentType in interface ElementInfo<NType,NClass>
See Also:
ElementInfo.getContentInMemoryType()

getContentInMemoryType

public NType getContentInMemoryType()
Description copied from interface: ElementInfo
T of JAXBElement<T>.

This is tied to the in-memory representation.

Specified by:
getContentInMemoryType in interface ElementInfo<NType,NClass>
See Also:
ElementInfo.getContentType()

getProperty

public CElementPropertyInfo getProperty()
Description copied from interface: ElementInfo
Gets the object that represents the value property.

Specified by:
getProperty in interface ElementInfo<NType,NClass>
Returns:
non-null.

getScope

public CClassInfo getScope()
Description copied from interface: Element
If non-null, this element is only active inside the given scope.

Specified by:
getScope in interface Element<NType,NClass>

getType

public NType getType()
Deprecated. why are you calling a method that returns this?

Description copied from interface: ElementInfo
Returns the representation for JAXBElement<contentInMemoryType>.

This returns the signature in Java and thus isn't affected by the adapter.

Specified by:
getType in interface ElementInfo<NType,NClass>
Specified by:
getType in interface TypeInfo<NType,NClass>
Returns:
always non-null.

getElementName

public QName getElementName()
Description copied from interface: Element
Gets the element name of the class.

Specified by:
getElementName in interface Element<NType,NClass>
Returns:
Always non-null.

toType

public com.sun.codemodel.JType toType(Outline o,
                                      Aspect aspect)
Description copied from interface: NType
Returns the representation of this type in code model.

This operation requires the whole model to be built, and hence it takes Outline.

Under some code generation strategy, some bean classes are considered implementation specific (such as impl.FooImpl class) These classes always have accompanying "exposed" type (such as the Foo interface).

For such Jekyll and Hyde type, the aspect parameter determines which personality is returned.

Specified by:
toType in interface CTypeInfo
Specified by:
toType in interface NType
aspect - If Aspect.IMPLEMENTATION, this method returns the implementation specific class that this type represents. If Aspect.EXPOSED, this method returns the publicly exposed type that this type represents. For ordinary classes, the aspect parameter is meaningless.
See Also:
NType.toType(Outline, Aspect)

getSqueezedName

public String getSqueezedName()
Returns the "squeezed name" of this element.

See Also:
CClassInfo.getSqueezedName()

getSubstitutionHead

public CElementInfo getSubstitutionHead()
Description copied from interface: Element
If this element can substitute another element, return that element.

Substitutability of elements are transitive.

Specified by:
getSubstitutionHead in interface Element<NType,NClass>
Specified by:
getSubstitutionHead in interface ElementInfo<NType,NClass>
Returns:
null if no such element exists.

getSubstitutionMembers

public Collection<CElementInfo> getSubstitutionMembers()
Description copied from interface: ElementInfo
All the ElementInfos whose ElementInfo.getSubstitutionHead() points to this object.

Specified by:
getSubstitutionMembers in interface ElementInfo<NType,NClass>
Returns:
can be empty but never null.

setSubstitutionHead

public void setSubstitutionHead(CElementInfo substitutionHead)

isBoxedType

public boolean isBoxedType()
Description copied from interface: NType
Returns true iff this type represents a class that has a unboxed form. For example, for String this is false, but for Integer this is true.

Specified by:
isBoxedType in interface NType

fullName

public String fullName()
Description copied from interface: NType
Human readable name of this type.

Specified by:
fullName in interface CClassInfoParent
Specified by:
fullName in interface NType

accept

public <T> T accept(CClassInfoParent.Visitor<T> visitor)
Specified by:
accept in interface CClassInfoParent

getOwnerPackage

public com.sun.codemodel.JPackage getOwnerPackage()
Description copied from interface: CClassInfoParent
Gets the nearest JPackage.

Specified by:
getOwnerPackage in interface CClassInfoParent

shortName

public String shortName()

hasClass

public boolean hasClass()
True if this element has its own class (as opposed to be represented as an instance of JAXBElement.