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

The following examples show how to use com.sun.tools.xjc.model.CEnumLeafInfo. 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: 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 #3
Source File: CClassifyingVisitor.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public U onElement(CElementPropertyInfo elementPropertyInfo) {
	final Collection<? extends CTypeInfo> types = context.getGetTypes()
			.process(context, elementPropertyInfo);
	if (types.size() == 1) {
		final CTypeInfo type = types.iterator().next();
		if (type instanceof CBuiltinLeafInfo) {
			return onBuiltinElement(elementPropertyInfo);
		} else if (type instanceof CEnumLeafInfo) {
			return onEnumElement(elementPropertyInfo);
		} else if (type instanceof CArrayInfo) {
			return onArrayElement(elementPropertyInfo);
		} else if (type instanceof CClass) {
			return onClassElement(elementPropertyInfo);
		} else {
			throw new UnsupportedOperationException("Unexpected type.");
		}
	} else {
		return onHeteroElement(elementPropertyInfo);
	}
}
 
Example #4
Source File: SchemaAnnotationUtils.java    From jaxb2-rich-contract-plugin with MIT License 5 votes vote down vote up
public static String getEnumAnnotationDescription(CEnumLeafInfo enumLeafInfo) {
    // To get annotations in the class level javadoc, there needs to be an annotation
    // element as a child of the simpleType element , e.g.
    //<xs:simpleType name="SomeSimpleType">
    //   <xs:annotation>
    //      <xs:documentation>This annotation will be used in the class javadoc</xs:documentation>
    //   </xs:annotation>
    XSAnnotation annotation = enumLeafInfo.getSchemaComponent().getAnnotation();
    return resolveDescription(annotation);
}
 
Example #5
Source File: AdaptSingleEnumNonReferenceAsEnumValue.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public TypeUse getPropertyType(ProcessModel context,
		CPropertyInfo propertyInfo) {
	Collection<? extends CTypeInfo> types = context.getGetTypes().process(
			context, propertyInfo);
	return ((CEnumLeafInfo) types.iterator().next()).base;
}
 
Example #6
Source File: EmbeddableAttributesMapping.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 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 #7
Source File: CClassifyingVisitor.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public U onValue(CValuePropertyInfo valuePropertyInfo) {
	final CNonElement type = context.getGetTypes().getTarget(context,
			valuePropertyInfo);
	if (type instanceof CBuiltinLeafInfo) {
		return onBuiltinValue(valuePropertyInfo);
	} else if (type instanceof CEnumLeafInfo) {
		return onEnumValue(valuePropertyInfo);
	} else {
		return onOtherValue(valuePropertyInfo);
	}
}
 
Example #8
Source File: CClassifyingVisitor.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public U onAttribute(CAttributePropertyInfo attributePropertyInfo) {

		final CNonElement type = context.getGetTypes().getTarget(context,
				attributePropertyInfo);
		if (type instanceof CBuiltinLeafInfo) {
			return onBuiltinAttribute(attributePropertyInfo);
		} else if (type instanceof CEnumLeafInfo) {
			return onEnumAttribute(attributePropertyInfo);
		} else {
			return onOtherAttribute(attributePropertyInfo);
		}
	}
 
Example #9
Source File: EnumValuePlugin.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected void processEnumOutline(EnumOutline enumOutline) {
	CEnumLeafInfo enumLeafInfo = enumOutline.target;
	JClass enumType = enumLeafInfo.base.toType(enumOutline.parent(),
			Aspect.EXPOSED).boxify();

	final JDefinedClass theClass = enumOutline.clazz;

	ClassUtils._implements(theClass, theClass.owner().ref(EnumValue.class)
			.narrow(enumType));

	final JMethod enumValue$enumValue = theClass.method(JMod.PUBLIC,
			enumType, "enumValue");
	enumValue$enumValue.annotate(Override.class);
	enumValue$enumValue.body()._return(JExpr._this().invoke("value"));
}
 
Example #10
Source File: CustomizationsPlugin.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void postProcessEnumLeafInfo(Model model, CEnumLeafInfo enumLeafInfo) {
	final String packagedClassName = ClassUtils.getPackagedClassName(enumLeafInfo);
	final String customizationsFileName = packagedClassName.replace(".", "/") + ".xml";
	
	final List<CPluginCustomization> customizations = readCustomizations(customizationsFileName);
	
	enumLeafInfo.getCustomizations().addAll(customizations);
	for (CEnumConstant enumConstant : enumLeafInfo.getConstants()) {
		postProcessEnumConstant(model, enumLeafInfo, enumConstant);
	}
}
 
Example #11
Source File: CustomizationsPlugin.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void postProcessModel(Model model) {
	for (final CClassInfo classInfo : model.beans().values()) {
		postProcessClassInfo(model, classInfo);
	}
	for (final CEnumLeafInfo enumLeafInfo : model.enums().values()) {
		postProcessEnumLeafInfo(model, enumLeafInfo);
	}
}
 
