Package org.codehaus.preon.buffer

Examples of org.codehaus.preon.buffer.ByteOrder


    public CodecSelector create(ResolverContext context,
                                List<Codec<?>> allCodecs) {
        int size = -1;
        List<Expression<Integer, Resolver>> expressions = new ArrayList<Expression<Integer, Resolver>>();
        List<Codec<?>> codecs = new ArrayList<Codec<?>>();
        ByteOrder byteOrder = null;
        for (Codec<?> codec : allCodecs) {
            for (Class<?> valueType : codec.getTypes()) {
                TypePrefix prefix = (TypePrefix) valueType
                        .getAnnotation(TypePrefix.class);
                if (prefix == null) {
                    throw new CodecConstructionException(
                            "To little context to decide between codecs.");
                } else {
                    if (byteOrder == null) {
                        byteOrder = prefix.byteOrder();
                    } else {
                        if (byteOrder != prefix.byteOrder()) {
                            throw new CodecConstructionException("Two distinct types of byte orders are not supported: "
                            + "expected " + byteOrder.asText() + ", got "
                            + prefix.byteOrder().asText() + " for " + codec);
                        }
                    }
                    if (size != -1) {
                        if (size != prefix.size()) {
View Full Code Here


            Class<?> actualType = resolveActualType(overrides, type);
            if (NUMERIC_TYPES.keySet().contains(actualType)) {
                NumericType numericType = NUMERIC_TYPES.get(actualType);
                if (overrides == null || overrides.isAnnotationPresent(Bound.class)) {
                    ByteOrder endian = ByteOrder.LittleEndian;
                    int size = numericType.getDefaultSize();
                    Expression<Integer, Resolver> sizeExpr = Expressions
                            .createInteger(context, Integer.toString(size));
                    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());
//                    }
View Full Code Here

TOP

Related Classes of org.codehaus.preon.buffer.ByteOrder

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.