コード例 #1
0
  /**
   * @param project
   * @param attInfo
   * @param counter
   */
  public static String createDefaultName(IProject project, ISchemaAttribute attInfo, int counter) {
    if (attInfo.getType().getName().equals("boolean")) // $NON-NLS-1$
    return "true"; //$NON-NLS-1$

    String tag = attInfo.getParent().getName();
    return project.getName() + "." + tag + counter; // $NON-NLS-1$
  }
コード例 #2
0
 /**
  * Creates a default class name including package prefix. Uses the schema attribute to determine a
  * default name, prepends a default package name based on the project and appends the counter if
  * more than one such class exists.
  *
  * @param project project that the class name is being generated for
  * @param attInfo the schema attribute describing the new class
  * @param counter used to make each generated name unique
  */
 public static String createDefaultClassName(
     IProject project, ISchemaAttribute attInfo, int counter) {
   String tag = attInfo.getParent().getName();
   String expectedType = attInfo.getBasedOn();
   String className = ""; // $NON-NLS-1$
   if (expectedType == null) {
     StringBuffer buf = new StringBuffer(tag);
     buf.setCharAt(0, Character.toUpperCase(tag.charAt(0)));
     className = buf.toString();
   } else {
     className = expectedType;
     int dotLoc = className.lastIndexOf('.');
     if (dotLoc != -1) className = className.substring(dotLoc + 1);
     if (className.length() > 2
         && className.charAt(0) == 'I'
         && Character.isUpperCase(className.charAt(1))) className = className.substring(1);
   }
   String packageName = createDefaultPackageName(project, className);
   className += counter;
   return packageName + "." + className; // $NON-NLS-1$
 }