@MediumTest
  public void testLargeField() throws Exception {
    mDatabase.execSQL("CREATE TABLE test (_id INTEGER PRIMARY KEY, data TEXT);");

    StringBuilder sql = new StringBuilder(2100);
    sql.append("INSERT INTO test (data) VALUES ('");
    Random random = new Random(System.currentTimeMillis());
    StringBuilder randomString = new StringBuilder(1979);
    for (int i = 0; i < 1979; i++) {
      randomString.append((random.nextInt() & 0xf) % 10);
    }
    sql.append(randomString);
    sql.append("');");
    mDatabase.execSQL(sql.toString());

    Cursor c = mDatabase.query("test", null, null, null, null, null, null);
    assertNotNull(c);
    assertEquals(1, c.getCount());

    assertTrue(c.moveToFirst());
    assertEquals(0, c.getPosition());
    String largeString = c.getString(c.getColumnIndexOrThrow("data"));
    assertNotNull(largeString);
    assertEquals(randomString.toString(), largeString);
    c.close();
  }
Esempio n. 2
1
  public List<Shred> getShredsWithTagsInTagsList(List<String> tags) {
    StringBuilder shredId =
        new StringBuilder("SELECT s.Id FROM Shred s, TagsForShred tfs, Tag t  ");
    shredId.append("WHERE tfs.ShredId = s.id AND tfs.TagId = t.Id AND ");
    shredId.append("(");
    for (int i = 0; i < tags.size() - 1; i++) {
      shredId.append(" t.Label='").append(tags.get(i)).append("' OR ");
    }
    shredId.append(" t.Label='").append(tags.get(tags.size() - 1)).append("' )");
    shredId.append(" Group By ( s.id) HAVING (Count(s.id) >= ?)");

    String selectShreds =
        "SELECT "
            + ShredderDAOImpl.SHREDDER_SQL
            + ", "
            + SHRED_SQL
            + " FROM Shred s,"
            + " Rating r, Shredder sr, GuitarForShredder gs, "
            + " EquiptmentForShredder es WHERE r.ShredId = s.id AND "
            + "gs.ShredderId = sr.id AND es.ShredderId = sr.id AND s.Id IN ("
            + shredId.toString()
            + ") AND s.Owner = sr.id LIMIT "
            + NO_SHREDS_IN_RESULT_SET;

    long t1 = System.currentTimeMillis();
    List<Shred> res =
        getShredsFromSQLString(selectShreds, new Object[] {tags.size()}, new ShredMapper());
    System.out.println("Shreds by tags: " + (System.currentTimeMillis() - t1));
    logger.info("Shreds by tags: " + (System.currentTimeMillis() - t1));
    return res;
  }
  @LargeTest
  public void testManyRowsTxt() throws Exception {
    mDatabase.execSQL("CREATE TABLE test (_id INTEGER PRIMARY KEY, data TEXT);");
    StringBuilder sql = new StringBuilder(2100);
    sql.append("INSERT INTO test (data) VALUES ('");
    Random random = new Random(System.currentTimeMillis());
    StringBuilder randomString = new StringBuilder(1979);
    for (int i = 0; i < 1979; i++) {
      randomString.append((random.nextInt() & 0xf) % 10);
    }
    sql.append(randomString);
    sql.append("');");

    // if cursor window size changed, adjust this value too
    final int count = 600; // more than two fillWindow needed
    for (int i = 0; i < count; i++) {
      mDatabase.execSQL(sql.toString());
    }

    Cursor c = mDatabase.query("test", new String[] {"data"}, null, null, null, null, null);
    assertNotNull(c);

    int i = 0;
    while (c.moveToNext()) {
      assertEquals(randomString.toString(), c.getString(0));
      i++;
    }
    assertEquals(count, i);
    assertEquals(count, c.getCount());
    c.close();
  }
  private static void generateNameByString(
      Set<String> possibleNames,
      String value,
      NameValidator validator,
      boolean forStaticVariable,
      Project project) {
    if (!JavaPsiFacade.getInstance(project).getNameHelper().isIdentifier(value)) return;
    if (forStaticVariable) {
      StringBuilder buffer = new StringBuilder(value.length() + 10);
      char[] chars = new char[value.length()];
      value.getChars(0, value.length(), chars, 0);
      boolean wasLow = Character.isLowerCase(chars[0]);

      buffer.append(Character.toUpperCase(chars[0]));
      for (int i = 1; i < chars.length; i++) {
        if (Character.isUpperCase(chars[i])) {
          if (wasLow) {
            buffer.append('_');
            wasLow = false;
          }
        } else {
          wasLow = true;
        }

        buffer.append(Character.toUpperCase(chars[i]));
      }
      possibleNames.add(validator.validateName(buffer.toString(), true));
    } else {
      possibleNames.add(validator.validateName(value, true));
    }
  }
  public void addSetterComment(Method method, FullyQualifiedTable table, String columnName) {
    StringBuilder sb = new StringBuilder();

    method.addJavaDocLine("/**"); // $NON-NLS-1$
    method.addJavaDocLine(" * This method was generated by Apache iBATIS ibator."); // $NON-NLS-1$

    sb.append(" * This method sets the value of the database column "); // $NON-NLS-1$
    sb.append(table);
    sb.append('.');
    sb.append(columnName);
    method.addJavaDocLine(sb.toString());

    method.addJavaDocLine(" *"); // $NON-NLS-1$

    Parameter parm = method.getParameters().get(0);
    sb.setLength(0);
    sb.append(" * @param "); // $NON-NLS-1$
    sb.append(parm.getName());
    sb.append(" the value for "); // $NON-NLS-1$
    sb.append(table);
    sb.append('.');
    sb.append(columnName);
    method.addJavaDocLine(sb.toString());

    addIbatorJavadocTag(method);

    method.addJavaDocLine(" */"); // $NON-NLS-1$
  }
