本文整理汇总了Java中com.redhat.lightblue.metadata.types.DateType类的典型用法代码示例。如果您正苦于以下问题:Java DateType类的具体用法?Java DateType怎么用?Java DateType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DateType类属于com.redhat.lightblue.metadata.types包,在下文中一共展示了DateType类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testTranslate_SimpleField_Date
import com.redhat.lightblue.metadata.types.DateType; //导入依赖的package包/类
@Test
public void testTranslate_SimpleField_Date() throws JSONException{
Attribute keyAttribute = new Attribute("key", "20150109201731.570Z");
//Note in and out data are formatted differently
SearchResultEntry result = new SearchResultEntry(-1, "uid=john.doe,dc=example,dc=com", new Attribute[]{
keyAttribute
});
EntityMetadata md = fakeEntityMetadata(
"fakeMetadata",
new SimpleField("key", DateType.TYPE)
);
JsonDoc document = new ResultTranslatorToJson(factory, md, new TrivialLdapFieldNameTranslator()).translate(result);
assertNotNull(document);
String lbDate = Constants.getDateFormat().format(keyAttribute.getValueAsDate());
JSONAssert.assertEquals(
"{\"key\":\"" + lbDate + "\",\"dn\":\"uid=john.doe,dc=example,dc=com\"}",
document.toString(),
true);
}
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:25,代码来源:ResultTranslatorToJsonTest.java
示例2: rawValueToJson
import com.redhat.lightblue.metadata.types.DateType; //导入依赖的package包/类
private static JsonNode rawValueToJson(Object value) {
if(value instanceof Number) {
if(value instanceof Float || value instanceof Double) {
return DoubleType.TYPE.toJson(JsonNodeFactory.instance,value);
} else {
return IntegerType.TYPE.toJson(JsonNodeFactory.instance,value);
}
} else if(value instanceof Date) {
return DateType.TYPE.toJson(JsonNodeFactory.instance,value);
} else if(value instanceof Boolean) {
return BooleanType.TYPE.toJson(JsonNodeFactory.instance,value);
} else if(value==null) {
return JsonNodeFactory.instance.nullNode();
} else {
return JsonNodeFactory.instance.textNode(value.toString());
}
}
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:18,代码来源:DocTranslator.java
示例3: translate
import com.redhat.lightblue.metadata.types.DateType; //导入依赖的package包/类
@Override
protected JsonNode translate(SimpleField field, Object o) {
Type type = field.getType();
Attribute attr = (Attribute) o;
Object value = null;
if(type instanceof DateType){
value = attr.getValueAsDate();
}
else if(type instanceof BinaryType){
value = attr.getValueByteArray();
}
else{
value = attr.getValue();
}
if(value == null){
throw new NullPointerException("Unable to convert LDAP attribute to json resulting in a null value: " + attr.getName());
}
return toJson(field.getType(), value);
}
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:23,代码来源:ResultTranslatorToJson.java
示例4: fromJson
import com.redhat.lightblue.metadata.types.DateType; //导入依赖的package包/类
@Override
protected Object fromJson(Type type, JsonNode node){
if(type instanceof DateType){
return StaticUtils.encodeGeneralizedTime((Date)type.fromJson(node));
}
else if(type instanceof BinaryType){
return type.fromJson(node);
}
else{
return super.fromJson(type, node).toString();
}
}
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:13,代码来源:LdapTranslatorFromJson.java
示例5: getTypeForClass
import com.redhat.lightblue.metadata.types.DateType; //导入依赖的package包/类
private Type getTypeForClass(Class<?> type) {
if (type.equals(String.class) || type.isEnum()) {
return StringType.TYPE;
}
if (type.equals(boolean.class) || type.equals(Boolean.class)) {
return BooleanType.TYPE;
}
if (type.equals(Date.class) || Temporal.class.isAssignableFrom(type)) {
return DateType.TYPE;
}
if (type.equals(BigDecimal.class)) {
return BigDecimalType.TYPE;
}
if (type.equals(BigInteger.class)) {
return BigIntegerType.TYPE;
}
if (type.equals(byte[].class)) {
return BinaryType.TYPE;
}
if (type.equals(double.class) || type.equals(Double.class)) {
return DoubleType.TYPE;
}
if (type.equals(int.class) || type.equals(Integer.class)) {
return IntegerType.TYPE;
}
if (Iterable.class.isAssignableFrom(type)) {
return ArrayType.TYPE;
}
// TODO: Reference type, UUID type
return ObjectType.TYPE;
}
开发者ID:lightblue-platform,项目名称:lightblue-java-generator,代码行数:42,代码来源:MetadataGenerator.java
注:本文中的com.redhat.lightblue.metadata.types.DateType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论