Java Code Examples for com.sun.tools.xjc.model.CClassInfo#getProperties()

The following examples show how to use com.sun.tools.xjc.model.CClassInfo#getProperties() . 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: GetVersionPropertyInfos.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public Collection<CPropertyInfo> process(ProcessModel context,
		CClassInfo classInfo) {

	final Collection<CPropertyInfo> version = new LinkedList<CPropertyInfo>();

	if (classInfo.getBaseClass() != null) {
		version.addAll(process(context, classInfo.getBaseClass()));
	}

	if (!CustomizationUtils.containsCustomization(classInfo,
			Customizations.IGNORED_ELEMENT_NAME)) {

		for (CPropertyInfo propertyInfo : classInfo.getProperties()) {
			if (CustomizationUtils.containsCustomization(propertyInfo,
					Customizations.VERSION_ELEMENT_NAME)
					&& !CustomizationUtils.containsCustomization(
							propertyInfo,
							Customizations.IGNORED_ELEMENT_NAME)) {
				version.add(propertyInfo);
			}
		}
	}
	return version;
}
 
Example 2
Source File: GetIdPropertyInfos.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public Collection<CPropertyInfo> process(ProcessModel context,
		CClassInfo classInfo) {

	final Collection<CPropertyInfo> ids = new LinkedList<CPropertyInfo>();

	if (classInfo.getBaseClass() != null) {
		ids.addAll(process(context, classInfo.getBaseClass()));
	}

	if (!CustomizationUtils.containsCustomization(classInfo,
			Customizations.IGNORED_ELEMENT_NAME)) {

		for (CPropertyInfo propertyInfo : classInfo.getProperties()) {
			if ((CustomizationUtils.containsCustomization(propertyInfo,
					Customizations.ID_ELEMENT_NAME) || CustomizationUtils
					.containsCustomization(propertyInfo,
							Customizations.EMBEDDED_ID_ELEMENT_NAME))
					&& !CustomizationUtils.containsCustomization(
							propertyInfo,
							Customizations.IGNORED_ELEMENT_NAME)) {
				ids.add(propertyInfo);
			}
		}
	}
	return ids;
}
 
Example 3
Source File: CustomizationUtils.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static CPropertyInfo findPropertyWithCustomization(CClassInfo classInfo, final QName name) {

		for (final CPropertyInfo propertyInfo : classInfo.getProperties()) {
			final CCustomizations customizations = getCustomizations(propertyInfo);
			final CPluginCustomization customization = customizations.find(name.getNamespaceURI(), name.getLocalPart());
			if (customization != null)
				return propertyInfo;
		}
		return null;
	}
 
Example 4
Source File: CustomizationUtils.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static CPropertyInfo findInheritedPropertyWithCustomization(CClassInfo classInfo, final QName name) {
	for (final CPropertyInfo propertyInfo : classInfo.getProperties()) {
		if (containsCustomization(propertyInfo, name)) {
			return propertyInfo;
		}
	}
	final CClassInfo superClassInfo = classInfo.getBaseClass();
	if (superClassInfo != null) {
		return findInheritedPropertyWithCustomization(superClassInfo, name);
	} else {
		return null;
	}
}
 
Example 5
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 6
Source File: CustomizationsPlugin.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void postProcessClassInfo(Model model, CClassInfo classInfo) {
	final String packagedClassName = ClassUtils.getPackagedClassName(classInfo);
	final String customizationsFileName = packagedClassName.replace(".", "/") + ".xml";
	
	final List<CPluginCustomization> customizations = readCustomizations(customizationsFileName);
	
	classInfo.getCustomizations().addAll(customizations);
	
	for (CPropertyInfo propertyInfo: classInfo.getProperties())
	{
		postProcessPropertyInfo(model, classInfo, propertyInfo);
	}
}
 
