This commit is contained in:
Timo Westkämper 2009-04-24 08:40:57 +00:00
parent ee21f63823
commit dd73e4c2b6
3 changed files with 62 additions and 0 deletions

View File

@ -159,6 +159,7 @@ public abstract class BaseSerializer<SubType extends BaseSerializer<SubType>> ex
}
strings[i] = toString(args.get(i),wrap);
}
// TODO : use faster custom rendering
appendOperationResult(operator, String.format(pattern, strings));
}

View File

@ -0,0 +1,60 @@
package com.mysema.query.serialization;
import java.util.ArrayList;
import java.util.List;
import com.mysema.util.Assert;
/**
* PatternElement provides
*
* @author tiwe
* @version $Id$
*/
public class OperationPattern {
// private static final Pattern patter
private final String pattern;
private final List<Element> elements = new ArrayList<Element>();
public OperationPattern(String pattern){
this.pattern = Assert.notNull(pattern);
}
public int hashCode(){
return pattern.hashCode();
}
public boolean equals(Object o){
if (o == this){
return true;
}else if (o instanceof OperationPattern){
return ((OperationPattern)o).pattern.equals(pattern);
}else{
return false;
}
}
public class Element{
private final int index;
private final String text;
public Element(int index, String text){
this.index = index;
this.text = text;
}
public int getIndex() {
return index;
}
public String getText() {
return text;
}
}
}

View File

@ -20,6 +20,7 @@ import com.mysema.query.grammar.types.PathMetadata.PathType;
* @author tiwe
* @version $Id$
*/
// TODO : replace String.format based expressions with custom expressions
public abstract class OperationPatterns{
private final Map<Op<?>,String> patterns = new HashMap<Op<?>,String>();