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

The following examples show how to use com.sun.tools.xjc.model.CPropertyInfo. 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: DefaultCustomizing.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public Version getVersion(CPropertyInfo property) {
	final Persistence persistence = getModelCustomization(property);
	if (persistence.getDefaultVersion() == null) {
		throw new AssertionError("Default version element is not provided.");
	}
	final Version defaultVersion = (Version) persistence
			.getDefaultVersion().copyTo(new Version());
	final Version version;
	if (CustomizationUtils.containsCustomization(property,
			Customizations.VERSION_ELEMENT_NAME)) {
		version = findCustomization(property,
				Customizations.VERSION_ELEMENT_NAME, defaultVersion,
				this.<Version> merge());
	} else {
		version = defaultVersion;
	}
	return version;
}
 
Example #2
Source File: WrapSingleBuiltinNonReference.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public CreatePropertyInfos getCreatePropertyInfos(ProcessModel context,
		CPropertyInfo propertyInfo) {

	final CBuiltinLeafInfo originalTypeUse = getTypeUse(context,
			propertyInfo);

	final TypeUse adaptingTypeUse = context.getAdaptBuiltinTypeUse()
			.process(context, propertyInfo);

	if (adaptingTypeUse == originalTypeUse
			|| adaptingTypeUse.getAdapterUse() == null) {
		logger.debug("No adaptation required.");
		return CreateNoPropertyInfos.INSTANCE;

	} else {
		return new AdaptSingleBuiltinNonReference(adaptingTypeUse);
	}
}
 
Example #3
Source File: DefaultCreateDefaultVersionPropertyInfos.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 #4
Source File: DefaultCustomizing.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public EmbeddedId getEmbeddedId(CPropertyInfo property) {
	final Persistence persistence = getModelCustomization(property);
	if (persistence.getDefaultEmbeddedId() == null) {
		throw new AssertionError(
				"Default embedded id element is not provided.");
	}
	final EmbeddedId defaultId = (EmbeddedId) persistence
			.getDefaultEmbeddedId().copyTo(new EmbeddedId());
	final EmbeddedId id;
	if (CustomizationUtils.containsCustomization(property,
			Customizations.EMBEDDED_ID_ELEMENT_NAME)) {
		id = findCustomization(property,
				Customizations.EMBEDDED_ID_ELEMENT_NAME, defaultId,
				this.<EmbeddedId> merge());
	} else {
		id = defaultId;
	}
	return id;
}
 
Example #5
Source File: DefaultCustomizing.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@SuppressWarnings("unchecked")
private <T> T findCustomization(CPropertyInfo propertyInfo, QName name) {
	final CPluginCustomization customization = CustomizationUtils
			.findCustomization(propertyInfo, name);
	final T t = (T) unmarshalCustomization(customization);
	return t;
}
 
Example #6
Source File: AbstractAdaptEnumPropertyInfo.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Collection<CPropertyInfo> process(ProcessModel context,
		final CPropertyInfo core) {
	final CPropertyInfo newPropertyInfo = createPropertyInfo(context, core);

	newPropertyInfo.realization = new FieldRenderer() {

		public FieldOutline generate(ClassOutlineImpl classOutline,
				CPropertyInfo propertyInfo) {
			return generateField(core, classOutline, propertyInfo);
		}

	};
	Customizations.markIgnored(core);
	return Collections.singletonList(newPropertyInfo);
}
 
Example #7
Source File: DefaultCustomizing.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ManyToOne getManyToOne(CPropertyInfo property) {

		final Persistence persistence = getModelCustomization(property);
		if (persistence.getDefaultManyToOne() == null) {
			// TODO
			throw new AssertionError(
					"Default many-to-one element is not provided.");
		}
		final ManyToOne defaultManyToOne = (ManyToOne) persistence
				.getDefaultManyToOne().copyTo(new ManyToOne());

		final ManyToOne cmanyToOne;

		if (CustomizationUtils.containsCustomization(property,
				Customizations.MANY_TO_ONE_ELEMENT_NAME)) {
			cmanyToOne = findCustomization(property,
					Customizations.MANY_TO_ONE_ELEMENT_NAME, defaultManyToOne,
					new Merge<ManyToOne>() {
						public void merge(ManyToOne value,
								ManyToOne defaultValue) {
							DefaultCustomizing.this.merge(value, defaultValue);
						}
					});
		} else {
			return defaultManyToOne;
		}
		return cmanyToOne;
	}
 
