Beispiel #1
0
  private static List<String> match(
      PropertyResourceBundle sourceBundle, PropertyResourceBundle targetBundle) {

    List<String> remaining = new ArrayList<String>();

    Enumeration<String> targetKeys = targetBundle.getKeys();
    while (targetKeys.hasMoreElements()) {
      String targetKey = targetKeys.nextElement();
      Enumeration<String> sourceKeys = sourceBundle.getKeys();
      boolean matched = false;
      while (sourceKeys.hasMoreElements()) {
        if (sourceKeys.nextElement().equals(targetKey)) {
          matched = true;
          break;
        }
      }

      if (!matched && !remaining.contains(targetKey)) remaining.add(targetKey);
    }

    System.out.println("Source keys: " + sourceBundle.keySet().size());
    System.out.println("Target keys: " + targetBundle.keySet().size());
    System.out.println("Remaining: " + remaining.size());

    return remaining;
  }
 public static void setGroovyClasspath(Map optionMap, IJavaProject javaProject) {
   IFile file = javaProject.getProject().getFile("groovy.properties"); // $NON-NLS-1$
   if (file.exists()) {
     try {
       PropertyResourceBundle prb = new PropertyResourceBundle(file.getContents());
       Enumeration e = prb.getKeys();
       // System.err.println("Loading groovy settings for project '"+project.getName()+"'");
       while (e.hasMoreElements()) {
         String k = (String) e.nextElement();
         String v = (String) prb.getObject(k);
         v = fixup(v, javaProject);
         // System.out.println(k+"="+v);
         if (k.equals(CompilerOptions.OPTIONG_GroovyClassLoaderPath)) {
           optionMap.put(CompilerOptions.OPTIONG_GroovyClassLoaderPath, v);
         }
       }
     } catch (IOException ioe) {
       System.err.println("Problem configuring groovy classloader classpath");
       ioe.printStackTrace();
     } catch (CoreException ce) {
       System.err.println("Problem configuring groovy classloader classpath");
       ce.printStackTrace();
     } catch (Throwable t) {
       System.err.println("Problem configuring groovy classloader classpath");
       t.printStackTrace();
     }
   } else {
     try {
       String classpath = calculateClasspath(javaProject);
       optionMap.put(CompilerOptions.OPTIONG_GroovyClassLoaderPath, classpath);
     } catch (Throwable t) {
       System.err.println(
           "Problem configuring groovy classloader classpath (not using groovy.properties)");
       t.printStackTrace();
     }
   }
   optionMap.put(CompilerOptions.OPTIONG_GroovyProjectName, javaProject.getProject().getName());
 }
 /* (non-Javadoc)
  * @see java.util.ResourceBundle#getKeys()
  */
 public Enumeration getKeys() {
   return bundle.getKeys();
 }
 public Enumeration<String> getKeys() {
   return bundle.getKeys();
 }