本文整理汇总了Java中org.geomajas.layer.feature.attribute.BooleanAttribute类的典型用法代码示例。如果您正苦于以下问题:Java BooleanAttribute类的具体用法?Java BooleanAttribute怎么用?Java BooleanAttribute使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BooleanAttribute类属于org.geomajas.layer.feature.attribute包,在下文中一共展示了BooleanAttribute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDefaultAttributeInstance1
import org.geomajas.layer.feature.attribute.BooleanAttribute; //导入依赖的package包/类
public static ManyToOneAttribute getDefaultAttributeInstance1(Long id) {
Map<String, PrimitiveAttribute<?>> attributes = new HashMap<String, PrimitiveAttribute<?>>();
attributes.put("textAttr", new StringAttribute("manyToOne-1"));
attributes.put("booleanAttr", new BooleanAttribute(true));
attributes.put("intAttr", new IntegerAttribute(100));
attributes.put("floatAttr", new FloatAttribute(100.0f));
attributes.put("doubleAttr", new DoubleAttribute(100.0));
DateFormat format = new SimpleDateFormat("dd/MM/yyyy");
Date date;
try {
date = format.parse("01/01/2009");
} catch (ParseException e) {
date = new Date();
}
attributes.put("dateAttr", new DateAttribute(date));
return new ManyToOneAttribute(new AssociationValue(new LongAttribute(id), attributes));
}
示例2: getDefaultAttributeInstance
import org.geomajas.layer.feature.attribute.BooleanAttribute; //导入依赖的package包/类
public static ManyToOneAttribute getDefaultAttributeInstance(Long id) {
DateFormat format = new SimpleDateFormat("dd/MM/yyyy");
Date date;
try {
date = format.parse("01/01/2009");
} catch (ParseException e) {
date = new Date();
}
Map<String, PrimitiveAttribute<?>> attributes = new HashMap<String, PrimitiveAttribute<?>>();
attributes.put(PARAM_TEXT_ATTR, new StringAttribute("manyToOne-1"));
attributes.put(PARAM_BOOLEAN_ATTR, new BooleanAttribute(true));
attributes.put(PARAM_INT_ATTR, new IntegerAttribute(100));
attributes.put(PARAM_FLOAT_ATTR, new FloatAttribute(100.0f));
attributes.put(PARAM_DOUBLE_ATTR, new DoubleAttribute(100.0));
attributes.put(PARAM_DATE_ATTR, new DateAttribute(date));
return new ManyToOneAttribute(new AssociationValue(new LongAttribute(id), attributes));
}
示例3: setAttributes
import org.geomajas.layer.feature.attribute.BooleanAttribute; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void setAttributes() throws Exception {
Date date = new Date();
Map<String, Attribute> attributes = new HashMap<String, Attribute>();
attributes.put(PARAM_TEXT_ATTR, new StringAttribute("new name"));
attributes.put(PARAM_INT_ATTR, new IntegerAttribute(5));
attributes.put(PARAM_FLOAT_ATTR, new FloatAttribute(5.0f));
attributes.put(PARAM_DOUBLE_ATTR, new DoubleAttribute(5.0));
attributes.put(PARAM_BOOLEAN_ATTR, new BooleanAttribute(false));
attributes.put(PARAM_DATE_ATTR, new DateAttribute(date));
featureModel.setAttributes(feature1, attributes);
Assert.assertEquals("new name", featureModel.getAttribute(feature1, PARAM_TEXT_ATTR).getValue());
Assert.assertEquals(5, featureModel.getAttribute(feature1, PARAM_INT_ATTR).getValue());
Assert.assertEquals(5.0f, featureModel.getAttribute(feature1, PARAM_FLOAT_ATTR).getValue());
Assert.assertEquals(5.0, featureModel.getAttribute(feature1, PARAM_DOUBLE_ATTR).getValue());
Assert.assertFalse((Boolean) featureModel.getAttribute(feature1, PARAM_BOOLEAN_ATTR).getValue());
Assert.assertEquals(date, featureModel.getAttribute(feature1, PARAM_DATE_ATTR).getValue());
}
示例4: setAttributes
import org.geomajas.layer.feature.attribute.BooleanAttribute; //导入依赖的package包/类
@Test
@SuppressWarnings("rawtypes")
public void setAttributes() throws Exception {
Date date = new Date();
Map<String, Attribute> attributes = new HashMap<String, Attribute>();
attributes.put(PARAM_TEXT_ATTR, new StringAttribute("new name"));
attributes.put(PARAM_INT_ATTR, new IntegerAttribute(5));
attributes.put(PARAM_FLOAT_ATTR, new FloatAttribute(5.0f));
attributes.put(PARAM_DOUBLE_ATTR, new DoubleAttribute(5.0));
attributes.put(PARAM_BOOLEAN_ATTR, new BooleanAttribute(false));
attributes.put(PARAM_DATE_ATTR, new DateAttribute(date));
featureModel.setAttributes(feature1, attributes);
Assert.assertEquals("new name", featureModel.getAttribute(feature1, PARAM_TEXT_ATTR).getValue());
Assert.assertEquals(5, featureModel.getAttribute(feature1, PARAM_INT_ATTR).getValue());
Assert.assertEquals(5.0f, featureModel.getAttribute(feature1, PARAM_FLOAT_ATTR).getValue());
Assert.assertEquals(5.0, featureModel.getAttribute(feature1, PARAM_DOUBLE_ATTR).getValue());
Assert.assertFalse((Boolean) featureModel.getAttribute(feature1, PARAM_BOOLEAN_ATTR).getValue());
Assert.assertEquals(date, featureModel.getAttribute(feature1, PARAM_DATE_ATTR).getValue());
}
示例5: setBooleanAttribute
import org.geomajas.layer.feature.attribute.BooleanAttribute; //导入依赖的package包/类
/**
* Set attribute value of given type.
*
* @param name attribute name
* @param value attribute value
*/
public void setBooleanAttribute(String name, Boolean value) {
Attribute attribute = getAttributes().get(name);
if (!(attribute instanceof BooleanAttribute)) {
throw new IllegalStateException("Cannot set boolean value on attribute with different type, " +
attribute.getClass().getName() + " setting value " + value);
}
((BooleanAttribute) attribute).setValue(value);
}
示例6: getAttributeValue
import org.geomajas.layer.feature.attribute.BooleanAttribute; //导入依赖的package包/类
Object getAttributeValue(Attribute attribute) {
if (attribute instanceof PrimitiveAttribute<?>) {
PrimitiveAttribute<?> p = (PrimitiveAttribute<?>) attribute;
switch (p.getType()) {
case BOOLEAN:
return ((BooleanAttribute) p).getValue();
case SHORT:
return ((ShortAttribute) p).getValue();
case INTEGER:
return ((IntegerAttribute) p).getValue();
case LONG:
return ((LongAttribute) p).getValue();
case FLOAT:
return ((FloatAttribute) p).getValue();
case DOUBLE:
return ((DoubleAttribute) p).getValue();
case CURRENCY:
return ((CurrencyAttribute) p).getValue();
case STRING:
return ((StringAttribute) p).getValue();
case DATE:
return ((DateAttribute) p).getValue();
case URL:
return ((UrlAttribute) p).getValue();
case IMGURL:
return ((ImageUrlAttribute) p).getValue();
}
throw new IllegalArgumentException("Unknown primitive in test");
} else {
throw new IllegalArgumentException("Non primitives not supported by test");
}
}
开发者ID:geomajas,项目名称:geomajas-project-client-gwt,代码行数:33,代码来源:GwtTestDefaultAttributeFormFactory.java
示例7: newAttribute
import org.geomajas.layer.feature.attribute.BooleanAttribute; //导入依赖的package包/类
Attribute newAttribute() {
if (attribute instanceof PrimitiveAttribute<?>) {
PrimitiveAttribute<?> p = (PrimitiveAttribute<?>) attribute;
switch (p.getType()) {
case BOOLEAN:
return new BooleanAttribute();
case SHORT:
return new ShortAttribute();
case INTEGER:
return new IntegerAttribute();
case LONG:
return new LongAttribute();
case FLOAT:
return new FloatAttribute();
case DOUBLE:
return new DoubleAttribute();
case CURRENCY:
return new CurrencyAttribute();
case STRING:
return new StringAttribute();
case DATE:
return new DateAttribute();
case URL:
return new UrlAttribute();
case IMGURL:
return new ImageUrlAttribute();
}
throw new IllegalArgumentException("Unknown primtive in test");
} else {
throw new IllegalArgumentException("Non primitives not supported by test");
}
}
开发者ID:geomajas,项目名称:geomajas-project-client-gwt,代码行数:33,代码来源:GwtTestDefaultAttributeFormFactory.java
示例8: buildAttributeWidget
import org.geomajas.layer.feature.attribute.BooleanAttribute; //导入依赖的package包/类
@Override
public Widget buildAttributeWidget(BooleanAttribute attribute) {
Label label = new Label();
// Simply put "yes" or "no" instead of 1 and 0.
if (attribute.getValue()) {
label.getElement().setInnerText(MSG.yes());
} else {
label.getElement().setInnerText(MSG.no());
}
return label;
}
示例9: testUpdate
import org.geomajas.layer.feature.attribute.BooleanAttribute; //导入依赖的package包/类
@Test
public void testUpdate() throws Exception {
HibernateTestFeature f1 = (HibernateTestFeature) layer.create(HibernateTestFeature.getDefaultInstance1(null));
Assert.assertNotNull(f1.getId());
Object feature = layer.read(f1.getId().toString());
Assert.assertNotNull("The requested feature could not be found!", feature);
// Create a detached copy
HibernateTestFeature detached = HibernateTestFeature.getDefaultInstance1(null);
detached.setId(((HibernateTestFeature) feature).getId());
Map<String, Attribute> attributes = new HashMap<String, Attribute>();
attributes.put(PARAM_TEXT_ATTR, new StringAttribute("new name"));
attributes.put(PARAM_FLOAT_ATTR, new FloatAttribute(5f));
Calendar c = Calendar.getInstance();
attributes.put(PARAM_DATE_ATTR, new DateAttribute(c.getTime()));
attributes.put(PARAM_BOOLEAN_ATTR, new BooleanAttribute(false));
// Set a ManyToOne attribute without an ID (a new one)
attributes.put(PARAM_MANY_TO_ONE, HibernateTestManyToOne.getDefaultAttributeInstance1(null));
layer.getFeatureModel().setAttributes(detached, attributes);
layer.saveOrUpdate(detached);
feature = layer.read(f1.getId().toString());
Assert.assertEquals("new name", layer.getFeatureModel().getAttribute(feature, PARAM_TEXT_ATTR).getValue());
Assert.assertEquals(5f, layer.getFeatureModel().getAttribute(feature, PARAM_FLOAT_ATTR).getValue());
Assert.assertEquals(c.getTime(), layer.getFeatureModel().getAttribute(feature, PARAM_DATE_ATTR).getValue());
Assert.assertEquals(false, layer.getFeatureModel().getAttribute(feature, PARAM_BOOLEAN_ATTR).getValue());
ManyToOneAttribute manytoOne = (ManyToOneAttribute) layer.getFeatureModel().getAttribute(feature,
PARAM_MANY_TO_ONE);
Assert.assertNotNull(manytoOne.getValue());
Assert.assertNotNull(manytoOne.getValue().getId()); // Test for ID
}
示例10: setNullAttributes
import org.geomajas.layer.feature.attribute.BooleanAttribute; //导入依赖的package包/类
@Test
@SuppressWarnings("rawtypes")
public void setNullAttributes() throws Exception {
Date date = new Date();
Map<String, Attribute> attributes = new HashMap<String, Attribute>();
attributes.put(PARAM_TEXT_ATTR, null);
attributes.put(PARAM_INT_ATTR, null);
attributes.put(PARAM_FLOAT_ATTR, null);
attributes.put(PARAM_DOUBLE_ATTR, null);
attributes.put(PARAM_BOOLEAN_ATTR, null);
attributes.put(PARAM_DATE_ATTR, null);
featureModel.setAttributes(feature1, attributes);
Assert.assertNull(featureModel.getAttribute(feature1, PARAM_TEXT_ATTR).getValue());
Assert.assertNull(featureModel.getAttribute(feature1, PARAM_INT_ATTR).getValue());
Assert.assertNull(featureModel.getAttribute(feature1, PARAM_FLOAT_ATTR).getValue());
Assert.assertNull(featureModel.getAttribute(feature1, PARAM_DOUBLE_ATTR).getValue());
Assert.assertNull(featureModel.getAttribute(feature1, PARAM_BOOLEAN_ATTR).getValue());
Assert.assertNull(featureModel.getAttribute(feature1, PARAM_DATE_ATTR).getValue());
attributes.put(PARAM_TEXT_ATTR, new StringAttribute("new name"));
attributes.put(PARAM_INT_ATTR, new IntegerAttribute(5));
attributes.put(PARAM_FLOAT_ATTR, new FloatAttribute(5.0f));
attributes.put(PARAM_DOUBLE_ATTR, new DoubleAttribute(5.0));
attributes.put(PARAM_BOOLEAN_ATTR, new BooleanAttribute(false));
attributes.put(PARAM_DATE_ATTR, new DateAttribute(date));
featureModel.setAttributes(feature1, attributes);
Assert.assertEquals("new name", featureModel.getAttribute(feature1, PARAM_TEXT_ATTR).getValue());
Assert.assertEquals(5, featureModel.getAttribute(feature1, PARAM_INT_ATTR).getValue());
Assert.assertEquals(5.0f, featureModel.getAttribute(feature1, PARAM_FLOAT_ATTR).getValue());
Assert.assertEquals(5.0, featureModel.getAttribute(feature1, PARAM_DOUBLE_ATTR).getValue());
Assert.assertFalse((Boolean) featureModel.getAttribute(feature1, PARAM_BOOLEAN_ATTR).getValue());
Assert.assertEquals(date, featureModel.getAttribute(feature1, PARAM_DATE_ATTR).getValue());
}
示例11: testUpdate
import org.geomajas.layer.feature.attribute.BooleanAttribute; //导入依赖的package包/类
@Test
@SuppressWarnings("rawtypes")
public void testUpdate() throws Exception {
SimpleFeature f1 = (SimpleFeature) layer.create(SimpleFeature.getDefaultInstance1(null));
Assert.assertNotNull(f1.getId());
Object feature = layer.read(f1.getId().toString());
Assert.assertNotNull("The requested feature could not be found!", feature);
// Create a detached copy
SimpleFeature detached = SimpleFeature.getDefaultInstance1(null);
detached.setId(((SimpleFeature) feature).getId());
Map<String, Attribute> attributes = new HashMap<String, Attribute>();
attributes.put(PARAM_TEXT_ATTR, new StringAttribute("new name"));
attributes.put(PARAM_FLOAT_ATTR, new FloatAttribute(5f));
Calendar c = Calendar.getInstance();
attributes.put(PARAM_DATE_ATTR, new DateAttribute(c.getTime()));
attributes.put(PARAM_BOOLEAN_ATTR, new BooleanAttribute(false));
layer.getFeatureModel().setAttributes(detached, attributes);
layer.saveOrUpdate(detached);
feature = layer.read(f1.getId().toString());
Assert.assertEquals("new name", layer.getFeatureModel().getAttribute(feature, PARAM_TEXT_ATTR).getValue());
Assert.assertEquals(5f, layer.getFeatureModel().getAttribute(feature, PARAM_FLOAT_ATTR).getValue());
Assert.assertEquals(c.getTime(), layer.getFeatureModel().getAttribute(feature, PARAM_DATE_ATTR).getValue());
Assert.assertEquals(false, layer.getFeatureModel().getAttribute(feature, PARAM_BOOLEAN_ATTR).getValue());
}
示例12: toPrimitiveDto
import org.geomajas.layer.feature.attribute.BooleanAttribute; //导入依赖的package包/类
private Attribute<?> toPrimitiveDto(Object value, PrimitiveAttributeInfo info) {
switch (info.getType()) {
case BOOLEAN:
return new BooleanAttribute((Boolean) convertToClass(value, Boolean.class));
case SHORT:
return new ShortAttribute((Short) convertToClass(value, Short.class));
case INTEGER:
return new IntegerAttribute((Integer) convertToClass(value, Integer.class));
case LONG:
return new LongAttribute((Long) convertToClass(value, Long.class));
case FLOAT:
return new FloatAttribute((Float) convertToClass(value, Float.class));
case DOUBLE:
return new DoubleAttribute((Double) convertToClass(value, Double.class));
case CURRENCY:
return new CurrencyAttribute((String) convertToClass(value, String.class));
case STRING:
return new StringAttribute(value == null ? null : value.toString());
case DATE:
return new DateAttribute((Date) value);
case URL:
return new UrlAttribute((String) value);
case IMGURL:
return new ImageUrlAttribute((String) value);
default:
throw new IllegalArgumentException("Cannot create primitive attribute of type " + info);
}
}
示例13: testBooleanToDto
import org.geomajas.layer.feature.attribute.BooleanAttribute; //导入依赖的package包/类
@Test
public void testBooleanToDto() throws Exception {
PrimitiveAttributeInfo attributeInfo = new PrimitiveAttributeInfo();
attributeInfo.setType(PrimitiveType.BOOLEAN);
Assert.assertTrue(converter.toDto(Boolean.TRUE, attributeInfo) instanceof BooleanAttribute);
Assert.assertTrue(((BooleanAttribute) converter.toDto(Boolean.TRUE, attributeInfo)).getValue());
Assert.assertFalse(((BooleanAttribute) converter.toDto(Boolean.FALSE, attributeInfo)).getValue());
}
示例14: fromForm
import org.geomajas.layer.feature.attribute.BooleanAttribute; //导入依赖的package包/类
@Override
public void fromForm(String name, Attribute<?> attribute) {
AbstractReadOnlyAttributeInfo info = attributeInfoMap.get(name);
if (null == attribute || null == info || !isIncluded(info) || !(info instanceof EditableAttributeInfo)) {
return;
}
if (info instanceof PrimitiveAttributeInfo) {
PrimitiveAttribute<?> primitive = (PrimitiveAttribute<?>) attribute;
switch (primitive.getType()) {
case BOOLEAN:
getValue(name, (BooleanAttribute) primitive); // NOSONAR valid cast
break;
case SHORT:
getValue(name, (ShortAttribute) primitive); // NOSONAR valid cast
break;
case INTEGER:
getValue(name, (IntegerAttribute) primitive); // NOSONAR valid cast
break;
case LONG:
getValue(name, (LongAttribute) primitive); // NOSONAR valid cast
break;
case FLOAT:
getValue(name, (FloatAttribute) primitive); // NOSONAR valid cast
break;
case DOUBLE:
getValue(name, (DoubleAttribute) primitive); // NOSONAR valid cast
break;
case CURRENCY:
getValue(name, (CurrencyAttribute) primitive); // NOSONAR valid cast
break;
case STRING:
getValue(name, (StringAttribute) primitive); // NOSONAR valid cast
break;
case URL:
getValue(name, (UrlAttribute) primitive); // NOSONAR valid cast
break;
case IMGURL:
getValue(name, (ImageUrlAttribute) primitive); // NOSONAR valid cast
break;
case DATE:
getValue(name, (DateAttribute) primitive); // NOSONAR valid cast
break;
default:
throw new IllegalStateException("Unhandled primitive attribute type " +
primitive.getType());
}
} else {
AssociationAttribute<?> association = (AssociationAttribute<?>) attribute;
FormItem item = formWidget.getItem(name);
Object associationItem = item.getAttributeAsObject(AssociationItem.ASSOCIATION_ITEM_ATTRIBUTE_KEY);
switch (association.getType()) {
case MANY_TO_ONE:
((ManyToOneItem<?>) associationItem).fromItem((ManyToOneAttribute) attribute); // NOSONAR valid cast
break;
case ONE_TO_MANY:
((OneToManyItem<?>) associationItem).fromItem((OneToManyAttribute) attribute); // NOSONAR valid cast
break;
default:
throw new IllegalStateException("Unhandled association attribute type " +
association.getType());
}
}
}
示例15: toPrimitive
import org.geomajas.layer.feature.attribute.BooleanAttribute; //导入依赖的package包/类
private Attribute<?> toPrimitive(Object value, AttributeType type) {
// String attribute?
if (type.getBinding().equals(String.class)) {
return new StringAttribute(value == null ? null : value.toString());
}
// Number attributes:
try {
if ((Integer.class).equals(type.getBinding())) {
return new IntegerAttribute((Integer) convertToClass(value, Integer.class));
}
if ((Short.class).equals(type.getBinding())) {
return new ShortAttribute((Short) convertToClass(value, Short.class));
} else if (Long.class.equals(type.getBinding())) {
return new LongAttribute((Long) convertToClass(value, Long.class));
} else if (Float.class.equals(type.getBinding())) {
return new FloatAttribute((Float) convertToClass(value, Float.class));
} else if (Double.class.equals(type.getBinding())) {
return new DoubleAttribute((Double) convertToClass(value, Double.class));
} else if (BigDecimal.class.equals(type.getBinding())) {
return new DoubleAttribute((Double) convertToClass(
null == value ? null : Double.valueOf(value.toString()), Double.class));
}
} catch (NumberFormatException e) {
return new StringAttribute(value == null ? null : value.toString());
}
// Boolean and date attributes:
if (Boolean.class.equals(type.getBinding())) {
return new BooleanAttribute((Boolean) convertToClass(value, Boolean.class));
} else if (java.sql.Date.class.equals(type.getBinding())) {
// note: java.sql.Date extends java.util.Date but takes care that time part is of no importance
return new DateAttribute((java.util.Date) convertToClass(value, java.sql.Date.class));
} else if (java.sql.Timestamp.class.equals(type.getBinding())) {
// java.sql.Timestamp extends java.util.Date
return new DateAttribute((java.util.Date) convertToClass(value, java.sql.Timestamp.class));
} else if (java.util.Date.class.equals(type.getBinding())) {
// a branch with test on java.util.Date is still needed!
return new DateAttribute((java.util.Date) convertToClass(value, java.util.Date.class));
}
// Last resort...
return new StringAttribute(value == null ? null : value.toString());
}