当前位置: 首页>>代码示例>>Java>>正文


Java XmlEnum类代码示例

本文整理汇总了Java中javax.xml.bind.annotation.XmlEnum的典型用法代码示例。如果您正苦于以下问题:Java XmlEnum类的具体用法?Java XmlEnum怎么用?Java XmlEnum使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


XmlEnum类属于javax.xml.bind.annotation包,在下文中一共展示了XmlEnum类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: EnumLeafInfoImpl

import javax.xml.bind.annotation.XmlEnum; //导入依赖的package包/类
/**
 * @param clazz
 * @param type
 *      clazz and type should both point to the enum class
 *      that this {@link EnumLeafInfo} represents.
 *      Because of the type parameterization we have to take them separately.
 */
public EnumLeafInfoImpl(ModelBuilder<T,C,F,M> builder,
                        Locatable upstream, C clazz, T type ) {
    super(builder,upstream);
    this.clazz = clazz;
    this.type = type;

    elementName = parseElementName(clazz);

    // compute the type name
    // TODO: I guess it must be allowed for enums to have @XmlElement
    typeName = parseTypeName(clazz);

    // locate the base type.
    // this can be done eagerly because there shouldn't be no cycle.
    XmlEnum xe = builder.reader.getClassAnnotation(XmlEnum.class, clazz, this);
    if(xe!=null) {
        T base = builder.reader.getClassValue(xe, "value");
        baseType = builder.getTypeInfo(base,this);
    } else {
        baseType = builder.getTypeInfo(builder.nav.ref(String.class),this);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:30,代码来源:EnumLeafInfoImpl.java

示例2: _typeNormalizedDesc

import javax.xml.bind.annotation.XmlEnum; //导入依赖的package包/类
private static String _typeNormalizedDesc(final Class<?> type) {
	String dataTypeDesc = null;
	if (CollectionUtils.isMap(type)) {
		//@SuppressWarnings("unchecked")
		//Class<? extends Map<?,?>> mapType =  (Class<? extends Map<?,?>>)type;
		// Map:(java.lang.Object,java.lang.Object)
		dataTypeDesc = "Map:" + type.getName() + "(" + Object.class.getCanonicalName() + "," + Object.class.getCanonicalName() + ")";
		
	} else if (CollectionUtils.isCollection(type)) {
		//@SuppressWarnings("unchecked")
		//Class<? extends Collection<?>> colType =  (Class<? extends Collection<?>>)type;
		dataTypeDesc = "Collection:" + type.getName() + "(" + Object.class.getCanonicalName() + ")";	
		
	} else if (type.isEnum() || type.getAnnotation(XmlEnum.class) != null) {
		dataTypeDesc = "Enum(" + type.getName() + ")";
		
	} else {
		dataTypeDesc = type.getName();
	}
	return dataTypeDesc;
}
 
开发者ID:opendata-euskadi,项目名称:r01fb,代码行数:22,代码来源:SimpleMarshallerMappingsFromAnnotationsLoader.java

示例3: getConversionMethod

import javax.xml.bind.annotation.XmlEnum; //导入依赖的package包/类
private static Method getConversionMethod(Class cls) {
    // Look for forName method that is generated by JAXB.
    Method m = fromValueMethod(cls, String.class);
    if (m != null) {
        return m;
    }
    
    // If cannot find forName(String) then look for @XmlEnum value
    if (log.isDebugEnabled()) {
        log.debug("try looking for @XmlEnum ");
    }
    XmlEnum xmlEnum = (XmlEnum)
        cls.getAnnotation(XmlEnum.class);
    if (xmlEnum != null) {
        Class argClass = xmlEnum.value();
        m = fromValueMethod(cls, argClass);
        if (m !=null) {
            return m;
        }
        Class primitiveClass = getPrimitiveClass(argClass);
        if (primitiveClass != null) {
            m = fromValueMethod(cls, primitiveClass);
            if (m != null) {
                return m;
            }
        }
    }
    
    // Look for valueOf(String) method
    if (log.isDebugEnabled()) {
        log.debug("try looking for valueOf method ");
    }
    m = valueOfMethod(cls);
    if (m != null) {
        return m;
    }
    
    throw new IllegalArgumentException();
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:40,代码来源:XmlEnumUtils.java

示例4: XmlEnumQuick

import javax.xml.bind.annotation.XmlEnum; //导入依赖的package包/类
public XmlEnumQuick(Locatable upstream, XmlEnum core) {
    super(upstream);
    this.core = core;
}
 
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:5,代码来源:XmlEnumQuick.java

示例5: newInstance

import javax.xml.bind.annotation.XmlEnum; //导入依赖的package包/类
protected Quick newInstance(Locatable upstream, Annotation core) {
    return new XmlEnumQuick(upstream, ((XmlEnum) core));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:XmlEnumQuick.java

示例6: annotationType

import javax.xml.bind.annotation.XmlEnum; //导入依赖的package包/类
public Class<XmlEnum> annotationType() {
    return XmlEnum.class;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:XmlEnumQuick.java

示例7: _fieldTypeStandardDesc

import javax.xml.bind.annotation.XmlEnum; //导入依赖的package包/类
/**
 * Obtiene la descripci�n del tipo de un field en un formato normalizado a partir de ciertos datos de la clase, el field, etc
 * @param type el tipo que contiene el field
 * @param field el field
 * @param actualFieldType el tipo de dato actual del field (resolviendo gen�ricos, etc)
 * @return
 */
private static String _fieldTypeStandardDesc(final Class<?> type,
										 	 final Field field,final Class<?> actualFieldType) {
	String dataTypeDesc = null;
	if (actualFieldType != Object.class && ReflectionUtils.isTypeDef(actualFieldType)) {
		// Definici�n de clase java
		dataTypeDesc = Class.class.getCanonicalName(); 	// "java.lang.Class";
		
	} else if (ReflectionUtils.isImplementing(actualFieldType,LanguageTexts.class) && !actualFieldType.equals(LanguageTextsI18NBundleBacked.class)) {
		//"Map:(r01f.locale.Language,java.lang.String)";
		dataTypeDesc = "Map:" + actualFieldType.getName() + "(" + Language.class.getCanonicalName() + "," + String.class.getCanonicalName() + ")";	
		
	} else if (CollectionUtils.isMap(actualFieldType)) {
		// Mapa
		Class<?> keyAndValueComponentTypes[] = _mapFieldKeyValueComponentTypes(type,field);
		if (keyAndValueComponentTypes != null && keyAndValueComponentTypes.length == 2) {
			String keyType = keyAndValueComponentTypes[0] != null ? keyAndValueComponentTypes[0].getName() 
																  : Object.class.getCanonicalName(); //"java.lang.Object";
			String valueType = keyAndValueComponentTypes[1] != null ? keyAndValueComponentTypes[1].getName() 
																	: Object.class.getCanonicalName(); //"java.lang.Object";
			dataTypeDesc = "Map:" + actualFieldType.getName() + "(" + keyType + "," + valueType + ")";
		} else {
			dataTypeDesc = "Map:" + actualFieldType.getName();
		}
		
	} else if (CollectionUtils.isCollection(actualFieldType)) {
		// Colecci�n
		Class<?> componentType = _collectionFieldComponentType(type,field);
		if (componentType != null) {
			dataTypeDesc = "Collection:" + actualFieldType.getName() + "(" + componentType.getName() + ")";
		} else {
			dataTypeDesc = "Collection:" + actualFieldType.getName();
		}
		
	} else if (CollectionUtils.isArray(actualFieldType)) {
		// Array
		dataTypeDesc = _collectionFieldComponentType(type,field).getName() + "[]";
		
	} else if (actualFieldType.isEnum() || actualFieldType.getAnnotation(XmlEnum.class) != null) {
		// Enumeraci�n
		dataTypeDesc = "Enum(" + actualFieldType.getName() + ")";
		
	} else if (!actualFieldType.isPrimitive() && !ReflectionUtils.isInstanciable(actualFieldType)) {
		// [C] Es un interfaz
		dataTypeDesc = field.getType().getName();

	} else {
		// [D] Tipo NO generico (el caso m�s normal)
		dataTypeDesc = actualFieldType.getName();
	}
	return dataTypeDesc;
}
 
开发者ID:opendata-euskadi,项目名称:r01fb,代码行数:59,代码来源:SimpleMarshallerMappingsFromAnnotationsLoader.java

示例8: getConversionType

import javax.xml.bind.annotation.XmlEnum; //导入依赖的package包/类
/**
 * @param e Class of enum 
 * @return a base type that can be used for constructing the enum
 */
public static Class getConversionType(final Class e) {
    Class cls = null;
    if (log.isDebugEnabled()) {
        log.debug("getConversionType for " + e);
    }
    try {
        cls = (Class)     
            AccessController.doPrivileged(new PrivilegedAction() {
                public Object run() {
                    // Look for forName method that is generated by JAXB.
                    Method m = fromValueMethod(e, String.class);
                    if (m != null) {
                        return String.class;
                    }
                    
                    // If we cannot find forName(String) then look for @XmlEnum value
                    // and then look for a forName with the indicated base type
                    if (log.isDebugEnabled()) {
                        log.debug("try looking for @XmlEnum ");
                    }
                    XmlEnum xmlEnum = (XmlEnum)
                        e.getAnnotation(XmlEnum.class);
                    if (xmlEnum != null) {
                        Class argClass = xmlEnum.value();
                        m = fromValueMethod(e, argClass);
                        if (m !=null) {
                            return argClass;
                        }
                        Class primitiveClass = getPrimitiveClass(argClass);
                        if (primitiveClass != null) {
                            m = fromValueMethod(e, primitiveClass);
                            if (m != null) {
                                return argClass;
                            }
                        }
                    }
                    
                    // If still not found look for valueOf(String) method
                    if (log.isDebugEnabled()) {
                        log.debug("try looking for valueOf method ");
                    }
                    m = valueOfMethod(e);
                    if (m != null) {
                        return String.class;
                    }
                   
                    throw ExceptionFactory.makeWebServiceException(new IllegalArgumentException());
                }});
    } finally {
        if (log.isDebugEnabled()) {
            log.debug("getConversionType is" + cls);
        }
    }    
    return cls;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:60,代码来源:XmlEnumUtils.java


注:本文中的javax.xml.bind.annotation.XmlEnum类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。