Example #1
0
 private static void setupType(
     JaxType currentType,
     StringBuffer currentTypeName,
     ClassDoc containingClass,
     JAXDoclet<?> doclet)
     throws InvalidJaxTypeException {
   if (currentTypeName.length() == 0) {
     throw new InvalidJaxTypeException();
   }
   currentType.typeName = currentTypeName.toString();
   currentType.type = resolveType(currentType.typeName, containingClass, doclet);
   currentTypeName.setLength(0);
 }
Example #2
0
 public static JaxType parseType(String typeName, ClassDoc containingClass, JAXDoclet<?> doclet)
     throws InvalidJaxTypeException {
   typeName = typeName.trim();
   char[] chars = typeName.toCharArray();
   Stack<JaxType> types = new Stack<JaxType>();
   JaxType currentType = new JaxType();
   types.push(currentType);
   StringBuffer currentTypeName = new StringBuffer();
   for (int i = 0; i < chars.length; i++) {
     char c = chars[i];
     log("Looking at char " + c);
     if (c == '<') {
       log("Start params for " + currentTypeName);
       // we're done for the type name
       setupType(currentType, currentTypeName, containingClass, doclet);
       // add a parameter to the current type
       JaxType parameterType = new JaxType();
       currentType.parameters.add(parameterType);
       currentType = parameterType;
       // prepare for the parameter type
       types.push(currentType);
     } else if (c == '>') {
       // we're done for the parameter type
       if (currentTypeName.length() > 0)
         setupType(currentType, currentTypeName, containingClass, doclet);
       // reset and pop
       types.pop();
       currentType = types.peek();
       log("End params for " + currentType.typeName);
       // we should have at least the top type
       if (types.size() < 1) throw new InvalidJaxTypeException();
     } else if (c == ',') {
       // we're done for the parameter type, unless it was already done by
       // closing its parameter list
       if (currentTypeName.length() > 0) {
         setupType(currentType, currentTypeName, containingClass, doclet);
         // reset, pop
         types.pop();
         currentType = types.peek();
       }
       log("Next params for " + currentType.typeName);
       // we should have at least the top type
       if (types.size() < 1) throw new InvalidJaxTypeException();
       // add a parameter to the current type
       JaxType parameterType = new JaxType();
       currentType.parameters.add(parameterType);
       currentType = parameterType;
       // prepare for the parameter type
       types.push(currentType);
     } else if (c == '[' || c == ']') {
       log("Dimension for " + currentType.typeName);
       // done for the class name unless it was already done by
       // closing its parameter list
       if (currentTypeName.length() > 0) {
         setupType(currentType, currentTypeName, containingClass, doclet);
       }
       // FIXME: check dimension correctness
       currentType.dimension += c;
     } else {
       log("Name char: " + currentTypeName);
       // if the currentType already has a name, barf
       if (currentType.typeName != null) throw new InvalidJaxTypeException();
       currentTypeName.append(c);
     }
   }
   // perhaps we didn't have any parameters or dimension
   if (currentTypeName.length() > 0) {
     log("End of type without param or dimension for " + currentTypeName);
     setupType(currentType, currentTypeName, containingClass, doclet);
   }
   // we should have the original type to return
   if (types.size() != 1) throw new InvalidJaxTypeException();
   return currentType;
 }