Package javax.xml.bind.annotation

Examples of javax.xml.bind.annotation.XmlEnumValue


  public String findEnumValue(Enum<?> e)
  {
    Class<?> enumClass = e.getDeclaringClass();
    String enumValue = e.name();
    try {
      XmlEnumValue xmlEnumValue = enumClass.getDeclaredField(enumValue).getAnnotation(XmlEnumValue.class);
      return (xmlEnumValue != null) ? xmlEnumValue.value() : enumValue;
    } catch (NoSuchFieldException e1) {
      throw new IllegalStateException("Could not locate Enum entry '"+enumValue+"' (Enum class "+enumClass.getName()+")", e1);
    }
  }
View Full Code Here


    Map<String, Object> enumValueMap = new LinkedHashMap<String, Object>();
    Collection<EnumConstantDeclaration> enumConstants = ((EnumDeclaration) getDelegate()).getEnumConstants();
    HashSet<String> enumValues = new HashSet<String>(enumConstants.size());
    for (EnumConstantDeclaration enumConstant : enumConstants) {
      String value = enumConstant.getSimpleName();
      XmlEnumValue enumValue = enumConstant.getAnnotation(XmlEnumValue.class);
      if (enumValue != null) {
        value = enumValue.value();
      }

      if (!enumValues.add(value)) {
        throw new ValidationException(enumConstant.getPosition(), getQualifiedName() + ": duplicate enum value: " + value);
      }
View Full Code Here

        for (Iterator<JavaField> fieldIt = javaClass.getDeclaredFields().iterator(); fieldIt.hasNext();) {
            JavaField field = fieldIt.next();
            if (field.isEnumConstant()) {
                String fieldValue = field.getName();
                if (helper.isAnnotationPresent(field, XmlEnumValue.class)) {
                    XmlEnumValue xmlEnumValue = (XmlEnumValue) helper.getAnnotation(field, XmlEnumValue.class);
                    fieldValue = xmlEnumValue.value();
                }
                info.addObjectToFieldValuePair(field.getName(), fieldValue);
            }
        }
    }
View Full Code Here

        if (value != null) {
            if (buffer.charAt(buffer.length() - 1) != '[') {
                buffer.append(", ");
            }
            if (value instanceof Enum<?>) try {
                final XmlEnumValue xml = value.getClass().getField(((Enum<?>) value).name()).getAnnotation(XmlEnumValue.class);
                if (xml != null) {
                    value = xml.value();
                }
            } catch (NoSuchFieldException e) {
                // Should never happen with Enums. But if it
                // happen anyway, this is not a fatal error.
                Logging.unexpectedException(XLink.class, "toString", e);
View Full Code Here

        for (Iterator<JavaField> fieldIt = javaClass.getDeclaredFields().iterator(); fieldIt.hasNext();) {
            JavaField field = fieldIt.next();
            if (field.isEnumConstant()) {
                String fieldValue = field.getName();
                if (helper.isAnnotationPresent(field, XmlEnumValue.class)) {
                    XmlEnumValue xmlEnumValue = (XmlEnumValue) helper.getAnnotation(field, XmlEnumValue.class);
                    fieldValue = xmlEnumValue.value();
                }
                info.addObjectToFieldValuePair(field.getName(), fieldValue);
            }
        }
    }
View Full Code Here

      EnumConstantInfo[] constants = enumInfo.getEnumConstants();
      valid = new HashMap<Object, Object>(constants.length);
      for (EnumConstantInfo constant : constants)
      {
         String enumValue = constant.getName();
         XmlEnumValue xmlEnumValue = constant.getUnderlyingAnnotation(XmlEnumValue.class);
         if (xmlEnumValue != null)
            enumValue = xmlEnumValue.value();
        
         Object key;
         try
         {
            key = enumType.convertValue(enumValue, false);
View Full Code Here

        for (Iterator<JavaField> fieldIt = javaClass.getDeclaredFields().iterator(); fieldIt.hasNext();) {
            JavaField field = fieldIt.next();
            if (field.isEnumConstant()) {
                String fieldValue = field.getName();
                if (helper.isAnnotationPresent(field, XmlEnumValue.class)) {
                    XmlEnumValue xmlEnumValue = (XmlEnumValue) helper.getAnnotation(field, XmlEnumValue.class);
                    fieldValue = xmlEnumValue.value();
                }
                info.addObjectToFieldValuePair(field.getName(), fieldValue);
            }
        }
    }
View Full Code Here

        for (Iterator<JavaField> fieldIt = javaClass.getDeclaredFields().iterator(); fieldIt.hasNext();) {
            JavaField field = fieldIt.next();
            if (field.isEnumConstant()) {
                String fieldValue = field.getName();
                if (helper.isAnnotationPresent(field, XmlEnumValue.class)) {
                    XmlEnumValue xmlEnumValue = (XmlEnumValue) helper.getAnnotation(field, XmlEnumValue.class);
                    fieldValue = xmlEnumValue.value();
                }
                info.addObjectToFieldValuePair(field.getName(), fieldValue);
            }
        }
    }
View Full Code Here

      EnumConstantInfo[] constants = enumInfo.getEnumConstants();
      valid = new HashMap<Object, Object>(constants.length);
      for (EnumConstantInfo constant : constants)
      {
         String enumValue = constant.getName();
         XmlEnumValue xmlEnumValue = constant.getUnderlyingAnnotation(XmlEnumValue.class);
         if (xmlEnumValue != null)
            enumValue = xmlEnumValue.value();
        
         Object key = enumValue;
         try
         {
            key = enumType.convertValue(enumValue, false);
View Full Code Here

/*  67 */     EnumConstantInfo[] constants = enumInfo.getEnumConstants();
/*  68 */     this.valid = new HashMap(constants.length);
/*  69 */     for (EnumConstantInfo constant : constants)
/*     */     {
/*  71 */       String enumValue = constant.getName();
/*  72 */       XmlEnumValue xmlEnumValue = (XmlEnumValue)constant.getUnderlyingAnnotation(XmlEnumValue.class);
/*  73 */       if (xmlEnumValue != null) {
/*  74 */         enumValue = xmlEnumValue.value();
/*     */       }
/*  76 */       Object key = enumValue;
/*     */       try
/*     */       {
/*  79 */         key = enumType.convertValue(enumValue, false);
View Full Code Here

TOP

Related Classes of javax.xml.bind.annotation.XmlEnumValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.