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


Java MatchMode.EXACT屬性代碼示例

本文整理匯總了Java中org.hibernate.criterion.MatchMode.EXACT屬性的典型用法代碼示例。如果您正苦於以下問題:Java MatchMode.EXACT屬性的具體用法?Java MatchMode.EXACT怎麽用?Java MatchMode.EXACT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.hibernate.criterion.MatchMode的用法示例。


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

示例1: runTaxonomyQuery

private List<Taxonomy> runTaxonomyQuery(String query)
{
    MatchMode[] modes = {MatchMode.EXACT, MatchMode.START, MatchMode.ANYWHERE};
    LinkedHashSet<Taxonomy> results = new LinkedHashSet<Taxonomy>();
    
    for ( MatchMode mode : modes ) {        
    	log.info("Running match mode: "+mode);
        List<Taxonomy> taxes = runTaxonomyQuery(query,mode);
        results.addAll(taxes);
        if(results.size() >= 10){
        	log.info("Exiting because of results.size() being >= 10");
        }else if(results.size() > 0 && mode == MatchMode.EXACT){
        	log.info("Exiting because of exact match");
        }
        
        if ( (results.size() >= 10) || (results.size() > 0 && mode == MatchMode.EXACT) ) {
        	log.info("Results size:"+results.size());
            return new ArrayList<Taxonomy>(results);
        }
    }
    
    return new ArrayList<Taxonomy>(results);
}
 
開發者ID:glycoinfo,項目名稱:eurocarbdb,代碼行數:23,代碼來源:Autocompleter.java

示例2: formatExpr

private String formatExpr(String p1, String p2, MatchMode mode) {
	String pct = "'%'";
	String expr = p1 + " like ";
	if (mode == MatchMode.ANYWHERE) {
		return expr + "concat(" + pct + "," + p2 + "," + pct + ")";  
	} else if (mode == MatchMode.START) {
		return expr + "concat(" + p2 + "," + pct + ")";
	} else if (mode == MatchMode.END) {
		return expr + "concat(" + pct + "," + p2 + ")";
	} else if (mode == MatchMode.EXACT) {
		return expr + p2;
	} else { 
		throw new RuntimeException("Unrecognized MatchMode: " + mode);
	}
}
 
開發者ID:Breeze,項目名稱:breeze.server.java,代碼行數:15,代碼來源:LikePropertyExpression.java

示例3: toHibernateMatchMode

/**
 * Convert match type to Hibernate match mode
 * 
 * @param matchType
 *            match type
 * @return corresponding Hibernate match mode
 */
private static MatchMode toHibernateMatchMode(final MatchType matchType)
{
	switch (matchType)
	{
		case EXACT:
		{
			return MatchMode.EXACT;
		}

		case STARTS_WITH:
		{
			return MatchMode.START;
		}

		case ENDS_WITH:
		{
			return MatchMode.END;
		}

		case CONTAINS:
		{
			return MatchMode.ANYWHERE;
		}
	}

	return null;
}
 
開發者ID:openfurther,項目名稱:further-open-core,代碼行數:34,代碼來源:CriterionBuilderHibernateImpl.java

示例4: testMatches

/**
 * The test.
 */
@Test
public void testMatches() {
    String prefix = UUID.randomUUID().toString();
    String mainContent = UUID.randomUUID().toString();
    String suffix = UUID.randomUUID().toString();

    NoteData noteListData = new NoteData();
    noteListData.setContent(prefix + mainContent + suffix);
    noteListData.setId(1L);

    NoteService noteService = EasyMock.createMock(NoteService.class);
    EasyMock.expect(noteService.getNote(EasyMock.anyLong(),
            EasyMock.anyObject(Converter.class)))
            .andReturn(noteListData.getContent()).anyTimes();
    EasyMock.replay(noteService);

    Matcher<NoteData> matcher = new FullTextSearchFiltersMatcher(noteService,
            MatchMode.ANYWHERE);
    Assert.assertTrue(matcher.matches(noteListData));

    // Anywhere
    matcher = new FullTextSearchFiltersMatcher(noteService, MatchMode.ANYWHERE, prefix,
            mainContent, suffix);
    Assert.assertTrue(matcher.matches(noteListData));
    matcher = new FullTextSearchFiltersMatcher(noteService, MatchMode.ANYWHERE, UUID
            .randomUUID().toString());
    Assert.assertFalse(matcher.matches(noteListData));
    // Start
    matcher = new FullTextSearchFiltersMatcher(noteService, MatchMode.START, prefix);
    Assert.assertTrue(matcher.matches(noteListData));
    matcher = new FullTextSearchFiltersMatcher(noteService, MatchMode.START, mainContent);
    Assert.assertFalse(matcher.matches(noteListData));
    // End
    matcher = new FullTextSearchFiltersMatcher(noteService, MatchMode.END, suffix);
    Assert.assertTrue(matcher.matches(noteListData));
    matcher = new FullTextSearchFiltersMatcher(noteService, MatchMode.END, mainContent);
    Assert.assertFalse(matcher.matches(noteListData));
    // Exact
    matcher = new FullTextSearchFiltersMatcher(noteService, MatchMode.EXACT, prefix
            + mainContent + suffix);
    Assert.assertTrue(matcher.matches(noteListData));
    matcher = new FullTextSearchFiltersMatcher(noteService, MatchMode.EXACT, mainContent);
    Assert.assertFalse(matcher.matches(noteListData));
}
 
開發者ID:Communote,項目名稱:communote-server,代碼行數:47,代碼來源:FullTextSearchFiltersMatcherTest.java

示例5: createLikeRestriction

/**
 * Creates a like restriction.
 *
 * @param propertyDescriptor
 *     the property descriptor.
 * @param prefixedProperty
 *     the complete property path.
 * @param propertyValue
 *     the value to create the like restriction for
 * @param componentDescriptor
 *     the component descriptor
 * @param queryComponent
 *     the query component
 * @param context
 *     the context
 * @return the created criterion or null if no criterion necessary.
 */
protected Criterion createLikeRestriction(IPropertyDescriptor propertyDescriptor, String prefixedProperty,
                                          String propertyValue, IComponentDescriptor<?> componentDescriptor,
                                          IQueryComponent queryComponent, Map<String, Object> context) {
  MatchMode matchMode;
  if (propertyValue.contains("%")) {
    matchMode = MatchMode.EXACT;
  } else {
    matchMode = MatchMode.START;
  }
  if (propertyDescriptor instanceof IStringPropertyDescriptor && ((IStringPropertyDescriptor) propertyDescriptor)
      .isUpperCase()) {
    // don't use ignoreCase() to be able to leverage indices.
    return Restrictions.like(prefixedProperty, propertyValue.toUpperCase(), matchMode);
  }
  return Restrictions.like(prefixedProperty, propertyValue, matchMode).ignoreCase();
}
 
開發者ID:jspresso,項目名稱:jspresso-ce,代碼行數:33,代碼來源:DefaultCriteriaFactory.java


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