Author: reto
Date: Tue Feb 19 15:22:33 2013
New Revision: 1447762

URL: http://svn.apache.org/r1447762
Log:
Fixed  formatting and import order to comply with codig guidelines

Modified:
    
stanbol/trunk/commons/web/rdfviewable-writer/src/main/java/org/apache/stanbol/commons/web/rdfviewable/writer/impl/RdfSerializingWriter.java

Modified: 
stanbol/trunk/commons/web/rdfviewable-writer/src/main/java/org/apache/stanbol/commons/web/rdfviewable/writer/impl/RdfSerializingWriter.java
URL: 
http://svn.apache.org/viewvc/stanbol/trunk/commons/web/rdfviewable-writer/src/main/java/org/apache/stanbol/commons/web/rdfviewable/writer/impl/RdfSerializingWriter.java?rev=1447762&r1=1447761&r2=1447762&view=diff
==============================================================================
--- 
stanbol/trunk/commons/web/rdfviewable-writer/src/main/java/org/apache/stanbol/commons/web/rdfviewable/writer/impl/RdfSerializingWriter.java
 (original)
+++ 
stanbol/trunk/commons/web/rdfviewable-writer/src/main/java/org/apache/stanbol/commons/web/rdfviewable/writer/impl/RdfSerializingWriter.java
 Tue Feb 19 15:22:33 2013
@@ -18,9 +18,6 @@
  */
 package org.apache.stanbol.commons.web.rdfviewable.writer.impl;
 
-import org.apache.clerezza.rdf.core.serializedform.Serializer;
-import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
-
 import java.io.IOException;
 import java.io.OutputStream;
 import java.lang.annotation.Annotation;
@@ -28,7 +25,6 @@ import java.lang.reflect.Type;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
-
 import javax.ws.rs.Produces;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Context;
@@ -37,12 +33,13 @@ import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.UriInfo;
 import javax.ws.rs.ext.MessageBodyWriter;
 import javax.ws.rs.ext.Provider;
-
 import org.apache.clerezza.rdf.core.Resource;
 import org.apache.clerezza.rdf.core.Triple;
 import org.apache.clerezza.rdf.core.TripleCollection;
 import org.apache.clerezza.rdf.core.UriRef;
 import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
+import org.apache.clerezza.rdf.core.serializedform.Serializer;
+import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
 import org.apache.clerezza.rdf.utils.GraphNode;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Property;
@@ -54,115 +51,116 @@ import org.apache.stanbol.commons.web.vi
  * By default this returns a serialization of the context of the GraphNode. The
  * template path of the RdfViewable is ignored.
  *
- * Same as with <code>org.apache.clerezza.jaxrs.rdf.providers</code> the 
- * expansion can be widened by using the query parameters xPropObj and
- * xProSubj. These parameters specify property uris (both parameters might be
- * repeated). For the specified properties their objects respectively subjects
- * are expanded as if they were bnodes.
- * 
+ * Same as with
+ * <code>org.apache.clerezza.jaxrs.rdf.providers</code> the expansion can be
+ * widened by using the query parameters xPropObj and xProSubj. These 
parameters
+ * specify property uris (both parameters might be repeated). For the specified
+ * properties their objects respectively subjects are expanded as if they were
+ * bnodes.
+ *
  */
 @Component
 @Service(Object.class)
