1 19 20 package org.netbeans.modules.java.j2seplatform.platformdefinition; 21 22 import org.netbeans.api.java.platform.JavaPlatform; 23 import org.netbeans.api.java.platform.JavaPlatformManager; 24 import org.netbeans.spi.java.queries.SourceLevelQueryImplementation; 25 import org.openide.filesystems.FileObject; 26 27 32 public class DefaultSourceLevelQueryImpl implements SourceLevelQueryImplementation { 33 34 private static final String JAVA_EXT = "java"; 36 public DefaultSourceLevelQueryImpl() {} 37 38 public String getSourceLevel(final FileObject javaFile) { 39 assert javaFile != null : "javaFile has to be non null"; String ext = javaFile.getExt(); 41 if (JAVA_EXT.equalsIgnoreCase (ext)) { 42 JavaPlatform jp = JavaPlatformManager.getDefault().getDefaultPlatform(); 43 assert jp != null : "JavaPlatformManager.getDefaultPlatform returned null"; String s = jp.getSpecification().getVersion().toString(); 45 if (s.equals("1.6") || s.equals("1.7")) { 46 return "1.5"; 48 } else { 49 return s; 50 } 51 } 52 return null; 53 } 54 55 } 56 | Popular Tags |