Esempio n. 6
1
 private void readFromParcel(Parcel in) {
   // fieldToAccept = in.readInt();
   title.append(in.readString());
   date.append(in.readString());
   description.append(in.readString());
   setImageURL(in.readString());
 }
Esempio n. 7
1
  public String oneCookie(String name) {
    Cookie found = null;
    List<Cookie> allFound = null;
    for (Cookie cookie : getCookies()) {
      if (cookie.name().equals(name)) {
        if (found == null) {
          found = cookie;
        } else if (allFound == null) {
          allFound = new ArrayList<>(2);
          allFound.add(found);
        } else {
          allFound.add(cookie);
        }
      }
    }

    if (found == null) {
      return null;
    } else if (allFound != null) {
      StringBuilder s =
          new StringBuilder("Multiple cookies with name '").append(name).append("': ");
      int i = 0;
      for (Cookie cookie : allFound) {
        s.append(cookie.toString());
        if (++i < allFound.size()) {
          s.append(", ");
        }
      }

      throw new IllegalStateException(s.toString());
    } else {
      return found.value();
    }
  }
Esempio n. 8
1
  /**
   * Break on commas, except those inside quotes, e.g.: size(300, 200, PDF, "output,weirdname.pdf");
   * No special handling implemented for escaped (\") quotes.
   */
  private static StringList breakCommas(String contents) {
    StringList outgoing = new StringList();

    boolean insideQuote = false;
    // The current word being read
    StringBuilder current = new StringBuilder();
    char[] chars = contents.toCharArray();
    for (int i = 0; i < chars.length; i++) {
      char c = chars[i];
      if (insideQuote) {
        current.append(c);
        if (c == '\"') {
          insideQuote = false;
        }
      } else {
        if (c == ',') {
          if (current.length() != 0) {
            outgoing.append(current.toString());
            current.setLength(0);
          }
        } else {
          current.append(c);
          if (c == '\"') {
            insideQuote = true;
          }
        }
      }
    }
    if (current.length() != 0) {
      outgoing.append(current.toString());
    }
    return outgoing;
  }
