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

The following examples show how to use com.sun.tools.xjc.model.CReferencePropertyInfo. 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: SimplifyPlugin.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 #2
Source File: SimplifyPlugin.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 #3
Source File: AbstractField.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Annotate the field according to the recipes given as {@link CPropertyInfo}.
 */
protected void annotate( JAnnotatable field ) {

    assert(field!=null);

    if (prop instanceof CAttributePropertyInfo) {
        annotateAttribute(field);
    } else if (prop instanceof CElementPropertyInfo) {
        annotateElement(field);
    } else if (prop instanceof CValuePropertyInfo) {
        field.annotate(XmlValue.class);
    } else if (prop instanceof CReferencePropertyInfo) {
        annotateReference(field);
    }

    outline.parent().generateAdapterIfNecessary(prop,field);
}
 
Example #4
Source File: AbstractWrapCollectionField.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
protected void fix(final JBlock body) {

		// final JFieldRef wrappedPropertyField = field;
		//
		// final JFieldRef wrappingPropertyField = itemsField;

		body._if(wrappingPropertyField.eq(JExpr._null()))._then().assign(
				wrappingPropertyField,
				JExpr._new(codeModel.ref(ArrayList.class).narrow(
						wrappingPropertyExposedType.boxify())));

		final JClass utilsClass =

		(wrappedProperty instanceof CReferencePropertyInfo && ((CReferencePropertyInfo) wrappedProperty)
				.isMixed()) ? codeModel.ref(MixedItemUtils.class) : codeModel
				.ref(ItemUtils.class);
		body._if(
				utilsClass.staticInvoke("shouldBeWrapped").arg(
						wrappedPropertyField))._then().assign(
				wrappedPropertyField,

				utilsClass.staticInvoke("wrap").arg(wrappedPropertyField).arg(
						wrappingPropertyField).arg(
						wrappingPropertyExposedType.boxify().dotclass()));
	}
 
Example #5
Source File: SingleWrappingReferenceObjectField.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public SingleWrappingReferenceObjectField(ClassOutlineImpl context,
		CPropertyInfo prop, CReferencePropertyInfo core,
		String contextPath, boolean _final) {
	super(context, prop, core);
	this.contextPath = context.implClass.field(JMod.PUBLIC | JMod.STATIC
			| (_final ? JMod.FINAL : JMod.NONE), String.class, prop
			.getName(true)
			+ "ContextPath", JExpr.lit(contextPath));
}
 
Example #6
Source File: WrapSingleSubstitutedElementReference.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public CElementInfo getElementInfo(ProcessModel context,
		final CReferencePropertyInfo referencePropertyInfo) {
	final CElement element = context.getGetTypes()
			.getElements(context, referencePropertyInfo).iterator().next();
	assert element instanceof CElementInfo;

	final CElementInfo elementInfo = (CElementInfo) element;
	return elementInfo;
}
 
Example #7
Source File: SimplifyPlugin.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private CReferencePropertyInfo createContentReferencePropertyInfo(
		final Model model, CReferencePropertyInfo property) {
	final String propertyName = "Mixed" + property.getName(true);
	final CReferencePropertyInfo referencePropertyInfo = new CReferencePropertyInfo(
			propertyName, /* collection */true, /* required */false, /* mixed */
			true, property.getSchemaComponent(),
			property.getCustomizations(), property.getLocator(), false,
			true, property.isMixedExtendedCust());
	return referencePropertyInfo;
}
 
Example #8
Source File: SimplifyPlugin.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private CReferencePropertyInfo createReferencePropertyInfo(
		final Model model, CReferencePropertyInfo property, CElement element) {
	final String propertyName = createPropertyName(model, property, element);
	final CReferencePropertyInfo referencePropertyInfo = new CReferencePropertyInfo(
			propertyName, property.isCollection(), /* required */false,/* mixed */
			false, element.getSchemaComponent(),
			element.getCustomizations(), element.getLocator(),
			property.isDummy(), property.isContent(),
			property.isMixedExtendedCust());
	referencePropertyInfo.getElements().add(element);
	return referencePropertyInfo;
}
 
Example #9
Source File: SimplifyPlugin.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void postProcessClassInfo(final Model model,
		final CClassInfo classInfo) {
	final List<CPropertyInfo> properties = new ArrayList<CPropertyInfo>(
			classInfo.getProperties());
	for (CPropertyInfo property : properties) {
		property.accept(new CPropertyVisitor<Void>() {

			public Void onElement(CElementPropertyInfo elementProperty) {
				postProcessElementPropertyInfo(model, classInfo,
						elementProperty);
				return null;
			}

			public Void onAttribute(CAttributePropertyInfo attributeProperty) {
				// TODO Auto-generated method stub
				return null;
			}

			public Void onValue(CValuePropertyInfo valueProperty) {
				// TODO Auto-generated method stub
				return null;
			}

			public Void onReference(CReferencePropertyInfo p) {
				postProcessReferencePropertyInfo(model, classInfo, p);
				return null;
			}

		});
	}
}
 
