Skip to content

Commit 5d3b8e7

Browse files
author
Mohamed Ezzat
committed
squid:S2130 - Parsing should be used to convert Strings to primitives
1 parent 1d874f1 commit 5d3b8e7

4 files changed

Lines changed: 29 additions & 29 deletions

File tree

‎biojava-core/src/main/java/org/biojava/nbio/core/sequence/location/InsdcParser.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ private List<Location> parseLocationString(String string, int versus) throws Par
228228

229229
String accession = m.group(1);
230230
Strand s = versus == 1 ? Strand.POSITIVE : Strand.NEGATIVE;
231-
int start = new Integer(m.group(3));
231+
int start = Integer.parseInt(m.group(3));
232232
int end = m.group(6) == null ? start : new Integer(m.group(6));
233233

234234
if (featureGlobalStart > start) {

‎biojava-structure/src/main/java/org/biojava/nbio/structure/align/xml/AFPChainXMLParser.java‎

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -260,31 +260,31 @@ public static AFPChain[] parseMultiXML(String xml) throws IOException {
260260
if ( version != null)
261261
a.setVersion(version);
262262

263-
a.setAlnLength( new Integer(getAttribute(rootElement,"alnLength")).intValue());
264-
a.setBlockNum( new Integer(getAttribute(rootElement,"blockNum")).intValue());
265-
a.setGapLen( new Integer(getAttribute(rootElement,"gapLen")).intValue());
266-
a.setOptLength( new Integer(getAttribute(rootElement,"optLength")).intValue());
267-
a.setTotalLenIni( new Integer(getAttribute(rootElement,"totalLenIni")).intValue());
268-
a.setBlockNum( new Integer(getAttribute(rootElement,"blockNum")).intValue());
263+
a.setAlnLength( Integer.parseInt(getAttribute(rootElement,"alnLength")));
264+
a.setBlockNum( Integer.parseInt(getAttribute(rootElement,"blockNum")));
265+
a.setGapLen( Integer.parseInt(getAttribute(rootElement,"gapLen")));
266+
a.setOptLength( Integer.parseInt(getAttribute(rootElement,"optLength")));
267+
a.setTotalLenIni( Integer.parseInt(getAttribute(rootElement,"totalLenIni")));
268+
a.setBlockNum( Integer.parseInt(getAttribute(rootElement,"blockNum")));
269269

270270
if ( a.getAlgorithmName().equals(CeCPMain.algorithmName)){
271271
a.setSequentialAlignment(a.getBlockNum() == 1);
272272
}
273273

274-
a.setAlignScore(new Double(getAttribute(rootElement,"alignScore")).doubleValue());
275-
a.setChainRmsd(new Double(getAttribute(rootElement,"chainRmsd")).doubleValue());
276-
Double identity = new Double(getAttribute(rootElement,"identity")).doubleValue();
274+
a.setAlignScore(Double.parseDouble(getAttribute(rootElement,"alignScore")));
275+
a.setChainRmsd(Double.parseDouble(getAttribute(rootElement,"chainRmsd")));
276+
Double identity = Double.parseDouble(getAttribute(rootElement,"identity"));
277277
a.setIdentity(identity);
278278

279-
a.setNormAlignScore(new Double(getAttribute(rootElement,"normAlignScore")).doubleValue());
280-
a.setProbability(new Double(getAttribute(rootElement,"probability")).doubleValue());
281-
a.setSimilarity(new Double(getAttribute(rootElement,"similarity")).doubleValue());
282-
a.setTotalRmsdIni(new Double(getAttribute(rootElement,"totalRmsdIni")).doubleValue());
283-
a.setTotalRmsdOpt(new Double(getAttribute(rootElement,"totalRmsdOpt")).doubleValue());
284-
a.setAlignScoreUpdate(new Double(getAttribute(rootElement,"alignScoreUpdate")).doubleValue());
285-
int ca1Length = new Integer(getAttribute(rootElement,"ca1Length")).intValue();
279+
a.setNormAlignScore(Double.parseDouble(getAttribute(rootElement,"normAlignScore")));
280+
a.setProbability(Double.parseDouble(getAttribute(rootElement,"probability")));
281+
a.setSimilarity(Double.parseDouble(getAttribute(rootElement,"similarity")));
282+
a.setTotalRmsdIni(Double.parseDouble(getAttribute(rootElement,"totalRmsdIni")));
283+
a.setTotalRmsdOpt(Double.parseDouble(getAttribute(rootElement,"totalRmsdOpt")));
284+
a.setAlignScoreUpdate(Double.parseDouble(getAttribute(rootElement,"alignScoreUpdate")));
285+
int ca1Length = Integer.parseInt(getAttribute(rootElement,"ca1Length"));
286286
a.setCa1Length(ca1Length);
287-
int ca2Length = new Integer(getAttribute(rootElement,"ca2Length")).intValue();
287+
int ca2Length = Integer.parseInt(getAttribute(rootElement,"ca2Length"));
288288
a.setCa2Length(ca2Length);
289289

290290
String tmScoreS = getAttribute(rootElement,"tmScore");
@@ -315,7 +315,7 @@ public static AFPChain[] parseMultiXML(String xml) throws IOException {
315315
Atom[] blockShiftVector = new Atom[a.getBlockNum()];
316316
a.setBlockShiftVector(blockShiftVector);
317317

318-
int afpNum = new Integer(getAttribute(rootElement,"afpNum")).intValue();
318+
int afpNum = Integer.parseInt(getAttribute(rootElement,"afpNum"));
319319
List<AFP> afpSet = new ArrayList<AFP>();
320320
for (int afp=0;afp<afpNum;afp++){
321321
afpSet.add( new AFP());
@@ -398,18 +398,18 @@ private static void processBlock(Node block, AFPChain a, int minLength){
398398
Matrix[] ms = a.getBlockRotationMatrix();
399399
Atom[] shifts = a.getBlockShiftVector();
400400

401-
int blockNr = new Integer( map.getNamedItem("blockNr").getTextContent()).intValue();
401+
int blockNr = Integer.parseInt( map.getNamedItem("blockNr").getTextContent());
402402

403-
int thisBlockGap = new Integer(map.getNamedItem("blockGap").getTextContent()).intValue();
403+
int thisBlockGap = Integer.parseInt(map.getNamedItem("blockGap").getTextContent());
404404
blockGap[blockNr] = thisBlockGap;
405405

406-
int thisBlockSize = new Integer(map.getNamedItem("blockSize").getTextContent()).intValue();
406+
int thisBlockSize = Integer.parseInt(map.getNamedItem("blockSize").getTextContent());
407407
blockSize[blockNr] = thisBlockSize;
408408

409-
double thisBlockScore = new Double(map.getNamedItem("blockScore").getTextContent()).doubleValue();
409+
double thisBlockScore = Double.parseDouble(map.getNamedItem("blockScore").getTextContent());
410410
blockScore[blockNr] = thisBlockScore;
411411

412-
double thisBlockRmsd = new Double(map.getNamedItem("blockRmsd").getTextContent()).doubleValue();
412+
double thisBlockRmsd = Double.parseDouble(map.getNamedItem("blockRmsd").getTextContent());
413413
blockRmsd[blockNr] = thisBlockRmsd;
414414

415415

@@ -425,7 +425,7 @@ private static void processBlock(Node block, AFPChain a, int minLength){
425425
nrEqr++;
426426
NamedNodeMap atts = eqr.getAttributes();
427427

428-
int eqrNr = new Integer(atts.getNamedItem("eqrNr").getTextContent()).intValue();
428+
int eqrNr = Integer.parseInt(atts.getNamedItem("eqrNr").getTextContent());
429429

430430
String pdbres1 = atts.getNamedItem("pdbres1").getTextContent();
431431
String chain1 = atts.getNamedItem("chain1").getTextContent();

‎biojava-structure/src/main/java/org/biojava/nbio/structure/jama/Matrix.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@ public static Matrix read (BufferedReader input) throws java.io.IOException {
10601060
do {
10611061
if (j >= n) throw new java.io.IOException
10621062
("Row " + v.size() + " is too long.");
1063-
row[j++] = Double.valueOf(tokenizer.sval).doubleValue();
1063+
row[j++] = Double.parseDouble(tokenizer.sval);
10641064
} while (tokenizer.nextToken() == StreamTokenizer.TT_WORD);
10651065
if (j < n) throw new java.io.IOException
10661066
("Row " + v.size() + " is too short.");

‎biojava-structure/src/main/java/org/biojava/nbio/structure/secstruc/DSSPParser.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ private static List<SecStrucState> generalParse(BufferedReader reader,
144144
//Only happens if dssp inserts a line indicating a chain break
145145
if(!resNumStr.equals("")) {
146146

147-
int index = Integer.valueOf(indexStr);
147+
int index = Integer.parseInt(indexStr);
148148
//Get the group of the structure corresponding to the residue
149-
int resNum = Integer.valueOf(resNumStr);
149+
int resNum = Integer.parseInt(resNumStr);
150150
char insCode = line.charAt(10);
151151
String chainId = line.substring(11,13).trim();
152152
ResidueNumber r = new ResidueNumber(chainId, resNum, insCode);
@@ -187,7 +187,7 @@ private static List<SecStrucState> generalParse(BufferedReader reader,
187187

188188
String[] p = val.split(",");
189189

190-
int partner = Integer.valueOf(p[0]);
190+
int partner = Integer.parseInt(p[0]);
191191
if (partner != 0) partner += index;
192192
double energy = Double.valueOf(p[1]) * 1000.0;
193193

0 commit comments

Comments
 (0)