Esempio n. 9
1
 public String getPrimaryDisplay() {
   StringBuilder sb = new StringBuilder();
   sb.append("");
   sb.append(
       (user.getPrimaryDisplay().toString() == null ? " " : user.getPrimaryDisplay().toString()));
   return sb.toString();
 }
  public static String reformatQuery(String query, String matchingSensors, String unionElement) {

    String lower_query = query.toLowerCase();

    String listSensors[] = matchingSensors.split(",");
    for (int i = 0; i < listSensors.length; i++) logger.warn(i + " : " + listSensors[i]);

    // replace "sensors"
    String ref_query =
        new StringBuilder(lower_query.replaceAll(LIST_SENSORS_RESERVED_WORD_REGEX, matchingSensors))
            .toString();

    // check for aggregates, containing reserved word $union
    if (ref_query.indexOf(UNION_RESERVED_WORD) > 0) {
      StringBuilder unionOfAll = new StringBuilder();
      if (unionElement != "") {
        System.out.println("what_to_repeat => " + unionElement);
        for (int i = 0; i < listSensors.length; i++) {
          unionOfAll.append(unionElement.replaceAll(SENSOR_RESERVED_WORD_REGEX, listSensors[i]));
          if (i < listSensors.length - 1) unionOfAll.append("\n union \n");
        }
      }
      System.out.println("unionofAll => " + unionOfAll);
      ref_query = ref_query.replaceAll(UNION_RESERVED_WORD_REGEX, unionOfAll.toString());
    }

    return ref_query;
  }
Esempio n. 11
1
 private static String accessToString(int access) {
   StringBuilder ret = new StringBuilder();
   ret.append(((access & READ) > 0) ? "r" : "-");
   ret.append(((access & WRITE) > 0) ? "w" : "-");
   ret.append(((access & ADMIN) > 0) ? "a" : "-");
   return ret.toString();
 }
Esempio n. 12
0
 @Override
 public String toString() {
   StringBuilder sb = new StringBuilder();
   sb.append("live nodes:" + liveNodes);
   sb.append(" collections:" + collectionStates);
   return sb.toString();
 }
Esempio n. 13
0
 @Override
 public String toString() {
   StringBuilder sb = new StringBuilder();
   sb.append("LineColor");
   sb.append(super.toString());
   return sb.toString();
 }
Esempio n. 14
0
 @Override
 public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
   if (r instanceof AbstractRunnable) {
     if (((AbstractRunnable) r).isForceExecution()) {
       BlockingQueue<Runnable> queue = executor.getQueue();
       if (!(queue instanceof SizeBlockingQueue)) {
         throw new IllegalStateException("forced execution, but expected a size queue");
       }
       try {
         ((SizeBlockingQueue) queue).forcePut(r);
       } catch (InterruptedException e) {
         Thread.currentThread().interrupt();
         throw new IllegalStateException("forced execution, but got interrupted", e);
       }
       return;
     }
   }
   rejected.inc();
   StringBuilder sb = new StringBuilder("rejected execution ");
   if (executor.isShutdown()) {
     sb.append(SHUTTING_DOWN_KEY + " ");
   } else {
     if (executor.getQueue() instanceof SizeBlockingQueue) {
       sb.append("(queue capacity ")
           .append(((SizeBlockingQueue) executor.getQueue()).capacity())
           .append(") ");
     }
   }
   sb.append("on ").append(r.toString());
   throw new EsRejectedExecutionException(sb.toString());
 }
  /**
   * Get the resource name given a full filename.
   *
   * @param fileName the full filename (which must be inside the directory)
   * @return the resource name (i.e., the filename with the directory stripped off)
   */
  String getResourceName(String fileName) {
    // FIXME: there is probably a more robust way to do this

    // Strip off the directory part.
    String dirPath = directory.getPath();
    if (!fileName.startsWith(dirPath)) {
      throw new IllegalStateException("Filename " + fileName + " not inside directory " + dirPath);
    }

    // The problem here is that we need to take the relative part of the filename
    // and break it into components that we can then reconstruct into
    // a resource name (using '/' characters to separate the components).
    // Unfortunately, the File class does not make this task particularly easy.

    String relativeFileName = fileName.substring(dirPath.length());
    File file = new File(relativeFileName);
    LinkedList<String> partList = new LinkedList<String>();
    do {
      partList.addFirst(file.getName());
    } while ((file = file.getParentFile()) != null);

    StringBuilder buf = new StringBuilder();
    for (String part : partList) {
      if (buf.length() > 0) {
        buf.append('/');
      }
      buf.append(part);
    }

    return buf.toString();
  }