Example #10
Source File: DefaultProcessPropertyInfos.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Collection<CPropertyInfo> onCollectionClassElementReference(
		CReferencePropertyInfo referencePropertyInfo) {
	logger.error("["
			+ referencePropertyInfo.getName(true)
			+ "] is a collection class element reference. See issue #71.");
	return Collections.emptyList();
}
 
Example #11
Source File: SingleWrappingReferenceField.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected CElementInfo getElementInfo() {
	final CReferencePropertyInfo referencePropertyInfo = (CReferencePropertyInfo) core;

	final Collection<CElement> elements = referencePropertyInfo
			.getElements();

	final CElement element = elements.iterator().next();

	final CElementInfo elementInfo = (CElementInfo) element.getType();
	return elementInfo;
}
 
Example #12
Source File: CClassifyingVisitor.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public U onArrayElementReference(
		CReferencePropertyInfo referencePropertyInfo) {
	return !referencePropertyInfo.isCollection() ? classifier
			.onSingleArrayElementReference(referencePropertyInfo)
			: classifier
					.onCollectionArrayElementReference(referencePropertyInfo);
}
 
Example #13
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 #14
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 #15
Source File: SingleWrappingReferenceObjectField.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public JExpression unwrapCondifiton(JExpression source) {

	final CReferencePropertyInfo core = (CReferencePropertyInfo) this.core;

	JExpression predicate = null;
	if (core.getElements().isEmpty()) {
		predicate = null;
	} else {
		for (CElement element : core.getElements()) {
			if (element instanceof CElementInfo) {
				CElementInfo elementinfo = (CElementInfo) element;

				final SingleWrappingReferenceElementInfoField field = new SingleWrappingReferenceElementInfoField(
						outline, prop, core, elementinfo);
				final JExpression condition = field
						.unwrapCondifiton(source);
				predicate = (predicate == null) ? condition : JOp.cor(
						predicate, condition);
			} else {
				// TODO Other cases currently not supported.
			}
		}
	}

	final JExpression isElement = codeModel.ref(JAXBContextUtils.class)
			.staticInvoke("isElement").arg(contextPath).arg(source);
	return predicate == null ? isElement : JOp.cand(JOp.not(predicate),
			isElement);
}
 
Example #16
Source File: DefaultProcessPropertyInfos.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Collection<CPropertyInfo> onCollectionEnumElementReference(
		CReferencePropertyInfo referencePropertyInfo) {
	logger.error("["
			+ referencePropertyInfo.getName(true)
			+ "] is a collection enum element reference. See issue #68 (http://java.net/jira/browse/HYPERJAXB3-68).");
	return Collections.emptyList();
}
 
Example #17
Source File: DefaultProcessPropertyInfos.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Collection<CPropertyInfo> onCollectionBuiltinElementReference(
		CReferencePropertyInfo referencePropertyInfo) {

	logger.error("["
			+ referencePropertyInfo.getName(true)
			+ "] is a collection builtin element reference. See issue #67 (http://java.net/jira/browse/HYPERJAXB3-67).");
	return Collections.emptyList();
}
 
Example #18
Source File: DefaultProcessPropertyInfos.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Collection<CPropertyInfo> onSingleClassReference(
		CReferencePropertyInfo referencePropertyInfo) {
	// logger.error("[" + referencePropertyInfo.getName(true)
	// + "] is a single class reference. See issue #66.");
	// return Collections.emptyList();
	return context.getWrapSingleClassReference().process(context,
			referencePropertyInfo);
}
 
Example #19
Source File: CClassifyingVisitor.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public U onSubstitutedElementReference(
		CReferencePropertyInfo referencePropertyInfo) {
	return !referencePropertyInfo.isCollection() ? classifier
			.onSingleSubstitutedElementReference(referencePropertyInfo)
			: classifier
					.onCollectionSubstitutedElementReference(referencePropertyInfo);
}
 
Example #20
Source File: CClassifyingVisitor.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public U onBuiltinElementReference(
		CReferencePropertyInfo referencePropertyInfo) {
	return !referencePropertyInfo.isCollection() ? classifier
			.onSingleBuiltinElementReference(referencePropertyInfo)
			: classifier
					.onCollectionBuiltinElementReference(referencePropertyInfo);
}
 
Example #21
Source File: CClassifyingVisitor.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public U onClassElementReference(
		CReferencePropertyInfo referencePropertyInfo) {
	return !referencePropertyInfo.isCollection() ? classifier
			.onSingleClassElementReference(referencePropertyInfo)
			: classifier
					.onCollectionClassElementReference(referencePropertyInfo);
}
 
Example #22
Source File: DefaultProcessPropertyInfos.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public Collection<CPropertyInfo> onCollectionArrayElementReference(
		CReferencePropertyInfo referencePropertyInfo) {
	throw new UnsupportedOperationException("Arrays are not supported.");
}
 
Example #23
Source File: DefaultProcessPropertyInfos.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public Collection<CPropertyInfo> onSingleBuiltinElementReference(
		CReferencePropertyInfo referencePropertyInfo) {
	return context.getWrapSingleBuiltinElementReference().process(
			context, referencePropertyInfo);
}
 
