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

The following examples show how to use com.sun.tools.xjc.outline.EnumConstantOutline. 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: CMEnumConstantOutlineGenerator.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public MEnumConstantOutline generate(MEnumOutline parent,
		MModelInfo<NType, NClass> modelInfo,
		MEnumConstantInfo<NType, NClass> enumConstantInfo) {

	final CEnumLeafInfo eli = enumConstant.getEnclosingClass();

	final EnumOutline enumOutline = outline.getEnum(eli);

	for (EnumConstantOutline enumConstantOutline : enumOutline.constants) {
		if (enumConstantOutline.target == enumConstant) {
			return new CMEnumConstantOutline(parent, enumConstantInfo,
					enumConstantOutline.constRef);
		}
	}
	return null;
}
 
Example #2
Source File: EnumModelBuilder.java    From mxjc with MIT License 5 votes vote down vote up
public static void buildEnumModel(Outline outline, CGModel cgModel, ErrorReceiver errorReceiver) {
for (EnumOutline eo : outline.getEnums()) {
	EnumInfo enumInfo = new EnumInfo();
	enumInfo.setPackageName(eo._package()._package().name());
	enumInfo.setName(eo.clazz.name());
	if (!StringUtil.isEmpty(enumInfo.getPackageName())) {
		enumInfo.setFullName(enumInfo.getPackageName() + "." + enumInfo.getName());
	} else {
		enumInfo.setFullName(enumInfo.getName());
	}
	
	// enum constant
	for (EnumConstantOutline eco : eo.constants) {
		EnumConstantInfo enumConstant = new EnumConstantInfo();
		// name of this enum constant
		enumConstant.setName(eco.target.getName());
		// value of this enum constant
		enumConstant.setValue(eco.target.getLexicalValue());
		// java doc on this enum constant
		enumConstant.setDocComment(eco.target.javadoc);

		// add this enum constant in the enum model
		enumInfo.getEnumConstants().add(enumConstant);
	}

	// xsd annotation as doc comment
	String docComment = ModelBuilder.getDocumentation(eo.target
			.getSchemaComponent());
	enumInfo.setDocComment(docComment);

	// add this enum in the codegen model
	cgModel.getEnums().add(enumInfo);
}
  }
 
Example #3
Source File: CustomizationUtils.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static CCustomizations getCustomizations(EnumConstantOutline enumConstantOutline) {
	return getCustomizations(enumConstantOutline.target);
}
 
Example #4
Source File: AnnotatePlugin.java    From jpmml-model with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public boolean run(Outline outline, Options options, ErrorHandler errorHandler){
	JCodeModel codeModel = outline.getCodeModel();

	Collection<? extends ClassOutline> classOutlines = outline.getClasses();
	for(ClassOutline classOutline : classOutlines){
		JDefinedClass beanClazz = classOutline.implClass;

		CPluginCustomization classCustomization = CustomizationUtils.findCustomization(classOutline, AnnotatePlugin.ANNOTATE_CLASS_QNAME);
		if(classCustomization != null){
			annotate(codeModel, beanClazz, classCustomization);
		}

		Map<String, JFieldVar> fieldVars = beanClazz.fields();

		FieldOutline[] fieldOutlines = classOutline.getDeclaredFields();
		for(FieldOutline fieldOutline : fieldOutlines){
			CPropertyInfo propertyInfo = fieldOutline.getPropertyInfo();

			List<CPluginCustomization> propertyCustomizations = CustomizationUtils.findPropertyCustomizationsInProperty(propertyInfo, AnnotatePlugin.ANNOTATE_PROPERTY_QNAME);
			for(CPluginCustomization propertyCustomization : propertyCustomizations){
				JFieldVar fieldVar = fieldVars.get(propertyInfo.getName(false));

				annotate(codeModel, fieldVar, propertyCustomization);
			}
		}
	}

	Collection<? extends EnumOutline> enumOutlines = outline.getEnums();
	for(EnumOutline enumOutline : enumOutlines){
		JDefinedClass clazz = enumOutline.clazz;

		CPluginCustomization enumCustomization = CustomizationUtils.findCustomization(enumOutline, AnnotatePlugin.ANNOTATE_ENUM_QNAME);
		if(enumCustomization != null){
			annotate(codeModel, clazz, enumCustomization);
		}

		List<EnumConstantOutline> enumConstantOutlines = enumOutline.constants;
		for(EnumConstantOutline enumConstantOutline : enumConstantOutlines){
			CCustomizations enumConstantCustomizations = enumConstantOutline.target.getCustomizations();

			for(CPluginCustomization enumConstantCustomization : enumConstantCustomizations){
				Element element = enumConstantCustomization.element;

				if((AnnotatePlugin.ANNOTATE_ENUM_CONSTANT_QNAME.getNamespaceURI()).equals(element.getNamespaceURI()) && (AnnotatePlugin.ANNOTATE_ENUM_CONSTANT_QNAME.getLocalPart()).equals(element.getLocalName())){
					annotate(codeModel, enumConstantOutline.constRef, enumConstantCustomization);

					enumConstantCustomization.markAsAcknowledged();
				}
			}
		}
	}

	return true;
}