Esempio n. 16
0
 private String createCurrentFrameworkText(final String path) {
   final StringBuilder builder = new StringBuilder();
   builder.append("<form>");
   builder.append("<p><img href=\"" + IMAGE_FOR_LINK + "\"/> " + path + "</p>");
   builder.append("</form>");
   return builder.toString();
 }
Esempio n. 17
0
  public List<String> getDependencies() {
    List<Dependency> deps = pom.getDependencies();
    if (deps == null) return null;

    final List<String> dependencies = new ArrayList<String>();
    for (Dependency dep : deps) {
      if (!dep.isOptional()) {
        String coords =
            dep.getGroupId()
                + ":"
                + dep.getArtifactId()
                + ":"
                + dep.getVersion()
                + (dep.getClassifier() != null && !dep.getClassifier().isEmpty()
                    ? ":" + dep.getClassifier()
                    : "");
        List<Exclusion> exclusions = dep.getExclusions();
        if (exclusions != null && !exclusions.isEmpty()) {
          StringBuilder sb = new StringBuilder();
          sb.append('(');
          for (Exclusion ex : exclusions)
            sb.append(ex.getGroupId()).append(':').append(ex.getArtifactId()).append(',');
          sb.delete(sb.length() - 1, sb.length());
          sb.append(')');
          coords += sb.toString();
        }
        dependencies.add(coords);
      }
    }
    return dependencies;
  }
 protected void calculateFormLabelWidth(FacesContext context, UIComponent component) {
   StringBuilder script = new StringBuilder();
   script.append("XSP.addOnLoad(function(){XSP.resizeForm("); // $NON-NLS-1$
   JavaScriptUtil.addString(script, component.getClientId(context));
   script.append(")});"); // $NON-NLS-1$
   ExtLibUtil.addScript(context, script.toString());
 }
Esempio n. 19
0
  /**
   * 外部サービス・訪問リハ
   *
   * @param map
   * @param sysSvcCdItems
   * @return
   */
  public ArrayList<HashMap<String, String>> getSystemServiceCodeItemHomonReha(
      Map<String, String> map, ArrayList<HashMap<String, String>> sysSvcCdItems) {
    // パラメータ抽出
    // =========================================================================
    // 1330105 施設区分
    int _1330105 = getIntValue(map, "1330105");

    // 1330107 外部サービス
    int _1330107 = getIntValue(map, "1330107");

    // 1330113 訪問リハ-施設区分
    int _1330113 = getIntValue(map, "1330113");

    // 独自コード生成
    // ===========================================================================
    StringBuilder sb = new StringBuilder();

    // 施設区分
    sb.append(CODE_CHAR[_1330105]);

    // 外部サービス
    sb.append(CODE_CHAR[_1330107]);

    // 訪問リハ-施設区分
    sb.append(CODE_CHAR[_1330113]);

    putSystemServiceCodeItem(sysSvcCdItems, sb.toString());

    return sysSvcCdItems;
  }