Example #24
Source File: DefaultGetTypes.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public Set<com.sun.tools.xjc.model.CElement> getElements(C context,
		CReferencePropertyInfo referencePropertyInfo) {

	return referencePropertyInfo.getElements();
}
 
Example #25
Source File: WrapSingleHeteroReference.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 4 votes vote down vote up
protected Collection<CPropertyInfo> createElementProperties(
		ProcessModel context, final CReferencePropertyInfo propertyInfo) {

	Set<CElement> elements = context.getGetTypes().getElements(context,
			propertyInfo);

	final Collection<CPropertyInfo> properties = new ArrayList<CPropertyInfo>(
			elements.size());

	for (CElement element : elements) {

		final CElementPropertyInfo itemPropertyInfo = new CElementPropertyInfo(
				propertyInfo.getName(true)
						+ ((CClassInfo) propertyInfo.parent()).model
								.getNameConverter().toPropertyName(
										element.getElementName()
												.getLocalPart()),
				CollectionMode.NOT_REPEATED, ID.NONE,
				propertyInfo.getExpectedMimeType(),
				propertyInfo.getSchemaComponent(),
				new CCustomizations(CustomizationUtils
						.getCustomizations(propertyInfo)),
				propertyInfo.getLocator(), false);

		if (element instanceof CElementInfo) {
			final CElementInfo elementInfo = (CElementInfo) element;
			if (!elementInfo.getSubstitutionMembers().isEmpty()) {
				logger.error("["
						+ ((CClassInfo) propertyInfo.parent()).getName()
						+ "."
						+ propertyInfo.getName(true)
						+ "] is a single hetero reference containing element ["
						+ elementInfo.getSqueezedName()
						+ "] which is a substitution group head. See issue #95.");
			} else {
				itemPropertyInfo.getTypes().addAll(
						context.getGetTypes().getTypes(context,
								((CElementInfo) element).getProperty()));

				itemPropertyInfo.realization = new FieldRenderer() {
					public FieldOutline generate(
							ClassOutlineImpl classOutline, CPropertyInfo p) {
						SingleWrappingReferenceElementInfoField field = new SingleWrappingReferenceElementInfoField(
								classOutline, p, propertyInfo, elementInfo);
						field.generateAccessors();
						return field;
					}
				};
				Customizations.markGenerated(itemPropertyInfo);

				properties.add(itemPropertyInfo);
			}
		} else if (element instanceof CClassInfo) {

			final CClassInfo classInfo = (CClassInfo) element;

			final QName elementName = classInfo.getElementName();
			final QName typeName = classInfo.getTypeName();
			final CTypeRef typeRef = new CTypeRef(classInfo, elementName,
					typeName, false, null);

			itemPropertyInfo.realization = new FieldRenderer() {
				public FieldOutline generate(ClassOutlineImpl classOutline,
						CPropertyInfo p) {
					SingleWrappingClassInfoField field = new SingleWrappingClassInfoField(
							classOutline, p, propertyInfo, classInfo);
					field.generateAccessors();
					return field;
				}
			};

			itemPropertyInfo.getTypes().add(typeRef);

			Customizations.markGenerated(itemPropertyInfo);
			properties.add(itemPropertyInfo);

		} else if (element instanceof CClassRef) {
			final CClassRef classRef = (CClassRef) element;
			logger.error("CClassRef elements are not supported yet.");

			logger.error("["
					+ ((CClassInfo) propertyInfo.parent()).getName()
					+ "."
					+ propertyInfo.getName(true)
					+ "] is a single hetero reference containing unsupported CClassRef element ["
					+ classRef.fullName() + "]. See issue #94.");

		}
	}
	return properties;
}
 
Example #26
Source File: CClassifyingVisitor.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public U onHeteroReference(CReferencePropertyInfo referencePropertyInfo) {
	return !referencePropertyInfo.isCollection() ? classifier
			.onSingleHeteroReference(referencePropertyInfo) : classifier
			.onCollectionHeteroReference(referencePropertyInfo);
}
 
Example #27
Source File: CClassifyingVisitor.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public U onWildcardReference(CReferencePropertyInfo referencePropertyInfo) {
	return !referencePropertyInfo.isCollection() ? classifier
			.onSingleWildcardReference(referencePropertyInfo) : classifier
			.onCollectionWildcardReference(referencePropertyInfo);
}
 
Example #28
Source File: CClassifyingVisitor.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public U onClassReference(CReferencePropertyInfo referencePropertyInfo) {
	return !referencePropertyInfo.isCollection() ? classifier
			.onSingleClassReference(referencePropertyInfo) : classifier
			.onCollectionClassReference(referencePropertyInfo);
}
 
Example #29
Source File: DefaultProcessPropertyInfos.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public Collection<CPropertyInfo> onCollectionClassReference(
		CReferencePropertyInfo referencePropertyInfo) {
	logger.error("[" + referencePropertyInfo.getName(true)
			+ "] is a collection class reference. See issue #70.");
	return Collections.emptyList();
}
 
Example #30
Source File: GetTypes.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public Set<CElement> getElements(C context,
CReferencePropertyInfo referencePropertyInfo);