本文整理了Java中org.apache.jackrabbit.oak.api.Type
类的一些代码示例,展示了Type
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Type
类的具体详情如下:
包路径:org.apache.jackrabbit.oak.api.Type
类名称:Type
[英]Instances of this class map Java types to PropertyType. Passing an instance of this class to PropertyState#getValue(Type) determines the return type of that method.
[中]此类的实例将Java类型映射到PropertyType。将此类的实例传递给PropertyState#getValue(Type)将确定该方法的返回类型。
代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak
/**
* @see javax.jcr.Value#getType()
*/
@Override
public int getType() {
return type.tag();
}
代码示例来源:origin: apache/jackrabbit-oak
/**
* Determine the array type which has this type as base type
* @return array type with this type as base type
* @throws IllegalStateException if {@code isArray} is true.
*/
public Type<?> getArrayType() {
checkState(!isArray(), "Not a simply type");
return fromTag(tag, true);
}
代码示例来源:origin: apache/jackrabbit-oak
/**
* @see Object#equals(Object)
*/
@Override
public boolean equals(Object other) {
if (other instanceof ValueImpl) {
ValueImpl that = (ValueImpl) other;
Type<?> thisType = this.type;
if (thisType.isArray()) {
thisType = thisType.getBaseType();
}
Type<?> thatType = that.type;
if (thatType.isArray()) {
thatType = thatType.getBaseType();
}
try {
return thisType == thatType
&& Objects.equal(
getValue(thatType, index),
that.getValue(thatType, that.index));
} catch (RepositoryException e) {
LOG.warn("Error while comparing values", e);
return false;
}
} else {
return false;
}
}
代码示例来源:origin: org.apache.jackrabbit/oak-solr-core
@Override
public String getFieldNameFor(Type<?> propertyType) {
for (String typeMapping : typeMappings) {
String[] mapping = typeMapping.split("=");
if (mapping.length == 2 && mapping[0] != null && mapping[1] != null) {
Type<?> type = Type.fromString(mapping[0]);
if (type != null && type.tag() == propertyType.tag()) {
return mapping[1];
}
}
}
return null;
}
代码示例来源:origin: apache/jackrabbit-oak
/**
* Returns the numeric constant value of the type with the specified name.
*
* In contrast to {@link javax.jcr.PropertyType#valueFromName(String)} this method
* requires all type names to be all upper case.
* See also: OAK-294 and http://java.net/jira/browse/JSR_283-811
*
* @param name the name of the property type.
* @return the numeric constant value.
* @throws IllegalStateException if {@code name} is not a valid property type name.
*/
public static int valueFromName(String name) {
Type<?> type = Type.fromString(name);
if (type.isArray()) {
throw new IllegalStateException("unknown property type: " + name);
}
return type.tag();
}
代码示例来源:origin: org.apache.jackrabbit/oak-core
@NotNull
@Override
public PropertyDefinition getDefinition(
Tree parent, PropertyState property, boolean exactTypeMatch)
throws RepositoryException {
Type<?> type = property.getType();
EffectiveNodeType effective = getEffectiveNodeType(parent);
return effective.getPropertyDefinition(
property.getName(), type.isArray(), type.tag(), exactTypeMatch);
}
代码示例来源:origin: apache/jackrabbit-oak
private boolean addTypedOrderedFields(D doc,
PropertyState property,
String pname,
PropertyDefinition pd) {
// Ignore and warn if property multi-valued as not supported
if (property.getType().isArray()) {
log.warn(
"[{}] Ignoring ordered property {} of type {} for path {} as multivalued ordered property not supported",
getIndexName(), pname,
Type.fromTag(property.getType().tag(), true), path);
return false;
}
int tag = property.getType().tag();
int idxDefinedTag = pd.getType();
// Try converting type to the defined type in the index definition
if (tag != idxDefinedTag) {
log.debug(
"[{}] Ordered property defined with type {} differs from property {} with type {} in "
+ "path {}",
getIndexName(),
Type.fromTag(idxDefinedTag, false), property.toString(),
Type.fromTag(tag, false), path);
tag = idxDefinedTag;
}
return indexTypeOrderedFields(doc, pname, tag, property, pd);
}
代码示例来源:origin: org.apache.jackrabbit/oak-jcr
@NotNull
protected PropertyState createMultiState(
String oakName, List<Value> values, Type<?> type)
throws RepositoryException {
if (values.isEmpty()) {
Type<?> base = type.getBaseType();
if (base == UNDEFINED) {
base = STRING;
}
return PropertyBuilder.array(base)
.setName(oakName).getPropertyState();
}
if (type == UNDEFINEDS) {
type = Type.fromTag(values.get(0).getType(), true);
}
if (type == NAMES || type == PATHS) {
Type<?> base = type.getBaseType();
List<String> strings = newArrayListWithCapacity(values.size());
for (Value value : values) {
strings.add(getOakValue(value, base));
}
return createProperty(oakName, strings, type);
} else {
return createProperty(oakName, values, type.tag());
}
}
代码示例来源:origin: apache/jackrabbit-oak
public void serialize(PropertyState property) {
Type<?> type = property.getType();
if (!type.isArray()) {
serialize(property, type, 0);
} else {
Type<?> base = type.getBaseType();
int count = property.count();
if (base == STRING || count > 0) {
json.array();
for (int i = 0; i < count; i++) {
serialize(property, base, i);
}
json.endArray();
} else {
// type-safe encoding of an empty array
json.value(TypeCodes.EMPTY_ARRAY
+ PropertyType.nameFromValue(type.tag()));
}
}
}
代码示例来源:origin: apache/jackrabbit-oak
private void assertTypeLessThan(Type<?> a, Type<?> b) {
assertTrue(a.compareTo(b) < 0);
assertTrue(b.compareTo(a) > 0);
if (a.tag() > b.tag()) {
fail("Types should be ordered by increasing tag value");
}
if (b.tag() == a.tag() && a.isArray() && !b.isArray()) {
fail("If their tag is the same, types should be ordered by multiplicity");
}
}
代码示例来源:origin: apache/jackrabbit-oak
Type.fromString(TreeUtil.getString(definition, JCR_REQUIREDTYPE));
if (requiredType != Type.UNDEFINED) {
if (TreeUtil.getBoolean(definition, JCR_MULTIPLE)) {
requiredType = requiredType.getArrayType();
ValueHelper.checkSupportedConversion(propertyState.getType().tag(), requiredType.tag());
propertyState = PropertyStates.convert(propertyState, requiredType);
代码示例来源:origin: apache/jackrabbit-oak
/**
* Create a new instance for building {@code PropertyState} instances
* of the given {@code type}.
* @param type type of the {@code PropertyState} instances to be built.
* @throws IllegalArgumentException if {@code type.isArray()} is {@code true}.
*/
public PropertyBuilder(Type<T> type) {
checkArgument(!type.isArray(), "type must not be array");
this.type = type;
}
代码示例来源:origin: apache/jackrabbit-oak
private boolean indexFacets(D doc, PropertyState property, String pname, PropertyDefinition pd) {
int tag = property.getType().tag();
int idxDefinedTag = pd.getType();
// Try converting type to the defined type in the index definition
if (tag != idxDefinedTag) {
log.debug("[{}] Facet property defined with type {} differs from property {} with type {} in "
+ "path {}",
getIndexName(),
Type.fromTag(idxDefinedTag, false), property.toString(),
Type.fromTag(tag, false), path);
tag = idxDefinedTag;
}
return indexFacetProperty(doc, tag, property, pname);
}
代码示例来源:origin: apache/jackrabbit-oak
@NotNull
protected PropertyState createSingleState(
String oakName, Value value, Type<?> type)
throws RepositoryException {
if (type == UNDEFINED) {
type = Type.fromTag(value.getType(), false);
}
if (type == NAME || type == PATH) {
return createProperty(oakName, getOakValue(value, type), type);
} else {
return createProperty(oakName, value);
}
}
代码示例来源:origin: apache/jackrabbit-oak
@Override
public Converter getConverter(String value) {
return Conversions.convert(value, type.getBaseType());
}
代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak
@Override
public String toString() {
StringBuilder builder = new StringBuilder("- ");
if (getOakName() == null) {
builder.append(RESIDUAL_NAME);
} else {
builder.append(getOakName());
}
if (requiredType != PropertyType.STRING) {
builder.append(" (");
builder.append(Type.fromTag(requiredType, false).toString());
builder.append(")");
}
if (isAutoCreated()) {
builder.append(" a");
}
if (isProtected()) {
builder.append(" p");
}
if (isMandatory()) {
builder.append(" m");
}
if (getOnParentVersion() != OnParentVersionAction.COPY) {
builder.append(" ");
builder.append(OnParentVersionAction.nameFromValue(getOnParentVersion()));
}
return builder.toString();
}
代码示例来源:origin: apache/jackrabbit-oak
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
} else if (object instanceof PropertyTemplate) {
PropertyTemplate that = (PropertyTemplate) object;
return name.equals(that.name) && type.equals(that.type);
} else {
return false;
}
}
代码示例来源:origin: apache/jackrabbit-oak
result = PropertyStates.createProperty("value", values.get(0), type);
} else {
type = type.getArrayType();
result = PropertyStates.createProperty("value", values, type);
代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak
@Nonnull
@Override
public PropertyDefinition getDefinition(
Tree parent, PropertyState property, boolean exactTypeMatch)
throws RepositoryException {
Type<?> type = property.getType();
EffectiveNodeType effective = getEffectiveNodeType(parent);
return effective.getPropertyDefinition(
property.getName(), type.isArray(), type.tag(), exactTypeMatch);
}
代码示例来源:origin: org.apache.jackrabbit/oak-core
/**
* Returns the numeric constant value of the type with the specified name.
*
* In contrast to {@link javax.jcr.PropertyType#valueFromName(String)} this method
* requires all type names to be all upper case.
* See also: OAK-294 and http://java.net/jira/browse/JSR_283-811
*
* @param name the name of the property type.
* @return the numeric constant value.
* @throws IllegalStateException if {@code name} is not a valid property type name.
*/
public static int valueFromName(String name) {
Type<?> type = Type.fromString(name);
if (type.isArray()) {
throw new IllegalStateException("unknown property type: " + name);
}
return type.tag();
}
内容来源于网络,如有侵权,请联系作者删除!