< prev index next >

src/java.prefs/share/classes/java/util/prefs/AbstractPreferences.java

Print this page
rev 52881 : 8214971: Replace use of string.equals("") with isEmpty()
Reviewed-by: jlaskey, prappo, lancea, dfuchs, redestad

*** 201,220 **** * ({@code '/'}), or {@code parent} is {@code null} and * name isn't {@code ""}. */ protected AbstractPreferences(AbstractPreferences parent, String name) { if (parent==null) { ! if (!name.equals("")) throw new IllegalArgumentException("Root name '"+name+ "' must be \"\""); this.absolutePath = "/"; root = this; } else { if (name.indexOf('/') != -1) throw new IllegalArgumentException("Name '" + name + "' contains '/'"); ! if (name.equals("")) throw new IllegalArgumentException("Illegal name: empty string"); root = parent.root; absolutePath = (parent==root ? "/" + name : parent.absolutePath() + "/" + name); --- 201,220 ---- * ({@code '/'}), or {@code parent} is {@code null} and * name isn't {@code ""}. */ protected AbstractPreferences(AbstractPreferences parent, String name) { if (parent==null) { ! if (!name.isEmpty()) throw new IllegalArgumentException("Root name '"+name+ "' must be \"\""); this.absolutePath = "/"; root = this; } else { if (name.indexOf('/') != -1) throw new IllegalArgumentException("Name '" + name + "' contains '/'"); ! if (name.isEmpty()) throw new IllegalArgumentException("Illegal name: empty string"); root = parent.root; absolutePath = (parent==root ? "/" + name : parent.absolutePath() + "/" + name);
*** 846,856 **** */ public Preferences node(String path) { synchronized(lock) { if (removed) throw new IllegalStateException("Node has been removed."); ! if (path.equals("")) return this; if (path.equals("/")) return root; if (path.charAt(0) != '/') return node(new StringTokenizer(path, "/", true)); --- 846,856 ---- */ public Preferences node(String path) { synchronized(lock) { if (removed) throw new IllegalStateException("Node has been removed."); ! if (path.isEmpty()) return this; if (path.equals("/")) return root; if (path.charAt(0) != '/') return node(new StringTokenizer(path, "/", true));
*** 909,919 **** */ public boolean nodeExists(String path) throws BackingStoreException { synchronized(lock) { ! if (path.equals("")) return !removed; if (removed) throw new IllegalStateException("Node has been removed."); if (path.equals("/")) return true; --- 909,919 ---- */ public boolean nodeExists(String path) throws BackingStoreException { synchronized(lock) { ! if (path.isEmpty()) return !removed; if (removed) throw new IllegalStateException("Node has been removed."); if (path.equals("/")) return true;
< prev index next >