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


Java MatchMode.ANYWHERE屬性代碼示例

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


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

public TextMatchMode(String originalText) {
	this.originalText = originalText;
	updatedText = originalText;
	if (originalText.equals("*")){
		matchMode = MatchMode.ANYWHERE;
		updatedText = "";
	}else if (originalText.startsWith("*") && originalText.endsWith("*")) {
		matchMode = MatchMode.ANYWHERE;
		updatedText = originalText.substring(1, originalText.length() - 1);
	} else if (originalText.startsWith("*")) {
		matchMode = MatchMode.END;
		updatedText = originalText.substring(1, originalText.length());
	} else if (originalText.endsWith("*")) {
		matchMode = MatchMode.START;
		updatedText = originalText.substring(0, originalText.length() - 1);
	}
}
 
開發者ID:NCIP,項目名稱:cananolab,代碼行數:17,代碼來源:TextMatchMode.java

示例3: 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

示例4: 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

示例5: 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

示例6: createCriterion

private Criterion createCriterion(CriteriaWrapper crit, BinaryPredicate pred,
        String contextAlias) {
    Operator op = pred.getOperator();
    String symbol = _operatorMap.get(op.getName());
    Expression expr1 = pred.getExpr1();
    Expression expr2 = pred.getExpr2();
    Criterion cr;
    if (expr1 instanceof PropExpression) {
        PropExpression pexpr1 = (PropExpression) expr1;
        String propPath = pexpr1.getPropertyPath();
        String propName;
        if (pexpr1.getProperty().getParentType().isComplexType()) {
            // don't process the property path in this case.
            propName = propPath;
        } else {
            propName = _aliasBuilder.getPropertyName(crit, propPath);
        }

        propName = (contextAlias == null) ? propName : contextAlias + "."
                + propName;

        if (expr2 instanceof LitExpression) {
            Object value = ((LitExpression) expr2).getValue();
            if (value == null) {
                if (op == Operator.Equals) {
                    cr = Restrictions.isNull(propName);
                } else if (op == Operator.NotEquals) {
                    cr = Restrictions.isNotNull(propName);
                } else {
                    throw new RuntimeException("Binary Predicate with a null value and the "
                            + op.getName() + "operator is not supported .");
                }
            } else if (symbol != null) {
                cr = new OperatorExpression(propName, value, symbol);
            } else if (op == Operator.In) {
                cr = Restrictions.in(propName, ((List) value).toArray());
            } else if (op == Operator.StartsWith) {
                cr = Restrictions.like(propName, ((String) value),
                        MatchMode.START);
            } else if (op == Operator.EndsWith) {
                cr = Restrictions.like(propName, (String) value,
                        MatchMode.END);
            } else if (op == Operator.Contains) {
                cr = Restrictions.like(propName, ((String) value),
                        MatchMode.ANYWHERE);
            } else {
                throw new RuntimeException("Binary Predicate with the "
                        + op.getName() + "operator is not yet supported.");
            }
        } else {
            // javax.persistence.criteria.CriteriaBuilder x = new
            // javax.persistence.criteria.CriteriaBuilder();
            String otherPropPath = ((PropExpression) expr2)
                    .getPropertyPath();
            if (symbol != null) {
                cr = new PropertyExpression(propName, otherPropPath, symbol);
            } else if (op == Operator.StartsWith) {
                cr = new LikePropertyExpression(propName, otherPropPath,
                        MatchMode.START);
            } else if (op == Operator.EndsWith) {
                cr = new LikePropertyExpression(propName, otherPropPath,
                        MatchMode.END);
            } else if (op == Operator.Contains) {
                cr = new LikePropertyExpression(propName, otherPropPath,
                        MatchMode.ANYWHERE);
            } else {
                throw new RuntimeException("Property comparison with the "
                        + op.getName() + "operator is not yet supported.");
            }

        }
        return cr;
    } else {
        throw new RuntimeException(
                "Function expressions not yet supported.");
    }

}
 
開發者ID:Breeze,項目名稱:breeze.server.java,代碼行數:78,代碼來源:CriteriaBuilder.java

示例7: UserQueryParameters

/**
 * Create parameters for configuring the user query.
 *
 * @param maxCount
 *            the upper limit of users to retrieve. A value of less than or equal to 0 means no
 *            limit.
 * @param offset
 *            the offset in the result set from where matches should be retrieved
 */
public UserQueryParameters(int maxCount, int offset) {
    matchMode = MatchMode.ANYWHERE;
    rolesToExclude = new HashSet<UserRole>();
    rolesToInclude = new HashSet<UserRole>();
    ResultSpecification resultSpecification = new ResultSpecification(offset, maxCount);
    setResultSpecification(resultSpecification);
}
 
開發者ID:Communote,項目名稱:communote-server,代碼行數:16,代碼來源:UserQueryParameters.java


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