src/share/classes/javax/naming/NameImpl.java

Print this page

        

*** 43,53 **** class NameImpl { private static final byte LEFT_TO_RIGHT = 1; private static final byte RIGHT_TO_LEFT = 2; private static final byte FLAT = 0; ! private Vector components; private byte syntaxDirection = LEFT_TO_RIGHT; private String syntaxSeparator = "/"; private String syntaxSeparator2 = null; private boolean syntaxCaseInsensitive = false; --- 43,53 ---- class NameImpl { private static final byte LEFT_TO_RIGHT = 1; private static final byte RIGHT_TO_LEFT = 2; private static final byte FLAT = 0; ! private Vector<String> components; private byte syntaxDirection = LEFT_TO_RIGHT; private String syntaxSeparator = "/"; private String syntaxSeparator2 = null; private boolean syntaxCaseInsensitive = false;
*** 95,105 **** i += syntaxSeparator2.length(); } return (i); } ! private final int extractComp(String name, int i, int len, Vector comps) throws InvalidNameException { String beginQuote; String endQuote; boolean start = true; boolean one = false; --- 95,105 ---- i += syntaxSeparator2.length(); } return (i); } ! private final int extractComp(String name, int i, int len, Vector<String> comps) throws InvalidNameException { String beginQuote; String endQuote; boolean start = true; boolean one = false;
*** 268,278 **** NameImpl(Properties syntax) { if (syntax != null) { recordNamingConvention(syntax); } ! components = new Vector(); } NameImpl(Properties syntax, String n) throws InvalidNameException { this(syntax); --- 268,278 ---- NameImpl(Properties syntax) { if (syntax != null) { recordNamingConvention(syntax); } ! components = new Vector<>(); } NameImpl(Properties syntax, String n) throws InvalidNameException { this(syntax);
*** 282,293 **** for (int i = 0; i < len; ) { i = extractComp(n, i, len, components); String comp = rToL ! ? (String)components.firstElement() ! : (String)components.lastElement(); if (comp.length() >= 1) { compsAllEmpty = false; } if (i < len) { --- 282,293 ---- for (int i = 0; i < len; ) { i = extractComp(n, i, len, components); String comp = rToL ! ? components.firstElement() ! : components.lastElement(); if (comp.length() >= 1) { compsAllEmpty = false; } if (i < len) {
*** 302,312 **** } } } } ! NameImpl(Properties syntax, Enumeration comps) { this(syntax); // %% comps could shrink in the middle. while (comps.hasMoreElements()) components.addElement(comps.nextElement()); --- 302,312 ---- } } } } ! NameImpl(Properties syntax, Enumeration<String> comps) { this(syntax); // %% comps could shrink in the middle. while (comps.hasMoreElements()) components.addElement(comps.nextElement());
*** 453,465 **** int size = components.size(); for (int i = 0; i < size; i++) { if (syntaxDirection == RIGHT_TO_LEFT) { comp = ! stringifyComp((String) components.elementAt(size - 1 - i)); } else { ! comp = stringifyComp((String) components.elementAt(i)); } if ((i != 0) && (syntaxSeparator != null)) answer.append(syntaxSeparator); if (comp.length() >= 1) compsAllEmpty = false; --- 453,465 ---- int size = components.size(); for (int i = 0; i < size; i++) { if (syntaxDirection == RIGHT_TO_LEFT) { comp = ! stringifyComp(components.elementAt(size - 1 - i)); } else { ! comp = stringifyComp(components.elementAt(i)); } if ((i != 0) && (syntaxSeparator != null)) answer.append(syntaxSeparator); if (comp.length() >= 1) compsAllEmpty = false;
*** 472,487 **** public boolean equals(Object obj) { if ((obj != null) && (obj instanceof NameImpl)) { NameImpl target = (NameImpl)obj; if (target.size() == this.size()) { ! Enumeration mycomps = getAll(); ! Enumeration comps = target.getAll(); while (mycomps.hasMoreElements()) { // %% comps could shrink in the middle. ! String my = (String)mycomps.nextElement(); ! String his = (String)comps.nextElement(); if (syntaxTrimBlanks) { my = my.trim(); his = his.trim(); } if (syntaxCaseInsensitive) { --- 472,487 ---- public boolean equals(Object obj) { if ((obj != null) && (obj instanceof NameImpl)) { NameImpl target = (NameImpl)obj; if (target.size() == this.size()) { ! Enumeration<String> mycomps = getAll(); ! Enumeration<String> comps = target.getAll(); while (mycomps.hasMoreElements()) { // %% comps could shrink in the middle. ! String my = mycomps.nextElement(); ! String his = comps.nextElement(); if (syntaxTrimBlanks) { my = my.trim(); his = his.trim(); } if (syntaxCaseInsensitive) {
*** 541,566 **** public int size() { return (components.size()); } ! public Enumeration getAll() { return components.elements(); } public String get(int posn) { ! return ((String) components.elementAt(posn)); } ! public Enumeration getPrefix(int posn) { if (posn < 0 || posn > size()) { throw new ArrayIndexOutOfBoundsException(posn); } return new NameImplEnumerator(components, 0, posn); } ! public Enumeration getSuffix(int posn) { int cnt = size(); if (posn < 0 || posn > cnt) { throw new ArrayIndexOutOfBoundsException(posn); } return new NameImplEnumerator(components, posn, cnt); --- 541,566 ---- public int size() { return (components.size()); } ! public Enumeration<String> getAll() { return components.elements(); } public String get(int posn) { ! return components.elementAt(posn); } ! public Enumeration<String> getPrefix(int posn) { if (posn < 0 || posn > size()) { throw new ArrayIndexOutOfBoundsException(posn); } return new NameImplEnumerator(components, 0, posn); } ! public Enumeration<String> getSuffix(int posn) { int cnt = size(); if (posn < 0 || posn > cnt) { throw new ArrayIndexOutOfBoundsException(posn); } return new NameImplEnumerator(components, posn, cnt);
*** 568,586 **** public boolean isEmpty() { return (components.isEmpty()); } ! public boolean startsWith(int posn, Enumeration prefix) { if (posn < 0 || posn > size()) { return false; } try { ! Enumeration mycomps = getPrefix(posn); while (mycomps.hasMoreElements()) { ! String my = (String)mycomps.nextElement(); ! String his = (String)prefix.nextElement(); if (syntaxTrimBlanks) { my = my.trim(); his = his.trim(); } if (syntaxCaseInsensitive) { --- 568,586 ---- public boolean isEmpty() { return (components.isEmpty()); } ! public boolean startsWith(int posn, Enumeration<String> prefix) { if (posn < 0 || posn > size()) { return false; } try { ! Enumeration<String> mycomps = getPrefix(posn); while (mycomps.hasMoreElements()) { ! String my = mycomps.nextElement(); ! String his = prefix.nextElement(); if (syntaxTrimBlanks) { my = my.trim(); his = his.trim(); } if (syntaxCaseInsensitive) {
*** 595,618 **** return false; } return true; } ! public boolean endsWith(int posn, Enumeration suffix) { // posn is number of elements in suffix // startIndex is the starting position in this name // at which to start the comparison. It is calculated by // subtracting 'posn' from size() int startIndex = size() - posn; if (startIndex < 0 || startIndex > size()) { return false; } try { ! Enumeration mycomps = getSuffix(startIndex); while (mycomps.hasMoreElements()) { ! String my = (String)mycomps.nextElement(); ! String his = (String)suffix.nextElement(); if (syntaxTrimBlanks) { my = my.trim(); his = his.trim(); } if (syntaxCaseInsensitive) { --- 595,618 ---- return false; } return true; } ! public boolean endsWith(int posn, Enumeration<String> suffix) { // posn is number of elements in suffix // startIndex is the starting position in this name // at which to start the comparison. It is calculated by // subtracting 'posn' from size() int startIndex = size() - posn; if (startIndex < 0 || startIndex > size()) { return false; } try { ! Enumeration<String> mycomps = getSuffix(startIndex); while (mycomps.hasMoreElements()) { ! String my = mycomps.nextElement(); ! String his = suffix.nextElement(); if (syntaxTrimBlanks) { my = my.trim(); his = his.trim(); } if (syntaxCaseInsensitive) {
*** 627,641 **** return false; } return true; } ! public boolean addAll(Enumeration comps) throws InvalidNameException { boolean added = false; while (comps.hasMoreElements()) { try { ! Object comp = comps.nextElement(); if (size() > 0 && syntaxDirection == FLAT) { throw new InvalidNameException( "A flat name can only have a single component"); } components.addElement(comp); --- 627,641 ---- return false; } return true; } ! public boolean addAll(Enumeration<String> comps) throws InvalidNameException { boolean added = false; while (comps.hasMoreElements()) { try { ! String comp = comps.nextElement(); if (size() > 0 && syntaxDirection == FLAT) { throw new InvalidNameException( "A flat name can only have a single component"); } components.addElement(comp);
*** 645,660 **** } } return added; } ! public boolean addAll(int posn, Enumeration comps) throws InvalidNameException { boolean added = false; for (int i = posn; comps.hasMoreElements(); i++) { try { ! Object comp = comps.nextElement(); if (size() > 0 && syntaxDirection == FLAT) { throw new InvalidNameException( "A flat name can only have a single component"); } components.insertElementAt(comp, i); --- 645,660 ---- } } return added; } ! public boolean addAll(int posn, Enumeration<String> comps) throws InvalidNameException { boolean added = false; for (int i = posn; comps.hasMoreElements(); i++) { try { ! String comp = comps.nextElement(); if (size() > 0 && syntaxDirection == FLAT) { throw new InvalidNameException( "A flat name can only have a single component"); } components.insertElementAt(comp, i);
*** 688,699 **** return r; } public int hashCode() { int hash = 0; ! for (Enumeration e = getAll(); e.hasMoreElements();) { ! String comp = (String)e.nextElement(); if (syntaxTrimBlanks) { comp = comp.trim(); } if (syntaxCaseInsensitive) { comp = comp.toLowerCase(); --- 688,699 ---- return r; } public int hashCode() { int hash = 0; ! for (Enumeration<String> e = getAll(); e.hasMoreElements();) { ! String comp = e.nextElement(); if (syntaxTrimBlanks) { comp = comp.trim(); } if (syntaxCaseInsensitive) { comp = comp.toLowerCase();
*** 704,729 **** return hash; } } final ! class NameImplEnumerator implements Enumeration { ! Vector vector; int count; int limit; ! NameImplEnumerator(Vector v, int start, int lim) { vector = v; count = start; limit = lim; } public boolean hasMoreElements() { return count < limit; } ! public Object nextElement() { if (count < limit) { return vector.elementAt(count++); } throw new NoSuchElementException("NameImplEnumerator"); } --- 704,729 ---- return hash; } } final ! class NameImplEnumerator implements Enumeration<String> { ! Vector<String> vector; int count; int limit; ! NameImplEnumerator(Vector<String> v, int start, int lim) { vector = v; count = start; limit = lim; } public boolean hasMoreElements() { return count < limit; } ! public String nextElement() { if (count < limit) { return vector.elementAt(count++); } throw new NoSuchElementException("NameImplEnumerator"); }