com.sun.tools.xjc.model.CClassInfo Java Examples
The following examples show how to use
com.sun.tools.xjc.model.CClassInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GetVersionPropertyInfos.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 6 votes |
public Collection<CPropertyInfo> process(ProcessModel context, CClassInfo classInfo) { final Collection<CPropertyInfo> version = new LinkedList<CPropertyInfo>(); if (classInfo.getBaseClass() != null) { version.addAll(process(context, classInfo.getBaseClass())); } if (!CustomizationUtils.containsCustomization(classInfo, Customizations.IGNORED_ELEMENT_NAME)) { for (CPropertyInfo propertyInfo : classInfo.getProperties()) { if (CustomizationUtils.containsCustomization(propertyInfo, Customizations.VERSION_ELEMENT_NAME) && !CustomizationUtils.containsCustomization( propertyInfo, Customizations.IGNORED_ELEMENT_NAME)) { version.add(propertyInfo); } } } return version; }
Example #2
Source File: XJCCMInfoFactory.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 6 votes |
private MContainer getContainer(CClassInfoParent parent) { return parent.accept(new Visitor<MContainer>() { public MContainer onBean(CClassInfo bean) { return getTypeInfo(bean); } public MContainer onPackage(JPackage pkg) { return getPackage(pkg); } public MContainer onElement(CElementInfo element) { return getElementInfo(element); } }); }
Example #3
Source File: DefaultCustomizing.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 6 votes |
public Entity getEntity(CClassInfo classInfo) { final Persistence persistence = getModelCustomization(classInfo); if (persistence.getDefaultEntity() == null) { // TODO throw new AssertionError("Default entity element is not provided."); } final Entity defaultEntity = (Entity) persistence.getDefaultEntity() .copyTo(new Entity()); final Entity cEntity; if (CustomizationUtils.containsCustomization(classInfo, Customizations.ENTITY_ELEMENT_NAME)) { cEntity = findCustomization(classInfo, Customizations.ENTITY_ELEMENT_NAME, defaultEntity, this.<Entity> merge()); } else { addCustomization(classInfo, Customizations.ENTITY_ELEMENT_NAME, defaultEntity); return defaultEntity; } return cEntity; }
Example #4
Source File: DefaultCustomizing.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 6 votes |
public Object getEntityOrMappedSuperclassOrEmbeddable(CClassInfo classInfo) { // final Persistence persistence = getModelCustomization(classInfo); if (CustomizationUtils.containsCustomization(classInfo, Customizations.ENTITY_ELEMENT_NAME)) { return getEntity(classInfo); } else if (CustomizationUtils.containsCustomization(classInfo, Customizations.MAPPED_SUPERCLASS_ELEMENT_NAME)) { return getMappedSuperclass(classInfo); } else if (CustomizationUtils.containsCustomization(classInfo, Customizations.EMBEDDABLE_ELEMENT_NAME)) { return getEmbeddable(classInfo); } else { // Default is entity return getEntity(classInfo); } }
Example #5
Source File: DefaultCustomizing.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 6 votes |
public GeneratedVersion getGeneratedVersion(CClassInfo classInfo) { final Persistence persistence = getModelCustomization(classInfo); if (persistence.getDefaultGeneratedVersion() == null) { throw new AssertionError( "Default generated version element is not provided."); } final GeneratedVersion defaultGeneratedVersion = (GeneratedVersion) persistence .getDefaultGeneratedVersion().copyTo(new GeneratedVersion()); final GeneratedVersion generatedVersion; if (CustomizationUtils.containsCustomization(classInfo, Customizations.GENERATED_VERSION_ELEMENT_NAME)) { generatedVersion = findCustomization(classInfo, Customizations.GENERATED_VERSION_ELEMENT_NAME, defaultGeneratedVersion, this.<GeneratedVersion> merge()); } else { generatedVersion = defaultGeneratedVersion.isForced() ? defaultGeneratedVersion : null; } return generatedVersion; }
Example #6
Source File: DefaultCustomizing.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 6 votes |
public GeneratedProperty getGeneratedProperty(CClassInfo classInfo, String propertyName) { GeneratedProperty generatedProperty = null; if (classInfo != null && CustomizationUtils.containsCustomization(classInfo, Customizations.GENERATED_PROPERTY_ELEMENT_NAME)) { final Collection<GeneratedProperty> generatedProperties; generatedProperties = findCustomizations(classInfo, Customizations.GENERATED_PROPERTY_ELEMENT_NAME); for (GeneratedProperty p : generatedProperties) { if (propertyName.equals(p.getName())) { generatedProperty = p; } } } return generatedProperty; }
Example #7
Source File: GetIdPropertyInfos.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 6 votes |
public Collection<CPropertyInfo> process(ProcessModel context, CClassInfo classInfo) { final Collection<CPropertyInfo> ids = new LinkedList<CPropertyInfo>(); if (classInfo.getBaseClass() != null) { ids.addAll(process(context, classInfo.getBaseClass())); } if (!CustomizationUtils.containsCustomization(classInfo, Customizations.IGNORED_ELEMENT_NAME)) { for (CPropertyInfo propertyInfo : classInfo.getProperties()) { if ((CustomizationUtils.containsCustomization(propertyInfo, Customizations.ID_ELEMENT_NAME) || CustomizationUtils .containsCustomization(propertyInfo, Customizations.EMBEDDED_ID_ELEMENT_NAME)) && !CustomizationUtils.containsCustomization( propertyInfo, Customizations.IGNORED_ELEMENT_NAME)) { ids.add(propertyInfo); } } } return ids; }
Example #8
Source File: DefaultCustomizing.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 6 votes |
public GeneratedId getGeneratedId(CClassInfo classInfo) { final Persistence persistence = getModelCustomization(classInfo); if (persistence.getDefaultGeneratedId() == null) { throw new AssertionError("Default id element is not provided."); } final GeneratedId defaultId = (GeneratedId) persistence .getDefaultGeneratedId().copyTo(new GeneratedId()); final GeneratedId id; if (CustomizationUtils.containsCustomization(classInfo, Customizations.GENERATED_ID_ELEMENT_NAME)) { id = findCustomization(classInfo, Customizations.GENERATED_ID_ELEMENT_NAME, defaultId, this.<GeneratedId> merge()); } else { id = defaultId; } return id; }
Example #9
Source File: DefaultCustomizing.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 6 votes |
public MappedSuperclass getMappedSuperclass(CClassInfo classInfo) { final Persistence persistence = getModelCustomization(classInfo); if (persistence.getDefaultMappedSuperclass() == null) { // TODO throw new AssertionError( "Default mapped superclass element is not provided."); } final MappedSuperclass defaultMappedSuperclass = (MappedSuperclass) persistence .getDefaultMappedSuperclass().copyTo(new MappedSuperclass()); final MappedSuperclass cMappedSuperclass; if (CustomizationUtils.containsCustomization(classInfo, Customizations.MAPPED_SUPERCLASS_ELEMENT_NAME)) { cMappedSuperclass = findCustomization(classInfo, Customizations.MAPPED_SUPERCLASS_ELEMENT_NAME, defaultMappedSuperclass, this.<MappedSuperclass> merge()); } else { return defaultMappedSuperclass; } return cMappedSuperclass; }
Example #10
Source File: DefaultCustomizing.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 6 votes |
public Embeddable getEmbeddable(CClassInfo classInfo) { final Persistence persistence = getModelCustomization(classInfo); if (persistence.getDefaultEmbeddable() == null) { // TODO throw new AssertionError( "Default embeddable element is not provided."); } final Embeddable defaultEmbeddable = (Embeddable) persistence .getDefaultEmbeddable().copyTo(new Embeddable()); final Embeddable cEmbeddable; if (CustomizationUtils.containsCustomization(classInfo, Customizations.EMBEDDABLE_ELEMENT_NAME)) { cEmbeddable = findCustomization(classInfo, Customizations.EMBEDDABLE_ELEMENT_NAME, defaultEmbeddable, this.<Embeddable> merge()); } else { return defaultEmbeddable; } return cEmbeddable; }
Example #11
Source File: DefaultCreateDefaultVersionPropertyInfos.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 6 votes |
public Collection<CPropertyInfo> process(ProcessModel context, CClassInfo classInfo) { final GeneratedVersion cversion = context.getCustomizing() .getGeneratedVersion(classInfo); if (cversion == null) { return Collections.emptyList(); } else { final CPropertyInfo propertyInfo = createPropertyInfo(context, classInfo, cversion); return Collections.singletonList(propertyInfo); } }
Example #12
Source File: DefaultProcessPropertyInfos.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 6 votes |
public boolean isSelfOrAncestorRootClass(ProcessModel context, CClassInfo classInfo) { if (isRootClass(context, classInfo)) { return true; } else if (classInfo.getRefBaseClass() != null) { return isSelfOrAncestorRootClass(context, classInfo.getRefBaseClass()); } else if (classInfo.getBaseClass() != null) { return isSelfOrAncestorRootClass(context, classInfo.getBaseClass()); } else { return !CustomizationUtils.containsCustomization(classInfo, Customizations.MAPPED_SUPERCLASS_ELEMENT_NAME) && !CustomizationUtils.containsCustomization(classInfo, Customizations.EMBEDDABLE_ELEMENT_NAME); } }
Example #13
Source File: DefaultIgnoring.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 6 votes |
public boolean isClassInfoIgnored(ProcessModel context, CClassInfo classInfo) { if (isPackageInfoIgnored(context, classInfo.model, getPackageInfo(classInfo))) { logger.debug("Class info is ignored since package is ignored."); markAsAcknowledged(classInfo); return true; } else if (CustomizationUtils.containsCustomization(classInfo, Customizations.IGNORED_ELEMENT_NAME)) { logger.debug("Class info is ignored per customization."); markAsAcknowledged(classInfo); return true; } else if (classInfo.getBaseClass() != null && isClassInfoIgnored(context, classInfo.getBaseClass())) { logger.debug("Class info is ignored since base class info is ignored."); markAsAcknowledged(classInfo); return true; } else { return false; } }
Example #14
Source File: DefaultGetTypes.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 6 votes |
public Collection<? extends CTypeInfo> ref(C context, CPropertyInfo propertyInfo) { final Collection<? extends CTypeInfo> types = propertyInfo.ref(); final JType baseType = propertyInfo.baseType; final ID id = propertyInfo.id(); final CTypeInfo parent = propertyInfo.parent(); if (ID.IDREF.equals(id) && baseType != null) { if (parent instanceof CClassInfo) { final CClassInfo parentClassInfo = (CClassInfo) parent; final String fullName = baseType.fullName(); for (CClassInfo possibleClassInfo : parentClassInfo.model .beans().values()) { final String possibleFullName = possibleClassInfo .fullName(); if (fullName != null && fullName.equals(possibleFullName)) { return Collections.singleton(possibleClassInfo); } } } } return types; }
Example #15
Source File: SchemaAnnotationUtils.java From jaxb2-rich-contract-plugin with MIT License | 6 votes |
public static String getClassAnnotationDescription(CClassInfo classInfo) { // To get annotations in the class level javadoc, there needs to be an annotation // element as a child of the complexType element (be it named or anonymous), e.g. //<xs:element name="SomeElement"> // <xs:complexType> // <xs:annotation> // <xs:documentation>This annotation will be used in the class javadoc</xs:documentation> // </xs:annotation> // or // <xs:complexType name="SomeComplexType"> // <xs:annotation> // <xs:documentation>This annotation will be used in the class javadoc</xs:documentation> // </xs:annotation> XSAnnotation annotation = classInfo.getSchemaComponent().getAnnotation(); return resolveDescription(annotation); }
Example #16
Source File: EjbPlugin.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 6 votes |
private void checkCustomizations(CClassInfo classInfo, CPropertyInfo customizable) { for (CPluginCustomization pluginCustomization : CustomizationUtils .getCustomizations(customizable)) { if (!pluginCustomization.isAcknowledged() && Customizations.NAMESPACE_URI .equals(pluginCustomization.element .getNamespaceURI())) { logger.warn("Unacknowledged customization [" + getName(pluginCustomization.element) + "] in the property [" + classInfo.getName() + "." + customizable.getName(true) + "]."); pluginCustomization.markAsAcknowledged(); } } }
Example #17
Source File: SimplifyPlugin.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 6 votes |
private void postProcessReferencePropertyInfo(final Model model, final CClassInfo classInfo, CReferencePropertyInfo property) { if (CustomizationUtils .containsPropertyCustomizationInPropertyOrClass( property, org.jvnet.jaxb2_commons.plugin.simplify.Customizations.PROPERTY_ELEMENT_NAME, org.jvnet.jaxb2_commons.plugin.simplify.Customizations.AS_ELEMENT_PROPERTY_ELEMENT_NAME)) { simplifyReferencePropertyInfoAsElementPropertyInfo(model, classInfo, property); } else if (CustomizationUtils .containsPropertyCustomizationInPropertyOrClass( property, org.jvnet.jaxb2_commons.plugin.simplify.Customizations.PROPERTY_ELEMENT_NAME, org.jvnet.jaxb2_commons.plugin.simplify.Customizations.AS_REFERENCE_PROPERTY_ELEMENT_NAME)) { simplifyReferencePropertyInfoAsReferencePropertyInfo(model, classInfo, property); } }
Example #18
Source File: SimplifyPlugin.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 6 votes |
private void simplifyElementPropertyInfoAsElementPropertyInfo( final Model model, final CClassInfo classInfo, CElementPropertyInfo property) { if (property.getTypes().size() > 1) { logger.debug(MessageFormat .format("Element property [{0}] has several types and will be simplified.", property.getName(false))); int index = classInfo.getProperties().indexOf(property); for (CTypeRef typeRef : property.getTypes()) { final CElementPropertyInfo elementPropertyInfo = createElementPropertyInfo( model, property, typeRef); classInfo.getProperties().add(index++, elementPropertyInfo); } classInfo.getProperties().remove(property); } else { logger.warn(MessageFormat .format("Element property [{0}] will not be simplified as it does not contain multiple types.", property.getName(false))); } }
Example #19
Source File: SimplifyPlugin.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 6 votes |
private void simplifyReferencePropertyInfoAsReferencePropertyInfo( final Model model, final CClassInfo classInfo, CReferencePropertyInfo property) { if (property.getElements().size() <= 1 && !property.isMixed()) { logger.warn(MessageFormat .format("Element reference property [{0}] will not be simplified as it does not contain multiple elements and is not mixed.", property.getName(false))); } else { logger.debug(MessageFormat .format("Element reference property [{0}] contains multiple elements or is mixed and will be simplified.", property.getName(false))); int index = classInfo.getProperties().indexOf(property); for (CElement element : property.getElements()) { final CReferencePropertyInfo referencePropertyInfo = createReferencePropertyInfo( model, property, element); classInfo.getProperties().add(index++, referencePropertyInfo); } if (property.isMixed()) { classInfo.getProperties().add(index++, createContentReferencePropertyInfo(model, property)); } classInfo.getProperties().remove(property); } }
Example #20
Source File: DefaultProcessModel.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 5 votes |
private void orderClassInfo(CClassInfo classInfo, List<CClassInfo> orderedClassInfos, Set<CClassInfo> addedClassInfos) { if (!addedClassInfos.contains(classInfo)) { if (classInfo.getBaseClass() != null) { orderClassInfo(classInfo.getBaseClass(), orderedClassInfos, addedClassInfos); } orderedClassInfos.add(classInfo); addedClassInfos.add(classInfo); } }
Example #21
Source File: SchemaAnnotationUtils.java From jaxb2-rich-contract-plugin with MIT License | 5 votes |
public static String getFieldAnnotationDescription(CPropertyInfo propertyInfo) { XSAnnotation annotation = resolveXSAnnotation(propertyInfo.getSchemaComponent()); String annotationText = resolveDescription(annotation); // if there is no annotation on the element itself then see if there is an annotation for the type // of that element (e.g. its anonymous or named type) //<xs:element name="SomeElement"> // <xs:annotation> // <xs:documentation>This is the annotation for the element so will be considered first.</xs:documentation> // </xs:annotation> // <xs:complexType> // <xs:annotation> // <xs:documentation>This is the annotation for the type so will be considered second</xs:documentation> // </xs:annotation> if (annotationText.isEmpty()) { if (propertyInfo instanceof CElementPropertyInfo) { CElementPropertyInfo elementPropertyInfo = (CElementPropertyInfo) propertyInfo; if (elementPropertyInfo.getTypes() != null && !elementPropertyInfo.getTypes().isEmpty()) { CNonElement target = elementPropertyInfo.getTypes().get(0).getTarget(); if (target instanceof CClassInfo) { annotationText = getClassAnnotationDescription((CClassInfo) target); } } } } return annotationText; }
Example #22
Source File: DefaultCreateDefaultIdPropertyInfos.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 5 votes |
protected CPropertyInfo createPropertyInfo(ProcessModel context, CClassInfo classInfo) { final GeneratedId cid = context.getCustomizing().getGeneratedId( classInfo); final String propertyName = getPropertyName(context, cid); final QName attributeName = getAttributeName(context, cid); final CNonElement propertyTypeInfo = getPropertyTypeInfo(context, cid); final CCustomizations customizations = new CCustomizations(); final CPluginCustomization id = createIdCustomization(context, cid); customizations.add(id); // // CPluginCustomization generated = CustomizationUtils // .createCustomization(org.jvnet.jaxb2_commons.plugin.Customizations.GENERATED_ELEMENT_NAME); // generated.markAsAcknowledged(); // customizations.add(generated); final CPropertyInfo propertyInfo = new CAttributePropertyInfo( propertyName, null, customizations, null, attributeName, propertyTypeInfo, propertyTypeInfo.getTypeName(), false); if (cid.isTransient() != null && cid.isTransient()) { propertyInfo.realization = new GenericFieldRenderer( TransientSingleField.class); } Customizations.markGenerated(propertyInfo); return propertyInfo; }
Example #23
Source File: DefaultCreateDefaultVersionPropertyInfos.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 5 votes |
protected CPropertyInfo createPropertyInfo(ProcessModel context, CClassInfo classInfo, GeneratedVersion cversion) { final String propertyName = getPropertyName(context, cversion); final QName attributeName = getAttributeName(context, cversion); final CNonElement propertyTypeInfo = getPropertyTypeInfo(context, cversion); final CCustomizations customizations = new CCustomizations(); final CPluginCustomization version = createVersionCustomization(context, cversion); customizations.add(version); // // CPluginCustomization generated = CustomizationUtils // .createCustomization(org.jvnet.jaxb2_commons.plugin.Customizations.GENERATED_ELEMENT_NAME); // generated.markAsAcknowledged(); // customizations.add(generated); final CPropertyInfo propertyInfo = new CAttributePropertyInfo( propertyName, null, customizations, null, attributeName, propertyTypeInfo, propertyTypeInfo.getTypeName(), false); if (cversion.isTransient() != null && cversion.isTransient()) { propertyInfo.realization = new GenericFieldRenderer( TransientSingleField.class); } Customizations.markGenerated(propertyInfo); return propertyInfo; }
Example #24
Source File: DefaultCustomizing.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 5 votes |
public GeneratedProperty getGeneratedProperty(CPropertyInfo propertyInfo) { final GeneratedProperty generatedProperty; if (CustomizationUtils.containsCustomization(propertyInfo, Customizations.GENERATED_PROPERTY_ELEMENT_NAME)) { generatedProperty = findCustomization(propertyInfo, Customizations.GENERATED_PROPERTY_ELEMENT_NAME); } else { generatedProperty = getGeneratedProperty( (CClassInfo) propertyInfo.parent(), propertyInfo.getName(true)); } return generatedProperty; }
Example #25
Source File: AbstractWrappingField.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 5 votes |
public JClass getScope(CClassInfo scope) { if (scope == null) { return codeModel.ref(GlobalScope.class); } else { return scope.toType(outline.parent(), Aspect.EXPOSED); } }
Example #26
Source File: CustomizationsPlugin.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 5 votes |
private void postProcessClassInfo(Model model, CClassInfo classInfo) { final String packagedClassName = ClassUtils.getPackagedClassName(classInfo); final String customizationsFileName = packagedClassName.replace(".", "/") + ".xml"; final List<CPluginCustomization> customizations = readCustomizations(customizationsFileName); classInfo.getCustomizations().addAll(customizations); for (CPropertyInfo propertyInfo: classInfo.getProperties()) { postProcessPropertyInfo(model, classInfo, propertyInfo); } }
Example #27
Source File: EjbPlugin.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 5 votes |
private void checkCustomizations(Outline outline) { for (final CClassInfo classInfo : outline.getModel().beans().values()) { checkCustomizations(classInfo); for (final CPropertyInfo propertyInfo : classInfo.getProperties()) { checkCustomizations(classInfo, propertyInfo); } } }
Example #28
Source File: CustomizationsPlugin.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 5 votes |
private void postProcessModel(Model model) { for (final CClassInfo classInfo : model.beans().values()) { postProcessClassInfo(model, classInfo); } for (final CEnumLeafInfo enumLeafInfo : model.enums().values()) { postProcessEnumLeafInfo(model, enumLeafInfo); } }
Example #29
Source File: CustomizedIgnoring.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 5 votes |
public boolean isIgnored(CClassInfo classInfo) { for (QName name : getIgnoredCustomizationElementNames()) { if (CustomizationUtils.containsCustomization(classInfo, name)) { return true; } } return false; }
Example #30
Source File: InheritancePlugin.java From jpmml-model with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void postProcessModel(Model model, ErrorHandler errorHandler){ super.postProcessModel(model, errorHandler); Map<String, CClassRef> classRefCache = new HashMap<>(); CClassRef defaultBaseClazz = getClassRef(classRefCache, model, "org.dmg.pmml.PMMLObject"); Collection<CClassInfo> classInfos = (model.beans()).values(); for(CClassInfo classInfo : classInfos){ CClassRef baseClazz = defaultBaseClazz; CPluginCustomization extendsCustomization = CustomizationUtils.findCustomization(classInfo, Customizations.EXTENDS_ELEMENT_NAME); if(extendsCustomization != null){ ExtendsClass extendsClass = (ExtendsClass)CustomizationUtils.unmarshall(Customizations.getContext(), extendsCustomization); String name = getClassName(extendsClass); int lt = name.indexOf('<'); if(lt > -1){ name = name.substring(0, lt); } baseClazz = getClassRef(classRefCache, model, name); } classInfo.setBaseClass(baseClazz); } }