Esempio n. 20
0
  /**
   * Generate the standard IES Data Format Header and write it into the output stream 'out'.
   *
   * @param group
   * @param filename
   * @param loggingInterval
   * @param logChannelList
   * @return
   */
  public String getIESDataFormatHeaderString(
      LogIntervalContainerGroup group,
      String filename,
      int loggingInterval,
      HashMap<String, LogChannel> logChannelList) {

    StringBuilder sb = new StringBuilder();
    setHeaderTop(sb, loggingInterval, filename);

    // write channel specific header informations
    int colNumber = 4;
    for (LogRecordContainer container : group.getList()) {

      LogChannel logChannel = logChannelList.get(container.getChannelId());
      appendChannelSpecificComment(sb, logChannel, colNumber);
      ++colNumber;
    }
    List<LogRecordContainer> containers = group.getList();
    appendColumnHeaderTimestamp(sb);

    Iterator<LogRecordContainer> iterator = containers.iterator();

    while (iterator.hasNext()) {
      sb.append(iterator.next().getChannelId());
      if (iterator.hasNext()) {
        sb.append(Const.SEPARATOR);
      }
    }

    sb.append(Const.LINESEPARATOR);
    return sb.toString();
  }
Esempio n. 21
0
  @Override
  public void observe(Event event) {
    if (event instanceof MoveSelectedEvent) {
      Move theMove = ((MoveSelectedEvent) event).getMove();
      if (theQueue.size() < 2) {
        theQueue.add(theMove);
      }
    } else if (event instanceof ServerNewGameStateEvent) {
      stateFromServer = ((ServerNewGameStateEvent) event).getState();
    } else if (event instanceof ServerCompletedMatchEvent) {
      theGUI.updateGameState(stateFromServer);

      List<Role> theRoles = getStateMachine().getRoles();
      List<Integer> theGoals = ((ServerCompletedMatchEvent) event).getGoals();

      StringBuilder finalMessage = new StringBuilder();
      finalMessage.append("Goals: ");
      for (int i = 0; i < theRoles.size(); i++) {
        finalMessage.append(theRoles.get(i));
        finalMessage.append(" = ");
        finalMessage.append(theGoals.get(i));
        if (i < theRoles.size() - 1) {
          finalMessage.append(", ");
        }
      }

      theGUI.showFinalMessage(finalMessage.toString());
    }
  }
Esempio n. 22
0
  /**
   * Generate the standard IES Data Format Header and write it into the output stream 'out'.
   *
   * @param filename
   * @param logChannelList
   * @return
   */
  public String getIESDataFormatHeaderString(String filename, List<LogChannel> logChannelList) {

    StringBuilder sb0 = new StringBuilder();
    StringBuilder sb1 = new StringBuilder();
    setHeaderTop(sb0, logChannelList.get(0).getLoggingInterval(), filename);

    // write channel specific header informations
    int colNumber = 4;
    Iterator<LogChannel> iterator = logChannelList.listIterator();
    while (iterator.hasNext()) {

      LogChannel logChannel = iterator.next();
      appendChannelSpecificComment(sb0, logChannel, colNumber);

      sb1.append(logChannel.getId());
      if (iterator.hasNext()) {
        sb1.append(Const.SEPARATOR);
      }
      ++colNumber;
    }
    appendColumnHeaderTimestamp(sb0);
    sb0.append(sb1);
    sb0.append(Const.LINESEPARATOR);
    return sb0.toString();
  }
