Package com.mysema.query.types.path

Examples of com.mysema.query.types.path.StringPath


    public void RegexToLike() {
        assertEquals("%", like(ConstantImpl.create(".*")));
        assertEquals("_",  like(ConstantImpl.create(".")));
        assertEquals(".", like(ConstantImpl.create("\\.")));
       
        StringPath path = new StringPath("path");
        assertEquals("path + %", like(path.append(".*")));
        assertEquals("% + path", like(path.prepend(".*")));
        assertEquals("path + _", like(path.append(".")));
        assertEquals("_ + path", like(path.prepend(".")));
    }
View Full Code Here


   
    @Test
    @Ignore
    public void RegexToLikeSpeed() {
        // 3255
        StringPath path = new StringPath("path");       
        final int iterations = 1000000;
        long start = System.currentTimeMillis();
        for (int i = 0; i < iterations; i++) {
            like(ConstantImpl.create(".*"));
            like(ConstantImpl.create("."));               
            like(path.append(".*"));
            like(path.prepend(".*"));
            like(path.append("."));
            like(path.prepend("."));   
        }
        long duration = System.currentTimeMillis() - start;
        System.err.println(duration);
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    @Test
    public void NewInstanceObjectArray() {
        ArrayConstructorExpression<String> constructor = new ArrayConstructorExpression<String>(
                String[].class,  new StringPath("test"), new StringPath("test2"));

        String[] strings = constructor.newInstance((Object[])new String[]{"1", "2"});
        assertEquals("1", strings[0]);
        assertEquals("2", strings[1]);
View Full Code Here

    enum ExampleEnum {A,B}

    @SuppressWarnings("unchecked")
    @Test
    public void Various() {
        Expression[] args = new Expression[]{new StringPath("x"), new StringPath("y")};
        List<Operation<?>> operations = new ArrayList<Operation<?>>();
//        paths.add(new ArrayOperation(String[].class, "p"));
        operations.add(new BooleanOperation(Ops.EQ, args));
        operations.add(new ComparableOperation(String.class, Ops.SUBSTR_1ARG, args));
        operations.add(new DateOperation(Date.class, Ops.DateTimeOps.CURRENT_DATE, args));
View Full Code Here

        }
    }

    @Test
    public void Various() {
        StringPath str = user.lastName;
        List<Predicate> predicates = new ArrayList<Predicate>();
        predicates.add(str.between("a", "b"));
        predicates.add(str.contains("a"));
        predicates.add(str.containsIgnoreCase("a"));
        predicates.add(str.endsWith("a"));
        predicates.add(str.endsWithIgnoreCase("a"));
        predicates.add(str.eq("a"));
        predicates.add(str.equalsIgnoreCase("a"));
        predicates.add(str.goe("a"));
        predicates.add(str.gt("a"));
        predicates.add(str.in("a","b","c"));
        predicates.add(str.isEmpty());
        predicates.add(str.isNotNull());
        predicates.add(str.isNull());
//        predicates.add(str.like("a"));
        predicates.add(str.loe("a"));
        predicates.add(str.lt("a"));
        predicates.add(str.matches("a"));
        predicates.add(str.ne("a"));
        predicates.add(str.notBetween("a", "b"));
        predicates.add(str.notIn("a","b","c"));
        predicates.add(str.startsWith("a"));
        predicates.add(str.startsWithIgnoreCase("a"));

        for (Predicate predicate : predicates) {
            where(predicate).count();
            where(predicate.not()).count();
        }
View Full Code Here

public class TermElementTest {

    @Test
    public void test() {
        StringPath title = new StringPath("title");
        LuceneSerializer serializer = new LuceneSerializer(false,true);
        QueryMetadata metadata = new DefaultQueryMetadata();
        assertEquals("title:\"Hello World\"", serializer.toQuery(title.eq("Hello World"), metadata).toString());
        assertEquals("title:Hello World", serializer.toQuery(title.eq(new TermElement("Hello World")), metadata).toString());
    }
View Full Code Here

public class PhraseElementTest {

    @Test
    public void test() {
        StringPath title = new StringPath("title");
        LuceneSerializer serializer = new LuceneSerializer(false,false);
        QueryMetadata metadata = new DefaultQueryMetadata();
        assertEquals("title:Hello World", serializer.toQuery(title.eq("Hello World"), metadata).toString());
        assertEquals("title:\"Hello World\"", serializer.toQuery(title.eq(new PhraseElement("Hello World")), metadata).toString());
    }
View Full Code Here

        assertEquals(true, bean.married);
    }

    @Test
    public void with_Class_and_Alias_using_fields() {
        StringPath name2 = new StringPath("name2");
        QBean<Entity> beanProjection = new QBean<Entity>(Entity.class, true, name.as(name2), age, married);
        Entity bean = beanProjection.newInstance("Fritz", 30, true);
        assertNull(bean.name);
        assertEquals("Fritz", bean.name2);
        assertEquals(30, bean.age);
View Full Code Here

    @Test
    public void Constructors() {
        Templates templates = new JavaTemplates();
        Template template = TemplateFactory.DEFAULT.create("{0}");
        ImmutableList<Expression<?>> args = ImmutableList.<Expression<?>>of(new StringPath("a"));
        List<TemplateExpression<?>> customs = Arrays.<TemplateExpression<?>>asList(
            new BooleanTemplate(template, args),
            new ComparableTemplate<String>(String.class, template, args),
            new DateTemplate<java.sql.Date>(java.sql.Date.class, template, args),
            new DateTimeTemplate<Date>(Date.class, template, args),
View Full Code Here

public class ExpressionSerializationTest {

    @Test
    public void Serialize() throws ClassNotFoundException, IOException {
        QTuple e = new QTuple(new StringPath("x"), new NumberPath(Integer.class, "y"));
        serialize(e);
        serialize(e.newInstance("a",1));
    }
View Full Code Here

TOP

Related Classes of com.mysema.query.types.path.StringPath

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.