Example #12
Source File: CustomizedIgnoring.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public boolean isIgnored(CEnumLeafInfo enumLeafInfo) {
	for (QName name : getIgnoredCustomizationElementNames()) {
		if (CustomizationUtils.containsCustomization(enumLeafInfo, name)) {
			return true;
		}
	}
	return false;
}
 
Example #13
Source File: CustomizationUtils.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static boolean containsCustomization(CEnumLeafInfo enumLeafInfo, QName name) {
	final CPluginCustomization customization = findCustomization(enumLeafInfo, name);
	if (customization != null) {
		customization.markAsAcknowledged();
	}
	return customization != null;
}
 
Example #14
Source File: CustomizationUtils.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static CPluginCustomization findCustomization(CEnumLeafInfo enumLeafInfo, QName name) {
	final CCustomizations customizations = CustomizationUtils.getCustomizations(enumLeafInfo);
	final CPluginCustomization customization = customizations.find(name.getNamespaceURI(), name.getLocalPart());
	if (customization != null) {
		customization.markAsAcknowledged();
	}
	return customization;
}
 
Example #15
Source File: CustomizationUtils.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static List<CPluginCustomization> findCustomizations(CEnumLeafInfo enumInfo, QName name) {
	final CCustomizations customizations = CustomizationUtils.getCustomizations(enumInfo);

	final List<CPluginCustomization> pluginCustomizations = new LinkedList<CPluginCustomization>();

	for (CPluginCustomization pluginCustomization : customizations) {
		if (fixNull(pluginCustomization.element.getNamespaceURI()).equals(name.getNamespaceURI())
				&& fixNull(pluginCustomization.element.getLocalName()).equals(name.getLocalPart())) {
			pluginCustomization.markAsAcknowledged();
			pluginCustomizations.add(pluginCustomization);
		}
	}

	return pluginCustomizations;
}
 
Example #16
Source File: ClassUtils.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static String getPackagedClassName(final CEnumLeafInfo enumLeafInfo) {
	
	if (enumLeafInfo.parent instanceof CClassInfo) {
		return getPackagedClassName((CClassInfo) enumLeafInfo.parent) + '$'
				+ enumLeafInfo.shortName;
	} else {
		final String r = enumLeafInfo.parent.fullName();
		if (r.length() == 0)
			return enumLeafInfo.shortName;
		else
			return r + '.' + enumLeafInfo.shortName;
	}
}
 
Example #17
Source File: CustomizationUtils.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static CCustomizations getCustomizations(final CEnumLeafInfo enumLeafInfo) {
	return enumLeafInfo.getCustomizations();
}
 
Example #18
Source File: CustomizationsPlugin.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void postProcessEnumConstant(Model model, CEnumLeafInfo enumLeafInfo, CEnumConstant enumConstant) {
	final String packagedClassName = ClassUtils.getPackagedClassName(enumLeafInfo);
	final String customizationsFileName = packagedClassName.replace(".", "/") + "." +enumConstant.getName() + ".xml";
	final List<CPluginCustomization> customizations = readCustomizations(customizationsFileName);
	enumConstant.getCustomizations().addAll(customizations);
}
 
Example #19
Source File: XJCCMEnumLeafInfoOrigin.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public XJCCMEnumLeafInfoOrigin(CEnumLeafInfo source) {
	super(source);
}
 
Example #20
Source File: XJCCMInfoFactory.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected MEnumLeafInfoOrigin createEnumLeafInfoOrigin(CEnumLeafInfo info) {
	return new XJCCMEnumLeafInfoOrigin(info);
}
 
Example #21
Source File: XJCCMInfoFactory.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected String getLocalName(CEnumLeafInfo info) {
	return info.shortName;
}
 
Example #22
Source File: XJCCMInfoFactory.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected MContainer getContainer(CEnumLeafInfo info) {
	final CClassInfoParent parent = info.parent;
	return parent == null ? null : getContainer(parent);
}
 
Example #23
Source File: XJCCMInfoFactory.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected MPackageInfo getPackage(CEnumLeafInfo info) {
	return getPackage(info.parent);
}
 
Example #24
Source File: CMEnumOutlineGenerator.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public CMEnumOutlineGenerator(Outline outline, CEnumLeafInfo enumLeafInfo) {
	Validate.notNull(outline);
	Validate.notNull(enumLeafInfo);
	this.outline = outline;
	this.enumLeafInfo = enumLeafInfo;
}
 
Example #25
Source File: Ignoring.java    From jaxb2-basics with BSD 2-Clause "Simplified" License votes vote down vote up
public boolean isIgnored(CEnumLeafInfo enumLeafInfo);