Commits

Sam Adams  committed 59fd9ac

Made loads of stuff final\!

  • Participants
  • Parent commits 6851c32

Comments (0)

Files changed (7)

File chemistry-common/src/main/java/uk/ac/cam/ch/wwmm/chempound/chemistry/Cml2RdfConverter.java

  */
 public class Cml2RdfConverter {
 
-    protected void addParameters(Model model, Resource parentNode, List<CMLParameter> parameters) {
-        for (CMLParameter parameter : parameters) {
-            QName dictRef = getDictRefUri(parameter);
+    protected void addParameters(final Model model, final Resource parentNode, final List<CMLParameter> parameters) {
+        for (final CMLParameter parameter : parameters) {
+            final QName dictRef = getDictRefUri(parameter);
 
-            Property prop = getProperty(model, dictRef);
-            CMLScalar scalar = (CMLScalar) parameter.getFirstCMLChild(CMLScalar.TAG);
+            final Property prop = getProperty(model, dictRef);
+            final CMLScalar scalar = (CMLScalar) parameter.getFirstCMLChild(CMLScalar.TAG);
             if (scalar != null) {
-                RDFNode rdfNode = CmlRdfUtils.createResource(scalar, model);
+                final RDFNode rdfNode = CmlRdfUtils.createResource(scalar, model);
                 if (rdfNode.isResource()) {
                     // Ignore duplicate complex types
                     if (parentNode.hasProperty(prop)) {
         }
     }
 
-    protected void addCmlProperties(Model model, Resource resource, List<CMLProperty> nodes) {
-        for (CMLProperty property : nodes) {
-            Elements elements = property.getChildElements();
+    protected void addCmlProperties(final Model model, final Resource resource, final List<CMLProperty> nodes) {
+        for (final CMLProperty property : nodes) {
+            final Elements elements = property.getChildElements();
             if (elements.size() == 1) {
-                Element child = elements.get(0);
+                final Element child = elements.get(0);
                 addProperty(model, resource, property, child);
             }
         }
     }
 
-    protected void addProperty(Model model, Resource resource, CMLProperty property, Element value) {
+    protected void addProperty(final Model model, final Resource resource, final CMLProperty property, final Element value) {
         if (value instanceof CMLScalar) {
-            QName dictRef = getDictRefUri(property);
+            final QName dictRef = getDictRefUri(property);
             if (dictRef != null) {
-                Property prop = getProperty(model, dictRef);
+                final Property prop = getProperty(model, dictRef);
                 addScalar(model, resource, prop, (CMLScalar) value);
             } else {
                 System.err.println("** Missing dictRef **");
                 System.err.println("*********************");
             }
         } else {
-            QName dictRef = getDictRefUri(property);
+            final QName dictRef = getDictRefUri(property);
             if (dictRef != null) {
-                Property prop = getHasProperty(model, dictRef);
+                final Property prop = getHasProperty(model, dictRef);
                 resource.addLiteral(prop, true);
             } else {
                 System.err.println("** Missing dictRef **");
     }
 
 
-    protected void addScalar(Model model, Resource resource, Property property, CMLScalar value) {
-        RDFNode rdfNode = createScalarValueResource(model, property, value);
+    protected void addScalar(final Model model, final Resource resource, final Property property, final CMLScalar value) {
+        final RDFNode rdfNode = createScalarValueResource(model, property, value);
         resource.addProperty(property, rdfNode);
     }
 
-    protected RDFNode createScalarValueResource(Model model, Property property, CMLScalar value) {
-        RDFNode rdfNode = CmlRdfUtils.createResource(value, model);
+    protected RDFNode createScalarValueResource(final Model model, final Property property, final CMLScalar value) {
+        final RDFNode rdfNode = CmlRdfUtils.createResource(value, model);
         return rdfNode;
     }
 
-    protected Property getProperty(Model model, QName dictRef) {
-        String uri = getPropertyUri(dictRef.getNamespaceURI(), dictRef.getLocalPart());
+    protected Property getProperty(final Model model, final QName dictRef) {
+        final String uri = getPropertyUri(dictRef.getNamespaceURI(), dictRef.getLocalPart());
         return model.createProperty(uri);
     }
 
-    protected final String getPropertyUri(QName dictRef) {
+    protected final String getPropertyUri(final QName dictRef) {
         return getPropertyUri(dictRef.getNamespaceURI(), dictRef.getLocalPart());
     }
 
-    protected String getPropertyUri(String namespaceURI, String localPart) {
+    protected String getPropertyUri(final String namespaceURI, final String localPart) {
         if (namespaceURI.endsWith("#") || namespaceURI.endsWith("/")) {
             return namespaceURI + localPart;
         } else {
         }
     }
 
-    protected Property getHasProperty(Model model, QName dictRef) {
+    protected Property getHasProperty(final Model model, final QName dictRef) {
         String localPart = dictRef.getLocalPart();
         localPart = "has"+Character.toUpperCase(localPart.charAt(0)) + localPart.substring(1);
-        String uri = getPropertyUri(dictRef.getNamespaceURI(), localPart);
+        final String uri = getPropertyUri(dictRef.getNamespaceURI(), localPart);
         return model.createProperty(uri);
     }
 
 
-    public <T extends HasDictRef> Multimap<String, T> generateDictRefMap(Elements elements, Class<T> type) {
-        List<Element> nodes = new ArrayList<Element>();
+    public <T extends HasDictRef> Multimap<String, T> generateDictRefMap(final Elements elements, final Class<T> type) {
+        final List<Element> nodes = new ArrayList<Element>();
         for (int i = 0; i < elements.size(); i++) {
             nodes.add(elements.get(i));
         }
         return generateDictRefMap(nodes, type);
     }
 
-    protected <T extends HasDictRef> Multimap<String, T> generateDictRefMap(List<Element> nodes, Class<T> type) {
-        Multimap<String,T> map = ArrayListMultimap.create();
-        for (Element node : nodes) {
-            T element = type.cast(node);
-            QName dictRef = getDictRefUri(element);
+    protected <T extends HasDictRef> Multimap<String, T> generateDictRefMap(final List<Element> nodes, final Class<T> type) {
+        final Multimap<String,T> map = ArrayListMultimap.create();
+        for (final Element node : nodes) {
+            final T element = type.cast(node);
+            final QName dictRef = getDictRefUri(element);
             if (dictRef != null) {
                 map.put(getPropertyUri(dictRef), element);
             }
     }
 
 
-    protected QName getDictRefUri(String dictRef, CMLElement context) {
-        int i = dictRef.indexOf(':');
-        String prefix = dictRef.substring(0, i);
-        String localName = dictRef.substring(i+1);
-        String uri = context.getNamespaceURI(prefix);
+    protected QName getDictRefUri(final String dictRef, final CMLElement context) {
+        final int i = dictRef.indexOf(':');
+        final String prefix = dictRef.substring(0, i);
+        final String localName = dictRef.substring(i+1);
+        final String uri = context.getNamespaceURI(prefix);
         if (uri == null) {
             System.out.println("!! No dictRef URI: "+dictRef);
             return null;
         return new QName(uri, localName, prefix);
     }
 
-    protected QName getDictRefUri(HasDictRef element) {
-        String dictRef = element.getDictRef();
-        CMLElement context = (CMLElement) element;
+    protected QName getDictRefUri(final HasDictRef element) {
+        final String dictRef = element.getDictRef();
+        final CMLElement context = (CMLElement) element;
         if (dictRef != null) {
             return getDictRefUri(dictRef, context);
         }
         return null;
     }
 
-    protected List<CMLProperty> findCmlProperties(Element context) {
-        List<CMLProperty> properties = new ArrayList<CMLProperty>();
-        List<Node> list = CMLUtil.getQueryNodes(context, "./cml:property | ./cml:propertyList/cml:property", CMLConstants.CML_XPATH);
-        for (Node node : list) {
+    protected List<CMLProperty> findCmlProperties(final Element context) {
+        final List<CMLProperty> properties = new ArrayList<CMLProperty>();
+        final List<Node> list = CMLUtil.getQueryNodes(context, "./cml:property | ./cml:propertyList/cml:property", CMLConstants.CML_XPATH);
+        for (final Node node : list) {
             properties.add((CMLProperty)node);
         }
         return properties;
     }
 
-    protected List<CMLParameter> findCmlParameters(Element context) {
-        List<CMLParameter> properties = new ArrayList<CMLParameter>();
-        List<Node> list = CMLUtil.getQueryNodes(context, "./cml:parameter | ./cml:parameterList/cml:parameter", CMLConstants.CML_XPATH);
-        for (Node node : list) {
+    protected List<CMLParameter> findCmlParameters(final Element context) {
+        final List<CMLParameter> properties = new ArrayList<CMLParameter>();
+        final List<Node> list = CMLUtil.getQueryNodes(context, "./cml:parameter | ./cml:parameterList/cml:parameter", CMLConstants.CML_XPATH);
+        for (final Node node : list) {
             properties.add((CMLParameter)node);
         }
         return properties;

File chemistry-common/src/main/java/uk/ac/cam/ch/wwmm/chempound/chemistry/CmlRdfUtils.java

  */
 public class CmlRdfUtils {
 
-
-    public static RDFNode createResource(CMLScalar scalar, Model model) {
-        RDFNode valueNode = createValueNode(scalar, model);
-        RDFNode unitsNode = createUnitsNode(scalar, model);
-        RDFNode errorNode = createErrorNode(scalar, model);
+    public static RDFNode createResource(final CMLScalar scalar, final Model model) {
+        final RDFNode valueNode = createValueNode(scalar, model);
+        final RDFNode unitsNode = createUnitsNode(scalar, model);
+        final RDFNode errorNode = createErrorNode(scalar, model);
 
         // Force bNode creation for non-string
         if (unitsNode == null && errorNode == null) {
             }
         }
 
-        Resource bnode = model.createResource();
+        final Resource bnode = model.createResource();
         bnode.addProperty(RDF.value, valueNode);
         if (unitsNode != null) {
             bnode.addProperty(CmlRdf.units, unitsNode);
         return bnode;
     }
 
-    public static RDFNode createValueNode(CMLScalar scalar, Model model) {
-        String dataType = scalar.getDataType();
+    public static RDFNode createValueNode(final CMLScalar scalar, final Model model) {
+        final String dataType = scalar.getDataType();
         if ("xsd:string".equals(dataType)) {
             return model.createTypedLiteral(scalar.getString().trim());
         }
             return model.createTypedLiteral(scalar.getBoolean());
         }
         if ("xsd:date".equals(dataType)) {
-            DateTime dt = scalar.getDate();
+            final DateTime dt = scalar.getDate();
             return model.createTypedLiteral(dt.toDate());
         }
         throw new IllegalArgumentException("Unsupported data type: "+dataType);
     }
 
-    public static RDFNode createUnitsNode(CMLScalar scalar, Model model) {
-        String units = scalar.getUnits();
+    public static RDFNode createUnitsNode(final CMLScalar scalar, final Model model) {
+        final String units = scalar.getUnits();
         if (units != null) {
-            String uri = getDictRefUri(units, scalar);
+            final String uri = getDictRefUri(units, scalar);
             if (uri != null) {
                 return model.createResource(uri);
             }
         return null;
     }
 
-    public static RDFNode createErrorNode(CMLScalar scalar, Model model) {
+    public static RDFNode createErrorNode(final CMLScalar scalar, final Model model) {
         if (scalar.getErrorValueAttribute() != null) {
             return model.createTypedLiteral(scalar.getErrorValue());
         }
         return null;
     }
 
-    public static String getDictRefUri(String dictRef, CMLElement context) {
-        int i = dictRef.indexOf(':');
-        String prefix = dictRef.substring(0, i);
-        String localName = dictRef.substring(i+1);
-        String uri = context.getNamespaceURI(prefix);
+    public static String getDictRefUri(final String dictRef, final CMLElement context) {
+        final int i = dictRef.indexOf(':');
+        final String prefix = dictRef.substring(0, i);
+        final String localName = dictRef.substring(i+1);
+        final String uri = context.getNamespaceURI(prefix);
         if (uri == null) {
             // TODO
             return null;
         return uri + localName;
     }
 
-    public static String getDictRefUri(HasDictRef element) {
-        String dictRef = element.getDictRef();
-        CMLElement context = (CMLElement) element;
+    public static String getDictRefUri(final HasDictRef element) {
+        final String dictRef = element.getDictRef();
+        final CMLElement context = (CMLElement) element;
         if (dictRef != null) {
             return getDictRefUri(dictRef, context);
         }

File chemistry-common/src/main/java/uk/ac/cam/ch/wwmm/chempound/chemistry/inchi/InchiTool.java

 	 * @return the InChI string for the objects molecule. Returns null if there
 	 * was a problem during generation.
 	 */
-	public static String generateInchi(CMLMolecule molecule, String options) {
+	public static String generateInchi(final CMLMolecule molecule, final String options) {
         if (molecule == null) {
             throw new IllegalArgumentException("Null argument: molecule");
         }
         try {
-            JniInchiInput input = getInchiInput(molecule, options);
-            JniInchiOutput output = JniInchiWrapper.getInchi(input);
+            final JniInchiInput input = getInchiInput(molecule, options);
+            final JniInchiOutput output = JniInchiWrapper.getInchi(input);
             if (output.getReturnStatus() == INCHI_RET.OKAY) {
                 return output.getInchi();
             }
         }
 	}
 
-    public static String generateInchiKey(String inchi) {
+    public static String generateInchiKey(final String inchi) {
         if (inchi == null) {
             throw new IllegalArgumentException("Null argument: inchi");
         }
         try {
-            JniInchiOutputKey output = JniInchiWrapper.getInchiKey(inchi);
+            final JniInchiOutputKey output = JniInchiWrapper.getInchiKey(inchi);
             return output.getKey();
         } catch (JniInchiException e) {
             throw new RuntimeException(e);
 	 * @throws net.sf.jniinchi.JniInchiException if there is an error is generating the
 	 * <code>JniInchiInput</code>.
 	 */
-	private static JniInchiInput getInchiInput(CMLMolecule molecule, String options) throws JniInchiException {
-		JniInchiInput input = new JniInchiInput(options);
-		Map<String, JniInchiAtom> jniAtomList = new HashMap<String, JniInchiAtom>(molecule.getAtomCount());
-		for (CMLAtom atom : molecule.getAtoms()) {
-            JniInchiAtom inchiAtom = new JniInchiAtom(atom.getX3(), atom.getY3(), atom.getZ3(), atom.getElementType());
+	private static JniInchiInput getInchiInput(final CMLMolecule molecule, final String options) throws JniInchiException {
+		final JniInchiInput input = new JniInchiInput(options);
+		final Map<String, JniInchiAtom> jniAtomList = new HashMap<String, JniInchiAtom>(molecule.getAtomCount());
+		for (final CMLAtom atom : molecule.getAtoms()) {
+            final JniInchiAtom inchiAtom = new JniInchiAtom(atom.getX3(), atom.getY3(), atom.getZ3(), atom.getElementType());
             inchiAtom.setImplicitH(0);
-            JniInchiAtom a1 = input.addAtom(inchiAtom);
+            final JniInchiAtom a1 = input.addAtom(inchiAtom);
 			jniAtomList.put(atom.getId(), a1);
 		}
-		for (CMLBond bond : molecule.getBonds()) {
-			String[] atomRefs = bond.getAtomRefs2();
-			JniInchiAtom a0 = jniAtomList.get(atomRefs[0]);
-			JniInchiAtom a1 = jniAtomList.get(atomRefs[1]);
+		for (final CMLBond bond : molecule.getBonds()) {
+			final String[] atomRefs = bond.getAtomRefs2();
+			final JniInchiAtom a0 = jniAtomList.get(atomRefs[0]);
+			final JniInchiAtom a1 = jniAtomList.get(atomRefs[1]);
 			input.addBond(new JniInchiBond(a0, a1, getBondType(bond)));
 		}
 		return input;
 	 *
 	 * @return bond type of the provided bond.
 	 */
-	private static INCHI_BOND_TYPE getBondType(CMLBond bond) {
-		String order = bond.getOrder();
+	private static INCHI_BOND_TYPE getBondType(final CMLBond bond) {
+		final String order = bond.getOrder();
 		if ("1".equals(order) || "S".equals(order)) {
 			return INCHI_BOND_TYPE.SINGLE;
 		} else if ("2".equals(order) || "D".equals(order)) {
 	}
 
 
-    public static void attachIdentifiers(Node root) {
-        for (Node node : CMLUtil.getQueryNodes(root, "//cml:molecule", CML_XPATH)) {
-            CMLMolecule mol = (CMLMolecule) node;
-            String inchi = InchiTool.generateInchi(mol, null);
+    public static void attachIdentifiers(final Node root) {
+        for (final Node node : CMLUtil.getQueryNodes(root, "//cml:molecule", CML_XPATH)) {
+            final CMLMolecule mol = (CMLMolecule) node;
+            final String inchi = InchiTool.generateInchi(mol, null);
             attachInchi(mol, inchi);
-            String inchiKey = InchiTool.generateInchiKey(inchi);
+            final String inchiKey = InchiTool.generateInchiKey(inchi);
             attachInchiKey(mol, inchiKey);
         }
     }
 
-    public static void attachInchi(CMLMolecule mol, String inchi) {
-        CMLIdentifier identifier = new CMLIdentifier();
+    public static void attachInchi(final CMLMolecule mol, final String inchi) {
+        final CMLIdentifier identifier = new CMLIdentifier();
         identifier.setConvention("iupac:inchi");
         identifier.setCMLValue(inchi);
         mol.appendChild(identifier);
     }
 
-    public static void attachInchiKey(CMLMolecule mol, String inchiKey) {
-        CMLIdentifier identifier = new CMLIdentifier();
+    public static void attachInchiKey(final CMLMolecule mol, final String inchiKey) {
+        final CMLIdentifier identifier = new CMLIdentifier();
         identifier.setConvention("iupac:inchiKey");
         identifier.setCMLValue(inchiKey);
         mol.appendChild(identifier);

File chemistry-importer/src/main/java/uk/ac/cam/ch/wwmm/chempound/chemistry/CmlImporter.java

         return imageDimension;
     }
 
-    public void setImageDimension(int imageDimension) {
+    public void setImageDimension(final int imageDimension) {
         this.imageDimension = imageDimension;
     }
 
         return thumbnailDimension;
     }
 
-    public void setThumbnailDimension(int thumbnailDimension) {
+    public void setThumbnailDimension(final int thumbnailDimension) {
         this.thumbnailDimension = thumbnailDimension;
     }
 
 
 
-    protected void createImages(LocalResource resource, String ext, File imageFile, File thumbnailFile) throws IOException {
-        File tempFile = File.createTempFile("mol", ext);
+    protected void createImages(final LocalResource resource, final String ext, final File imageFile, final File thumbnailFile) throws IOException {
+        final File tempFile = File.createTempFile("mol", ext);
         try {
             write(resource, tempFile);
 
-            ImageGeneratorJmol imageGen = new ImageGeneratorJmol();
+            final ImageGeneratorJmol imageGen = new ImageGeneratorJmol();
             try {
                 imageGen.loadMolecule(tempFile);
 
         }
     }
 
-    protected void createImages(CMLMolecule molecule, File imageFile, File thumbnailFile) throws IOException {
-        File tempFile = File.createTempFile("mol", "cml");
+    protected void createImages(final CMLMolecule molecule, final File imageFile, final File thumbnailFile) throws IOException {
+        final File tempFile = File.createTempFile("mol", "cml");
         try {
             write(molecule, tempFile);
 
-            ImageGeneratorJmol imageGen = new ImageGeneratorJmol();
+            final ImageGeneratorJmol imageGen = new ImageGeneratorJmol();
             try {
                 imageGen.loadMolecule(tempFile);
                 imageGen.setShowAxes(true);
         }
     }
 
-    protected void createThumbnail(File thumbnailFile, ImageGeneratorJmol imageGen) {
+    protected void createThumbnail(final File thumbnailFile, final ImageGeneratorJmol imageGen) {
         imageGen.setShowAxes(false);
         imageGen.setShowUnitCell(false);
         imageGen.setFrankOn(false);
         imageGen.createImage(thumbnailFile, getThumbnailDimension(), getThumbnailDimension());
     }
 
-    protected void createImage(File imageFile, ImageGeneratorJmol imageGen) {
+    protected void createImage(final File imageFile, final ImageGeneratorJmol imageGen) {
         imageGen.setShowAxes(true);
         imageGen.setShowUnitCell(true);
         imageGen.createImage(imageFile, getImageDimension(), getImageDimension());
     }
 
 
-    protected static void write(Element element, File file) throws IOException {
-        Element copy = (Element) element.copy();
+    protected static void write(final Element element, final File file) throws IOException {
+        final Element copy = (Element) element.copy();
         write(new Document(copy), file);
     }
 
-    protected static void write(Document doc, File file) throws IOException {
-        BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file));
+    protected static void write(final Document doc, final File file) throws IOException {
+        final BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file));
         try {
-            Serializer ser = new Serializer(out);
+            final Serializer ser = new Serializer(out);
             ser.write(doc);
         } finally {
             IOUtils.closeQuietly(out);
         }
     }
 
-    protected static void write(LocalResource resource, File file) throws IOException {
-        FileOutputStream out = new FileOutputStream(file);
+    protected static void write(final LocalResource resource, final File file) throws IOException {
+        final FileOutputStream out = new FileOutputStream(file);
         try {
-            InputStream in = resource.openInputStream();
+            final InputStream in = resource.openInputStream();
             try {
                 IOUtils.copy(in, out);
             } finally {
         }
     }
 
-    protected static LocalResource createCmlResource(Element cml, String path) throws IOException {
-        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
-        Serializer ser = new Serializer(buffer);
-        Document doc = cml.getDocument() != null ? cml.getDocument() : new Document(cml);
+    protected static LocalResource createCmlResource(final Element cml, final String path) throws IOException {
+        final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+        final Serializer ser = new Serializer(buffer);
+        final Document doc = cml.getDocument() != null ? cml.getDocument() : new Document(cml);
         ser.write(doc);
-        byte[] bytes = buffer.toByteArray();
+        final byte[] bytes = buffer.toByteArray();
         return new InMemoryResource(path, CHEMICAL_CML, bytes);
     }
 
-    protected static LocalResource createImageResource(File file, String path) throws IOException {
-        byte[] buffer = FileUtils.readFileToByteArray(file);
+    protected static LocalResource createImageResource(final File file, final String path) throws IOException {
+        final byte[] buffer = FileUtils.readFileToByteArray(file);
         return new InMemoryResource(path, MimeType.IMAGE_PNG, buffer);
     }
 
 
-    protected static LocalResource createCmlResource(Document doc, String path) throws IOException {
-        byte[] bytes = writeDocument(doc);
+    protected static LocalResource createCmlResource(final Document doc, final String path) throws IOException {
+        final byte[] bytes = writeDocument(doc);
         return new InMemoryResource(path, CHEMICAL_CML, bytes);
     }
 
 
-    public static Document reloadCml(Element cml) throws IOException, ParsingException {
-        Document doc = cml.getDocument() == null ? new Document(cml) : cml.getDocument();
+    public static Document reloadCml(final Element cml) throws IOException, ParsingException {
+        final Document doc = cml.getDocument() == null ? new Document(cml) : cml.getDocument();
         return reloadCml(doc);
     }
 
-    public static Document reloadCml(Document doc) throws IOException, ParsingException {
-        byte[] buffer = writeDocument(doc);
+    public static Document reloadCml(final Document doc) throws IOException, ParsingException {
+        final byte[] buffer = writeDocument(doc);
         return readCml(buffer);
     }
 
-    public static Document readCml(byte[] buffer) throws IOException, ParsingException {
-        CMLBuilder builder = new CMLBuilder();
+    public static Document readCml(final byte[] buffer) throws IOException, ParsingException {
+        final CMLBuilder builder = new CMLBuilder();
         return builder.build(new ByteArrayInputStream(buffer));
     }
 
-    public static byte[] writeDocument(Document doc) throws IOException {
-        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
-        Serializer ser = new Serializer(buffer);
+    public static byte[] writeDocument(final Document doc) throws IOException {
+        final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+        final Serializer ser = new Serializer(buffer);
         ser.write(doc);
         return buffer.toByteArray();
     }

File chemistry-jmol-plugin/src/main/java/uk/ac/cam/ch/wwmm/chempound/plugins/jmol/JmolPlugin.java

     private Directory directory;
 
     @Inject
-    public JmolPlugin(Context context) {
+    public JmolPlugin(final Context context) {
         super(context, "jmol");
     }
 
     @Override
     public void start() throws Exception {
         super.start();
-        String path = "/"+JmolPlugin.class.getPackage().getName().replace('.', '/') + "/resources";
-        LocalReference ref = LocalReference.createClapReference(LocalReference.CLAP_CLASS, path);
+        final String path = "/"+JmolPlugin.class.getPackage().getName().replace('.', '/') + "/resources";
+        final LocalReference ref = LocalReference.createClapReference(LocalReference.CLAP_CLASS, path);
         this.directory = new Directory(getContext(), ref);
         this.directory.setListingAllowed(true);
         this.directory.setNegotiatingContent(false);
     }
 
     @Override
-    public void handle(Request request, Response response) {
+    public void handle(final Request request, final Response response) {
         this.directory.handle(request, response);
     }
 

File chemistry-search-structure/src/main/java/uk/ac/cam/ch/wwmm/chempound/webapp/search/chemistry/MoleculeIndexer.java

  */
 public class MoleculeIndexer implements ContentIndexer<CMLMolecule> {
 
-    private ChempoundConfiguration config;
+    private final ChempoundConfiguration config;
 
-    private File indexFile;
+    private final File indexFile;
 
     @Inject
-    public MoleculeIndexer(ChempoundConfiguration config) throws IOException {
+    public MoleculeIndexer(final ChempoundConfiguration config) throws IOException {
         this.config = config;
-        File dir = new File(config.getWorkspace(), "index/molecule");
+        final File dir = new File(config.getWorkspace(), "index/molecule");
         FileUtils.forceMkdir(dir);
         this.indexFile = new File(dir, "index.smiles");
     }
     }
 
     @Override
-    public void index(Item item, List<? extends CMLMolecule> objects) throws FileNotFoundException {
-        List<String> smiles = new ArrayList<String>();
-        for (CMLMolecule mol : objects) {
+    public void index(final Item item, final List<? extends CMLMolecule> objects) throws FileNotFoundException {
+        final List<String> smiles = new ArrayList<String>();
+        for (final CMLMolecule mol : objects) {
             // TODO generate SMILES
         }
         appendToIndex(smiles, item.getUri());
     }
 
-    private synchronized void appendToIndex(List<String> smiles, URI uri) throws FileNotFoundException {
+    private synchronized void appendToIndex(final List<String> smiles, final URI uri) throws FileNotFoundException {
         if (!smiles.isEmpty()) {
-            boolean append = true;
-            PrintStream out = new PrintStream(new BufferedOutputStream(new FileOutputStream(indexFile, append)));
-            for (String s : smiles) {
+            final boolean append = true;
+            final PrintStream out = new PrintStream(new BufferedOutputStream(new FileOutputStream(indexFile, append)));
+            for (final String s : smiles) {
                 out.print(s);
                 out.print('\t');
                 out.print(uri.toString());

File chemistry-search-structure/src/main/java/uk/ac/cam/ch/wwmm/chempound/webapp/search/chemistry/StructureSearchProvider.java

 
     @Override
     public String getSearchForm() {
-        InputStream in = getClass().getResourceAsStream("search-structure.html");
+        final InputStream in = getClass().getResourceAsStream("search-structure.html");
         try {
             return IOUtils.toString(in, "UTF-8");
         } catch (IOException e) {
     }
 
     @Override
-    public SparqlQuery createSparqlQuery(Map<String, String> form) {
-        StructureSparqlQuery queryString = new StructureSparqlQuery();
+    public SparqlQuery createSparqlQuery(final Map<String, String> form) {
+        final StructureSparqlQuery queryString = new StructureSparqlQuery();
         processName(form, queryString);
         processSmiles(form, queryString);
         processInchi(form, queryString);
         return queryString;
     }
 
-    private void processSmiles(Map<String, String> form, StructureSparqlQuery queryString) {
-        String value = form.get("smiles");
+    private void processSmiles(final Map<String, String> form, final StructureSparqlQuery queryString) {
+        final String value = form.get("smiles");
         if (value != null && value.length() > 0) {
-            CMLMolecule molecule = SMILESTool.createMolecule(value);
-            String inchi = InchiTool.generateInchi(molecule, "");
-            String inchiKey = InchiTool.generateInchiKey(inchi);
+            final CMLMolecule molecule = SMILESTool.createMolecule(value);
+            final String inchi = InchiTool.generateInchi(molecule, "");
+            final String inchiKey = InchiTool.generateInchiKey(inchi);
             queryString.addInchiKey(inchiKey);
         }
     }
 
-    private void processName(Map<String, String> form, StructureSparqlQuery queryString) {
-        String value = form.get("sys_name");
+    private void processName(final Map<String, String> form, final StructureSparqlQuery queryString) {
+        final String value = form.get("sys_name");
         try {
             if (value != null && value.length() > 0) {
-                HttpClient client = new DefaultHttpClient();
-                String name = URLEncoder.encode(value, "UTF-8");
-                HttpGet get = new HttpGet("http://opsin.ch.cam.ac.uk/opsin/"+name);
-                HttpResponse response = client.execute(get);
-                CMLBuilder builder = new CMLBuilder();
-                Document doc = builder.build(response.getEntity().getContent());
-                CMLCml cml = (CMLCml) doc.getRootElement();
-                CMLMolecule molecule = (CMLMolecule) cml.getFirstCMLChild("molecule");
-                String inchi = InchiTool.generateInchi(molecule, "");
-                String inchiKey = InchiTool.generateInchiKey(inchi);
+                final HttpClient client = new DefaultHttpClient();
+                final String name = URLEncoder.encode(value, "UTF-8");
+                final HttpGet get = new HttpGet("http://opsin.ch.cam.ac.uk/opsin/"+name);
+                final HttpResponse response = client.execute(get);
+                final CMLBuilder builder = new CMLBuilder();
+                final Document doc = builder.build(response.getEntity().getContent());
+                final CMLCml cml = (CMLCml) doc.getRootElement();
+                final CMLMolecule molecule = (CMLMolecule) cml.getFirstCMLChild("molecule");
+                final String inchi = InchiTool.generateInchi(molecule, "");
+                final String inchiKey = InchiTool.generateInchiKey(inchi);
                 queryString.addInchiKey(inchiKey);
             }
         } catch (Exception e) {
         }
     }
 
-    private void processInchi(Map<String,String> form, StructureSparqlQuery queryString) {
-        String value = form.get("inchi");
+    private void processInchi(final Map<String,String> form, final StructureSparqlQuery queryString) {
+        final String value = form.get("inchi");
         if (value != null && value.length() > 0) {
             queryString.addInchi(value);
         }
     }
 
-    private void processInchiKey(Map<String,String> form, StructureSparqlQuery queryString) {
-        String value = form.get("inchi_key");
+    private void processInchiKey(final Map<String,String> form, final StructureSparqlQuery queryString) {
+        final String value = form.get("inchi_key");
         if (value != null && value.length() > 0) {
             queryString.addInchiKey(value);
         }
 
     static class StructureSparqlQuery extends SparqlQuery {
 
-        public void addInchiKey(String value) {
+        public void addInchiKey(final String value) {
             statements.add("  ?item <"+ CmlRdf.inchiKey +"> ?id"+i+ " .\n");
             statements.add("  ?id"+i+" <"+ RDF.value +"> ?ik"+i+ " .\n");
             statements.add("  FILTER regex(?ik"+i+", \"^"+ value +"\")\n");
             i++;
         }
 
-        public void addInchi(String value) {
+        public void addInchi(final String value) {
             statements.add("  ?item <"+CmlRdf.inchi+"> [<"+RDFS.label+"> ?val"+i+ "] .\n");
             statements.add("  FILTER (?val" + i + " = ?q" + i + ") \n");
             queryBindings.put("q+i", ResourceFactory.createPlainLiteral(value));