當前位置: 首頁>>代碼示例>>Java>>正文


Java Comparator類代碼示例

本文整理匯總了Java中com.amazonaws.mturk.requester.Comparator的典型用法代碼示例。如果您正苦於以下問題:Java Comparator類的具體用法?Java Comparator怎麽用?Java Comparator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Comparator類屬於com.amazonaws.mturk.requester包,在下文中一共展示了Comparator類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getQualificationComparator

import com.amazonaws.mturk.requester.Comparator; //導入依賴的package包/類
private Comparator getQualificationComparator(int qualNum) {
  String qualComparator = VelocityUtil.doMerge(qualificationComparator[qualNum], inputMap);

  if (qualComparator != null) {
    qualComparator = qualComparator.trim().toLowerCase();

    if ("lessthan".equals(qualComparator))
      return Comparator.LessThan;
    else if ("lessthanorequalto".equals(qualComparator))
      return Comparator.LessThanOrEqualTo;
    else if ("greaterthan".equals(qualComparator))
      return Comparator.GreaterThan;
    else if ("greaterthanorequalto".equals(qualComparator))
      return Comparator.GreaterThanOrEqualTo;
    else if ("equalto".equals(qualComparator))
      return Comparator.EqualTo;
    else if ("notequalto".equals(qualComparator))
      return Comparator.NotEqualTo;
    else if ("exists".equals(qualComparator))
      return Comparator.Exists;
    else {
      log.info("Your configuration file provided an unrecognized comparator: " + qualComparator);
      return null;
    }
  }
  else {
    return null;
  }
}
 
開發者ID:dbarowy,項目名稱:java-aws-mturk,代碼行數:30,代碼來源:HITProperties.java

示例2: createSimpleSurvey

import com.amazonaws.mturk.requester.Comparator; //導入依賴的package包/類
/**
 * Creates the simple survey.
 *
 */
public void createSimpleSurvey() {
  try {

    // This is an example of creating a qualification.
    // This is a built-in qualification -- user must be based in the US
    QualificationRequirement qualReq = new QualificationRequirement();
    qualReq.setQualificationTypeId(RequesterService.LOCALE_QUALIFICATION_TYPE_ID);
    qualReq.setComparator(Comparator.EqualTo);
    Locale country = new Locale();
    country.setCountry("US");
    qualReq.setLocaleValue(country);

    // The create HIT method takes in an array of QualificationRequirements
    // since a HIT can have multiple qualifications.
    QualificationRequirement[] qualReqs = null;
    qualReqs = new QualificationRequirement[] { qualReq };

    // Loading the question (QAP) file. HITQuestion is a helper class that
    // contains the QAP of the HIT defined in the external file. This feature 
    // allows you to write the entire QAP externally as a file and be able to 
    // modify it without recompiling your code.
    HITQuestion question = new HITQuestion(questionFile);
    
    //Creating the HIT and loading it into Mechanical Turk
    HIT hit = service.createHIT(null, // HITTypeId 
        title, 
        description, keywords, 
        question.getQuestion(),
        reward, assignmentDurationInSeconds,
        autoApprovalDelayInSeconds, lifetimeInSeconds,
        numAssignments, requesterAnnotation, 
        qualReqs,
        null // responseGroup
      );
    
    System.out.println("Created HIT: " + hit.getHITId());

    System.out.println("You may see your HIT with HITTypeId '" 
        + hit.getHITTypeId() + "' here: ");
    
    System.out.println(service.getWebsiteURL() 
        + "/mturk/preview?groupId=" + hit.getHITTypeId());
    
    //Demonstrates how a HIT can be retrieved if you know its HIT ID
    HIT hit2 = service.getHIT(hit.getHITId());
    
    System.out.println("Retrieved HIT: " + hit2.getHITId());
    
    if (!hit.getHITId().equals(hit2.getHITId())) {
      System.err.println("The HIT Ids should match: " 
          + hit.getHITId() + ", " + hit2.getHITId());
    }
    
  } catch (Exception e) {
    System.err.println(e.getLocalizedMessage());
  }
}
 
開發者ID:dbarowy,項目名稱:java-aws-mturk,代碼行數:62,代碼來源:SimpleSurvey.java


注:本文中的com.amazonaws.mturk.requester.Comparator類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。