Example 7
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 8
Source File: WildcardPlugin.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void postProcessModel(Model model, ErrorHandler errorHandler) {
	final boolean laxModel = CustomizationUtils.containsCustomization(
			model, Customizations.LAX_ELEMENT_NAME);
	final boolean skipModel = CustomizationUtils.containsCustomization(
			model, Customizations.SKIP_ELEMENT_NAME);
	final boolean strictModel = CustomizationUtils.containsCustomization(
			model, Customizations.STRICT_ELEMENT_NAME);
	for (CClassInfo classInfo : model.beans().values()) {
		final boolean laxClassInfo = CustomizationUtils
				.containsCustomization(classInfo,
						Customizations.LAX_ELEMENT_NAME);
		final boolean skipClassInfo = CustomizationUtils
				.containsCustomization(classInfo,
						Customizations.SKIP_ELEMENT_NAME);
		final boolean strictClassInfo = CustomizationUtils
				.containsCustomization(classInfo,
						Customizations.STRICT_ELEMENT_NAME);
		for (CPropertyInfo propertyInfo : classInfo.getProperties()) {
			if (propertyInfo instanceof CReferencePropertyInfo) {
				final CReferencePropertyInfo referencePropertyInfo = (CReferencePropertyInfo) propertyInfo;
				final boolean laxPropertyInfo = CustomizationUtils
						.containsCustomization(referencePropertyInfo,
								Customizations.LAX_ELEMENT_NAME);
				final boolean skipPropertyInfo = CustomizationUtils
						.containsCustomization(referencePropertyInfo,
								Customizations.SKIP_ELEMENT_NAME);
				final boolean strictPropertyInfo = CustomizationUtils
						.containsCustomization(referencePropertyInfo,
								Customizations.STRICT_ELEMENT_NAME);

				if (laxModel) {
					referencePropertyInfo.setWildcard(WildcardMode.LAX);
				} else if (skipModel) {
					referencePropertyInfo.setWildcard(WildcardMode.SKIP);
				} else if (strictModel) {
					referencePropertyInfo.setWildcard(WildcardMode.STRICT);
				}

				if (laxClassInfo) {
					referencePropertyInfo.setWildcard(WildcardMode.LAX);
				} else if (skipClassInfo) {
					referencePropertyInfo.setWildcard(WildcardMode.SKIP);
				} else if (strictClassInfo) {
					referencePropertyInfo.setWildcard(WildcardMode.STRICT);
				}

				if (laxPropertyInfo) {
					referencePropertyInfo.setWildcard(WildcardMode.LAX);
				} else if (skipPropertyInfo) {
					referencePropertyInfo.setWildcard(WildcardMode.SKIP);
				} else if (strictPropertyInfo) {
					referencePropertyInfo.setWildcard(WildcardMode.STRICT);
				}
			}
		}
	}
}
 
Example 9
Source File: EjbPlugin.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public boolean run(Outline outline, Options options) throws Exception {

	final Ring ring = Ring.begin();

	try {
		Ring.add(this.bgmBuilder);
		Ring.add(outline.getModel());

		final ModelAndOutlineProcessor<EjbPlugin> modelAndOutlineProcessor = getModelAndOutlineProcessor();

		modelAndOutlineProcessor.process(this, outline.getModel(), options);
	} catch (Exception ex) {
		ex.printStackTrace();
		throw ex;
	} finally {
		Ring.end(ring);

	}

	for (final CClassInfo classInfo : getCreatedClasses()) {
		final ClassOutline classOutline = outline.getClazz(classInfo);
		if (Customizations.isGenerated(classInfo)) {
			generateClassBody(outline, (ClassOutlineImpl) classOutline);
		}

		for (final CPropertyInfo propertyInfo : classInfo.getProperties()) {
			if (outline.getField(propertyInfo) == null) {
				generateFieldDecl(outline, (ClassOutlineImpl) classOutline,
						propertyInfo);
			}
		}
	}

	/*
	 * final Ring ring = Ring.begin(); try {
	 * 
	 * final ErrorReceiverFilter ef = new
	 * ErrorReceiverFilter(outline.getErrorReceiver());
	 * 
	 * Ring.add(XSSchemaSet.class,outline.getModel().schemaComponent);
	 * Ring.add(outline.getModel()); Ring.add(outline.getCodeModel());
	 * Ring.add(ErrorReceiver.class,ef);
	 * Ring.add(CodeModelClassFactory.class,new CodeModelClassFactory(ef));
	 * 
	 * final Class<BGMBuilder> theClass = BGMBuilder.class; Constructor<?>
	 * constructor = theClass.getDeclaredConstructors()[0];
	 * constructor.setAccessible(true); constructor.newInstance(new Object[]
	 * { "a", "b", true, new FieldRendererFactory() });
	 */

	modelAndOutlineProcessor.process(this, outline, options);

	generateRoundtripTestClass(outline);

	checkCustomizations(outline);
	return true;
	/*
	 * } finally { Ring.end(ring); }
	 */

}