com.sun.tools.xjc.outline.FieldOutline Java Examples

The following examples show how to use com.sun.tools.xjc.outline.FieldOutline. 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: AttributesMapping.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public boolean isFieldOutlineEnumerated(Mapping context,
		FieldOutline fieldOutline) {
	final CPropertyInfo propertyInfo = fieldOutline.getPropertyInfo();

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

	if (types.size() == 1) {

		final CTypeInfo type = types.iterator().next();

		return type instanceof CEnumLeafInfo;
	} else {
		return false;
	}
}
 
Example #2
Source File: ManyToManyMapping.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void createManyToMany$JoinTable(Mapping context,
		FieldOutline fieldOutline, ManyToMany manyToMany) {
	final Collection<FieldOutline> sourceIdFieldOutlines = context
			.getAssociationMapping().getSourceIdFieldsOutline(context,
					fieldOutline);
	final Collection<FieldOutline> targetIdFieldOutlines = context
			.getAssociationMapping().getTargetIdFieldsOutline(context,
					fieldOutline);
	// if (sourceIdFieldOutlines.isEmpty()) {
	// manyToMany.setJoinTable(null);
	// } else
	if (manyToMany.getJoinTable() != null) {
		context.getAssociationMapping().createJoinTable(context,
				fieldOutline, sourceIdFieldOutlines, targetIdFieldOutlines,
				manyToMany.getJoinTable());
	}
	// else {
	// // ***
	// final JoinTable joinTable = new JoinTable();
	// manyToMany.setJoinTable(joinTable);
	// context.getAssociationMapping().createJoinTable(context,
	// fieldOutline, sourceIdFieldOutlines, targetIdFieldOutlines,
	// manyToMany.getJoinTable());
	// }

}
 
Example #3
Source File: BoundPropertiesPlugin.java    From jaxb2-rich-contract-plugin with MIT License 6 votes vote down vote up
private JMethod generateLazyProxyInitGetter(final ClassOutline classOutline, final FieldOutline fieldOutline) {
	final JCodeModel m = classOutline.parent().getCodeModel();
	final JDefinedClass definedClass = classOutline.implClass;
	final String fieldName = fieldOutline.getPropertyInfo().getName(false);
	final String getterName = "get" + fieldOutline.getPropertyInfo().getName(true);
	final JFieldVar collectionField = definedClass.fields().get(fieldName);
	final JClass elementType = ((JClass) collectionField.type()).getTypeParameters().get(0);
	final JClass proxyFieldType = m.ref(BoundList.class).narrow(elementType);
	final JFieldRef collectionFieldRef = JExpr._this().ref(collectionField);
	final JFieldRef proxyField = JExpr._this().ref(collectionField.name() + BoundPropertiesPlugin.PROXY_SUFFIX);
	final JMethod oldGetter = definedClass.getMethod(getterName, new JType[0]);
	definedClass.methods().remove(oldGetter);
	final JMethod newGetter = definedClass.method(JMod.PUBLIC, proxyFieldType, getterName);
	newGetter.body()._if(collectionFieldRef.eq(JExpr._null()))._then().assign(collectionFieldRef, JExpr._new(m.ref(ArrayList.class).narrow(elementType)));
	final JBlock ifProxyNull = newGetter.body()._if(proxyField.eq(JExpr._null()))._then();
	ifProxyNull.assign(proxyField, JExpr._new(m.ref(BoundListProxy.class).narrow(elementType)).arg(collectionFieldRef));
	newGetter.body()._return(proxyField);
	return newGetter;
}
 
Example #4
Source File: PMMLPlugin.java    From jpmml-model with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
static
private FieldOutline getExtensionsField(ClassOutline classOutline){
	Predicate<FieldOutline> predicate = new Predicate<FieldOutline>(){

		@Override
		public boolean test(FieldOutline fieldOutline){
			CPropertyInfo propertyInfo = fieldOutline.getPropertyInfo();

			if(("extensions").equals(propertyInfo.getName(false)) && propertyInfo.isCollection()){
				JType elementType = CodeModelUtil.getElementType(fieldOutline.getRawType());

				return checkType(elementType, "org.dmg.pmml.Extension");
			}

			return false;
		}
	};

	return XJCUtil.findSingletonField(classOutline.getDeclaredFields(), predicate);
}
 