Example #8
Source File: DefinedPropertyOutline.java    From jaxb2-rich-contract-plugin with MIT License 5 votes vote down vote up
private CPropertyInfo getPropertyInfo(final CClassInfo classInfo, final String fieldName) {
	return classInfo.getProperties().stream()
				.filter(it -> it.getName(false).equals(fieldName))
				.findAny()
				.orElseThrow(() ->
						new IllegalStateException("Can't find property [" +
								fieldName + "] in class [" + classInfo.getTypeName() + "]"));
}
 
Example #9
Source File: DefaultCustomizing.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Integer createColumn$Scale(CPropertyInfo property) {
	final Integer scale;
	final Long fractionDigits = SimpleTypeAnalyzer
			.getFractionDigits(property.getSchemaComponent());
	final Long totalDigits = SimpleTypeAnalyzer.getTotalDigits(property
			.getSchemaComponent());
	if (fractionDigits != null) {
		scale = fractionDigits.intValue();
	} else if (totalDigits != null) {
		scale = totalDigits.intValue();
	} else {
		scale = null;
	}
	return scale;
}
 
Example #10
Source File: CustomizationUtils.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static List<CPluginCustomization> findPropertyCustomizationsInPropertyAndClass(CPropertyInfo propertyInfo,
		QName propertyCustomizationName, QName customizationName) {

	final List<CPluginCustomization> foundPropertyCustomizations = new LinkedList<CPluginCustomization>();
	foundPropertyCustomizations.addAll(findPropertyCustomizationsInProperty(propertyInfo, customizationName));
	if (propertyInfo.parent() instanceof CClassInfo) {
		foundPropertyCustomizations.addAll(findPropertyCustomizationsInClass((CClassInfo) propertyInfo.parent(),
				propertyInfo, propertyCustomizationName, customizationName));
	}
	return foundPropertyCustomizations;
}
 
Example #11
Source File: WrapSingleBuiltinReference.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public CreatePropertyInfos getCreatePropertyInfos(ProcessModel context,
		CPropertyInfo propertyInfo) {

	final TypeUse adaptingTypeUse = context.getAdaptBuiltinTypeUse()
			.process(context, propertyInfo);

	return new AdaptSingleBuiltinReference(adaptingTypeUse);
}
 
Example #12
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 #13
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 #14
Source File: WrapSingleHeteroReference.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Collection<CPropertyInfo> process(ProcessModel context,
		CPropertyInfo propertyInfo) {

	assert propertyInfo instanceof CReferencePropertyInfo;
	final CReferencePropertyInfo referencePropertyInfo = (CReferencePropertyInfo) propertyInfo;
	assert !referencePropertyInfo.isMixed();

	// if (referencePropertyInfo.getElements().isEmpty()) {
	final CPropertyInfo elementProperty = createElementProperty(referencePropertyInfo);

	final CPropertyInfo objectProperty = createObjectProperty(context,
			referencePropertyInfo);

	final Collection<CPropertyInfo> newPropertyInfos = new ArrayList<CPropertyInfo>(
			context.getGetTypes()
					.getElements(context, referencePropertyInfo).size() + 3);

	if (elementProperty != null) {
		newPropertyInfos.add(elementProperty);
	}
	if (objectProperty != null) {
		newPropertyInfos.add(objectProperty);
	}

	final Collection<CPropertyInfo> properties = createElementProperties(
			context, (CReferencePropertyInfo) propertyInfo);

	if (properties != null) {

		newPropertyInfos.addAll(properties);
	}

	Customizations.markIgnored(propertyInfo);

	return newPropertyInfos;
}
 
Example #15
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 #16
Source File: AttributesMapping.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public CTypeInfo getCommonBaseTypeInfo(Mapping context,
		FieldOutline fieldOutline) {
	final CPropertyInfo propertyInfo = fieldOutline.getPropertyInfo();

	final Collection<? extends CTypeInfo> types = context.getGetTypes()
			.process(context, propertyInfo);

	return CTypeInfoUtils.getCommonBaseTypeInfo(types);
}
 
Example #17
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 #18
Source File: DefaultCustomizing.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public OneToOne getOneToOne(CPropertyInfo property) {

		final Persistence persistence = getModelCustomization(property);
		if (persistence.getDefaultOneToOne() == null) {
			// TODO
			throw new AssertionError(
					"Default one-to-one element is not provided.");
		}
		final OneToOne defaultOneToOne = (OneToOne) persistence
				.getDefaultOneToOne().copyTo(new OneToOne());

		final OneToOne cOneToOne;

		if (CustomizationUtils.containsCustomization(property,
				Customizations.ONE_TO_ONE_ELEMENT_NAME)) {
			cOneToOne = findCustomization(property,
					Customizations.ONE_TO_ONE_ELEMENT_NAME, defaultOneToOne,
					new Merge<OneToOne>() {
						public void merge(OneToOne value, OneToOne defaultValue) {
							DefaultCustomizing.this.merge(value, defaultValue);
						}
					});
		} else {
			return defaultOneToOne;
		}
		return cOneToOne;
	}
 
