private static boolean isAcceptableSourceLevel(String minSourceLevel, String sourceLevel, Set acceptableSourceLevels) { if (minSourceLevel.equals(sourceLevel)) { return true; } SpecificationVersion minSpec = new SpecificationVersion(minSourceLevel); SpecificationVersion spec = new SpecificationVersion(sourceLevel); if (minSpec.compareTo(spec) > 0) { return false; } return acceptableSourceLevels.contains(sourceLevel); }
/** Parse from string. Must be Dewey-decimal. */ public SpecificationVersion(String version) throws NumberFormatException { synchronized (parseCache) { int[] d = parseCache.get(version); if (d == null) { d = parse(version); parseCache.put(version.intern(), d); } digits = d; } }
private static SpecificationVersion getDefaultSourceLevel () { if (defaultSourceLevel != null) { return defaultSourceLevel; } else { JavaPlatform defaultPlatform = JavaPlatformManager.getDefault().getDefaultPlatform(); SpecificationVersion v = defaultPlatform.getSpecification().getVersion(); if (v.equals(new SpecificationVersion("1.6")) || v.equals(new SpecificationVersion("1.7"))) { // #89131: these levels are not actually distinct from 1.5. - xxx not true, but may be acceptable to have 1.5 as default return new SpecificationVersion("1.5"); } else { return v; } } }
/** Try to make a specification version from a string. * Deal with errors gracefully and try to recover something from it. * E.g. "1.4.0beta" is technically erroneous; correct to "1.4.0". */ private static SpecificationVersion makeSpec(String vers) { if (vers != null) { try { return new SpecificationVersion(vers); } catch (NumberFormatException nfe) { System.err.println("WARNING: invalid specification version: " + vers); // NOI18N } do { vers = vers.substring(0, vers.length() - 1); try { return new SpecificationVersion(vers); } catch (NumberFormatException nfe) { // ignore } } while (vers.length() > 0); } // Nothing decent in it at all; use zero. return new SpecificationVersion("0"); // NOI18N }
void write(ObjectOutput dos) throws IOException { dos.writeUTF(codeName); dos.writeUTF(codeNameBase); dos.writeInt(codeNameRelease); writeStrings(dos, coveredPackages); dos.writeObject(dependencies); dos.writeUTF(implVersion); dos.writeUTF(buildVersion); writeStrings(dos, provides); writeStrings(dos, friendNames); dos.writeUTF(specVers != null ? specVers.toString() : "0"); Module.PackageExport.write(dos, publicPackages); }
private boolean isValidOrder(final Map<String,SpecificationVersion> firstAPImap, final HashMap<String,SpecificationVersion> secondAPImap) { final HashSet<String> hs = new HashSet<String>(firstAPImap.keySet()); hs.retainAll(secondAPImap.keySet()); if (hs.isEmpty()) return true; for ( final String api : hs ) { if (firstAPImap.get(api).compareTo(secondAPImap.get(api)) >= 0) return true; } return false; } }
public boolean equals (Object other) { if (other instanceof Profile) { Profile op = (Profile) other; return this.name == null ? op.name == null : this.name.equals(op.name) && this.version == null ? op.version == null : this.version.equals (op.version); } else return false; }
new SpecificationVersion(version); } catch (NumberFormatException nfe) { throw new IllegalArgumentException(nfe.toString());
J2MEProfile(String name, SpecificationVersion version, String displayName, String type, String dependencies, String classPath, boolean def) { super(name, version); assert name != null; assert version != null; this.displayName = displayName == null ? name : displayName; //this is an ugly workaround for IMP-NG profile where the NG is the version number so no other version number should be appended if ("IMP-NG".equalsIgnoreCase(getName())) this.displayNameWithVersion = getDisplayName(); //NOI18N else this.displayNameWithVersion = DISPLAY_NAME_WITH_VERSION_FORMAT.format(new Object[] {getDisplayName(), getVersion().toString()}, new StringBuffer(), null).toString(); assert type != null; this.type = type; this.dependencies = dependencies != null ? dependencies : ""; //NOI18N this.classPath = classPath == null ? "" : classPath; // NOI18N this.def = def; }
@CheckForNull private SpecificationVersion max ( @NullAllowed final SpecificationVersion a, @NullAllowed final SpecificationVersion b) { if (a == null) { return b; } else if (b == null) { return a; } else if (a.compareTo(b)>=0) { return a; } else { return b; } }
public boolean equals (Object other) { if (other instanceof Specification) { Specification os = (Specification) other; boolean re = this.name == null ? os.name == null : this.name.equals(os.name) && this.version == null ? os.version == null : this.version.equals (os.version); if (!re || this.profiles == null) return re; if (os.profiles == null || this.profiles.length != os.profiles.length) return false; for (int i=0; i<os.profiles.length; i++) re &= this.profiles[i].equals(os.profiles[i]); return re; } else return false; }
private static String getCompilerType (ScalaPlatform platform) { assert platform != null; String prop = platform.getSystemProperties().get("java.specification.version"); //NOI18N assert prop != null; SpecificationVersion specificationVersion = new SpecificationVersion (prop); SpecificationVersion jdk13 = new SpecificationVersion("1.3"); //NOI18N int c = specificationVersion.compareTo (jdk13); if (c<0) { return CLASSIC; } else if (c == 0) { return JAVAC13; } else { return MODERN; } }
@Override public SpecificationVersion getJavacardVersion() { return new SpecificationVersion ("9.9"); //NOI18N }
@Override public String getDisplayName() { String displayName = super.getDisplayName(); if (displayName == null) { displayName = NbBundle.getMessage(DefaultPlatformImpl.class, "TXT_DefaultPlatform", getSpecification().getVersion().toString()); this.internalSetDisplayName(displayName); } return displayName; }
@Override public int compareTo(final Object o) { final Profile p = (Profile)o; final int r = getName().compareTo(p.getName()); if (r != 0) return r; if (getVersion() == null) return p.getVersion() == null ? 0 : -1; return p.getVersion() == null ? 1 : getVersion().compareTo(p.getVersion()); }
/** Parse from string. Must be Dewey-decimal. */ public SpecificationVersion(String version) throws NumberFormatException { synchronized (parseCache) { int[] d = (int[])parseCache.get(version); if (d == null) { d = parse(version); parseCache.put(version.intern(), d); } digits = d; } }
private static boolean compatibleProfile (Profile platformProfile, Profile query) { String name = query.getName(); SpecificationVersion version = query.getVersion(); return ((name == null || name.equals (platformProfile.getName())) && (version == null || version.equals (platformProfile.getVersion()))); }
static boolean isDesignModeSupported(NbModuleProvider info) { try { SpecificationVersion current = info.getDependencyVersion("org.openide.windows"); if (current == null) { return false; } return current.compareTo(new SpecificationVersion("6.45")) >= 0; // NOI18N } catch (IOException ex) { Logger.getLogger(NewTCIterator.class.getName()).log(Level.INFO, null, ex); return false; } }
public J2MEProfile(String name, String version, String displayName, String type, String dependencies, String classPath, boolean def) { this(name, new SpecificationVersion(version), displayName, type, dependencies, classPath, def); }
public String getSourceLevel(final FileObject javaFile) { assert javaFile != null : "javaFile has to be non null"; //NOI18N String ext = javaFile.getExt(); if (JAVA_EXT.equalsIgnoreCase (ext)) { ScalaPlatform jp = ScalaPlatformManager.getDefault().getDefaultPlatform(); assert jp != null : "JavaPlatformManager.getDefaultPlatform returned null"; //NOI18N String s = jp.getSpecification().getVersion().toString(); if (s.equals("1.6") || s.equals("1.7")) { // #89131: these levels are not actually distinct from 1.5. return "1.5"; } else { return s; } } return null; }