Examples of BoundList


Examples of org.codehaus.preon.annotation.BoundList

     */

    @SuppressWarnings("unchecked")
    public <T> Codec<T> create(AnnotatedElement metadata, Class<T> type,
                               ResolverContext context) {
        BoundList settings = null;
        if (metadata != null
                && (settings = metadata.getAnnotation(BoundList.class)) != null
                && type.isArray()
                && settings.size() != null
                && settings.size().length() != 0) {
            Expression<Integer, Resolver> expr = getSizeExpression(settings,
                    context);
            Codec<Object> elementCodec = null;
            if (type.getComponentType().isPrimitive()) {
                elementCodec = (Codec<Object>) factory.create(null, type
View Full Code Here

Examples of org.codehaus.preon.annotation.BoundList

        this.codecFactory = codecFactory;
    }

    public <T> Codec<T> create(AnnotatedElement metadata, Class<T> type, ResolverContext context) {
        if (Map.class.isAssignableFrom(type)) {
            BoundList boundList = metadata.getAnnotation(BoundList.class);
            if (boundList != null && typeIsGuaranteedToBeEntry(boundList)) {
                Codec<List> listCodec =
                        codecFactory.create(metadata, List.class, context);
                if (listCodec != null) {
                    return new ListBasedMapCodec(listCodec);
View Full Code Here

Examples of org.codehaus.preon.annotation.BoundList

    // JavaDoc inherited.

    @SuppressWarnings("unchecked")
    public <T> Codec<T> create(AnnotatedElement metadata, Class<T> type,
                               ResolverContext context) {
        BoundList settings = null;
        if (metadata != null
                && (settings = metadata.getAnnotation(BoundList.class)) != null
                && java.util.List.class.equals(type)) {
            Codec<?> codec = createElementCodec(context, settings);
            if (settings.size().length() == 0) {
                // So, we don't know the number of elements in this list.
                // This means we need to keep on reading elements until we get
                // an 'EOF' or a DecodingException. In case of a
                // DecodingException, the pointer is expected to be moved back
                // to the first position.
                return (Codec<T>) new DynamicListCodec(codec);
            } else if (settings.offset().length() != 0) {
                // So the size is known. If the offset attribute has been set,
                // it means we can calculate the position of the individual
                // elements based on the index of that element.
                Expression<Integer, Resolver> size = getSizeExpression(
                        settings, context);
                Expression<Integer, Resolver> offsets = null;
                CodecDescriptorHolder holder = new CodecDescriptorHolder();
                offsets = Expressions.createInteger(new IndexedResolverContext(
                        context, holder), settings.offset());
                Codec<T> result = (Codec<T>) new OffsetListCodec(offsets, size,
                        codec);
                // TODO:
                holder.setDescriptor(result.getCodecDescriptor());
                return result;
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.