Example #19
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 #20
Source File: EjbPlugin.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #21
Source File: WrapSingleEnumNonReference.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Collection<CPropertyInfo> process(ProcessModel context,
		CPropertyInfo propertyInfo) {

	// Single
	assert !propertyInfo.isCollection();
	
	final Collection<? extends CTypeInfo> types = context.getGetTypes().process(
			context, propertyInfo);
	// Builtin
	assert types.size() == 1;
	assert types.iterator().next() instanceof CEnumLeafInfo;

	return getCreatePropertyInfos(context, propertyInfo).process(context,
			propertyInfo);
}
 
Example #22
Source File: DefaultCustomizing.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Basic getBasic(CPropertyInfo property) {
	final Basic defaultBasic = getDefaultBasic(property);
	final Basic basic;
	if (CustomizationUtils.containsCustomization(property,
			Customizations.BASIC_ELEMENT_NAME)) {
		basic = findCustomization(property,
				Customizations.BASIC_ELEMENT_NAME, defaultBasic,
				this.<Basic> merge());
	} else {
		basic = defaultBasic;
	}
	return basic;
}
 
Example #23
Source File: AbstractField.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected AbstractField( ClassOutlineImpl outline, CPropertyInfo prop ) {
    this.outline = outline;
    this.prop = prop;
    this.codeModel = outline.parent().getCodeModel();
    this.implType = getType(IMPLEMENTATION);
    this.exposedType = getType(Aspect.EXPOSED);
}
 
Example #24
Source File: AbstractAdaptBuiltinPropertyInfo.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Collection<CPropertyInfo> process(final ProcessModel context,
		final CPropertyInfo core) {
	final CPropertyInfo newPropertyInfo = createPropertyInfo(context, core);

	newPropertyInfo.realization = new FieldRenderer() {

		public FieldOutline generate(ClassOutlineImpl classOutline,
				CPropertyInfo propertyInfo) {
			return generateField(context, core, classOutline, propertyInfo);
		}

	};
	Customizations.markIgnored(core);
	return Collections.singletonList(newPropertyInfo);
}
 
Example #25
Source File: DefaultCustomizing.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #26
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 #27
Source File: DefaultCustomizing.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void assignColumn$LengthPrecisionScale(CPropertyInfo property,
		final Column column) {
	final Integer length = createColumn$Length(property);

	if (length != null) {
		column.setLength(length);
	}


	final Integer precision = createColumn$Precision(property);
	final Integer scale = createColumn$Scale(property);

	if (precision != null && precision.intValue() != 0) {
		column.setPrecision(precision);
	} else {
		if (scale != null && scale.intValue() != 0) {
			final Integer defaultPrecision = column.getPrecision();
			if (defaultPrecision != null) {
				final Integer defaultScale = column.getScale();
				final int integerDigits = defaultPrecision
						- (defaultScale == null ? 0 : defaultScale
								.intValue());
				column.setPrecision(integerDigits + scale.intValue());
				column.setScale(scale);
			}
		}
	}
	if (scale != null && scale.intValue() != 0) {
		column.setScale(scale);
	}
}
 
Example #28
Source File: AdaptingWrappingField.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public AdaptingWrappingField(ClassOutlineImpl context, CPropertyInfo prop,
		CPropertyInfo core, CAdapter adapter) {
	super(context, prop, core);

	this.xmlAdapterClass = adapter == null ? null : adapter
			.getAdapterClass(context.parent());

}
 
Example #29
Source File: DefaultCustomizing.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ElementCollection getElementCollection(CPropertyInfo property) {
	final ElementCollection defaultItem = getDefaultElementCollection(property);
	final ElementCollection item;
	if (CustomizationUtils.containsCustomization(property,
			Customizations.ELEMENT_COLLECTION_ELEMENT_NAME)) {
		item = findCustomization(property,
				Customizations.ELEMENT_COLLECTION_ELEMENT_NAME,
				defaultItem, this.<ElementCollection> merge());
	} else {
		item = defaultItem;
	}
	return item;
}
 
Example #30
Source File: DefaultProcessPropertyInfos.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public Collection<CPropertyInfo> onSingleWildcardReference(
		CReferencePropertyInfo referencePropertyInfo) {
	return context.getWrapSingleWildcardReference().process(context,
			referencePropertyInfo);
}