From: <aki...@us...> - 2006-12-15 22:44:48
|
Revision: 1089 http://svn.sourceforge.net/gridarta/?rev=1089&view=rev Author: akirschbaum Date: 2006-12-15 14:44:47 -0800 (Fri, 15 Dec 2006) Log Message: ----------- Prefer string constants over character constants in string concatenation. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CAttribDialog.java trunk/crossfire/src/cfeditor/CFArchTypeList.java trunk/crossfire/src/cfeditor/ScriptArchData.java trunk/crossfire/src/cfeditor/map/MapArchObject.java trunk/daimonin/src/daieditor/CAttribDialog.java trunk/daimonin/src/daieditor/CFArchTypeList.java trunk/daimonin/src/daieditor/CFTreasureListTree.java trunk/daimonin/src/daieditor/ScriptArchData.java Modified: trunk/crossfire/src/cfeditor/CAttribDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-12-15 22:29:24 UTC (rev 1088) +++ trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-12-15 22:44:47 UTC (rev 1089) @@ -796,7 +796,7 @@ // fetch the bitmask data, then build the attribute panel final CAttribBitmask bitmask = typelist.getBitmaskTable().get((String) (attrib.getMisc()[0])); ((BitmaskAttrib) (DialogAttrib<JTextComponent>) newAttr).bitmask = bitmask; - cLabel = new JButton(new MaskChangeAL(attrib.getNameNew() + ':', (BitmaskAttrib) (DialogAttrib<JTextComponent>) newAttr)); + cLabel = new JButton(new MaskChangeAL(attrib.getNameNew() + ":", (BitmaskAttrib) (DialogAttrib<JTextComponent>) newAttr)); final JTextArea input = new JTextArea(); input.setBackground(getBackground()); input.setEditable(false); @@ -959,7 +959,7 @@ case BOOL_SPEC: { final boolean value = ((DialogAttrib<JCheckBox>) attr).input.isSelected(); // true/false if (value) { - doc.insertString(doc.getLength(), '<' + attr.ref.getNameNew() + ">\n", docStyle); + doc.insertString(doc.getLength(), "<" + attr.ref.getNameNew() + ">\n", docStyle); } } break; @@ -968,7 +968,7 @@ case FLOAT: { final String value = ((DialogAttrib<JFormattedTextField>) attr).input.getText(); // the attrib value if (value != null && value.length() > 0 && !value.equals("0")) { - doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + '\n', docStyle); + doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + "\n", docStyle); } } break; @@ -977,7 +977,7 @@ case ANIMNAME: { final String value = ((DialogAttrib<JTextField>) attr).input.getText(); // the attrib value if (value != null && value.length() > 0) { - doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + '\n', docStyle); + doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + "\n", docStyle); } } break; @@ -986,7 +986,7 @@ case LIST: { final String value = ((DialogAttrib<JComboBox>) attr).input.getSelectedItem().toString().trim(); // the attrib value if (value != null && value.length() > 0 && !value.startsWith("<")) { - doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + '\n', docStyle); + doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + "\n", docStyle); } } break; @@ -1019,7 +1019,7 @@ case TREASURE: { final String value = ((DialogAttrib<JTextField>) attr).input.getText().trim(); // the attrib value if (value != null && value.length() > 0 && !value.equals(CFTreasureListTree.NONE_SYM)) { - doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + '\n', docStyle); + doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + "\n", docStyle); } } break; @@ -1071,7 +1071,7 @@ case BOOL: { // a boolean attribute (flag) if (((DialogAttrib<JCheckBox>) attr).input.isSelected() != (archetype.getAttributeInt(attr.ref.getNameOld()) == 1)) { - newArchText = newArchText + attr.ref.getNameOld() + ' ' + (((DialogAttrib<JCheckBox>) attr).input.isSelected() ? 1 : 0) + '\n'; + newArchText = newArchText + attr.ref.getNameOld() + " " + (((DialogAttrib<JCheckBox>) attr).input.isSelected() ? 1 : 0) + "\n"; } } break; @@ -1085,7 +1085,7 @@ } // now see if we need to write it into the archtext or not if ((valString.equals("0") && !(archetype.getAttributeString(attr.ref.getNameOld()).length() == 0)) || (!valString.equals("0") && !archetype.getAttributeString(attr.ref.getNameOld()).equals(valString))) { - newArchText = newArchText + attr.ref.getNameOld() + ' ' + valString + '\n'; + newArchText = newArchText + attr.ref.getNameOld() + " " + valString + "\n"; } } break; @@ -1111,14 +1111,14 @@ case INT: { final int value = ((Number) ((DialogAttrib<JFormattedTextField>) attr).input.getValue()).intValue(); if (archetype.getAttributeInt(attr.ref.getNameOld()) != value) { - newArchText = newArchText + attr.ref.getNameOld() + ' ' + value + '\n'; + newArchText = newArchText + attr.ref.getNameOld() + " " + value + "\n"; } } break; case LONG: { final long value = ((Number) ((DialogAttrib<JFormattedTextField>) attr).input.getValue()).longValue(); if (archetype.getAttributeLong(attr.ref.getNameOld()) != value) { - newArchText = newArchText + attr.ref.getNameOld() + ' ' + value + '\n'; + newArchText = newArchText + attr.ref.getNameOld() + " " + value + "\n"; } } break; @@ -1281,7 +1281,7 @@ // we assume the default gameObject is "right" and we are "wrong". The typedefs aren't that trustworthy. // BUT - if the gameObject has a changed type, the archetype has lost it's credibility. // So, in this special case, the fixed attribute applies always. - newArchText = newArchText + type.getAttr()[i].getNameOld() + ' ' + type.getAttr()[i].getNameNew() + '\n'; + newArchText = newArchText + type.getAttr()[i].getNameOld() + " " + type.getAttr()[i].getNameNew() + "\n"; } } } Modified: trunk/crossfire/src/cfeditor/CFArchTypeList.java =================================================================== --- trunk/crossfire/src/cfeditor/CFArchTypeList.java 2006-12-15 22:29:24 UTC (rev 1088) +++ trunk/crossfire/src/cfeditor/CFArchTypeList.java 2006-12-15 22:44:47 UTC (rev 1089) @@ -472,7 +472,7 @@ * @return name of this type, as defined in "typenumbers.xml" */ public String getArchTypeName(final int typeNr) { - return archTypeNumbers.containsKey(typeNr) ? archTypeNumbers.get(typeNr) : "*UNKNOWN" + typeNr + '*'; + return archTypeNumbers.containsKey(typeNr) ? archTypeNumbers.get(typeNr) : "*UNKNOWN" + typeNr + "*"; } /** Modified: trunk/crossfire/src/cfeditor/ScriptArchData.java =================================================================== --- trunk/crossfire/src/cfeditor/ScriptArchData.java 2006-12-15 22:29:24 UTC (rev 1088) +++ trunk/crossfire/src/cfeditor/ScriptArchData.java 2006-12-15 22:44:47 UTC (rev 1089) @@ -703,7 +703,7 @@ // file path is relative to map dir path = mainControl.getCurrentMap().getMapFile().getParentFile().getAbsolutePath(); // map dir if (!path.endsWith("/")) { - path += "/"; // append slash to map dir + path += '/'; // append slash to map dir } path += filePath; // append relative path to map dir path = path.replace('\\', '/'); // make sure there's only one kind of slash Modified: trunk/crossfire/src/cfeditor/map/MapArchObject.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapArchObject.java 2006-12-15 22:29:24 UTC (rev 1088) +++ trunk/crossfire/src/cfeditor/map/MapArchObject.java 2006-12-15 22:44:47 UTC (rev 1089) @@ -361,7 +361,7 @@ msgflag = false; } else { if (msgText.length() > 0) { - msgText.append("\n"); + msgText.append('\n'); } msgText.append(line2); } Modified: trunk/daimonin/src/daieditor/CAttribDialog.java =================================================================== --- trunk/daimonin/src/daieditor/CAttribDialog.java 2006-12-15 22:29:24 UTC (rev 1088) +++ trunk/daimonin/src/daieditor/CAttribDialog.java 2006-12-15 22:44:47 UTC (rev 1089) @@ -312,7 +312,7 @@ // read all type names int i = 0; for (final CFArchType tmp : typelist) { - namelist[i++] = ' ' + tmp.getTypeName(); + namelist[i++] = " " + tmp.getTypeName(); } // the active type appears selected in the box @@ -792,7 +792,7 @@ // fetch the bitmask data, then build the attribute panel final CAttribBitmask bitmask = typelist.getBitmaskTable().get(attrib.getMisc()[0]); ((BitmaskAttrib) (DialogAttrib<JTextComponent>) newAttr).bitmask = bitmask; - cLabel = new JButton(new MaskChangeAL(attrib.getNameNew() + ':', (BitmaskAttrib) (DialogAttrib<JTextComponent>) newAttr)); + cLabel = new JButton(new MaskChangeAL(attrib.getNameNew() + ":", (BitmaskAttrib) (DialogAttrib<JTextComponent>) newAttr)); final JTextArea input = new JTextArea(); input.setBackground(getBackground()); input.setEditable(false); @@ -813,7 +813,7 @@ if (treasureName.trim().length() == 0 || "none".equalsIgnoreCase(treasureName.trim())) { treasureName = CFTreasureListTree.NONE_SYM; } - final JTextField input = new JTextField(' ' + treasureName, TEXTFIELD_COLUMNS); + final JTextField input = new JTextField(" " + treasureName, TEXTFIELD_COLUMNS); input.setEditable(false); cLabel = new JButton(new ViewTreasurelistAL((DialogAttrib<JTextField>) newAttr, this)); cComp = input; @@ -955,7 +955,7 @@ case BOOL_SPEC: { final boolean value = ((DialogAttrib<JCheckBox>) attr).input.isSelected(); // true/false if (value) { - doc.insertString(doc.getLength(), '<' + attr.ref.getNameNew() + ">\n", docStyle); + doc.insertString(doc.getLength(), "<" + attr.ref.getNameNew() + ">\n", docStyle); } } break; @@ -964,7 +964,7 @@ case FLOAT: { final String value = ((DialogAttrib<JFormattedTextField>) attr).input.getText(); // the attrib value if (value != null && value.length() > 0 && !value.equals("0")) { - doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + '\n', docStyle); + doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + "\n", docStyle); } } break; @@ -973,7 +973,7 @@ case ANIMNAME: { final String value = ((DialogAttrib<JTextField>) attr).input.getText(); // the attrib value if (value != null && value.length() > 0) { - doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + '\n', docStyle); + doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + "\n", docStyle); } } break; @@ -982,7 +982,7 @@ case LIST: { final String value = ((DialogAttrib<JComboBox>) attr).input.getSelectedItem().toString().trim(); // the attrib value if (value != null && value.length() > 0 && !value.startsWith("<")) { - doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + '\n', docStyle); + doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + "\n", docStyle); } } break; @@ -1001,21 +1001,21 @@ } } if (out != null) { - doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + out + '\n', docStyle); + doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + out + "\n", docStyle); } } break; case BITMASK: { final String value = ((BitmaskAttrib) attr).input.getText().trim(); if (value != null && value.length() > 0 && !value.startsWith("<")) { - doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + '\n', docStyle); + doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + "\n", docStyle); } } break; case TREASURE: { final String value = ((DialogAttrib<JTextField>) attr).input.getText().trim(); // the attrib value if (value != null && value.length() > 0 && !value.equals(CFTreasureListTree.NONE_SYM)) { - doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + '\n', docStyle); + doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + "\n", docStyle); } } break; @@ -1065,7 +1065,7 @@ case BOOL: { // a boolean attribute (flag) if (((DialogAttrib<JCheckBox>) attr).input.isSelected() != (archetype.getAttributeInt(attr.ref.getNameOld()) == 1)) { - newArchText = newArchText + attr.ref.getNameOld() + ' ' + (((DialogAttrib<JCheckBox>) attr).input.isSelected() ? 1 : 0) + '\n'; + newArchText = newArchText + attr.ref.getNameOld() + " " + (((DialogAttrib<JCheckBox>) attr).input.isSelected() ? 1 : 0) + "\n"; } } break; @@ -1079,7 +1079,7 @@ } // now see if we need to write it into the archtext or not if ("0".equals(valString) && !(archetype.getAttributeString(attr.ref.getNameOld()).length() == 0) || !valString.equals("0") && !archetype.getAttributeString(attr.ref.getNameOld()).equals(valString)) { - newArchText = newArchText + attr.ref.getNameOld() + ' ' + valString + '\n'; + newArchText = newArchText + attr.ref.getNameOld() + " " + valString + "\n"; } } break; @@ -1099,14 +1099,14 @@ case INT: { final int value = ((Number) ((DialogAttrib<JFormattedTextField>) attr).input.getValue()).intValue(); if (archetype.getAttributeInt(attr.ref.getNameOld()) != value) { - newArchText = newArchText + attr.ref.getNameOld() + ' ' + value + '\n'; + newArchText = newArchText + attr.ref.getNameOld() + " " + value + "\n"; } } break; case LONG: { final long value = ((Number) ((DialogAttrib<JFormattedTextField>) attr).input.getValue()).longValue(); if (archetype.getAttributeLong(attr.ref.getNameOld()) != value) { - newArchText = newArchText + attr.ref.getNameOld() + ' ' + value + '\n'; + newArchText = newArchText + attr.ref.getNameOld() + " " + value + "\n"; } } break; @@ -1115,7 +1115,7 @@ // The following floating point equality comparison is okay and known not to cause problems. //noinspection FloatingPointEquality if (archetype.getAttributeDouble(attr.ref.getNameOld()) != value) { - newArchText = newArchText + attr.ref.getNameOld() + ' ' + value + '\n'; + newArchText = newArchText + attr.ref.getNameOld() + " " + value + "\n"; } } break; @@ -1153,7 +1153,7 @@ } } else if ("animation".equalsIgnoreCase(attr.ref.getNameOld())) { if (inline.length() > 0 && !inline.equals(archetype.getAttributeString(attr.ref.getNameOld()))) { - newArchText = newArchText + attr.ref.getNameOld() + ' ' + inline + '\n'; + newArchText = newArchText + attr.ref.getNameOld() + " " + inline + "\n"; gameObject.setAnimName(inline); } else { gameObject.setAnimName(archetype.getAnimName()); @@ -1163,13 +1163,13 @@ // decide we have to add a "face <name>" string to the gameObject text // Note, that the realFaceName itself is set below if (archetype.getFaceRealName() == null || archetype.getFaceRealName().compareTo(inline.trim()) != 0) { - newArchText = newArchText + attr.ref.getNameOld() + ' ' + inline + '\n'; + newArchText = newArchText + attr.ref.getNameOld() + " " + inline + "\n"; } } newFace = inline; } else { if (!inline.equals(archetype.getAttributeString(attr.ref.getNameOld()))) { - newArchText = newArchText + attr.ref.getNameOld() + ' ' + inline + '\n'; + newArchText = newArchText + attr.ref.getNameOld() + " " + inline + "\n"; } } } @@ -1215,7 +1215,7 @@ } else if (attrVal == 0) { newArchText = newArchText + attr.ref.getNameOld() + " 0\n"; } else if (archetype.getAttributeInt(attr.ref.getNameOld()) != attrVal) { - newArchText = newArchText + attr.ref.getNameOld() + ' ' + attrVal + '\n'; + newArchText = newArchText + attr.ref.getNameOld() + " " + attrVal + "\n"; } } break; @@ -1225,7 +1225,7 @@ final int combinedVal = val1 + val2; if (archetype.getAttributeInt(attr.ref.getNameOld()) != combinedVal) { - newArchText = newArchText + attr.ref.getNameOld() + ' ' + combinedVal + '\n'; + newArchText = newArchText + attr.ref.getNameOld() + " " + combinedVal + "\n"; } } break; @@ -1234,7 +1234,7 @@ final int value = ((BitmaskAttrib) attr).getValue(); // get bitmask value if (archetype.getAttributeInt(attr.ref.getNameOld()) != value) { - newArchText = newArchText + attr.ref.getNameOld() + ' ' + value + '\n'; + newArchText = newArchText + attr.ref.getNameOld() + " " + value + "\n"; } } break; @@ -1248,7 +1248,7 @@ if (!isNone && !CFTreasureListTree.containsTreasureList(inline) && !inline.equalsIgnoreCase(archetype.getAttributeString(attr.ref.getNameOld()))) { // The user has specified a WRONG treasurelist name, and it does not come // from the default gameObject. -> Error and out. - showMessageDialog(this, "In attribute '" + attr.ref.getNameNew() + "':\n" + '\'' + inline + "' is not a known treasurelist name!", "Input Error", ERROR_MESSAGE); + showMessageDialog(this, "In attribute '" + attr.ref.getNameNew() + "':\n" + "\'" + inline + "' is not a known treasurelist name!", "Input Error", ERROR_MESSAGE); return false; } @@ -1256,7 +1256,7 @@ if (isNone) { newArchText = newArchText + attr.ref.getNameOld() + " none\n"; } else { - newArchText = newArchText + attr.ref.getNameOld() + ' ' + inline + '\n'; + newArchText = newArchText + attr.ref.getNameOld() + " " + inline + "\n"; } } } @@ -1276,7 +1276,7 @@ // we assume the default gameObject is "right" and we are "wrong". The typedefs aren't that trustworthy. // BUT - if the gameObject has a changed type, the archetype has lost it's credibility. // So, in this special case, the fixed attribute applies always. - newArchText = newArchText + type.getAttr()[i].getNameOld() + ' ' + type.getAttr()[i].getNameNew() + '\n'; + newArchText = newArchText + type.getAttr()[i].getNameOld() + " " + type.getAttr()[i].getNameNew() + "\n"; } } } @@ -1286,7 +1286,7 @@ * But we need to add when needed the gameObject text - we do it here. */ if (gameObject.getDirection() != ((GameObject) archetype).getDirection()) { - newArchText = newArchText + "direction " + gameObject.getDirection() + '\n'; + newArchText = newArchText + "direction " + gameObject.getDirection() + "\n"; } // before we modify the archtext, we look for errors and save them. // later the user must confirm whether to keep or dump those errors Modified: trunk/daimonin/src/daieditor/CFArchTypeList.java =================================================================== --- trunk/daimonin/src/daieditor/CFArchTypeList.java 2006-12-15 22:29:24 UTC (rev 1088) +++ trunk/daimonin/src/daieditor/CFArchTypeList.java 2006-12-15 22:44:47 UTC (rev 1089) @@ -178,7 +178,7 @@ parseTypes(root); if (log.isInfoEnabled()) { - log.info("Loaded " + archTypeList.size() + " types from '" + IGUIConstants.TYPEDEF_FILE + '\''); + log.info("Loaded " + archTypeList.size() + " types from '" + IGUIConstants.TYPEDEF_FILE + "\'"); } } catch (final SAXException e) { log.error("Parsing error in '" + IGUIConstants.TYPEDEF_FILE + "':\n" + e.getMessage()); @@ -222,7 +222,7 @@ // every list entry adds value (Integer) and name (String) to the vector try { list.add(Integer.valueOf(elem.getAttribute("value"))); - list.add(' ' + elem.getAttribute("name").trim()); + list.add(" " + elem.getAttribute("name").trim()); } catch (final NumberFormatException ignore) { throw new RuntimeException("In '" + IGUIConstants.TYPEDEF_FILE + "', list " + root.getAttribute("name") + ": value '" + elem.getAttribute("value") + "' is not an integer."); } @@ -349,7 +349,7 @@ * @return name of this type, as defined in "typenumbers.xml" */ public String getArchTypeName(final int typeNr) { - return archTypeNumbers.containsKey(typeNr) ? archTypeNumbers.get(typeNr) : "*UNKNOWN" + typeNr + '*'; + return archTypeNumbers.containsKey(typeNr) ? archTypeNumbers.get(typeNr) : "*UNKNOWN" + typeNr + "*"; } /** Modified: trunk/daimonin/src/daieditor/CFTreasureListTree.java =================================================================== --- trunk/daimonin/src/daieditor/CFTreasureListTree.java 2006-12-15 22:29:24 UTC (rev 1088) +++ trunk/daimonin/src/daieditor/CFTreasureListTree.java 2006-12-15 22:44:47 UTC (rev 1089) @@ -593,7 +593,7 @@ public void actionPerformed(final ActionEvent e) { final String result = getSelectedTreasureList(); if (result != null) { - input.setText(' ' + result); + input.setText(" " + result); frame.setVisible(false); } } @@ -604,7 +604,7 @@ noneButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { // print "none" into the attribute dialog - input.setText(' ' + NONE_SYM); + input.setText(" " + NONE_SYM); frame.setVisible(false); } }); Modified: trunk/daimonin/src/daieditor/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/ScriptArchData.java 2006-12-15 22:29:24 UTC (rev 1088) +++ trunk/daimonin/src/daieditor/ScriptArchData.java 2006-12-15 22:44:47 UTC (rev 1089) @@ -182,7 +182,7 @@ final Vector<String> content = new Vector<String>(); for (final GameObject tmp : owner) { if (tmp.getArchTypNr() == 118) { - content.add(' ' + typeName(tmp.getAttributeInt("sub_type"))); + content.add(" " + typeName(tmp.getAttributeInt("sub_type"))); } } @@ -304,7 +304,7 @@ } path = path.replace('\\', '/'); if (!path.startsWith("/")) { - path = '/' + path; // leading slash + path = "/" + path; // leading slash } } else { // scriptfile is in a subirectory of mapfile -> relative path This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |