< prev index next >

src/java.base/share/classes/jdk/internal/org/objectweb/asm/TypePath.java

Print this page
rev 51919 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: dfuchs, alanb


 144      *
 145      * @param index
 146      *            an index between 0 and {@link #getLength()}, exclusive.
 147      * @return the index of the type argument that the given step is stepping
 148      *         into.
 149      */
 150     public int getStepArgument(int index) {
 151         return b[offset + 2 * index + 2];
 152     }
 153 
 154     /**
 155      * Converts a type path in string form, in the format used by
 156      * {@link #toString()}, into a TypePath object.
 157      *
 158      * @param typePath
 159      *            a type path in string form, in the format used by
 160      *            {@link #toString()}. May be null or empty.
 161      * @return the corresponding TypePath object, or null if the path is empty.
 162      */
 163     public static TypePath fromString(final String typePath) {
 164         if (typePath == null || typePath.length() == 0) {
 165             return null;
 166         }
 167         int n = typePath.length();
 168         ByteVector out = new ByteVector(n);
 169         out.putByte(0);
 170         for (int i = 0; i < n;) {
 171             char c = typePath.charAt(i++);
 172             if (c == '[') {
 173                 out.put11(ARRAY_ELEMENT, 0);
 174             } else if (c == '.') {
 175                 out.put11(INNER_TYPE, 0);
 176             } else if (c == '*') {
 177                 out.put11(WILDCARD_BOUND, 0);
 178             } else if (c >= '0' && c <= '9') {
 179                 int typeArg = c - '0';
 180                 while (i < n && (c = typePath.charAt(i)) >= '0' && c <= '9') {
 181                     typeArg = typeArg * 10 + c - '0';
 182                     i += 1;
 183                 }
 184                 if (i < n && typePath.charAt(i) == ';') {




 144      *
 145      * @param index
 146      *            an index between 0 and {@link #getLength()}, exclusive.
 147      * @return the index of the type argument that the given step is stepping
 148      *         into.
 149      */
 150     public int getStepArgument(int index) {
 151         return b[offset + 2 * index + 2];
 152     }
 153 
 154     /**
 155      * Converts a type path in string form, in the format used by
 156      * {@link #toString()}, into a TypePath object.
 157      *
 158      * @param typePath
 159      *            a type path in string form, in the format used by
 160      *            {@link #toString()}. May be null or empty.
 161      * @return the corresponding TypePath object, or null if the path is empty.
 162      */
 163     public static TypePath fromString(final String typePath) {
 164         if (typePath == null || typePath.isEmpty()) {
 165             return null;
 166         }
 167         int n = typePath.length();
 168         ByteVector out = new ByteVector(n);
 169         out.putByte(0);
 170         for (int i = 0; i < n;) {
 171             char c = typePath.charAt(i++);
 172             if (c == '[') {
 173                 out.put11(ARRAY_ELEMENT, 0);
 174             } else if (c == '.') {
 175                 out.put11(INNER_TYPE, 0);
 176             } else if (c == '*') {
 177                 out.put11(WILDCARD_BOUND, 0);
 178             } else if (c >= '0' && c <= '9') {
 179                 int typeArg = c - '0';
 180                 while (i < n && (c = typePath.charAt(i)) >= '0' && c <= '9') {
 181                     typeArg = typeArg * 10 + c - '0';
 182                     i += 1;
 183                 }
 184                 if (i < n && typePath.charAt(i) == ';') {


< prev index next >