Esempio n. 23
0
  /** Show an event in the LogCat view, for debugging */
  private void dumpEvent(MotionEvent event) {
    String names[] = {
      "DOWN", "UP", "MOVE", "CANCEL", "OUTSIDE", "POINTER_DOWN", "POINTER_UP", "7?", "8?", "9?"
    };
    StringBuilder sb = new StringBuilder();
    int action = event.getAction();
    int actionCode = action & MotionEvent.ACTION_MASK;
    sb.append("event ACTION_").append(names[actionCode]);

    if (actionCode == MotionEvent.ACTION_POINTER_DOWN
        || actionCode == MotionEvent.ACTION_POINTER_UP) {
      sb.append("(pid ").append(action >> MotionEvent.ACTION_POINTER_ID_SHIFT);
      sb.append(")");
    }

    sb.append("[");
    for (int i = 0; i < event.getPointerCount(); i++) {
      sb.append("#").append(i);
      sb.append("(pid ").append(event.getPointerId(i));
      sb.append(")=").append((int) event.getX(i));
      sb.append(",").append((int) event.getY(i));
      if (i + 1 < event.getPointerCount()) {
        sb.append(";");
      }
    }

    sb.append("]");
    Log.d("Touch Events ---------", sb.toString());
  }
 public StringBuilder append(StringBuilder sb, String role) {
   if (!isEmpty()) {
     sb.append(role).append("\n");
     for (Record record : _records) sb.append("  ").append(record).append("\n");
   }
   return sb;
 }
  /**
   * Creates a list of names separated by commas or an and symbol if its the last separation. This
   * is then used to say hello to the list of names.
   *
   * <p>i.e. if the input was {John, Mary, Luke} the output would be John, Mary & Luke
   *
   * @param names A list of names
   * @return The list of names separated as described above.
   */
  private String createNameListString(final List<String> names) {

    /*
     * If the list is null or empty then assume the call was anonymous.
     */
    if (names == null || names.isEmpty()) {
      return "Anonymous!";
    }

    final StringBuilder nameBuilder = new StringBuilder();
    for (int i = 0; i < names.size(); i++) {

      /*
       * Add the separator if its not the first string or the last separator since that should be an and (&) symbol.
       */
      if (i != 0 && i != names.size() - 1) nameBuilder.append(", ");
      else if (i != 0 && i == names.size() - 1) nameBuilder.append(" & ");

      nameBuilder.append(names.get(i));
    }

    nameBuilder.append("!");

    return nameBuilder.toString();
  }
Esempio n. 26
0
  /**
   * 读取文件
   *
   * @param 文件路径
   * @param 字符集名称一个受支持的名称
   * @return 如果文件不存在,返回null,否则返回文件的内容
   * @throws RuntimeException if an error occurs while operator BufferedReader
   */
  public static StringBuilder readFile(String filePath, String charsetName) {
    File file = new File(filePath);
    StringBuilder fileContent = new StringBuilder("");
    if (file == null || !file.isFile()) {
      return null;
    }

    BufferedReader reader = null;
    try {
      InputStreamReader is = new InputStreamReader(new FileInputStream(file), charsetName);
      reader = new BufferedReader(is);
      String line = null;
      while ((line = reader.readLine()) != null) {
        if (!fileContent.toString().equals("")) {
          fileContent.append("\r\n");
        }
        fileContent.append(line);
      }
      reader.close();
      return fileContent;
    } catch (IOException e) {
      throw new RuntimeException("IOException occurred. ", e);
    } finally {
      if (reader != null) {
        try {
          reader.close();
        } catch (IOException e) {
          throw new RuntimeException("IOException occurred. ", e);
        }
      }
    }
  }
Esempio n. 27
0
  public void executeMojo() throws MojoExecutionException {
    getLog().info("Validating " + getHosts() + " using migrations at " + getMigrationsPath() + "");

    try {
      MigrationManager manager = createMigrationManager();
      SortedSet<Migration> pendingMigrations = manager.pendingMigrations();
      StringBuilder sb = new StringBuilder();
      sb.append("\n            Database: ").append(getHosts());
      sb.append("\n          Up-to-date: ").append(pendingMigrations.isEmpty());
      sb.append("\n  Pending Migrations: ");

      if (!pendingMigrations.isEmpty()) {
        boolean first = true;
        for (Migration migration : pendingMigrations) {
          if (!first) {
            sb.append("\n                      ");
          }
          first = false;
          sb.append(migration.getFilename());
        }
      }

      getLog().info(sb.toString());
    } catch (Exception e) {
      throw new MojoExecutionException("Failed to validate " + getHosts(), e);
    }
  }
