Commits

Sam Adams  committed 6e34a8b

Fixed lots of checkstyle violations

  • Participants
  • Parent commits 44c8be4

Comments (0)

Files changed (7)

File crystallography-common/src/main/java/net/chempound/crystal/rdf/impl/CrystalStructureImpl.java

  */
 public class CrystalStructureImpl extends ItemImpl implements CrystalStructure {
 
-    public static Implementation factory = new Implementation() {
+    public static final Implementation factory = new Implementation() {
         @Override
         public EnhNode wrap(final Node node, final EnhGraph eg) {
             return new CrystalStructureImpl(node, eg);
 
     public List<Moiety> getMoieties() {
         final List<Moiety> list = new ArrayList<Moiety>();
-        for (StmtIterator it = listProperties(Cryst.hasMoiety); it.hasNext(); ) {
+        for (final StmtIterator it = listProperties(Cryst.hasMoiety); it.hasNext();) {
             final Statement s = it.next();
             list.add(new Moiety(s.getResource()));
         }

File crystallography-common/src/main/java/net/chempound/crystal/rdf/ont/Cryst.java

     public static final String NS = "http://www.xmlcml.org/cryst-rdf-schema#";
 
 
-    public static final Resource CrystallographicExperiment = m_model.createResource(NS+"CrystallographicExperiment");
+    public static final Resource CrystallographicExperiment = m_model.createResource(NS + "CrystallographicExperiment");
     public static final Resource CrystallochemicalStructure = m_model.createResource(NS + "CrystallochemicalStructure");
     public static final Resource UnitCell = m_model.createResource(NS + "UnitCell");
 

File crystallography-handler/src/main/java/net/chempound/crystal/display/CrystalStructureSplashPageWriter.java

         try {
             return IOUtils.toString(in);
         } catch (IOException e) {
-            throw new RuntimeException("Error reading file: "+s, e);
+            throw new RuntimeException("Error reading file: " + s, e);
         } finally {
             IOUtils.closeQuietly(in);
         }

File crystallography-handler/src/main/java/net/chempound/crystal/search/CrystalSparqlBuilder.java

     public void addInchiKey(final String value) {
         statements.add(String.format("  ?item <%1$s> [<%2$s> ?val%3$d] . \n", CmlRdf.inchiKey, RDF.value, i));
         statements.add(String.format("  FILTER (?val%1$d = ?q%1$d) \n", i));
-        queryBindings.put("q"+i, ResourceFactory.createPlainLiteral(value));
+        queryBindings.put("q" + i, ResourceFactory.createPlainLiteral(value));
         i++;
     }
 
     public void addFormulaWeight(final String value, final String type) {
         statements.add(String.format("  ?item <%1$s> [<%2$s> ?val%3$d] . \n", CifDict.chemicalFormulaWeight, RDF.value, i));
         statements.add(String.format("  FILTER (?val%1$d %2$s ?q%1$d) \n", i, getOperator(type)));
-        queryBindings.put("q"+i, ResourceFactory.createTypedLiteral(value, XSDDatatype.XSDdouble));
+        queryBindings.put("q" + i, ResourceFactory.createTypedLiteral(value, XSDDatatype.XSDdouble));
         i++;
     }
 
     public void addUnitCell(final Property prop, final String value, final String op) {
         statements.add(String.format("  ?item <%1$s> [<%2$s> [rdf:value ?val%3$d]] . \n", Cryst.hasUnitCell, prop, i));
         statements.add(String.format("  FILTER (?val%1$d %2$s ?q%1$d) \n", i, getOperator(op)));
-        queryBindings.put("q"+i, ResourceFactory.createTypedLiteral(value, XSDDatatype.XSDdouble));
+        queryBindings.put("q" + i, ResourceFactory.createTypedLiteral(value, XSDDatatype.XSDdouble));
         i++;
     }
 

File crystallography-importer/src/main/java/net/chempound/crystal/importer/CrystalCml2RdfConverter.java

         for (final Node node : arrays) {
             final CMLArray array = (CMLArray) node;
             final String dictRef = CmlRdfUtils.getDictRefUri(array);
-            if ((CifDict.NS+"publ_author_name").equals(dictRef)) {
+            if ((CifDict.NS + "publ_author_name").equals(dictRef)) {
                 final Property prop = model.createProperty(CifDict.NS, "publ_author_name");
                 for (final String name : array.getStrings()) {
                     thisCryst.addProperty(prop, name);
 
     private List<String> findAuthors(final Resource thisCryst) {
         final List<String> authors = new ArrayList<String>();
-        for (StmtIterator it = thisCryst.listProperties(CifDict.publAuthorName); it.hasNext();) {
+        for (final StmtIterator it = thisCryst.listProperties(CifDict.publAuthorName); it.hasNext();) {
             final Statement s = it.next();
             String name = s.getLiteral().getString();
             final int i = name.indexOf(", ");
             if (i != -1) {
-                name = name.substring(i+2)+" "+name.substring(0, i);
+                name = name.substring(i + 2) + " " + name.substring(0, i);
             }
             authors.add(name);
         }
             final String convention = identifier.getConvention();
             final String value = identifier.getCMLValue();
             if ("iupac:inchi".equals(convention)) {
-                final Resource inchi = model.createResource("info:inchi/"+value);
+                final Resource inchi = model.createResource("info:inchi/" + value);
                 inchi.addProperty(RDFS.label, value);
-                final Resource openmolecules = model.createResource("http://rdf.openmolecules.net/?"+value);
+                final Resource openmolecules = model.createResource("http://rdf.openmolecules.net/?" + value);
                 inchi.addProperty(OWL.sameAs, openmolecules);
                 resource.addProperty(CmlRdf.inchi, inchi);
             } else {
         thisCryst.addProperty(CifDict.numberOfSymmetryOperators, model.createTypedLiteral(numSymEls, XSDDatatype.XSDint));
 
         if (crystZ != null) {
-            final double zPrime = Double.valueOf(crystZ)/numSymEls;
+            final double zPrime = Double.valueOf(crystZ) / numSymEls;
             thisCryst.addProperty(CifDict.zPrime, model.createTypedLiteral(zPrime, XSDDatatype.XSDdouble));
         }
 
                 cellParamProp = Cryst.cellAngleGamma;
                 paramBNode.addProperty(CmlRdf.units, degrees);
             } else {
-                throw new RuntimeException("Unsupported cell parameter: "+dictRef);
+                throw new RuntimeException("Unsupported cell parameter: " + dictRef);
             }
 
             thisUnitCell.addProperty(cellParamProp, paramBNode);
         final URI baseUri = URI.create(thisCryst.getURI());
         for (final CMLMolecule moiety : moieties) {
             final String moietyId = moiety.getId();
-            final URI moietyUri = baseUri.resolve('#'+moietyId);
+            final URI moietyUri = baseUri.resolve('#' + moietyId);
             final Resource thisMoi = model.createResource(moietyUri.toString());
 
             thisMoi.addProperty(RDF.type, ChemAxiom.MolecularEntity);

File crystallography-importer/src/main/java/net/chempound/crystal/importer/CrystalStructureImporter.java

         final String cifId = originalCif.getId();
         for (final CIF cif : splitCifs) {
             final String datablockId = getDataBlockId(cif);
-            final String id = cifId+"_"+datablockId;
+            final String id = cifId + "_" + datablockId;
             loadCif(cif, id);
         }
     }
 
     public DepositRequest generateDepositRequest(final CIF cif, final String id) throws IOException, ParsingException {
 
-        final LocalResource cifResource = this.cifResource == null ? createCifResource(cif, id+".cif") : this.cifResource;
+        final LocalResource cifResource = this.cifResource == null ? createCifResource(cif, id + ".cif") : this.cifResource;
 
         final CMLCml completeCml = convertCifToCompleteCml(cif);
         attachIdentifiers(completeCml);
 
-        final LocalResource cmlResource = createCmlResource(completeCml, id+".cml");
+        final LocalResource cmlResource = createCmlResource(completeCml, id + ".cml");
 
         createImages(cifResource, id, "cif");
 
         final ChempoundAggregation item = depositRequest.getResourceMetadata();
         addType(item);
 
-        final LocalResource rdfResource = writeRdf(id+".rdf", model);
+        final LocalResource rdfResource = writeRdf(id + ".rdf", model);
 
         depositRequest.addResource(cifResource);
         depositRequest.addResource(cmlResource);
 
     private void addAuthors(final Model model) {
         final Resource root = model.getResource("");
-        StmtIterator it = root.listProperties(CifDict.publAuthorName);
-        List<String> names = new ArrayList<String>();
+        final StmtIterator it = root.listProperties(CifDict.publAuthorName);
+        final List<String> names = new ArrayList<String>();
         while (it.hasNext()) {
-            Statement s = it.next();
+            final Statement s = it.next();
             names.add(s.getObject().asLiteral().getString());
         }
-        for (String name : names) {
+        for (final String name : names) {
             root.addProperty(DCTerms.contributor, name);
         }
     }
 
     public static String getDataBlockId(final CIF cif) {
         final List<CIFDataBlock> dataBlocks = cif.getDataBlockList();
-        final CIFDataBlock dataBlock = dataBlocks.get(dataBlocks.size()-1);
+        final CIFDataBlock dataBlock = dataBlocks.get(dataBlocks.size() - 1);
         return dataBlock.getId();
     }
 

File crystallography-importer/src/main/java/net/chempound/crystal/importer/utils/CifStringParser.java

     public final String toHtml(final String s) {
         final StringBuilder html = new StringBuilder();
 
-        boolean sup = false, sub = false;
+        boolean sup = false;
+        boolean sub = false;
 
         for (int i = 0; i < s.length(); i++) {
 
                     break;
 
                 case '+':
-                    if ("+-".equals(s.substring(i, i+2))) {
+                    if ("+-".equals(s.substring(i, i + 2))) {
                         html.append(Latin1Supplement.Plus_Minus_Sign);
                     }
                     i += 1;
                     break;
 
                 case '-':
-                    if ("---".equals(s.substring(i, i+3))) {
+                    if ("---".equals(s.substring(i, i + 3))) {
                         // TODO single bond
                         html.append(GeneralPunctuation.Em_Dash);
                         i += 2;
                     }
-                    else if ("-+".equals(s.substring(i, i+2))) {
+                    else if ("-+".equals(s.substring(i, i + 2))) {
                         html.append(MathematicalOperators.Minus_Or_Plus_Sign);
                         i += 1;
                     }
-                    else if ("--".equals(s.substring(i, i+2))) {
+                    else if ("--".equals(s.substring(i, i + 2))) {
                         html.append(GeneralPunctuation.En_Dash);
                         i += 1;
                     } else {
                     break;
 
                 case '<':
-                    if (
-                            "<i>".equals(s.substring(i, i+3))
-                                    || "<b>".equals(s.substring(i, i+3))) {
-                        html.append(s.substring(i, i+3));
+                    if ("<i>".equals(s.substring(i, i + 3)) || "<b>".equals(s.substring(i, i + 3))) {
+                        html.append(s.substring(i, i + 3));
                         i += 2;
-                    } else if (
-                            "</i>".equals(s.substring(i, i+4))
-                                    || "</b>".equals(s.substring(i, i+4))) {
-                        html.append(s.substring(i, i+4));
+                    } else if ("</i>".equals(s.substring(i, i + 4)) || "</b>".equals(s.substring(i, i + 4))) {
+                        html.append(s.substring(i, i + 4));
                         i += 3;
                     } else {
-                        throw new IllegalArgumentException("Bad string: "+s);
+                        throw new IllegalArgumentException("Bad string: " + s);
                     }
                     break;
 
                 return 2;
 
             case ',':
-                throw new IllegalArgumentException("Unsupported cedilla character: "+s.charAt(i + 1));
+                throw new IllegalArgumentException("Unsupported cedilla character: " + s.charAt(i + 1));
             case '"':
-                throw new IllegalArgumentException("Unsupported umlaut character: "+s.charAt(i + 1));
+                throw new IllegalArgumentException("Unsupported umlaut character: " + s.charAt(i + 1));
             case '~':
-                throw new IllegalArgumentException("Unsupported tilde character: "+s.charAt(i + 1));
+                throw new IllegalArgumentException("Unsupported tilde character: " + s.charAt(i + 1));
             case ';':
-                throw new IllegalArgumentException("Unsupported ogonek character: "+s.charAt(i + 1));
+                throw new IllegalArgumentException("Unsupported ogonek character: " + s.charAt(i + 1));
             case '>':
-                throw new IllegalArgumentException("Unsupported double acute character: "+s.charAt(i + 1));
+                throw new IllegalArgumentException("Unsupported double acute character: " + s.charAt(i + 1));
             case '=':
-                throw new IllegalArgumentException("Unsupported overbar character: "+s.charAt(i + 1));
+                throw new IllegalArgumentException("Unsupported overbar character: " + s.charAt(i + 1));
             case '.':
-                throw new IllegalArgumentException("Unsupported overdot character: "+s.charAt(i + 1));
+                throw new IllegalArgumentException("Unsupported overdot character: " + s.charAt(i + 1));
             case '<':
-                throw new IllegalArgumentException("Unsupported caron character: "+s.charAt(i + 1));
+                throw new IllegalArgumentException("Unsupported caron character: " + s.charAt(i + 1));
             case '(':
-                throw new IllegalArgumentException("Unsupported breve character: "+s.charAt(i + 1));
+                throw new IllegalArgumentException("Unsupported breve character: " + s.charAt(i + 1));
 
             case '?':
-                if ('i' == s.charAt(i+1)) {
+                if ('i' == s.charAt(i + 1)) {
                     html.append(LatinExtendedA.Latin_Small_Letter_Dotless_I);
                     return 2;
                 }
-                throw new IllegalArgumentException("Unknown char: "+s.charAt(i+1));
+                throw new IllegalArgumentException("Unknown char: " + s.charAt(i + 1));
 
             case '&':
-                if ('s' == s.charAt(i+1)) {
+                if ('s' == s.charAt(i + 1)) {
                     html.append(Latin1Supplement.Latin_Small_Letter_Sharp_S);
                     return 2;
                 }
                 break;
 
             case '%':
-                if ('A' == s.charAt(i+1)) {
+                if ('A' == s.charAt(i + 1)) {
                     html.append(Latin1Supplement.Latin_Capital_Letter_A_With_Ring_Above);
                     return 2;
                 }
-                if ('a' == s.charAt(i+1)) {
+                if ('a' == s.charAt(i + 1)) {
                     html.append(Latin1Supplement.Latin_Small_Letter_A_With_Ring_Above);
                     return 2;
                 }
                 return 1;
 
             case '/':
-                if ('O' == s.charAt(i+1)) {
+                if ('O' == s.charAt(i + 1)) {
                     html.append(Latin1Supplement.Latin_Capital_Letter_O_With_Stroke);
                     return 2;
                 }
-                if ('o' == s.charAt(i+1)) {
+                if ('o' == s.charAt(i + 1)) {
                     html.append(Latin1Supplement.Latin_Small_Letter_O_With_Stroke);
                     return 2;
                 }
 
-                if ('L' == s.charAt(i+1)) {
+                if ('L' == s.charAt(i + 1)) {
                     html.append(LatinExtendedA.Latin_Capital_Letter_L_With_Stroke);
                     return 2;
                 }
-                if ('l' == s.charAt(i+1)) {
+                if ('l' == s.charAt(i + 1)) {
                     html.append(LatinExtendedA.Latin_Small_Letter_L_With_Stroke);
                     return 2;
                 }
 
-                if ('D' == s.charAt(i+1)) {
+                if ('D' == s.charAt(i + 1)) {
                     html.append(Latin1Supplement.Latin_Capital_Letter_Eth);
                     return 2;
                 }
-                if ('d' == s.charAt(i+1)) {
+                if ('d' == s.charAt(i + 1)) {
                     html.append(Latin1Supplement.Latin_Small_Letter_Eth);
                     return 2;
                 }
 
-                throw new IllegalArgumentException("Unknown char: "+s.charAt(i+1));
+                throw new IllegalArgumentException("Unknown char: " + s.charAt(i + 1));
 
 
             case '\\':
                 // rangle = >
                 // langle = <
 
-                if ("times".equals(s.substring(i+1, i+6))) {
+                if ("times".equals(s.substring(i + 1, i + 6))) {
                     html.append(Latin1Supplement.Multiplication_Sign);
                     return 6;
                 }
-                if ("infty".equals(s.substring(i+1, i+6))) {
+                if ("infty".equals(s.substring(i + 1, i + 6))) {
                     html.append(MathematicalOperators.Infinity);
                     return 6;
                 }
-                if ("neq".equals(s.substring(i+1, i+4))) {
+                if ("neq".equals(s.substring(i + 1, i + 4))) {
                     html.append(MathematicalOperators.Not_Equal_To);
                     return 4;
                 }
-                if ("rightarrow".equals(s.substring(i+1, i+11))) {
+                if ("rightarrow".equals(s.substring(i + 1, i + 11))) {
                     html.append(Arrows.Rightwards_Arrow);
                     return 11;
                 }
-                if ("leftarrow".equals(s.substring(i+1, i+10))) {
+                if ("leftarrow".equals(s.substring(i + 1, i + 10))) {
                     html.append(Arrows.Leftwards_Arrow);
                     return 10;
                 }
 
-                if ("square".equals(s.substring(i+1, i+7))) {
+                if ("square".equals(s.substring(i + 1, i + 7))) {
                     html.append(GeometricShapes.White_Square);
                     return 7;
                 }
 
                 throw new UnsupportedOperationException();
 
+            default:
+                // ignore
+
         }
 
         final char x = readGreekCharacter(c);
                 return Acute.Small_Letter_Y_With_Acute;
             case 'z':
                 return Acute.Small_Letter_Z_With_Acute;
+
+            default:
+                throw new IllegalArgumentException("Unsupported acute character: " + c);
         }
-        throw new IllegalArgumentException("Unsupported acute character: "+c);
     }
 
     private char readGraveCharacter(final char c) {
                 return Grave.Small_Letter_W_With_Grave;
             case 'y':
                 return Grave.Small_Letter_Y_With_Grave;
+
+            default:
+                throw new IllegalArgumentException("Unsupported grave character: " + c);
         }
-        throw new IllegalArgumentException("Unsupported grave character: "+c);
     }
 
     private char readCircumflexCharacter(final char c) {
-        throw new IllegalArgumentException("Unsupported circumflex character: "+c);
+        throw new IllegalArgumentException("Unsupported circumflex character: " + c);
     }
 
     private char readGreekCharacter(final char c) {
             case 'z':
                 return GreekAndCoptic.Greek_Small_Letter_Zeta;
 
+            default:
+                throw new IllegalArgumentException("Unsupported character: [" + c + "]");
         }
-
-        throw new IllegalArgumentException("Unsupported character: ["+c+"]");
     }
 
 }