本文整理汇总了Java中com.vaadin.data.util.filter.And类的典型用法代码示例。如果您正苦于以下问题:Java And类的具体用法?Java And怎么用?Java And使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
And类属于com.vaadin.data.util.filter包,在下文中一共展示了And类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: numericRange
import com.vaadin.data.util.filter.And; //导入依赖的package包/类
protected Container.Filter numericRange(Object propertyId, Class<?> numberClass, String pattern) {
Matcher matcher = numericRangePattern.matcher(pattern);
if (!matcher.find()) return null;
String left = matcher.group(1);
String right = matcher.group(2);
if (fpPattern.matcher(left).matches() && fpPattern.matcher(right).matches()) {
Number i = parseNumericValue(left, numberClass);
Number j = parseNumericValue(right, numberClass);
if (i.doubleValue() > j.doubleValue()) {
throw new Validator.InvalidValueException(
String.format("The given range '%s' is invalid", pattern));
}
return new And(
new Compare.GreaterOrEqual(propertyId, i),
new Compare.LessOrEqual(propertyId, j)
);
}
return null;
}
示例2: testDate_dd_mm
import com.vaadin.data.util.filter.And; //导入依赖的package包/类
@Test
public void testDate_dd_mm() {
DateTime today = DateTime.now();
int year = today.getYear();
Container.Filter expected = new And(
new Compare.GreaterOrEqual(DATE_PROPID, new DateTime(year, 1, 1, 0, 0, 0).toDate()),
new Compare.LessOrEqual(DATE_PROPID, new DateTime(year, 1, 1, 23, 59, 59, 999).toDate()));
Container.Filter filter = filterFactory.createFilter(Date.class, DATE_PROPID, "01-01");
log.info(filterToString(expected));
log.info(filterToString(filter));
assertEquals(expected, filter);
}
示例3: testDate_dd_mm_Range
import com.vaadin.data.util.filter.And; //导入依赖的package包/类
@Test
public void testDate_dd_mm_Range() {
DateTime today = DateTime.now();
int year = today.getYear();
Container.Filter expected = new And(
new Compare.GreaterOrEqual(DATE_PROPID, new DateTime(year, 1, 1, 0, 0, 0).toDate()),
new Compare.LessOrEqual(DATE_PROPID, new DateTime(year, 1, 31, 23, 59, 59, 999).toDate()));
Container.Filter filter = filterFactory.createFilter(Date.class, DATE_PROPID, "01-01..31-01");
log.info(filterToString(expected));
log.info(filterToString(filter));
assertEquals(expected, filter);
}
示例4: testDate_dd
import com.vaadin.data.util.filter.And; //导入依赖的package包/类
@Test
public void testDate_dd() {
DateTime today = DateTime.now();
int year = today.getYear(), month = today.getMonthOfYear();
Container.Filter expected = new And(
new Compare.GreaterOrEqual(DATE_PROPID, new DateTime(year, month, 1, 0, 0, 0).toDate()),
new Compare.LessOrEqual(DATE_PROPID, new DateTime(year, month, 1, 23, 59, 59, 999).toDate()));
Container.Filter filter = filterFactory.createFilter(Date.class, DATE_PROPID, "01");
log.info(filterToString(expected));
log.info(filterToString(filter));
assertEquals(expected, filter);
}
示例5: testDate_dd_Range
import com.vaadin.data.util.filter.And; //导入依赖的package包/类
@Test
public void testDate_dd_Range() {
DateTime today = DateTime.now();
int year = today.getYear(), month = today.getMonthOfYear();
int maxDay = today.dayOfMonth().getMaximumValue();
Container.Filter expected = new And(
new Compare.GreaterOrEqual(DATE_PROPID, new DateTime(year, month, 1, 0, 0, 0).toDate()),
new Compare.LessOrEqual(DATE_PROPID, new DateTime(year, month, maxDay, 23, 59, 59, 999).toDate()));
Container.Filter filter = filterFactory.createFilter(Date.class, DATE_PROPID, "01.." + maxDay);
log.info(filterToString(expected));
log.info(filterToString(filter));
assertEquals(expected, filter);
}
示例6: filterToString
import com.vaadin.data.util.filter.And; //导入依赖的package包/类
public String filterToString(Container.Filter filter) {
if (filter instanceof Compare.LessOrEqual) {
return String.format("%s <= %s", ((Compare.LessOrEqual) filter).getPropertyId(), ((Compare.LessOrEqual) filter).getValue());
} else
if (filter instanceof Compare.GreaterOrEqual) {
return String.format("%s >= %s", ((Compare.GreaterOrEqual) filter).getPropertyId(), ((Compare.GreaterOrEqual) filter).getValue());
} else
if (filter instanceof And) {
StringBuffer sb = new StringBuffer();
Collection<Container.Filter> coll = ((And) filter).getFilters();
for (Container.Filter f: coll) {
sb.append(filterToString(f));
sb.append(", ");
}
return sb.toString();
}
throw new UnsupportedOperationException("unsupported filter");
}
示例7: testSize_WriteThrough
import com.vaadin.data.util.filter.And; //导入依赖的package包/类
@Test
public void testSize_WriteThrough() {
QPerson person = QPerson.person;
expect(
entityProviderMock.getEntityCount(container, new And(new Equal(
"firstName", "Hello"), new Equal("lastName", "World"))))
.andReturn(123);
replay(entityProviderMock);
assertTrue(container.isApplyFiltersImmediately());
// container.addContainerFilter(new Equal("firstName", "Hello"));
// container.addContainerFilter(new Equal("lastName", "World"));
container.addContainerFilter(person.firstName.eq("Hello"));
container.addContainerFilter(person.lastName.eq("World"));
container.setEntityProvider(entityProviderMock);
container.setWriteThrough(true);
assertEquals(123, container.size());
verify(entityProviderMock);
}
示例8: testSize_WriteThrough
import com.vaadin.data.util.filter.And; //导入依赖的package包/类
@Test
public void testSize_WriteThrough() {
expect(
entityProviderMock.getEntityCount(container, new And(new Equal(
"firstName", "Hello"), new Equal("lastName", "World"))))
.andReturn(123);
replay(entityProviderMock);
assertTrue(container.isApplyFiltersImmediately());
container.addContainerFilter(new Equal("firstName", "Hello"));
container.addContainerFilter(new Equal("lastName", "World"));
container.setEntityProvider(entityProviderMock);
container.setWriteThrough(true);
assertEquals(123, container.size());
verify(entityProviderMock);
}
示例9: testGetChildren_Filtered
import com.vaadin.data.util.filter.And; //导入依赖的package包/类
@Test
public void testGetChildren_Filtered() {
LinkedList<SortBy> orderby = new LinkedList<SortBy>();
orderby.add(new SortBy("firstName", true));
LinkedList<Object> result = new LinkedList<Object>();
// Instruct mocks
expect(
entityProviderMock.getAllEntityIdentifiers(container, new And(new Equal(
"manager.id", 123l), new Equal("firstName", "blah")),
orderby)).andReturn(result);
replay(entityProviderMock);
// Set up container
container.setParentProperty("manager");
container.setEntityProvider(entityProviderMock);
container.sort(new Object[] { "firstName" }, new boolean[] { true });
container.addContainerFilter(new Equal("firstName", "blah"));
// Run test
assertSame(result, container.getChildren(123l));
// Verify
verify(entityProviderMock);
}
示例10: isAuthorizationValid
import com.vaadin.data.util.filter.And; //导入依赖的package包/类
public boolean isAuthorizationValid(String email, String password) {
/*try{
String queryString = "SELECT * FROM user WHERE email like '" + email + "' AND password like '" + password + "'" ;
FreeformQuery query = new FreeformQuery(queryString, connectionPool);
SQLContainer result = new SQLContainer(query);
for (Object ob : result.getItemIds()) {
if ((result.getItem(ob).getItemProperty("email").getValue().equals(email)) &&
(result.getItem(ob).getItemProperty("password").getValue().equals(password)))
return true;
}
} catch(Exception e){
e.printStackTrace();
}
*/
userContainer.addContainerFilter(new And(new Equal("email", email), new Equal("password", password)));
/*addContainerFilter( new Or(new And(new Equal("NAME", "Paul"),
new A(new Less("AGE", 18),
new Greater("AGE", 65))),
new Like("NAME", "A%")));
*/
return false;
}
示例11: filter
import com.vaadin.data.util.filter.And; //导入依赖的package包/类
private void filter(String filterString) {
container.removeAllContainerFilters();
if (filterString.length() > 0) {
String[] filterWords = filterString.split(" ");
Container.Filter[] filters = new Container.Filter[filterWords.length];
for (int i = 0; i < filterWords.length; ++i) {
String word = filterWords[i];
filters[i] = new Or(
new SimpleStringFilter("stringProperty", word, false, false),
new SimpleStringFilter("integerProperty", word, true, true),
new SimpleStringFilter("embeddedProperty.enumProperty", word, true, false)
);
}
container.addContainerFilter(new And(filters));
}
}
示例12: addShowPopulatedFilter
import com.vaadin.data.util.filter.And; //导入依赖的package包/类
protected void addShowPopulatedFilter(String propertyId, HeaderRow filterRow) {
HeaderCell cell = filterRow.getCell(propertyId);
CheckBox group = new CheckBox("Show Set Only");
group.setImmediate(true);
group.addValueChangeListener(l->{
container.removeContainerFilters(propertyId);
if (group.getValue()) {
container.addContainerFilter(new And(new Not(new Compare.Equal(propertyId,"")), new Not(new IsNull(propertyId))));
}
});
group.addStyleName(ValoTheme.CHECKBOX_SMALL);
cell.setComponent(group);
}
示例13: testIntRange
import com.vaadin.data.util.filter.And; //导入依赖的package包/类
@Test
public void testIntRange() {
Container.Filter expected = new And(
new Compare.GreaterOrEqual(INT_PROPID, 10),
new Compare.LessOrEqual(INT_PROPID, 100));
Container.Filter filter = filterFactory.createFilter(int.class, INT_PROPID, "10..100");
log.info(filterToString(expected));
log.info(filterToString(filter));
assertEquals(expected, filter);
}
示例14: testDoubleRange
import com.vaadin.data.util.filter.And; //导入依赖的package包/类
@Test
public void testDoubleRange() {
Container.Filter expected = new And(
new Compare.GreaterOrEqual(INT_PROPID, 10.1),
new Compare.LessOrEqual(INT_PROPID, 100.2));
Container.Filter filter = filterFactory.createFilter(double.class, INT_PROPID, "10.1..100.2");
log.info(filterToString(expected));
log.info(filterToString(filter));
assertEquals(expected, filter);
}
示例15: testDateYear
import com.vaadin.data.util.filter.And; //导入依赖的package包/类
@Test
public void testDateYear() {
Container.Filter expected = new And(
new Compare.GreaterOrEqual(DATE_PROPID, new DateTime(2014, 1, 1, 0, 0, 0).toDate()),
new Compare.LessOrEqual(DATE_PROPID, new DateTime(2014, 12, 31, 23, 59, 59, 999).toDate()));
Container.Filter filter = filterFactory.createFilter(Date.class, DATE_PROPID, "2014");
log.info(filterToString(expected));
log.info(filterToString(filter));
assertEquals(expected, filter);
}