mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-18 14:58:47 +00:00
initial add of EbeanORM server based on v2.8.1
This commit is contained in:
1 parent
2b74d0f9d9
commit
96ce4c0ddf
1188 files changed
+135034
No files matched your search
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* Copyright (C) 2006 Robin Bygrave
|
||||
*
|
||||
* This file is part of Ebean.
|
||||
*
|
||||
* Ebean is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Ebean is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Ebean; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package com.avaje.ebeaninternal.server.el;
|
||||
|
||||
/**
|
||||
* Case insensitive string matching.
|
||||
* <p>
|
||||
* Provides an alternative to using regular expressions.
|
||||
* </p>
|
||||
*/
|
||||
public final class CharMatch {
|
||||
|
||||
private final char[] upperChars;
|
||||
|
||||
private final int maxLength;
|
||||
|
||||
public CharMatch(String s) {
|
||||
this.upperChars = s.toUpperCase().toCharArray();
|
||||
this.maxLength = upperChars.length;
|
||||
}
|
||||
|
||||
public boolean startsWith(String other) {
|
||||
|
||||
if (other == null || other.length() < maxLength){
|
||||
return false;
|
||||
}
|
||||
|
||||
char ta[] = other.toCharArray();
|
||||
|
||||
int pos = -1;
|
||||
while (++pos < maxLength) {
|
||||
char c1 = upperChars[pos];
|
||||
char c2 = Character.toUpperCase(ta[pos]);
|
||||
if (c1 != c2) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean endsWith(String other) {
|
||||
|
||||
if (other == null || other.length() < maxLength){
|
||||
return false;
|
||||
}
|
||||
|
||||
char ta[] = other.toCharArray();
|
||||
|
||||
int offset = ta.length - maxLength;
|
||||
int pos = maxLength;
|
||||
while (--pos >= 0) {
|
||||
char c1 = upperChars[pos];
|
||||
char c2 = Character.toUpperCase(ta[offset+pos]);
|
||||
if (c1 != c2) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Copyright (C) 2006 Robin Bygrave
|
||||
*
|
||||
* This file is part of Ebean.
|
||||
*
|
||||
* Ebean is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Ebean is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Ebean; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package com.avaje.ebeaninternal.server.el;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* Comparator for use with the expression objects.
|
||||
*/
|
||||
public interface ElComparator<T> extends Comparator<T> {
|
||||
|
||||
/**
|
||||
* Compare given 2 beans.
|
||||
*/
|
||||
public int compare(T o1, T o2);
|
||||
|
||||
/**
|
||||
* Compare with a fixed value to a given bean.
|
||||
*/
|
||||
public int compareValue(Object value, T o2);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* Copyright (C) 2006 Robin Bygrave
|
||||
*
|
||||
* This file is part of Ebean.
|
||||
*
|
||||
* Ebean is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Ebean is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Ebean; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package com.avaje.ebeaninternal.server.el;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* Comparator based on multiple ordered comparators.
|
||||
* <p>
|
||||
* eg. "name, orderDate desc, id"
|
||||
* </p>
|
||||
*/
|
||||
public final class ElComparatorCompound<T> implements Comparator<T>, ElComparator<T> {
|
||||
|
||||
private final ElComparator<T>[] array;
|
||||
|
||||
public ElComparatorCompound(ElComparator<T>[] array) {
|
||||
this.array = array;
|
||||
}
|
||||
|
||||
public int compare(T o1, T o2) {
|
||||
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
int ret = array[i].compare(o1, o2);
|
||||
if (ret != 0){
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int compareValue(Object value, T o2) {
|
||||
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
int ret = array[i].compareValue(value, o2);
|
||||
if (ret != 0){
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* Copyright (C) 2006 Robin Bygrave
|
||||
*
|
||||
* This file is part of Ebean.
|
||||
*
|
||||
* Ebean is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Ebean is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Ebean; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package com.avaje.ebeaninternal.server.el;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* Comparator based on a ElGetValue.
|
||||
*/
|
||||
public final class ElComparatorProperty<T> implements Comparator<T>, ElComparator<T> {
|
||||
|
||||
private final ElPropertyValue elGetValue;
|
||||
|
||||
private final int nullOrder;
|
||||
|
||||
private final int asc;
|
||||
|
||||
public ElComparatorProperty(ElPropertyValue elGetValue, boolean ascending, boolean nullsHigh) {
|
||||
this.elGetValue = elGetValue;
|
||||
this.asc = ascending ? 1 : -1;
|
||||
this.nullOrder = asc * (nullsHigh ? 1 : -1);
|
||||
}
|
||||
|
||||
public int compare(T o1, T o2) {
|
||||
|
||||
Object val1 = elGetValue.elGetValue(o1);
|
||||
Object val2 = elGetValue.elGetValue(o2);
|
||||
|
||||
return compareValues(val1, val2);
|
||||
}
|
||||
|
||||
public int compareValue(Object value, T o2) {
|
||||
|
||||
Object val2 = elGetValue.elGetValue(o2);
|
||||
|
||||
return compareValues(value, val2);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public int compareValues(Object val1, Object val2){
|
||||
|
||||
if (val1 == null){
|
||||
return val2 == null ? 0 : nullOrder;
|
||||
}
|
||||
if (val2 == null){
|
||||
return -1 * nullOrder;
|
||||
}
|
||||
Comparable c = (Comparable)val1;
|
||||
return asc * c.compareTo(val2);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,271 @@
|
||||
/**
|
||||
* Copyright (C) 2006 Robin Bygrave
|
||||
*
|
||||
* This file is part of Ebean.
|
||||
*
|
||||
* Ebean is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Ebean is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Ebean; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package com.avaje.ebeaninternal.server.el;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.avaje.ebean.Filter;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
|
||||
/**
|
||||
* Default implementation of the Filter interface.
|
||||
*/
|
||||
public final class ElFilter<T> implements Filter<T> {
|
||||
|
||||
private final BeanDescriptor<T> beanDescriptor;
|
||||
|
||||
private ArrayList<ElMatcher<T>> matches = new ArrayList<ElMatcher<T>>();
|
||||
|
||||
private int maxRows;
|
||||
|
||||
private String sortByClause;
|
||||
|
||||
public ElFilter(BeanDescriptor<T> beanDescriptor) {
|
||||
this.beanDescriptor = beanDescriptor;
|
||||
}
|
||||
|
||||
private Object convertValue(String propertyName, Object value) {
|
||||
// convert type of value to match expected type
|
||||
ElPropertyValue elGetValue = beanDescriptor.getElGetValue(propertyName);
|
||||
return elGetValue.elConvertType(value);
|
||||
}
|
||||
|
||||
private ElComparator<T> getElComparator(String propertyName) {
|
||||
|
||||
return beanDescriptor.getElComparator(propertyName);
|
||||
}
|
||||
|
||||
private ElPropertyValue getElGetValue(String propertyName) {
|
||||
|
||||
return beanDescriptor.getElGetValue(propertyName);
|
||||
}
|
||||
|
||||
public Filter<T> sort(String sortByClause) {
|
||||
this.sortByClause = sortByClause;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected boolean isMatch(T bean) {
|
||||
for (int i = 0; i < matches.size(); i++) {
|
||||
ElMatcher<T> matcher = matches.get(i);
|
||||
if (!matcher.isMatch(bean)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public Filter<T> in(String propertyName, Set<?> matchingValues) {
|
||||
|
||||
ElPropertyValue elGetValue = getElGetValue(propertyName);
|
||||
|
||||
matches.add(new ElMatchBuilder.InSet<T>(matchingValues, elGetValue));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Filter<T> eq(String propertyName, Object value) {
|
||||
|
||||
value = convertValue(propertyName, value);
|
||||
ElComparator<T> comparator = getElComparator(propertyName);
|
||||
|
||||
matches.add(new ElMatchBuilder.Eq<T>(value, comparator));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Filter<T> ne(String propertyName, Object value) {
|
||||
|
||||
value = convertValue(propertyName, value);
|
||||
ElComparator<T> comparator = getElComparator(propertyName);
|
||||
|
||||
matches.add(new ElMatchBuilder.Ne<T>(value, comparator));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Filter<T> between(String propertyName, Object min, Object max) {
|
||||
|
||||
ElPropertyValue elGetValue = getElGetValue(propertyName);
|
||||
min = elGetValue.elConvertType(min);
|
||||
max = elGetValue.elConvertType(max);
|
||||
|
||||
ElComparator<T> elComparator = getElComparator(propertyName);
|
||||
|
||||
matches.add(new ElMatchBuilder.Between<T>(min, max, elComparator));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Filter<T> gt(String propertyName, Object value) {
|
||||
|
||||
value = convertValue(propertyName, value);
|
||||
ElComparator<T> comparator = getElComparator(propertyName);
|
||||
|
||||
matches.add(new ElMatchBuilder.Gt<T>(value, comparator));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Filter<T> ge(String propertyName, Object value) {
|
||||
|
||||
value = convertValue(propertyName, value);
|
||||
ElComparator<T> comparator = getElComparator(propertyName);
|
||||
|
||||
matches.add(new ElMatchBuilder.Ge<T>(value, comparator));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Filter<T> ieq(String propertyName, String value) {
|
||||
|
||||
ElPropertyValue elGetValue = getElGetValue(propertyName);
|
||||
|
||||
matches.add(new ElMatchBuilder.Ieq<T>(elGetValue, value));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Filter<T> isNotNull(String propertyName) {
|
||||
|
||||
ElPropertyValue elGetValue = getElGetValue(propertyName);
|
||||
|
||||
matches.add(new ElMatchBuilder.IsNotNull<T>(elGetValue));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Filter<T> isNull(String propertyName) {
|
||||
|
||||
ElPropertyValue elGetValue = getElGetValue(propertyName);
|
||||
|
||||
matches.add(new ElMatchBuilder.IsNull<T>(elGetValue));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Filter<T> le(String propertyName, Object value) {
|
||||
|
||||
value = convertValue(propertyName, value);
|
||||
ElComparator<T> comparator = getElComparator(propertyName);
|
||||
|
||||
matches.add(new ElMatchBuilder.Le<T>(value, comparator));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Filter<T> lt(String propertyName, Object value) {
|
||||
|
||||
value = convertValue(propertyName, value);
|
||||
ElComparator<T> comparator = getElComparator(propertyName);
|
||||
|
||||
matches.add(new ElMatchBuilder.Lt<T>(value, comparator));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Filter<T> regex(String propertyName, String regEx) {
|
||||
return regex(propertyName, regEx, 0);
|
||||
}
|
||||
|
||||
public Filter<T> regex(String propertyName, String regEx, int options) {
|
||||
|
||||
ElPropertyValue elGetValue = getElGetValue(propertyName);
|
||||
|
||||
matches.add(new ElMatchBuilder.RegularExpr<T>(elGetValue, regEx, options));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Filter<T> contains(String propertyName, String value) {
|
||||
|
||||
String quote = ".*"+Pattern.quote(value)+".*";
|
||||
|
||||
ElPropertyValue elGetValue = getElGetValue(propertyName);
|
||||
matches.add(new ElMatchBuilder.RegularExpr<T>(elGetValue, quote, 0));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Filter<T> icontains(String propertyName, String value) {
|
||||
|
||||
String quote = ".*"+Pattern.quote(value)+".*";
|
||||
|
||||
ElPropertyValue elGetValue = getElGetValue(propertyName);
|
||||
matches.add(new ElMatchBuilder.RegularExpr<T>(elGetValue, quote, Pattern.CASE_INSENSITIVE));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Filter<T> endsWith(String propertyName, String value) {
|
||||
|
||||
ElPropertyValue elGetValue = getElGetValue(propertyName);
|
||||
matches.add(new ElMatchBuilder.EndsWith<T>(elGetValue, value));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Filter<T> startsWith(String propertyName, String value) {
|
||||
|
||||
ElPropertyValue elGetValue = getElGetValue(propertyName);
|
||||
matches.add(new ElMatchBuilder.StartsWith<T>(elGetValue, value));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Filter<T> iendsWith(String propertyName, String value) {
|
||||
|
||||
ElPropertyValue elGetValue = getElGetValue(propertyName);
|
||||
matches.add(new ElMatchBuilder.IEndsWith<T>(elGetValue, value));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Filter<T> istartsWith(String propertyName, String value) {
|
||||
|
||||
ElPropertyValue elGetValue = getElGetValue(propertyName);
|
||||
matches.add(new ElMatchBuilder.IStartsWith<T>(elGetValue, value));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Filter<T> maxRows(int maxRows) {
|
||||
this.maxRows = maxRows;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<T> filter(List<T> list) {
|
||||
|
||||
if (sortByClause != null){
|
||||
// create shallow copy and sort
|
||||
list = new ArrayList<T>(list);
|
||||
beanDescriptor.sort(list, sortByClause);
|
||||
}
|
||||
|
||||
ArrayList<T> filterList = new ArrayList<T>();
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
T t = list.get(i);
|
||||
if (isMatch(t)) {
|
||||
filterList.add(t);
|
||||
if (maxRows > 0 && filterList.size() >= maxRows){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return filterList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,305 @@
|
||||
/**
|
||||
* Copyright (C) 2006 Robin Bygrave
|
||||
*
|
||||
* This file is part of Ebean.
|
||||
*
|
||||
* Ebean is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Ebean is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Ebean; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package com.avaje.ebeaninternal.server.el;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
/**
|
||||
* Contains the various ElMatcher implementations.
|
||||
*/
|
||||
class ElMatchBuilder {
|
||||
|
||||
/**
|
||||
* Case insensitive equals.
|
||||
*/
|
||||
static class RegularExpr<T> implements ElMatcher<T> {
|
||||
|
||||
final ElPropertyValue elGetValue;
|
||||
final String value;
|
||||
final Pattern pattern;
|
||||
|
||||
RegularExpr(ElPropertyValue elGetValue, String value, int options){
|
||||
this.elGetValue = elGetValue;
|
||||
this.value = value;
|
||||
this.pattern = Pattern.compile(value, options);
|
||||
}
|
||||
|
||||
public boolean isMatch(T bean) {
|
||||
String v = (String)elGetValue.elGetValue(bean);
|
||||
return pattern.matcher(v).matches();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Case insensitive equals.
|
||||
*/
|
||||
static abstract class BaseString<T> implements ElMatcher<T> {
|
||||
|
||||
final ElPropertyValue elGetValue;
|
||||
final String value;
|
||||
|
||||
public BaseString(ElPropertyValue elGetValue, String value){
|
||||
this.elGetValue = elGetValue;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public abstract boolean isMatch(T bean);
|
||||
}
|
||||
|
||||
static class Ieq<T> extends BaseString<T> {
|
||||
Ieq(ElPropertyValue elGetValue, String value) {
|
||||
super(elGetValue, value);
|
||||
}
|
||||
|
||||
public boolean isMatch(T bean) {
|
||||
String v = (String)elGetValue.elGetValue(bean);
|
||||
return value.equalsIgnoreCase(v);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Case insensitive starts with matcher.
|
||||
*/
|
||||
static class IStartsWith<T> implements ElMatcher<T> {
|
||||
|
||||
final ElPropertyValue elGetValue;
|
||||
final CharMatch charMatch;
|
||||
|
||||
IStartsWith(ElPropertyValue elGetValue, String value) {
|
||||
this.elGetValue = elGetValue;
|
||||
this.charMatch = new CharMatch(value);
|
||||
}
|
||||
|
||||
public boolean isMatch(T bean) {
|
||||
|
||||
String v = (String)elGetValue.elGetValue(bean);
|
||||
return charMatch.startsWith(v);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Case insensitive ends with matcher.
|
||||
*/
|
||||
static class IEndsWith<T> implements ElMatcher<T> {
|
||||
|
||||
final ElPropertyValue elGetValue;
|
||||
final CharMatch charMatch;
|
||||
|
||||
IEndsWith(ElPropertyValue elGetValue, String value) {
|
||||
this.elGetValue = elGetValue;
|
||||
this.charMatch = new CharMatch(value);
|
||||
}
|
||||
|
||||
public boolean isMatch(T bean) {
|
||||
|
||||
String v = (String)elGetValue.elGetValue(bean);
|
||||
return charMatch.endsWith(v);
|
||||
}
|
||||
}
|
||||
|
||||
static class StartsWith<T> extends BaseString<T> {
|
||||
StartsWith(ElPropertyValue elGetValue, String value) {
|
||||
super(elGetValue, value);
|
||||
}
|
||||
|
||||
public boolean isMatch(T bean) {
|
||||
String v = (String)elGetValue.elGetValue(bean);
|
||||
return value.startsWith(v);
|
||||
}
|
||||
}
|
||||
|
||||
static class EndsWith<T> extends BaseString<T> {
|
||||
EndsWith(ElPropertyValue elGetValue, String value) {
|
||||
super(elGetValue, value);
|
||||
}
|
||||
|
||||
public boolean isMatch(T bean) {
|
||||
String v = (String)elGetValue.elGetValue(bean);
|
||||
return value.endsWith(v);
|
||||
}
|
||||
}
|
||||
|
||||
static class IsNull<T> implements ElMatcher<T> {
|
||||
|
||||
final ElPropertyValue elGetValue;
|
||||
|
||||
public IsNull(ElPropertyValue elGetValue){
|
||||
this.elGetValue = elGetValue;
|
||||
}
|
||||
|
||||
public boolean isMatch(T bean) {
|
||||
return (null == elGetValue.elGetValue(bean));
|
||||
}
|
||||
}
|
||||
|
||||
static class IsNotNull<T> implements ElMatcher<T> {
|
||||
|
||||
final ElPropertyValue elGetValue;
|
||||
|
||||
public IsNotNull(ElPropertyValue elGetValue){
|
||||
this.elGetValue = elGetValue;
|
||||
}
|
||||
|
||||
public boolean isMatch(T bean) {
|
||||
return (null != elGetValue.elGetValue(bean));
|
||||
}
|
||||
}
|
||||
|
||||
static abstract class Base<T> implements ElMatcher<T> {
|
||||
|
||||
final Object filterValue;
|
||||
|
||||
final ElComparator<T> comparator;
|
||||
|
||||
public Base(Object filterValue, ElComparator<T> comparator){
|
||||
this.filterValue = filterValue;
|
||||
this.comparator = comparator;
|
||||
}
|
||||
|
||||
public abstract boolean isMatch(T value);
|
||||
}
|
||||
|
||||
static class InSet<T> implements ElMatcher<T> {
|
||||
|
||||
final Set<?> set;
|
||||
final ElPropertyValue elGetValue;
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public InSet(Set<?> set, ElPropertyValue elGetValue){
|
||||
this.set = new HashSet(set);
|
||||
this.elGetValue = elGetValue;
|
||||
}
|
||||
|
||||
public boolean isMatch(T bean) {
|
||||
|
||||
Object value = elGetValue.elGetValue(bean);
|
||||
if (value == null){
|
||||
return false;
|
||||
}
|
||||
|
||||
return set.contains(value);
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Equal To.
|
||||
*/
|
||||
static class Eq<T> extends Base<T> {
|
||||
|
||||
public Eq(Object filterValue, ElComparator<T> comparator){
|
||||
super(filterValue, comparator);
|
||||
}
|
||||
|
||||
public boolean isMatch(T value) {
|
||||
return comparator.compareValue(filterValue, value) == 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Not Equal To.
|
||||
*/
|
||||
static class Ne<T> extends Base<T> {
|
||||
|
||||
public Ne(Object filterValue, ElComparator<T> comparator){
|
||||
super(filterValue, comparator);
|
||||
}
|
||||
|
||||
public boolean isMatch(T value) {
|
||||
return comparator.compareValue(filterValue, value) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Between.
|
||||
*/
|
||||
static class Between<T> implements ElMatcher<T> {
|
||||
|
||||
final Object min;
|
||||
final Object max;
|
||||
final ElComparator<T> comparator;
|
||||
|
||||
Between(Object min, Object max, ElComparator<T> comparator){
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.comparator = comparator;
|
||||
}
|
||||
|
||||
public boolean isMatch(T value) {
|
||||
|
||||
return (comparator.compareValue(min, value) <= 0
|
||||
&& comparator.compareValue(max, value) >= 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Greater Than.
|
||||
*/
|
||||
static class Gt<T> extends Base<T> {
|
||||
Gt(Object filterValue, ElComparator<T> comparator){
|
||||
super(filterValue, comparator);
|
||||
}
|
||||
|
||||
public boolean isMatch(T value) {
|
||||
return comparator.compareValue(filterValue, value) == -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Greater Than or Equal To.
|
||||
*/
|
||||
static class Ge<T> extends Base<T> {
|
||||
Ge(Object filterValue, ElComparator<T> comparator){
|
||||
super(filterValue, comparator);
|
||||
}
|
||||
|
||||
public boolean isMatch(T value) {
|
||||
return comparator.compareValue(filterValue, value) >= 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Less Than or Equal To.
|
||||
*/
|
||||
static class Le<T> extends Base<T> {
|
||||
Le(Object filterValue, ElComparator<T> comparator){
|
||||
super(filterValue, comparator);
|
||||
}
|
||||
|
||||
public boolean isMatch(T value) {
|
||||
return comparator.compareValue(filterValue, value) <= 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Less Than.
|
||||
*/
|
||||
static class Lt<T> extends Base<T> {
|
||||
Lt(Object filterValue, ElComparator<T> comparator){
|
||||
super(filterValue, comparator);
|
||||
}
|
||||
|
||||
public boolean isMatch(T value) {
|
||||
return comparator.compareValue(filterValue, value) == 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Copyright (C) 2006 Robin Bygrave
|
||||
*
|
||||
* This file is part of Ebean.
|
||||
*
|
||||
* Ebean is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Ebean is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Ebean; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package com.avaje.ebeaninternal.server.el;
|
||||
|
||||
/**
|
||||
* Interface for defining matches for filter expressions.
|
||||
*/
|
||||
public interface ElMatcher<T> {
|
||||
|
||||
/**
|
||||
* Return true if the bean matches the expression.
|
||||
*/
|
||||
public boolean isMatch(T bean);
|
||||
}
|
||||
@@ -0,0 +1,331 @@
|
||||
/**
|
||||
* Copyright (C) 2006 Robin Bygrave
|
||||
*
|
||||
* This file is part of Ebean.
|
||||
*
|
||||
* Ebean is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Ebean is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Ebean; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package com.avaje.ebeaninternal.server.el;
|
||||
|
||||
import com.avaje.ebean.bean.EntityBean;
|
||||
import com.avaje.ebean.text.StringFormatter;
|
||||
import com.avaje.ebean.text.StringParser;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanProperty;
|
||||
import com.avaje.ebeaninternal.server.lib.util.StringHelper;
|
||||
import com.avaje.ebeaninternal.server.query.SplitName;
|
||||
import com.avaje.ebeaninternal.server.type.ScalarType;
|
||||
|
||||
|
||||
/**
|
||||
* A ElGetValue based on a chain of properties.
|
||||
* <p>
|
||||
* Used to get the value for an compound expression like customer.name or
|
||||
* customer.shippingAddress.city etc.
|
||||
* </p>
|
||||
* <p>
|
||||
* Note that if any element in the chain returns null, then null is returned and
|
||||
* no further processing of the chain occurs.
|
||||
* </p>
|
||||
*/
|
||||
public class ElPropertyChain implements ElPropertyValue {
|
||||
|
||||
private final String prefix;
|
||||
|
||||
private final String placeHolder;
|
||||
private final String placeHolderEncrypted;
|
||||
|
||||
private final String name;
|
||||
|
||||
private final String expression;
|
||||
|
||||
private final boolean containsMany;
|
||||
|
||||
private final ElPropertyValue[] chain;
|
||||
|
||||
private final boolean assocId;
|
||||
private final int last;
|
||||
private final BeanProperty lastBeanProperty;
|
||||
private final ScalarType<?> scalarType;
|
||||
|
||||
private final ElPropertyValue lastElPropertyValue;
|
||||
|
||||
public ElPropertyChain(boolean containsMany, boolean embedded, String expression, ElPropertyValue[] chain) {
|
||||
|
||||
this.containsMany = containsMany;
|
||||
this.chain = chain;
|
||||
this.expression = expression;
|
||||
int dotPos = expression.lastIndexOf('.');
|
||||
if (dotPos > -1){
|
||||
this.name = expression.substring(dotPos+1);
|
||||
if (embedded){
|
||||
int embPos = expression.lastIndexOf('.',dotPos-1);
|
||||
this.prefix = embPos == -1 ? null : expression.substring(0, embPos);
|
||||
|
||||
} else {
|
||||
this.prefix = expression.substring(0, dotPos);
|
||||
}
|
||||
} else {
|
||||
this.prefix = null;
|
||||
this.name = expression;
|
||||
}
|
||||
|
||||
this.assocId = chain[chain.length-1].isAssocId();
|
||||
|
||||
this.last = chain.length-1;
|
||||
this.lastBeanProperty = chain[chain.length-1].getBeanProperty();
|
||||
if (lastBeanProperty != null){
|
||||
this.scalarType = lastBeanProperty.getScalarType();
|
||||
} else {
|
||||
// case for nested compound type (non-scalar)
|
||||
this.scalarType = null;
|
||||
}
|
||||
this.lastElPropertyValue = chain[chain.length-1];
|
||||
this.placeHolder = getElPlaceHolder(prefix, lastElPropertyValue, false);
|
||||
this.placeHolderEncrypted = getElPlaceHolder(prefix, lastElPropertyValue, true);
|
||||
}
|
||||
|
||||
private String getElPlaceHolder(String prefix, ElPropertyValue lastElPropertyValue, boolean encrypted) {
|
||||
if (prefix == null){
|
||||
return lastElPropertyValue.getElPlaceholder(encrypted);
|
||||
}
|
||||
|
||||
String el = lastElPropertyValue.getElPlaceholder(encrypted);
|
||||
|
||||
if (!el.contains("${}")){
|
||||
// typically a secondary table property
|
||||
return StringHelper.replaceString(el, "${", "${"+prefix+".");
|
||||
} else {
|
||||
return StringHelper.replaceString(el, ROOT_ELPREFIX, "${"+prefix+"}");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Full ElGetValue support.
|
||||
*/
|
||||
public boolean isDeployOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if there is a many property from sinceProperty to
|
||||
* the end of this chain.
|
||||
*/
|
||||
public boolean containsManySince(String sinceProperty) {
|
||||
if (sinceProperty == null){
|
||||
return containsMany;
|
||||
}
|
||||
if (!expression.startsWith(sinceProperty)){
|
||||
return containsMany;
|
||||
}
|
||||
|
||||
int i = 1 + SplitName.count('.', sinceProperty);
|
||||
|
||||
for (; i < chain.length; i++) {
|
||||
if (chain[i].getBeanProperty().containsMany()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean containsMany() {
|
||||
return containsMany;
|
||||
}
|
||||
|
||||
public String getElPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getElName() {
|
||||
return expression;
|
||||
}
|
||||
|
||||
public String getElPlaceholder(boolean encrypted) {
|
||||
return encrypted ? placeHolderEncrypted : placeHolder;
|
||||
}
|
||||
|
||||
public boolean isDbEncrypted() {
|
||||
return lastElPropertyValue.isDbEncrypted();
|
||||
}
|
||||
|
||||
public boolean isLocalEncrypted() {
|
||||
return lastElPropertyValue.isLocalEncrypted();
|
||||
}
|
||||
|
||||
public Object[] getAssocOneIdValues(Object bean) {
|
||||
// Don't navigate the object graph as bean
|
||||
// is assumed to be the appropriate type
|
||||
return lastElPropertyValue.getAssocOneIdValues(bean);
|
||||
}
|
||||
|
||||
public String getAssocOneIdExpr(String prefix, String operator) {
|
||||
return lastElPropertyValue.getAssocOneIdExpr(expression, operator);
|
||||
}
|
||||
|
||||
public String getAssocIdInExpr(String prefix) {
|
||||
return lastElPropertyValue.getAssocIdInExpr(prefix);
|
||||
}
|
||||
|
||||
public String getAssocIdInValueExpr(int size) {
|
||||
return lastElPropertyValue.getAssocIdInValueExpr(size);
|
||||
}
|
||||
|
||||
public int getDeployOrder() {
|
||||
int i = lastBeanProperty.getDeployOrder();
|
||||
int max = chain.length-1;
|
||||
for (int j = 0; j < max; j++) {
|
||||
int xtra = ((max-j)*1000) * chain[j].getDeployOrder();
|
||||
i += xtra;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
public boolean isAssocId() {
|
||||
return assocId;
|
||||
}
|
||||
|
||||
public boolean isAssocProperty() {
|
||||
for (int i = 0; i < chain.length; i++) {
|
||||
if (chain[i].isAssocProperty()){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getDbColumn() {
|
||||
return lastElPropertyValue.getDbColumn();
|
||||
}
|
||||
|
||||
public BeanProperty getBeanProperty() {
|
||||
return lastBeanProperty;
|
||||
}
|
||||
|
||||
|
||||
public boolean isDateTimeCapable() {
|
||||
return scalarType != null && scalarType.isDateTimeCapable();
|
||||
}
|
||||
|
||||
public int getJdbcType() {
|
||||
return scalarType == null ? 0 : scalarType.getJdbcType();
|
||||
}
|
||||
|
||||
public Object parseDateTime(long systemTimeMillis) {
|
||||
return scalarType.parseDateTime(systemTimeMillis);
|
||||
}
|
||||
|
||||
public StringParser getStringParser() {
|
||||
return scalarType;
|
||||
}
|
||||
|
||||
public StringFormatter getStringFormatter() {
|
||||
return scalarType;
|
||||
}
|
||||
|
||||
public Object elConvertType(Object value){
|
||||
// just convert using the last one in the chain
|
||||
return lastElPropertyValue.elConvertType(value);
|
||||
}
|
||||
|
||||
public Object elGetValue(Object bean) {
|
||||
|
||||
for (int i = 0; i < chain.length; i++) {
|
||||
bean = chain[i].elGetValue(bean);
|
||||
if (bean == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return bean;
|
||||
}
|
||||
|
||||
public Object elGetReference(Object bean) {
|
||||
|
||||
Object prevBean = bean;
|
||||
for (int i = 0; i < last; i++) {
|
||||
// always return non null prevBean
|
||||
prevBean = chain[i].elGetReference(prevBean);
|
||||
}
|
||||
// try the last step in the chain
|
||||
bean = chain[last].elGetValue(prevBean);
|
||||
|
||||
return bean;
|
||||
}
|
||||
|
||||
|
||||
public void elSetLoaded(Object bean) {
|
||||
|
||||
for (int i = 0; i < last; i++) {
|
||||
bean = chain[i].elGetValue(bean);
|
||||
if (bean == null){
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (bean != null){
|
||||
((EntityBean)bean)._ebean_getIntercept().setLoaded();
|
||||
}
|
||||
}
|
||||
|
||||
public void elSetReference(Object bean) {
|
||||
|
||||
for (int i = 0; i < last; i++) {
|
||||
bean = chain[i].elGetValue(bean);
|
||||
if (bean == null){
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (bean != null){
|
||||
((EntityBean)bean)._ebean_getIntercept().setReference();
|
||||
}
|
||||
}
|
||||
|
||||
public void elSetValue(Object bean, Object value, boolean populate, boolean reference){
|
||||
|
||||
Object prevBean = bean;
|
||||
if (populate){
|
||||
for (int i = 0; i < last; i++) {
|
||||
// always return non null prevBean
|
||||
prevBean = chain[i].elGetReference(prevBean);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < last; i++) {
|
||||
// always return non null prevBean
|
||||
prevBean = chain[i].elGetValue(prevBean);
|
||||
if (prevBean == null){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (prevBean != null){
|
||||
if (lastBeanProperty != null){
|
||||
// last chain element maps to a real scalar property
|
||||
lastBeanProperty.setValueIntercept(prevBean, value);
|
||||
if (reference){
|
||||
((EntityBean)prevBean)._ebean_getIntercept().setReference();
|
||||
}
|
||||
} else {
|
||||
// a non-scalar property of a Compound value object
|
||||
lastElPropertyValue.elSetValue(prevBean, value, populate, reference);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* Copyright (C) 2006 Robin Bygrave
|
||||
*
|
||||
* This file is part of Ebean.
|
||||
*
|
||||
* Ebean is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Ebean is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Ebean; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package com.avaje.ebeaninternal.server.el;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Utility object used to build a ElPropertyChain.
|
||||
* <p>
|
||||
* Builds a ElPropertyChain based on a chain of properties with dot separators.
|
||||
* </p>
|
||||
* <p>
|
||||
* This can navigate an object graph based on dot notation such as
|
||||
* order.customer.name.
|
||||
* </p>
|
||||
*/
|
||||
public class ElPropertyChainBuilder {
|
||||
|
||||
private final String expression;
|
||||
|
||||
private final List<ElPropertyValue> chain = new ArrayList<ElPropertyValue>();
|
||||
|
||||
private final boolean embedded;
|
||||
|
||||
private boolean containsMany;
|
||||
|
||||
/**
|
||||
* Create with the original expression.
|
||||
*/
|
||||
public ElPropertyChainBuilder(boolean embedded, String expression) {
|
||||
this.embedded = embedded;
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
public boolean isContainsMany() {
|
||||
return containsMany;
|
||||
}
|
||||
|
||||
public void setContainsMany(boolean containsMany) {
|
||||
this.containsMany = containsMany;
|
||||
}
|
||||
|
||||
public String getExpression() {
|
||||
return expression;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a ElGetValue element to the chain.
|
||||
*/
|
||||
public ElPropertyChainBuilder add(ElPropertyValue element) {
|
||||
if (element == null){
|
||||
throw new NullPointerException("element null in expression "+expression);
|
||||
}
|
||||
chain.add(element);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the immutable ElGetChain from the build information.
|
||||
*/
|
||||
public ElPropertyChain build() {
|
||||
return new ElPropertyChain(containsMany, embedded, expression, chain.toArray(new ElPropertyValue[chain.size()]));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.avaje.ebeaninternal.server.el;
|
||||
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanProperty;
|
||||
|
||||
/**
|
||||
* Used to parse expressions in queries (where, orderBy etc).
|
||||
* <p>
|
||||
* Maps an expression to deployment information such as
|
||||
* the DB column and elPrefix/elPlaceHolder is used determine
|
||||
* joins and set place holders for table alias'.
|
||||
* </p>
|
||||
*/
|
||||
public interface ElPropertyDeploy {
|
||||
|
||||
/**
|
||||
* This is the elPrefix for all root level properties.
|
||||
*/
|
||||
public static final String ROOT_ELPREFIX = "${}";
|
||||
|
||||
/**
|
||||
* Return true if there is a property on the path that is a many property.
|
||||
*/
|
||||
public boolean containsMany();
|
||||
|
||||
/**
|
||||
* Return true if there is a property is on the path after sinceProperty
|
||||
* that is a 'many' property.
|
||||
*/
|
||||
public boolean containsManySince(String sinceProperty);
|
||||
|
||||
/**
|
||||
* Return the prefix path of the property.
|
||||
* <p>
|
||||
* This is use to determine joins required to support
|
||||
* this property.
|
||||
* </p>
|
||||
*/
|
||||
public String getElPrefix();
|
||||
|
||||
/**
|
||||
* Return the place holder in the form of ${elPrefix}dbColumn.
|
||||
* <p>
|
||||
* The ${elPrefix} is replaced by the appropriate table alias.
|
||||
* </p>
|
||||
*/
|
||||
public String getElPlaceholder(boolean encrypted);
|
||||
|
||||
/**
|
||||
* Return the name of the property.
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* The ElPrefix plus name.
|
||||
*/
|
||||
public String getElName();
|
||||
|
||||
/**
|
||||
* Return the deployment db column for this property.
|
||||
*/
|
||||
public String getDbColumn();
|
||||
|
||||
|
||||
/**
|
||||
* Return the underlying bean property.
|
||||
*/
|
||||
public BeanProperty getBeanProperty();
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
/**
|
||||
* Copyright (C) 2006 Robin Bygrave
|
||||
*
|
||||
* This file is part of Ebean.
|
||||
*
|
||||
* Ebean is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Ebean is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Ebean; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package com.avaje.ebeaninternal.server.el;
|
||||
|
||||
import com.avaje.ebean.text.StringFormatter;
|
||||
import com.avaje.ebean.text.StringParser;
|
||||
|
||||
/**
|
||||
* The expression language object that can get values.
|
||||
* <p>
|
||||
* This can be used for local sorting and filtering.
|
||||
* </p>
|
||||
*/
|
||||
public interface ElPropertyValue extends ElPropertyDeploy {
|
||||
|
||||
/**
|
||||
* Return the Id values for the given bean value.
|
||||
*/
|
||||
public Object[] getAssocOneIdValues(Object bean);
|
||||
|
||||
/**
|
||||
* Return the Id expression string.
|
||||
* <p>
|
||||
* Typically used to produce id = ? expression strings.
|
||||
* </p>
|
||||
*/
|
||||
public String getAssocOneIdExpr(String prefix, String operator);
|
||||
|
||||
/**
|
||||
* Return the logical id value expression taking into account embedded id's.
|
||||
*/
|
||||
public String getAssocIdInValueExpr(int size);
|
||||
|
||||
/**
|
||||
* Return the logical id in expression taking into account embedded id's.
|
||||
*/
|
||||
public String getAssocIdInExpr(String prefix);
|
||||
|
||||
/**
|
||||
* Return true if this is an ManyToOne or OneToOne associated bean property.
|
||||
*/
|
||||
public boolean isAssocId();
|
||||
|
||||
/**
|
||||
* Return true if any path of this path contains a Associated One or Many.
|
||||
*/
|
||||
public boolean isAssocProperty();
|
||||
|
||||
/**
|
||||
* Return true if the property is encrypted via Java.
|
||||
*/
|
||||
public boolean isLocalEncrypted();
|
||||
|
||||
/**
|
||||
* Return true if the property is encrypted in the DB.
|
||||
*/
|
||||
public boolean isDbEncrypted();
|
||||
|
||||
/**
|
||||
* Return the deploy order for the property.
|
||||
*/
|
||||
public int getDeployOrder();
|
||||
|
||||
/**
|
||||
* Return the default StringParser for the scalar property.
|
||||
*/
|
||||
public StringParser getStringParser();
|
||||
|
||||
/**
|
||||
* Return the default StringFormatter for the scalar property.
|
||||
*/
|
||||
public StringFormatter getStringFormatter();
|
||||
|
||||
/**
|
||||
* Return true if the last type is "DateTime capable" - can support
|
||||
* {@link #parseDateTime(long)}.
|
||||
*/
|
||||
public boolean isDateTimeCapable();
|
||||
|
||||
/**
|
||||
* Return the underlying JDBC type or 0 if this is not a scalar type.
|
||||
*/
|
||||
public int getJdbcType();
|
||||
|
||||
/**
|
||||
* For DateTime capable scalar types convert the long systemTimeMillis into
|
||||
* an appropriate java time (Date,Timestamp,Time,Calendar, JODA type etc).
|
||||
*/
|
||||
public Object parseDateTime(long systemTimeMillis);
|
||||
|
||||
/**
|
||||
* Return the value from a given entity bean.
|
||||
*/
|
||||
public Object elGetValue(Object bean);
|
||||
|
||||
/**
|
||||
* Return the value ensuring objects prior to the top scalar property are
|
||||
* automatically populated.
|
||||
*/
|
||||
public Object elGetReference(Object bean);
|
||||
|
||||
/**
|
||||
* Set a value given a root level bean.
|
||||
* <p>
|
||||
* If populate then
|
||||
* </p>
|
||||
*/
|
||||
public void elSetValue(Object bean, Object value, boolean populate, boolean reference);
|
||||
|
||||
/**
|
||||
* Make the owning bean of this property a reference (as in not new/dirty).
|
||||
*/
|
||||
public void elSetReference(Object bean);
|
||||
|
||||
/**
|
||||
* Convert the value to the expected type.
|
||||
* <p>
|
||||
* Typically useful for converting strings to the appropriate number type
|
||||
* etc.
|
||||
* </p>
|
||||
*/
|
||||
public Object elConvertType(Object value);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Copyright (C) 2009 Authors
|
||||
*
|
||||
* This file is part of Ebean.
|
||||
*
|
||||
* Ebean is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Ebean is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Ebean; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package com.avaje.ebeaninternal.server.el;
|
||||
|
||||
public interface ElSetValue {
|
||||
|
||||
/**
|
||||
* Set the value to the bean.
|
||||
*/
|
||||
public void elSetValue(Object bean, Object value);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Expression language.
|
||||
*/
|
||||
package com.avaje.ebeaninternal.server.el;
|
||||
Reference in new issue
Block a user