com.sun.xml.bind.v2.model.core.ID Java Examples

The following examples show how to use com.sun.xml.bind.v2.model.core.ID. 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: DefaultGetTypes.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 #2
Source File: CMInfoFactory.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected MTypeInfo<T, C> getTypeInfo(PropertyInfo<T, C> propertyInfo,
		TI typeInfo, boolean list, Adapter<T, C> adapter, ID id,
		MimeType mimeType) {
	final MTypeInfo<T, C> ti = getTypeInfo(typeInfo);

	if (list) {
		switch (id) {
		case ID:
			final MTypeInfo<T, C> tid = new CMID<T, C>(ti.getTargetType(),
					ti);
			return new CMList<T, C>(createListType(tid.getTargetType()),
					tid, null);
		case IDREF:
			return new CMIDREFS<T, C>(createListType(ti.getTargetType()),
					ti);
		default:
			return new CMList<T, C>(createListType(ti.getTargetType()), ti,
					null);
		}
	} else {
		switch (id) {
		case ID:
			return new CMID<T, C>(ti.getTargetType(), ti);
		case IDREF:
			return new CMIDREF<T, C>(ti.getTargetType(), ti);
		default:
			return ti;
		}
	}

}
 
Example #3
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 #4
Source File: DefaultTypeUse.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ID idUse() {
	return id;
}
 
Example #5
Source File: CExternalLeafInfo.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ID idUse() {
	return ID.NONE;
}
 
Example #6
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 #7
Source File: WrapSingleHeteroElement.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 4 votes vote down vote up
protected Collection<CPropertyInfo> createTypeProperties(
		final ProcessModel context, final CElementPropertyInfo propertyInfo) {

	final Collection<? extends CTypeRef> types = context.getGetTypes().getTypes(context, propertyInfo);
	// Set<CElement> elements = propertyInfo.getElements();

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

	for (final CTypeRef type : types) {
		final CElementPropertyInfo itemPropertyInfo = new CElementPropertyInfo(
				propertyInfo.getName(true)
						+ ((CClassInfo) propertyInfo.parent()).model
								.getNameConverter().toPropertyName(
										type.getTagName().getLocalPart()),
				CollectionMode.NOT_REPEATED, ID.NONE, propertyInfo
						.getExpectedMimeType(), propertyInfo
						.getSchemaComponent(),
				new CCustomizations(CustomizationUtils
						.getCustomizations(propertyInfo)), propertyInfo
						.getLocator(), false);

		itemPropertyInfo.getTypes().add(type);

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

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

		Collection<CPropertyInfo> newProperties = context
				.getProcessPropertyInfos().process(context,
						itemPropertyInfo);
		if (newProperties != null) {
			properties.addAll(newProperties);
		}

	}

	return properties;
}