Ejemplo n.º 1
0
 private void test(OsmPrimitive p) {
   for (String k : p.keySet()) {
     // Test key against URL validator
     if (!doTest(p, k, URL_KEYS, UrlValidator.getInstance(), INVALID_URL)) {
       // Test key against e-mail validator only if the URL validator did not fail
       doTest(p, k, EMAIL_KEYS, EmailValidator.getInstance(), INVALID_EMAIL);
     }
   }
 }
Ejemplo n.º 2
0
  /**
   * This method determines what text likely represents and sets the proper attribute on the Author.
   *
   * @param author
   * @param text
   */
  private void setAuthorAttribute(Author author, String text) {
    EmailValidator emailValidator = EmailValidator.getInstance(false);

    // Check if it is a valid email.
    if (emailValidator.isValid(text)) {
      // It is, so set it there.
      author.setEmail(text);

      return;
    }

    UrlValidator urlValidator = UrlValidator.getInstance();

    // Now check if it is a URL.
    if (urlValidator.isValid(text)) {
      author.setUrl(text);

      return;
    }

    // If all else fails, then it will just be a name!
    author.setName(text);
  }