Esempio n. 28
0
 /** Add any cookies for this URI to the request headers. */
 private void loadRequestCookies() throws IOException {
   CookieHandler cookieHandler = CookieHandler.getDefault();
   if (cookieHandler != null) {
     try {
       URI uri = getURL().toURI();
       Map<String, List<String>> cookieHeaders =
           cookieHandler.get(uri, getHeaderFieldsDoNotForceResponse());
       for (Map.Entry<String, List<String>> entry : cookieHeaders.entrySet()) {
         String key = entry.getKey();
         if (("Cookie".equalsIgnoreCase(key) || "Cookie2".equalsIgnoreCase(key))
             && !entry.getValue().isEmpty()) {
           List<String> cookies = entry.getValue();
           StringBuilder sb = new StringBuilder();
           for (int i = 0, size = cookies.size(); i < size; i++) {
             if (i > 0) {
               sb.append("; ");
             }
             sb.append(cookies.get(i));
           }
           setHeader(key, sb.toString());
         }
       }
     } catch (URISyntaxException e) {
       throw new IOException(e);
     }
   }
 }
Esempio n. 29
0
  /**
   * Handle the milliseconds. This means either fill up with zeros or truncate the date String so
   * that the fractional second addendum only contains 3 digits. Returns the given string unmodified
   * if it doesn't match {@link #SECOND_FRACTION}.
   *
   * @param dateString
   * @return the date String where the fractional second addendum is a most 3 digits
   */
  private static String handleMilliseconds(String dateString) {
    Matcher matcher = SECOND_FRACTION.matcher(dateString);
    if (!matcher.matches()) {
      // The date string does not contain any milliseconds
      return dateString;
    }

    int fractionalSecondsDigitCount = matcher.group(1).length();
    if (fractionalSecondsDigitCount == 3) {
      // The date string has exactly 3 fractional second digits
      return dateString;
    }

    // Gather information about the date string
    int posDecimal = dateString.indexOf(".");
    StringBuilder sb = new StringBuilder(dateString.length() - fractionalSecondsDigitCount + 3);
    if (fractionalSecondsDigitCount > 3) {
      // Append only 3 fractional digits after posDecimal
      sb.append(dateString.substring(0, posDecimal + 4));
    } else {
      // The date string has less then 3 fractional second digits
      sb.append(dateString.substring(0, posDecimal + fractionalSecondsDigitCount + 1));
      // Fill up the "missing" fractional second digits with zeros
      for (int i = fractionalSecondsDigitCount; i < 3; i++) {
        sb.append('0');
      }
    }
    // Append the timezone definition
    sb.append(dateString.substring(posDecimal + fractionalSecondsDigitCount + 1));
    return sb.toString();
  }
 public MethodDefinitionBuilder resultType(Method method, int flags) {
   if (Decl.isMpl(method)) {
     // Create a String with the TypeInfo
     StringBuilder sb = new StringBuilder();
     // It's a bunch of nested callables (# of param lists - 1)
     for (int i = 1; i < method.getParameterLists().size(); i++) {
       sb.append("ceylon.language::Callable<");
     }
     // Then the return type as defined originally
     sb.append(method.getType().getProducedTypeQualifiedName());
     // And then the parameter types of each nested callable
     for (int i = method.getParameterLists().size() - 1; i > 0; i--) {
       ParameterList plist = method.getParameterLists().get(i);
       for (Parameter p : plist.getParameters()) {
         sb.append(',');
         sb.append(p.getType().getProducedTypeQualifiedName());
       }
       sb.append('>');
     }
     return resultType(
         gen.makeAtType(sb.toString(), false),
         gen.makeJavaType(gen.functionalReturnType(method), flags));
   } else {
     ProducedTypedReference typedRef = gen.getTypedReference(method);
     ProducedTypedReference nonWideningTypedRef = gen.nonWideningTypeDecl(typedRef);
     ProducedType nonWideningType = gen.nonWideningType(typedRef, nonWideningTypedRef);
     return resultType(
         makeResultType(nonWideningTypedRef.getDeclaration(), nonWideningType, flags), method);
   }
 }