Example #5
Source File: BasicMapping.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public Basic process(Mapping context, FieldOutline fieldOutline,
		Options options) {

	final Basic basic = context.getCustomizing().getBasic(fieldOutline);

	createBasic$Name(context, fieldOutline, basic);

	createBasic$Column(context, fieldOutline, basic);

	if (basic.getLob() == null && basic.getTemporal() == null
			&& basic.getEnumerated() == null) {
		if (context.getAttributeMapping().isTemporal(context, fieldOutline)) {
			basic.setTemporal(context.getAttributeMapping().createTemporalType(
					context, fieldOutline));
		} else if (context.getAttributeMapping().isEnumerated(context, fieldOutline)) {
			basic.setEnumerated(context.getAttributeMapping()
					.createEnumerated(context, fieldOutline));
		} else if (context.getAttributeMapping().isLob(context, fieldOutline)) {
			basic.setLob(context.getAttributeMapping().createLob(context, fieldOutline));
		}

	}

	return basic;
}
 
Example #6
Source File: DefaultAttributeMapping.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public Integer createColumn$Precision(FieldOutline fieldOutline) {
	final Integer precision;
	final Long totalDigits = SimpleTypeAnalyzer.getTotalDigits(fieldOutline
			.getPropertyInfo().getSchemaComponent());
	final Long fractionDigits = SimpleTypeAnalyzer
			.getFractionDigits(fieldOutline.getPropertyInfo()
					.getSchemaComponent());
	if (totalDigits != null) {
		if (fractionDigits != null) {
			precision = totalDigits.intValue() + fractionDigits.intValue();
		} else {
			precision = totalDigits.intValue() * 2;
		}
	} else {
		precision = null;
	}
	return precision;
}
 
Example #7
Source File: DefinedClassOutline.java    From jaxb2-rich-contract-plugin with MIT License 6 votes vote down vote up
public DefinedClassOutline(final PluginContext pluginContext, final ClassOutline classOutline) {
	this.pluginContext = pluginContext;
	this.classOutline = classOutline;
	final List<DefinedPropertyOutline> properties = new ArrayList<>(classOutline.getDeclaredFields().length);

	for (final FieldOutline fieldOutline : classOutline.getDeclaredFields()) {
		properties.add(new DefinedPropertyOutline(fieldOutline));
	}
	this.declaredFields = Collections.unmodifiableList(properties);
	if (this.classOutline.getSuperClass() != null) {
		this.superClass = new DefinedClassOutline(this.pluginContext, this.classOutline.getSuperClass());
	} else {
		try {
			final Class<?> ungeneratedSuperClass = Class.forName(this.classOutline.implClass._extends().fullName());
			if (Object.class.equals(ungeneratedSuperClass)) {
				this.superClass = null;
			} else {
				this.superClass = new ReferencedClassOutline(this.pluginContext.codeModel, ungeneratedSuperClass);
			}
		} catch (final Exception e) {
			throw new RuntimeException("Cannot find superclass of " + this.classOutline.target.getName() + ": " + this.classOutline.target.getLocator());
		}
	}
}
 
Example #8
Source File: DefaultAssociationMapping.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void createElementCollection$CollectionTable$JoinColumns(
		Mapping context, FieldOutline fieldOutline,
		Collection<FieldOutline> idFieldOutlines,
		List<JoinColumn> joinColumns) {
	final Iterator<JoinColumn> joinColumnIterator = new ArrayList<JoinColumn>(
			joinColumns).iterator();
	for (FieldOutline idFieldOutline : idFieldOutlines) {
		final JoinColumn joinColumn;
		if (joinColumnIterator.hasNext()) {
			joinColumn = joinColumnIterator.next();
		} else {
			joinColumn = new JoinColumn();
			joinColumns.add(joinColumn);
		}
		createElementCollection$CollectionTable$JoinColumn(context,
				fieldOutline, idFieldOutline, joinColumn);

	}
}
 
