com.sun.tools.xjc.model.CNonElement Java Examples

The following examples show how to use com.sun.tools.xjc.model.CNonElement. 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: SingleWrappingReferenceField.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
protected JClass getDeclaredType() {

		final CElementPropertyInfo property = getElementInfo().getProperty();

		if (property.getAdapter() == null) {
			@SuppressWarnings("unused")
			final CNonElement type = property.ref().iterator().next();
			final JClass declaredType = (JClass) getType().toType(
					outline.parent(), Aspect.EXPOSED);
			return declaredType;
		}
		else
		{
			return (JClass) property.getAdapter().customType.toType(outline.parent(), Aspect.EXPOSED);
			
		}
	}
 
Example #2
Source File: AbstractAdaptPropertyInfo.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public CPropertyInfo createElementPropertyInfo(String propertyName,
		XSComponent source, TypeUse propertyType, QName propertyQName,
		CollectionMode collectionMode, CCustomizations customizations) {

	final CNonElement propertyTypeInfo = propertyType.getInfo();

	final CElementPropertyInfo propertyInfo = new CElementPropertyInfo(
			propertyName, collectionMode, propertyTypeInfo.idUse(),
			propertyTypeInfo.getExpectedMimeType(), source, customizations,
			null, true);

	final CTypeRef typeRef = new CTypeRef(propertyTypeInfo, propertyQName,
			propertyTypeInfo.getTypeName(), false, null);

	propertyInfo.setAdapter(propertyType.getAdapterUse());

	propertyInfo.getTypes().add(typeRef);
	return propertyInfo;
}
 
Example #3
Source File: DefaultCreateDefaultIdPropertyInfos.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public CNonElement getPropertyTypeInfo(ProcessModel context, GeneratedId id) {
	// final GeneratedId id =
	// context.getCustomizing().getGeneratedId(classInfo);
	final String javaType = id.getJavaType();
	Validate.notEmpty(javaType,
			"The hj:id/@javaType attribute must not be empty.");
	final QName schemaType = id.getSchemaType();
	Validate.notNull(schemaType,
			"The hj:id/@schemaType attribute must not be null.");
	try {
		final Class<?> theClass = ClassUtils.forName(javaType);
		return new CExternalLeafInfo(theClass, schemaType, null);
	} catch (ClassNotFoundException cnfex) {
		throw new IllegalArgumentException(
				"Class name ["
						+ javaType
						+ "] provided in the hj:id/@javaType attribute could not be resolved.",
				cnfex);
	}
}
 
Example #4
Source File: DefaultCreateDefaultVersionPropertyInfos.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public CNonElement getPropertyTypeInfo(ProcessModel context,
		GeneratedVersion cversion) {
	final String javaType = cversion.getJavaType();
	Validate.notEmpty(javaType,
			"The hj:version/@javaType attribute must not be empty.");
	final QName schemaType = cversion.getSchemaType();
	Validate.notNull(schemaType,
			"The hj:version/@schemaType attribute must not be null.");
	try {
		final Class<?> theClass = ClassUtils.forName(javaType);
		return new CExternalLeafInfo(theClass, schemaType, null);
	} catch (ClassNotFoundException cnfex) {
		throw new IllegalArgumentException(
				"Class name ["
						+ javaType
						+ "] provided in the hj:version/@javaType attribute could not be resolved.",
				cnfex);
	}
}
 
Example #5
Source File: SchemaAnnotationUtils.java    From jaxb2-rich-contract-plugin with MIT License 5 votes vote down vote up
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 #6
Source File: FieldUtils.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static FieldOutline createAttributeField(
		ClassOutlineImpl classOutline, String name, final QName attName,
		final CNonElement typeInfo, final boolean required
// ,
// final XSDatatype datatype,
// final JType type
) {

	final CPropertyInfo propertyInfo = new CAttributePropertyInfo(
	// name
			name,
			// source
			null, new CCustomizations(),
			// locator
			null,
			// attName
			attName,
			// typeUse
			typeInfo,
			// typeName
			typeInfo.getTypeName(),
			// required
			required);

	propertyInfo.realization = new FieldRendererFactory().getDefault();
	final FieldOutline fieldOutline =

	propertyInfo.realization.generate(classOutline, propertyInfo);

	return fieldOutline;

}
 
