Package com.theoryinpractise.halbuilder.impl

Examples of com.theoryinpractise.halbuilder.impl.ContentType


    private NamespaceManager namespaceManager = new NamespaceManager();
    private List<Link> links = Lists.newArrayList();
    private Set<URI> flags = Sets.newHashSet();

    public DefaultRepresentationFactory withRenderer(String contentType, Class<? extends RepresentationWriter<String>> rendererClass) {
        contentRenderers.put(new ContentType(contentType), rendererClass);
        return this;
    }
View Full Code Here


        contentRenderers.put(new ContentType(contentType), rendererClass);
        return this;
    }

    public DefaultRepresentationFactory withReader(String contentType, Class<? extends RepresentationReader> readerClass) {
        representationReaders.put(new ContentType(contentType), readerClass);
        return this;
    }
View Full Code Here

            bufferedReader.reset();

            Class<? extends RepresentationReader> readerClass;
            switch (firstChar) {
                case '{':
                    readerClass = representationReaders.get(new ContentType(HAL_JSON));
                    break;
                case '<':
                    readerClass = representationReaders.get(new ContentType(HAL_XML));
                    break;
                default:
                    throw new RepresentationException("unrecognized initial character in stream: " + firstChar);
            }
            Constructor<? extends RepresentationReader> readerConstructor = readerClass.getConstructor(RepresentationFactory.class);
View Full Code Here

    private NamespaceManager namespaceManager = new NamespaceManager();
    private List<Link> links = Lists.newArrayList();
    private Set<URI> flags = Sets.newHashSet();

    public DefaultRepresentationFactory withRenderer(String contentType, Class<? extends RepresentationWriter<String>> rendererClass) {
        contentRenderers.put(new ContentType(contentType), rendererClass);
        return this;
    }
View Full Code Here

        contentRenderers.put(new ContentType(contentType), rendererClass);
        return this;
    }

    public DefaultRepresentationFactory withReader(String contentType, Class<? extends RepresentationReader> readerClass) {
        representationReaders.put(new ContentType(contentType), readerClass);
        return this;
    }
View Full Code Here

    }

    @Override
    public ContentRepresentation readRepresentation(String contentType, Reader reader) {
        try {
            Class<? extends RepresentationReader> readerClass = representationReaders.get(new ContentType(contentType));
            if (readerClass == null) {
              throw new IllegalStateException("No representation reader for content type " + contentType + " registered.");
            }
            Constructor<? extends RepresentationReader> readerConstructor = readerClass.getConstructor(AbstractRepresentationFactory.class);
            return readerConstructor.newInstance(this).read(reader);
View Full Code Here

TOP

Related Classes of com.theoryinpractise.halbuilder.impl.ContentType

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.