本文整理了Java中org.nuxeo.ecm.core.schema.types.Field.getType()
方法的一些代码示例,展示了Field.getType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Field.getType()
方法的具体详情如下:
包路径:org.nuxeo.ecm.core.schema.types.Field
类名称:Field
方法名:getType
[英]Gets the field type.
[中]获取字段类型。
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
@Override
public ComplexType getType() {
return (ComplexType) field.getType();
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
@Override
public Type getType() {
return field.getType();
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
@Override
public ListType getType() {
return (ListType) field.getType();
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
@Override
public Serializable normalize(Object value) throws PropertyConversionException {
if (isNormalized(value)) {
return (Serializable) value;
}
if (value.getClass() == Date.class) {
Calendar cal = Calendar.getInstance();
cal.setTime((Date) value);
return cal;
}
if (value instanceof String) {
String string = (String) value;
if (string.length() == 0) {
return null;
}
return (Calendar) field.getType().decode(value.toString());
}
throw new PropertyConversionException(value.getClass(), Calendar.class);
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
/**
* Validates sub fields for given complex field.
*
* @since 7.1
*/
@SuppressWarnings("unchecked")
private List<ConstraintViolation> validateComplexTypeField(Schema schema, List<PathNode> path, Field field,
Object value) {
assert field.getType().isComplexType();
List<ConstraintViolation> violations = new ArrayList<>();
ComplexType complexType = (ComplexType) field.getType();
// this code does not support other type than Map as value
if (!(value instanceof Map)) {
return violations;
}
Map<String, Object> map = (Map<String, Object>) value;
for (Field child : complexType.getFields()) {
Object item = map.get(child.getName().getLocalName());
List<PathNode> subPath = new ArrayList<>(path);
subPath.add(new PathNode(child));
violations.addAll(validateAnyTypeField(schema, subPath, child, item, true));
}
return violations;
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
/**
* @since 7.1
*/
@SuppressWarnings("rawtypes")
private List<ConstraintViolation> validateAnyTypeField(Schema schema, List<PathNode> path, Field field,
Object value, boolean validateSubProperties) {
if (field.getType().isSimpleType()) {
return validateSimpleTypeField(schema, path, field, value);
} else if (field.getType().isComplexType()) {
List<ConstraintViolation> res = new ArrayList<>();
if (!field.isNillable() && (value == null || (value instanceof Map && ((Map) value).isEmpty()))) {
addNotNullViolation(res, schema, path);
}
if (validateSubProperties) {
List<ConstraintViolation> subs = validateComplexTypeField(schema, path, field, value);
if (subs != null) {
res.addAll(subs);
}
}
return res;
} else if (field.getType().isListType()) {
// maybe validate the list type here
if (validateSubProperties) {
return validateListTypeField(schema, path, field, value);
}
}
// unrecognized type : ignored
return Collections.emptyList();
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
/**
* @since 7.1
*/
private List<ConstraintViolation> validateAnyTypeProperty(Schema schema, List<PathNode> path, Property prop,
boolean dirtyOnly, boolean validateSubProperties) {
Field field = prop.getField();
if (!dirtyOnly || prop.isDirty()) {
if (field.getType().isSimpleType()) {
return validateSimpleTypeProperty(schema, path, prop, dirtyOnly);
} else if (field.getType().isComplexType()) {
// ignore for now the case when the complex property is null with a null contraints because it's
// currently impossible
if (validateSubProperties) {
return validateComplexTypeProperty(schema, path, prop, dirtyOnly);
}
} else if (field.getType().isListType()) {
if (validateSubProperties) {
return validateListTypeProperty(schema, path, prop, dirtyOnly);
}
}
}
// unrecognized type : ignored
return Collections.emptyList();
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
assert field.getType().isListType();
List<ConstraintViolation> violations = new ArrayList<>();
Collection<?> castedValue = null;
addNotNullViolation(violations, schema, path);
ListType listType = (ListType) field.getType();
Field listField = listType.getField();
int index = 0;
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
public static DocumentPropertyObjectResolverImpl create(DocumentModel doc, String xpath) {
Field field = Framework.getService(SchemaManager.class).getField(xpath);
if (field != null) {
ObjectResolver resolver = field.getType().getObjectResolver();
if (resolver != null) {
return new DocumentPropertyObjectResolverImpl(doc, xpath, resolver);
}
}
return null;
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
if (field != null && field.getType().isListType()) {
Field itemField = ((ListType) field.getType()).getField();
if (xpathToken.matches("\\d+")) {
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
Type type = field.getType();
if (type.isSimpleType()) {
ListType ltype = (ListType) type;
Field lfield = ltype.getField();
Type ftype = lfield.getType();
List<Object> list;
if (value instanceof Object[]) { // these are stored as arrays
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
protected boolean compatibleTypes(Type targetType, Type sourceType) {
if (!sourceType.getName().equals(targetType.getName())) {
return false;
}
if (sourceType.isComplexType()) {
for (Field field : ((ComplexType) sourceType).getFields()) {
Field targetField = ((ComplexType) targetType).getField(field.getName());
if (targetField == null || !field.getType().equals(targetField.getType())) {
return false;
}
}
}
if (sourceType.isListType()) {
if (!((ListType) sourceType).getFieldType().equals(((ListType) targetType).getFieldType())) {
return false;
}
if (((ListType) sourceType).getFieldType().isComplexType()) {
return compatibleTypes(((ListType) targetType).getFieldType(), ((ListType) sourceType).getFieldType());
}
}
return true;
}
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
boolean dirtyOnly) {
Field field = prop.getField();
assert field.getType().isComplexType();
List<ConstraintViolation> violations = new ArrayList<>();
boolean allChildrenPhantom = true;
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
/**
* @since 7.1
*/
private List<ConstraintViolation> validateSimpleTypeProperty(Schema schema, List<PathNode> path, Property prop,
boolean dirtyOnly) {
Field field = prop.getField();
assert field.getType().isSimpleType() || prop.isScalar();
List<ConstraintViolation> violations = new ArrayList<>();
Serializable value = prop.getValue();
Object defaultValue = field.getDefaultValue();
// check nullity constraint only if field doesn't have a default value (phantom case)
if (prop.isPhantom() && defaultValue == null || value == null) {
if (!field.isNillable()) {
addNotNullViolation(violations, schema, path);
}
} else {
violations.addAll(validateSimpleTypeField(schema, path, field, value));
}
return violations;
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
/**
* This method should be the only one to create {@link ConstraintViolation}.
*
* @since 7.1
*/
private List<ConstraintViolation> validateSimpleTypeField(Schema schema, List<PathNode> path, Field field,
Object value) {
Type type = field.getType();
assert type.isSimpleType() || type.isListType(); // list type to manage ArrayProperty
List<ConstraintViolation> violations = new ArrayList<>();
Set<Constraint> constraints;
if (type.isListType()) { // ArrayProperty
constraints = ((ListType) type).getFieldType().getConstraints();
} else {
constraints = field.getConstraints();
}
for (Constraint constraint : constraints) {
if (!constraint.validate(value)) {
ConstraintViolation violation = new ConstraintViolation(schema, path, constraint, value);
violations.add(violation);
}
}
return violations;
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
boolean dirtyOnly) {
Field field = prop.getField();
assert field.getType().isListType();
List<ConstraintViolation> violations = new ArrayList<>();
Serializable value = prop.getValue();
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
public static Property createProperty(Property parent, Field field, int flags) {
Type type = field.getType();
if (type instanceof SimpleTypeImpl) {
throw new IllegalArgumentException("Unsupported field type: " + field.getType().getName());
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
fieldPath = path + "/" + fieldPath;
Type type = field.getType();
if (type.isSimpleType()) {
continue; // not binary text
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-storage-sql
/**
* Gets the column type from a Nuxeo Schema field, including its constrained length if any.
*/
public static ColumnType fromField(Field field) {
return fromFieldType(field.getType(), field.getMaxLength());
}
代码示例来源:origin: org.nuxeo.ecm.automation/nuxeo-automation-core
protected static String getRangeClause(String field, BucketRange bucketRange) {
Type type = Framework.getService(SchemaManager.class).getField(field).getType();
Double from = bucketRange.getFrom() != null ? bucketRange.getFrom() : Double.NEGATIVE_INFINITY;
Double to = bucketRange.getTo() != null ? bucketRange.getTo() : Double.POSITIVE_INFINITY;
if (type instanceof IntegerType) {
return field + " BETWEEN " + from.intValue() + " AND " + to.intValue();
} else if (type instanceof LongType) {
return field + " BETWEEN " + from.longValue() + " AND " + to.longValue();
}
return field + " BETWEEN " + from + " AND " + to;
}
内容来源于网络,如有侵权,请联系作者删除!