Example #9
Source File: EmbeddableAttributesMapping.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public EmbeddableAttributes process(Mapping context,
		ClassOutline classOutline, Options options) {

	final EmbeddableAttributes attributes = new EmbeddableAttributes();

	final FieldOutline[] fieldOutlines = classOutline.getDeclaredFields();
	for (final FieldOutline fieldOutline : fieldOutlines) {

		final Object attributeMapping = getAttributeMapping(context,
				fieldOutline, options).process(context, fieldOutline,
				options);

		if (attributeMapping instanceof Basic) {
			attributes.getBasic().add((Basic) attributeMapping);
		} else if (attributeMapping instanceof Transient) {
			attributes.getTransient().add((Transient) attributeMapping);
		}
	}
	return attributes;
}
 
Example #10
Source File: AttributesMapping.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public boolean isFieldOutlineEmbedded(Mapping context,
		FieldOutline fieldOutline) {

	final CPropertyInfo propertyInfo = fieldOutline.getPropertyInfo();

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

	assert types.size() == 1;

	final CTypeInfo type = types.iterator().next();

	return (type instanceof CClass && CustomizationUtils
			.containsCustomization(fieldOutline,
					Customizations.EMBEDDED_ELEMENT_NAME))
			//
			||
			//
			(type instanceof CClassInfo && CustomizationUtils
					.containsCustomization(((CClassInfo) type),
							Customizations.EMBEDDABLE_ELEMENT_NAME))

	;
}
 
Example #11
Source File: CustomizationUtils.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static boolean containsCustomization(FieldOutline fieldOutline, QName name) {
	final CPluginCustomization customization = findCustomization(fieldOutline, name);
	if (customization != null) {
		customization.markAsAcknowledged();
	}
	return customization != null;
}
 
Example #12
Source File: EmbeddedIdMapping.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public EmbeddedId process(Mapping context, FieldOutline fieldOutline,
		Options options) {

	final EmbeddedId embeddedId = context.getCustomizing().getEmbeddedId(
			fieldOutline);

	createEmbeddedId$Name(context, fieldOutline, embeddedId);
	context.getAttributeMapping().createAttributeOverride(context,
			fieldOutline, embeddedId.getAttributeOverride());

	return embeddedId;
}
 
Example #13
Source File: FieldOutlineUtils.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static FieldOutline[] filter(final FieldOutline[] fieldOutlines,
		final Ignoring ignoring) {
	return ArrayUtils.filter(fieldOutlines, new Predicate<FieldOutline>() {
		public boolean evaluate(FieldOutline fieldOutline) {
			return !ignoring.isIgnored(fieldOutline);

		}
	}, FieldOutline.class);
}
 
Example #14
Source File: IdMapping.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Id process(Mapping context, FieldOutline fieldOutline,
		Options options) {

	final Id id = context.getCustomizing().getId(fieldOutline);

	createId$Name(context, fieldOutline, id);
	createId$Column(context, fieldOutline, id);
	createId$Temporal(context, fieldOutline, id);
	return id;
}
 
Example #15
Source File: DefaultAssociationMapping.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected void createJoinTable$JoinColumn$ReferencedColumnName(
		Mapping context, FieldOutline fieldOutline,
		FieldOutline idFieldOutline, JoinColumn joinColumn) {
	if (joinColumn.getName() == null
			|| "##default".equals(joinColumn.getName())) {
		joinColumn.setReferencedColumnName(context.getNaming()
				.getColumn$Name(context, idFieldOutline));
	}
}
 
Example #16
Source File: EjbPlugin.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private FieldOutline generateFieldDecl(Outline outline,
		ClassOutlineImpl cc, CPropertyInfo prop) {

	try {
		return (FieldOutline) generateFieldDecl.invoke(outline,
				new Object[] { cc, prop });
	} catch (Exception ex) {
		ex.printStackTrace();
		throw new RuntimeException(ex);
	}
}
 
