130 * Returns the index of the type argument that the given step is stepping into. This method should
131 * only be used for steps whose value is {@link #TYPE_ARGUMENT}.
132 *
133 * @param index an index between 0 and {@link #getLength()}, exclusive.
134 * @return the index of the type argument that the given step is stepping into.
135 */
136 public int getStepArgument(final int index) {
137 // Returns the type_argument_index of the path element of the given index.
138 return typePathContainer[typePathOffset + 2 * index + 2];
139 }
140
141 /**
142 * Converts a type path in string form, in the format used by {@link #toString()}, into a TypePath
143 * object.
144 *
145 * @param typePath a type path in string form, in the format used by {@link #toString()}. May be
146 * {@literal null} or empty.
147 * @return the corresponding TypePath object, or {@literal null} if the path is empty.
148 */
149 public static TypePath fromString(final String typePath) {
150 if (typePath == null || typePath.length() == 0) {
151 return null;
152 }
153 int typePathLength = typePath.length();
154 ByteVector output = new ByteVector(typePathLength);
155 output.putByte(0);
156 int typePathIndex = 0;
157 while (typePathIndex < typePathLength) {
158 char c = typePath.charAt(typePathIndex++);
159 if (c == '[') {
160 output.put11(ARRAY_ELEMENT, 0);
161 } else if (c == '.') {
162 output.put11(INNER_TYPE, 0);
163 } else if (c == '*') {
164 output.put11(WILDCARD_BOUND, 0);
165 } else if (c >= '0' && c <= '9') {
166 int typeArg = c - '0';
167 while (typePathIndex < typePathLength) {
168 c = typePath.charAt(typePathIndex++);
169 if (c >= '0' && c <= '9') {
170 typeArg = typeArg * 10 + c - '0';
|
130 * Returns the index of the type argument that the given step is stepping into. This method should
131 * only be used for steps whose value is {@link #TYPE_ARGUMENT}.
132 *
133 * @param index an index between 0 and {@link #getLength()}, exclusive.
134 * @return the index of the type argument that the given step is stepping into.
135 */
136 public int getStepArgument(final int index) {
137 // Returns the type_argument_index of the path element of the given index.
138 return typePathContainer[typePathOffset + 2 * index + 2];
139 }
140
141 /**
142 * Converts a type path in string form, in the format used by {@link #toString()}, into a TypePath
143 * object.
144 *
145 * @param typePath a type path in string form, in the format used by {@link #toString()}. May be
146 * {@literal null} or empty.
147 * @return the corresponding TypePath object, or {@literal null} if the path is empty.
148 */
149 public static TypePath fromString(final String typePath) {
150 if (typePath == null || typePath.isEmpty()) {
151 return null;
152 }
153 int typePathLength = typePath.length();
154 ByteVector output = new ByteVector(typePathLength);
155 output.putByte(0);
156 int typePathIndex = 0;
157 while (typePathIndex < typePathLength) {
158 char c = typePath.charAt(typePathIndex++);
159 if (c == '[') {
160 output.put11(ARRAY_ELEMENT, 0);
161 } else if (c == '.') {
162 output.put11(INNER_TYPE, 0);
163 } else if (c == '*') {
164 output.put11(WILDCARD_BOUND, 0);
165 } else if (c >= '0' && c <= '9') {
166 int typeArg = c - '0';
167 while (typePathIndex < typePathLength) {
168 c = typePath.charAt(typePathIndex++);
169 if (c >= '0' && c <= '9') {
170 typeArg = typeArg * 10 + c - '0';
|