Example #7
Source File: BuilderGenerator.java    From jaxb2-rich-contract-plugin with MIT License 5 votes vote down vote up
private JType getTagRefType(final PropertyOutline.TagRef tagRef, final Outline outline, final Aspect aspect) {
	final TypeInfo<NType, NClass> typeInfo = tagRef.getTypeInfo();
	final JType type;
	if (typeInfo instanceof CClassInfo) {
		type = ((CClassInfo) typeInfo).toType(outline, aspect);
	} else if (typeInfo instanceof CElementInfo) {
		final List<CNonElement> refs = ((CElementInfo) typeInfo).getProperty().ref();
		// This feels dirty but am not sure what we do if we get multiple refs
		if (refs.size() == 1) {
			try {
				type = ((CClassInfo) refs.get(0)).toType(outline, aspect);
			} catch (Exception e) {
				throw new RuntimeException(String.format("Unexpected type %s for tagRef %s",
						refs.get(0).getClass().getCanonicalName(),
						tagRef.getTagName()));
			}
		} else {
			throw new RuntimeException(String.format("Expecting one ref type for tagRef %s, found %s",
					tagRef.getTagName(),
					refs.size()));
		}
	} else {
		throw new RuntimeException(String.format("Unexpected type %s for tagRef %s",
				typeInfo.getClass().getCanonicalName(),
				tagRef.getTagName()));
	}
	return type;
}
 
Example #8
Source File: DefaultCreateDefaultIdPropertyInfos.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #9
Source File: DefaultCreateDefaultVersionPropertyInfos.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #10
Source File: CClassifyingVisitor.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public U onValue(CValuePropertyInfo valuePropertyInfo) {
	final CNonElement type = context.getGetTypes().getTarget(context,
			valuePropertyInfo);
	if (type instanceof CBuiltinLeafInfo) {
		return onBuiltinValue(valuePropertyInfo);
	} else if (type instanceof CEnumLeafInfo) {
		return onEnumValue(valuePropertyInfo);
	} else {
		return onOtherValue(valuePropertyInfo);
	}
}
 
Example #11
Source File: CClassifyingVisitor.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public U onAttribute(CAttributePropertyInfo attributePropertyInfo) {

		final CNonElement type = context.getGetTypes().getTarget(context,
				attributePropertyInfo);
		if (type instanceof CBuiltinLeafInfo) {
			return onBuiltinAttribute(attributePropertyInfo);
		} else if (type instanceof CEnumLeafInfo) {
			return onEnumAttribute(attributePropertyInfo);
		} else {
			return onOtherAttribute(attributePropertyInfo);
		}
	}
 
Example #12
Source File: DefaultTypeUse.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public DefaultTypeUse(CNonElement itemType, boolean collection, ID id,
		MimeType expectedMimeType, CAdapter adapter) {
	this.coreType = itemType;
	this.collection = collection;
	this.id = id;
	this.expectedMimeType = expectedMimeType;
	this.adapter = adapter;
}
 
Example #13
Source File: JAXBElementNameField.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public JAXBElementNameField(final ClassOutlineImpl context,
		final CPropertyInfo prop, final CReferencePropertyInfo core,
		final CPropertyInfo valueProperty, final CNonElement type) {
	super(context, prop, core);
	this.valueProperty = valueProperty;
	this.valueField = JExpr.refthis(valueProperty.getName(false));
	this.elementType = type;
}
 
Example #14
Source File: JAXBElementValueField.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public JAXBElementValueField(ClassOutlineImpl context, CPropertyInfo prop,
		CReferencePropertyInfo core, CPropertyInfo nameProperty,
		CNonElement type) {
	super(context, prop, core);
	this.nameProperty = nameProperty;
	this.nameField = JExpr.refthis(nameProperty.getName(false));
	this.type = type;
}
 
Example #15
Source File: DefaultGetTypes.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public CNonElement getTarget(C context, CAttributePropertyInfo propertyInfo) {
	return propertyInfo.getTarget();
}
 
Example #16
Source File: DefaultGetTypes.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public CNonElement getTarget(C context, CValuePropertyInfo propertyInfo) {
	return propertyInfo.getTarget();
}
 
Example #17
Source File: DefaultTypeUse.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public CNonElement getInfo() {
	return coreType;
}
 
Example #18
Source File: SingleWrappingReferenceField.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 4 votes vote down vote up
protected CNonElement getType() {
	final CElementPropertyInfo property = getElementInfo().getProperty();
	final CNonElement type = property.ref().iterator().next();
	return type;
}
 
Example #19
Source File: GetTypes.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License votes vote down vote up
public CNonElement getTarget(C context, CAttributePropertyInfo propertyInfo); 
Example #20
Source File: GetTypes.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License votes vote down vote up
public CNonElement getTarget(C context, CValuePropertyInfo propertyInfo);