Package org.glassfish.jersey.message.filtering.spi

Examples of org.glassfish.jersey.message.filtering.spi.ObjectGraph


                                 final Class<?> entityClass, final Map<String, ObjectGraph> entitySubgraphs) {
        final Set<String> processed = Sets.newHashSet();

        for (final Map.Entry<String, ObjectGraph> entry : entitySubgraphs.entrySet()) {
            final Subgraph subgraph = graph.addSubgraph(entry.getKey());
            final ObjectGraph entityGraph = entry.getValue();

            final Set<String> fields = entityGraph.getFields(entry.getKey());
            if (!fields.isEmpty()) {
                subgraph.addAttributeNodes(fields.toArray(new String[fields.size()]));
            }

            final Map<String, ObjectGraph> subgraphs = entityGraph.getSubgraphs(entry.getKey());
            if (!subgraphs.isEmpty()) {
                final Class<?> subEntityClass = entityGraph.getEntityClass();

                processed.add(getProcessedSubgraph(entityClass, entry.getKey(), subEntityClass));
                createSubgraphs(entry.getKey(), subgraph, subEntityClass, subgraphs, processed);
            }
        }
View Full Code Here


    private void createSubgraphs(final String parent, final Subgraph graph, final Class<?> entityClass,
                                 final Map<String, ObjectGraph> entitySubgraphs, final Set<String> processed) {
        for (final Map.Entry<String, ObjectGraph> entry : entitySubgraphs.entrySet()) {
            final Subgraph subgraph = graph.addSubgraph(entry.getKey());
            final ObjectGraph entityGraph = entry.getValue();
           
            String path = parent + "." + entry.getKey();

            final Set<String> fields = entityGraph.getFields(path);
            if (!fields.isEmpty()) {
                subgraph.addAttributeNodes(fields.toArray(new String[fields.size()]));
            }

            final Map<String, ObjectGraph> subgraphs = entityGraph.getSubgraphs();
            final Class<?> subEntityClass = entityGraph.getEntityClass();
            final String processedSubgraph = getProcessedSubgraph(entityClass, entry.getKey(), subEntityClass);

            if (!subgraphs.isEmpty() && !processed.contains(processedSubgraph)) {
                processed.add(processedSubgraph);
                createSubgraphs(path, subgraph, subEntityClass, subgraphs, processed);
View Full Code Here

    @Override
    public Object readFrom(final Class<Object> type, final Type genericType, final Annotation[] annotations,
                           final MediaType mediaType, final MultivaluedMap<String, String> httpHeaders,
                           final InputStream entityStream) throws IOException, WebApplicationException {
        final ObjectGraph objectGraph = provider.get()
                .getFilteringObject(FilteringHelper.getEntityClass(genericType), false, annotations);

        return objectGraphToString(objectGraph);
    }
View Full Code Here

    @Override
    public void writeTo(final Object o, final Class<?> type, final Type genericType, final Annotation[] annotations,
                        final MediaType mediaType, final MultivaluedMap<String, Object> httpHeaders,
                        final OutputStream entityStream) throws IOException, WebApplicationException {
        final ObjectGraph objectGraph = provider.get()
                .getFilteringObject(FilteringHelper.getEntityClass(genericType), true, annotations);

        entityStream.write(objectGraphToString(objectGraph).getBytes());
    }
View Full Code Here

TOP

Related Classes of org.glassfish.jersey.message.filtering.spi.ObjectGraph

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.