Changeset 7640 for trunk/projects/utils


Ignore:
Timestamp:
03/05/11 15:36:27 (9 years ago)
Author:
curtis
Message:

Fix some Eclipse warnings.

Location:
trunk/projects/utils/src/main/java
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/projects/utils/src/main/java/CompareTrees.java

    r6936 r7640  
    7373 
    7474  public static final void compare(File dir1, File dir2) { 
    75     if (dir1 == null && dir2 == null) return; 
     75    if (dir1 == null) { 
     76        if (dir2 == null) return; 
     77      System.out.println(">>> " + dir2 + "\t[" + 
     78        dir2.listFiles().length + " files]"); 
     79      return; 
     80    } 
    7681    if (dir2 == null) { 
    7782      System.out.println("<<< " + dir1 + "\t[" + 
    7883        dir1.listFiles().length + " files]"); 
    79       return; 
    80     } 
    81     if (dir1 == null) { 
    82       System.out.println(">>> " + dir2 + "\t[" + 
    83         dir2.listFiles().length + " files]"); 
    8484      return; 
    8585    } 
  • trunk/projects/utils/src/main/java/EditDistance.java

    r6936 r7640  
    5252  } 
    5353 
    54   public static int getEditDistance(String s, String t) { 
     54  public static int getEditDistance(final String s, final String t) { 
    5555    // Leveshtein algorithm 
    56     if (s == null) s = ""; 
    57     if (t == null) t = ""; 
    58  
    59     char[] a = s.toCharArray(); 
    60     char[] b = t.toCharArray(); 
    61     int[] w = new int[b.length + 1]; 
     56    final char[] a = s == null ? new char[0] : s.toCharArray(); 
     57    final char[] b = t == null ? new char[0] : t.toCharArray(); 
     58    final int[] w = new int[b.length + 1]; 
    6259 
    6360    int cur = 0, next = 0; 
  • trunk/projects/utils/src/main/java/LineLength.java

    r6936 r7640  
    6868        // argument is a flag 
    6969        if (args[i].equals("-tabwidth")) { 
    70           int q = -1; 
     70          int q; 
    7171          try { q = Integer.parseInt(args[++i]); } 
    72           catch (Exception exc) { } 
     72          catch (Exception exc) { q = -1; } 
    7373          if (q <= 0) System.out.println("Ignoring bogus tab width."); 
    7474          else tabWidth = q; 
     
    161161  } 
    162162 
    163   public boolean accept(File pathName) { 
    164     pathName = strip(pathName); 
     163  @Override 
     164        public boolean accept(final File pathName) { 
     165    final File strippedName = strip(pathName); 
    165166    return suffix ? 
    166       pathName.getName().endsWith(exp) : 
    167       expFile.getAbsoluteFile().equals(pathName.getAbsoluteFile()); 
     167      strippedName.getName().endsWith(exp) : 
     168      expFile.getAbsoluteFile().equals(strippedName.getAbsoluteFile()); 
    168169  } 
    169170 
  • trunk/projects/utils/src/main/java/TestMem.java

    r6936 r7640  
    3333*/ 
    3434 
     35import java.awt.Component; 
    3536import java.awt.event.ActionEvent; 
    3637import java.awt.event.ActionListener; 
     
    8990    memUsed = new JLabel(); 
    9091 
    91     memTotal.setAlignmentX(JLabel.CENTER_ALIGNMENT); 
    92     memMax.setAlignmentX(JLabel.CENTER_ALIGNMENT); 
    93     memFree.setAlignmentX(JLabel.CENTER_ALIGNMENT); 
    94     memUsed.setAlignmentX(JLabel.CENTER_ALIGNMENT); 
     92    memTotal.setAlignmentX(Component.CENTER_ALIGNMENT); 
     93    memMax.setAlignmentX(Component.CENTER_ALIGNMENT); 
     94    memFree.setAlignmentX(Component.CENTER_ALIGNMENT); 
     95    memUsed.setAlignmentX(Component.CENTER_ALIGNMENT); 
    9596 
    9697    refreshLabels(); 
     
    110111  } 
    111112 
    112   public void actionPerformed(ActionEvent e) { 
     113  @Override 
     114        public void actionPerformed(ActionEvent e) { 
    113115    String cmd = e.getActionCommand(); 
    114116    if ("malloc".equals(cmd)) { 
  • trunk/projects/utils/src/main/java/UniqueTraces.java

    r6936 r7640  
    6565        // in the middle of a stack trace 
    6666      } 
    67       buf.append(line); 
    68       buf.append("\n"); 
     67      if (buf != null) { 
     68        buf.append(line); 
     69        buf.append("\n"); 
     70      } 
    6971    } 
    70     traces.add(buf.toString()); 
     72    if (buf != null) traces.add(buf.toString()); 
    7173 
    7274    String[] traceStrings = new String[traces.size()]; 
Note: See TracChangeset for help on using the changeset viewer.