Examples of BoundNumber


Examples of org.codehaus.preon.annotation.BoundNumber

                    return (Codec<T>) new NumericCodec(sizeExpr, endian,
                            numericType, null);
                }
                if (overrides != null
                        && overrides.isAnnotationPresent(BoundNumber.class)) {
                    BoundNumber numericMetadata = overrides
                            .getAnnotation(BoundNumber.class);
                    ByteOrder endian = numericMetadata.byteOrder();
                    String size = numericMetadata.size();
//                    if(NUMERIC_TYPES.containsKey(numericMetadata.type())) {
//                      numericType = NUMERIC_TYPES.get(numericMetadata.type());
//                    }

                    if (size.length() == 0) {
                        size = Integer.toString(numericType.getDefaultSize());
                    }
                    Expression<Integer, Resolver> sizeExpr = Expressions
                            .createInteger(context, size);
                    Expression<Integer, Resolver> matchExpr = null;
                    if (numericMetadata.match().trim().length() != 0) {
                        matchExpr = Expressions.createInteger(context,
                                numericMetadata.match());
                    }
                    return (Codec<T>) new NumericCodec(sizeExpr, endian,
                            numericType, matchExpr);
                }
            }
View Full Code Here

Examples of org.codehaus.preon.annotation.BoundNumber

            return null;
        }

        public Class<?> resolveActualType(AnnotatedElement overrides, Class<?> type) {
            if (overrides != null && overrides.isAnnotationPresent(BoundNumber.class)) {
                BoundNumber numericMetadata = overrides.getAnnotation(BoundNumber.class);
                Class<?> typeOverride = numericMetadata.type();
                if (typeOverride != Number.class) {
                    return typeOverride;
                }
            }
            return type;
View Full Code Here

Examples of org.codehaus.preon.annotation.BoundNumber

        public <T> Codec<T> create(AnnotatedElement metadata, Class<T> type,
                                   ResolverContext context) {
            if (type.isEnum() && metadata.isAnnotationPresent(BoundNumber.class)) {
                Map<Long, T> mapping = EnumUtils.getBoundEnumOptionIndex(type);
                BoundNumber settings = metadata.getAnnotation(BoundNumber.class);
                Expression<Integer, Resolver> sizeExpr = Expressions.createInteger(
                        context, settings.size());
                return new EnumCodec<T>(type, mapping, sizeExpr, settings
                        .byteOrder());

            } else {
                return null;
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.