Esempio n. 1
0
  /**
   * Verifies whether given class is primitive.
   *
   * @param className fully qualified class name to verify
   * @return true if given class is primitive; false otherwise
   */
  public static boolean isPrimitive(String className) {
    for (Object clazz : PRIMITIVE_TYPE_MAP.values()) {
      if (((Class) clazz).getName().equals(className)) {
        return true;
      }
    }

    return false;
  }
Esempio n. 2
0
  /**
   * Saves the feature mapping to readable format, each line is a feature id and feature name,
   * sorted by feature id
   *
   * @param mapping mapping (name:id)
   * @param outputFile output file
   * @throws IOException
   */
  public static void saveMappingTextFormat(BidiMap mapping, File outputFile) throws IOException {
    PrintWriter pw = new PrintWriter(new FileOutputStream(outputFile));

    // sort values (feature indexes)
    @SuppressWarnings("unchecked")
    SortedSet<Object> featureIndexes = new TreeSet<Object>(mapping.values());

    for (Object featureIndex : featureIndexes) {
      pw.printf(
          Locale.ENGLISH, "%5d %s%n", (int) featureIndex, mapping.getKey(featureIndex).toString());
    }

    IOUtils.closeQuietly(pw);
  }