-@Property(name="javax.ws.rs", boolValue=true)
+@Property(name = "javax.ws.rs", boolValue = true)
 @Provider
 @Produces({SupportedFormat.N3, SupportedFormat.N_TRIPLE,
-       SupportedFormat.RDF_XML, SupportedFormat.TURTLE,
-       SupportedFormat.X_TURTLE, SupportedFormat.RDF_JSON})
+    SupportedFormat.RDF_XML, SupportedFormat.TURTLE,
+    SupportedFormat.X_TURTLE, SupportedFormat.RDF_JSON})
 public class RdfSerializingWriter implements MessageBodyWriter<RdfViewable> {
 
-       public static final String OBJ_EXP_PARAM = "xPropObj";
-       public static final String SUBJ_EXP_PARAM = "xPropSubj";
-       
+    public static final String OBJ_EXP_PARAM = "xPropObj";
+    public static final String SUBJ_EXP_PARAM = "xPropSubj";
+    
     @Reference
-       private Serializer serializer;
-       private UriInfo uriInfo;
+    private Serializer serializer;
+    private UriInfo uriInfo;
 
-       @Override
-       public boolean isWriteable(Class<?> type, Type genericType,
-                       Annotation[] annotations, MediaType mediaType) {
-               return RdfViewable.class.isAssignableFrom(type);
-       }
-
-       @Override
-       public long getSize(RdfViewable n, Class<?> type, Type genericType,
-                       Annotation[] annotations, MediaType mediaType) {
-               return -1;
-       }
-
-       @Override
-       public void writeTo(RdfViewable v, Class<?> type, Type genericType,
-                       Annotation[] annotations, MediaType mediaType,
-                       MultivaluedMap<String, Object> httpHeaders,
-                       OutputStream entityStream) throws IOException, 
WebApplicationException {
+    @Override
+    public boolean isWriteable(Class<?> type, Type genericType,
+            Annotation[] annotations, MediaType mediaType) {
+        return RdfViewable.class.isAssignableFrom(type);
+    }
+
+    @Override
+    public long getSize(RdfViewable n, Class<?> type, Type genericType,
+            Annotation[] annotations, MediaType mediaType) {
+        return -1;
+    }
+
+    @Override
+    public void writeTo(RdfViewable v, Class<?> type, Type genericType,
+            Annotation[] annotations, MediaType mediaType,
+            MultivaluedMap<String, Object> httpHeaders,
+            OutputStream entityStream) throws IOException, 
WebApplicationException {
         GraphNode node = v.getGraphNode();
-               serializer.serialize(entityStream, getExpandedContext(node), 
mediaType.toString());
-       }
+        serializer.serialize(entityStream, getExpandedContext(node), 
mediaType.toString());
+    }
 
-       @Context
-       public void setUriInfo(UriInfo uriInfo) {
-               this.uriInfo = uriInfo;
-       }
-
-       private TripleCollection getExpandedContext(GraphNode node) {
-               final TripleCollection result = new 
SimpleMGraph(node.getNodeContext());
-               final Set<Resource> expandedResources = new HashSet<Resource>();
-               expandedResources.add(node.getNode());
-               while (true) {
-                       Set<Resource> additionalExpansionRes = 
getAdditionalExpansionResources(result);
-                       additionalExpansionRes.removeAll(expandedResources);
-                       if (additionalExpansionRes.size() == 0) {
-                               return result;
-                       }
-                       for (Resource resource : additionalExpansionRes) {
-                               final GraphNode additionalNode = new 
GraphNode(resource, node.getGraph());
-                               result.addAll(additionalNode.getNodeContext());
-                               expandedResources.add(resource);
-                       }
-               }
-       }
-
-       private Set<Resource> getAdditionalExpansionResources(TripleCollection 
tc) {
-               final Set<UriRef> subjectExpansionProperties = 
getSubjectExpansionProperties();
-               final Set<UriRef> objectExpansionProperties = 
getObjectExpansionProperties();
-               final Set<Resource> result = new HashSet<Resource>();
-               if ((subjectExpansionProperties.size() > 0)
-                               || (objectExpansionProperties.size() > 0)) {
-                       for (Triple triple : tc) {
-                               final UriRef predicate = triple.getPredicate();
-                               if 
(subjectExpansionProperties.contains(predicate)) {
-                                       result.add(triple.getSubject());
-                               }
-                               if 
(objectExpansionProperties.contains(predicate)) {
-                                       result.add(triple.getObject());
-                               }
-                       }
-               }
-               return result;
-       }
-
-       private Set<UriRef> getSubjectExpansionProperties() {
-               final MultivaluedMap<String, String> queryParams = 
uriInfo.getQueryParameters();
-               final List<String> paramValues = 
queryParams.get(SUBJ_EXP_PARAM);
-               if (paramValues == null) {
-                       return new HashSet<UriRef>(0);
-               }
-               final Set<UriRef> result = new 
HashSet<UriRef>(paramValues.size());
-               for (String uriString : paramValues) {
-                       result.add(new UriRef(uriString));
-               }
-               return result;
-       }
-
-       private Set<UriRef> getObjectExpansionProperties() {
-               final MultivaluedMap<String, String> queryParams = 
uriInfo.getQueryParameters();
-               final List<String> paramValues = queryParams.get(OBJ_EXP_PARAM);
-               if (paramValues == null) {
-                       return new HashSet<UriRef>(0);
-               }
-               final Set<UriRef> result = new 
HashSet<UriRef>(paramValues.size());
-               for (String uriString : paramValues) {
-                       result.add(new UriRef(uriString));
-               }
-               return result;
-       }
+    @Context
+    public void setUriInfo(UriInfo uriInfo) {
+        this.uriInfo = uriInfo;
+    }
+
+    private TripleCollection getExpandedContext(GraphNode node) {
+        final TripleCollection result = new 
SimpleMGraph(node.getNodeContext());
+        final Set<Resource> expandedResources = new HashSet<Resource>();
+        expandedResources.add(node.getNode());
+        while (true) {
+            Set<Resource> additionalExpansionRes = 
getAdditionalExpansionResources(result);
+            additionalExpansionRes.removeAll(expandedResources);
+            if (additionalExpansionRes.size() == 0) {
+                return result;
+            }
+            for (Resource resource : additionalExpansionRes) {
+                final GraphNode additionalNode = new GraphNode(resource, 
node.getGraph());
+                result.addAll(additionalNode.getNodeContext());
+                expandedResources.add(resource);
+            }
+        }
+    }
+
+    private Set<Resource> getAdditionalExpansionResources(TripleCollection tc) 
{
+        final Set<UriRef> subjectExpansionProperties = 
getSubjectExpansionProperties();
+        final Set<UriRef> objectExpansionProperties = 
getObjectExpansionProperties();
+        final Set<Resource> result = new HashSet<Resource>();
+        if ((subjectExpansionProperties.size() > 0)
+                || (objectExpansionProperties.size() > 0)) {
+            for (Triple triple : tc) {
+                final UriRef predicate = triple.getPredicate();
+                if (subjectExpansionProperties.contains(predicate)) {
+                    result.add(triple.getSubject());
+                }
+                if (objectExpansionProperties.contains(predicate)) {
+                    result.add(triple.getObject());
+                }
+            }
+        }
+        return result;
+    }
+
+    private Set<UriRef> getSubjectExpansionProperties() {
+        final MultivaluedMap<String, String> queryParams = 
uriInfo.getQueryParameters();
+        final List<String> paramValues = queryParams.get(SUBJ_EXP_PARAM);
+        if (paramValues == null) {
+            return new HashSet<UriRef>(0);
+        }
+        final Set<UriRef> result = new HashSet<UriRef>(paramValues.size());
+        for (String uriString : paramValues) {
+            result.add(new UriRef(uriString));
+        }
+        return result;
+    }
+
+    private Set<UriRef> getObjectExpansionProperties() {
+        final MultivaluedMap<String, String> queryParams = 
uriInfo.getQueryParameters();
+        final List<String> paramValues = queryParams.get(OBJ_EXP_PARAM);
+        if (paramValues == null) {
+            return new HashSet<UriRef>(0);
+        }
+        final Set<UriRef> result = new HashSet<UriRef>(paramValues.size());
+        for (String uriString : paramValues) {
+            result.add(new UriRef(uriString));
+        }
+        return result;
+    }
 }


Reply via email to