Example #17
Source File: DefaultAttributeMapping.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Integer createColumn$Length(FieldOutline fieldOutline) {
	final Integer finalLength;
	final Long length = SimpleTypeAnalyzer.getLength(fieldOutline
			.getPropertyInfo().getSchemaComponent());

	if (length != null) {
		finalLength = length.intValue();
	} else {
		final Long maxLength = SimpleTypeAnalyzer.getMaxLength(fieldOutline
				.getPropertyInfo().getSchemaComponent());
		if (maxLength != null) {
			finalLength = maxLength.intValue();
		} else {
			final Long minLength = SimpleTypeAnalyzer
					.getMinLength(fieldOutline.getPropertyInfo()
							.getSchemaComponent());
			if (minLength != null) {
				int intMinLength = minLength.intValue();
				if (intMinLength > 127) {
					finalLength = intMinLength * 2;
				} else {
					finalLength = null;
				}
			} else {
				finalLength = null;
			}
		}
	}
	return finalLength;
}
 
Example #18
Source File: CMPropertyOutlineGenerator.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public MPropertyOutline generate(MClassOutline classOutline,
		MModelInfo<NType, NClass> modelInfo,
		MPropertyInfo<NType, NClass> propertyInfo) {

	final FieldOutline fieldOutline = outline.getField(this.propertyInfo);

	final MPropertyAccessorFactory propertyAccessorFactory = new CMPropertyAccessorFactory(
			this.fieldAccessorFactory, fieldOutline);
	return new CMPropertyOutline(classOutline, propertyInfo,
			propertyAccessorFactory);
}
 
Example #19
Source File: ElementCollectionMapping.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void createElementCollection$CollectionTable(Mapping context,
		FieldOutline fieldOutline, ElementCollection elementCollection) {
	if (elementCollection.getCollectionTable() == null) {
		elementCollection.setCollectionTable(new CollectionTable());
	}

	final CollectionTable collectionTable = elementCollection
			.getCollectionTable();
	createElementCollection$CollectionTable$Name(context, fieldOutline,
			collectionTable);
	createElementCollection$CollectionTable$JoinColumn(context,
			fieldOutline, collectionTable);
}
 
Example #20
Source File: AdaptCollectionBuiltinNonReference.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected FieldOutline generateField(ProcessModel context,
		CPropertyInfo core, ClassOutlineImpl classOutline,
		CPropertyInfo propertyInfo) {
	return new AdaptingWrappingCollectionField(classOutline, core, core,
			propertyInfo);
}
 
Example #21
Source File: AdaptSingleBuiltinReference.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected FieldOutline generateField(final ProcessModel context,
		final CPropertyInfo core, ClassOutlineImpl classOutline,
		CPropertyInfo propertyInfo) {
	assert core instanceof CReferencePropertyInfo;
	final CReferencePropertyInfo referencePropertyInfo = (CReferencePropertyInfo) core;
	// referencePropertyInfo.gete
	SingleWrappingReferenceField fieldOutline = new SingleWrappingReferenceField(
			classOutline, propertyInfo, referencePropertyInfo);
	fieldOutline.generateAccessors();
	return fieldOutline;
}
 
Example #22
Source File: EmbeddedAssociationMappingWrapper.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public EmbeddedAssociationMappingWrapper(
		AssociationMapping associationMapping,
		FieldOutline parentFieldOutline) {
	super();
	this.associationMapping = associationMapping;
	this.parentFieldOutline = parentFieldOutline;
}
 
Example #23
Source File: GroupInterfaceGenerator.java    From jaxb2-rich-contract-plugin with MIT License 5 votes vote down vote up
private FieldOutline findField(final ClassOutline implClass, final PropertyUse propertyUse) throws SAXException {
	if (!propertyUse.isFixed()) {
		for (final FieldOutline field : implClass.getDeclaredFields()) {
			if (field.getPropertyInfo().getName(true).equals(propertyUse.getName())) {
				return field;
			}
		}
		this.pluginContext.errorHandler.error(new SAXParseException(MessageFormat.format(GroupInterfaceGenerator.RESOURCE_BUNDLE.getString("error.property-not-found"), propertyUse.declaration.toString(), propertyUse.getName(), implClass.implClass.fullName()), propertyUse.declaration.getLocator()));
	}
	return null;
}
 
Example #24
Source File: EmbeddedAssociationMappingWrapper.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void createPrimaryKeyJoinColumns(Mapping context,
		FieldOutline fieldOutline,
		Collection<FieldOutline> idFieldOutlines,
		List<PrimaryKeyJoinColumn> primaryKeyJoinColumns) {
	associationMapping.createPrimaryKeyJoinColumns(context, fieldOutline,
			idFieldOutlines, primaryKeyJoinColumns);
}
 
Example #25
Source File: OneToOneMapping.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public OneToOne process(Mapping context, FieldOutline fieldOutline,
		Options options) {

	final OneToOne oneToOne = context.getCustomizing().getOneToOne(
			fieldOutline);
	createOneToOne$Name(context, fieldOutline, oneToOne);
	createOneToOne$TargetEntity(context, fieldOutline, oneToOne);
	createOneToOne$JoinTableOrJoinColumnOrPrimaryKeyJoinColumn(context,
			fieldOutline, oneToOne);
	return oneToOne;
}
 
Example #26
Source File: MetaPlugin.java    From jaxb2-rich-contract-plugin with MIT License 5 votes vote down vote up
private void generateNameOnlyMetaField(final PluginContext pluginContext, final JDefinedClass metaClass, final FieldOutline fieldOutline) {
	final PropertyOutline propertyOutline = new DefinedPropertyOutline(fieldOutline);
	final String constantName = getConstantName(fieldOutline);
	final Outline outline = pluginContext.outline;
	final String propertyName = constantName != null ? constantName : propertyOutline.getFieldName();
	final String metaFieldName = this.camelCase ? propertyName : fieldOutline.parent().parent().getModel().getNameConverter().toConstantName(propertyName);
	metaClass.field(JMod.PUBLIC | JMod.STATIC | JMod.FINAL | JMod.TRANSIENT, String.class, metaFieldName, JExpr.lit(propertyName));
}
 
Example #27
Source File: DefaultAssociationMapping.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected void createJoinTable$JoinColumn$Name(Mapping context,
		FieldOutline fieldOutline, FieldOutline idFieldOutline,
		JoinColumn joinColumn) {
	if (joinColumn.getName() == null
			|| "##default".equals(joinColumn.getName())) {
		joinColumn.setName(context.getNaming()
				.getJoinTable$JoinColumn$Name(context, fieldOutline,
						idFieldOutline));
	}
}
 
Example #28
Source File: DefaultAssociationMapping.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected void createJoinColumn$Name(Mapping context,
		FieldOutline fieldOutline, FieldOutline idFieldOutline,
		JoinColumn joinColumn) {
	if (joinColumn.getName() == null
			|| "##default".equals(joinColumn.getName())) {
		joinColumn.setName(context.getNaming().getJoinColumn$Name(context,
				fieldOutline, idFieldOutline));
	}
}
 
Example #29
Source File: BasicMapping.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void createBasic$Column(Mapping context, FieldOutline fieldOutline,
		final Basic basic) {
	if (basic.getColumn() == null) {
		basic.setColumn(new Column());
	}

	basic.setColumn(context.getAttributeMapping().createColumn(context, fieldOutline, basic.getColumn()));
}
 
Example #30
Source File: DefaultAssociationMapping.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected void createManyToOne$JoinTable$InverseJoinColumn$Name(
		Mapping context, FieldOutline fieldOutline,
		FieldOutline idFieldOutline, JoinColumn joinColumn) {
	if (joinColumn.getName() == null
			|| "##default".equals(joinColumn.getName())) {
		joinColumn.setName(context.getNaming()
				.getJoinTable$InverseJoinColumn$Name(context, fieldOutline,
						idFieldOutline));
	}
}