本文整理了Java中org.nuxeo.ecm.core.api.model.Property.isList()
方法的一些代码示例,展示了Property.isList()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Property.isList()
方法的具体详情如下:
包路径:org.nuxeo.ecm.core.api.model.Property
类名称:Property
方法名:isList
[英]Tests whether this property is of a list type.
[中]测试此属性是否为列表类型。
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
protected void setIsMoved() {
if (parent == null || !parent.isList()) {
throw new IllegalStateException("Cannot set IS_MOVED on removed or properties that are not map elements");
}
if ((flags & IS_MOVED) == 0) {
flags |= IS_MOVED;
((AbstractProperty) parent).setIsModified();
}
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
@Override
public void moveTo(int index) {
if (parent == null || !parent.isList()) {
throw new UnsupportedOperationException("Not a list item property");
}
ListProperty list = (ListProperty) parent;
if (list.moveTo(this, index)) {
setIsMoved();
}
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
protected void getXPath(StringBuilder buf) {
if (parent != null) {
((AbstractProperty) parent).getXPath(buf);
if (parent.isList()) {
buf.append('/');
int i = ((ListProperty) parent).children.indexOf(this);
buf.append(i);
} else {
if (buf.length() != 0) {
buf.append('/');
}
buf.append(getName());
}
}
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
@Override
public Object visit(ScalarProperty property, Object arg) throws PropertyException {
Serializable value = property.getValue();
if (property.getParent().isList()) {
((Collection<Serializable>) arg).add(value);
} else {
((Map<String, Serializable>) arg).put(getName(property), value);
}
return null;
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
protected Path collectPath(Path path) {
String name = getName();
if (parent != null) {
if (parent.isList()) {
int i = ((ListProperty) parent).children.indexOf(this);
name = name + '[' + i + ']';
}
path = ((AbstractProperty) parent).collectPath(path);
}
return path.append(name);
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
protected void setIsRemoved() {
if (isPhantom() || parent == null || parent.isList()) {
throw new IllegalStateException("Cannot set IS_REMOVED on removed or properties that are not map elements");
}
if ((flags & IS_REMOVED) == 0) { // if not already removed
// clear dirty + phatom flag if any
setDirtyFlags(IS_REMOVED);
((AbstractProperty) parent).setIsModified();
}
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
@Override
public Object visit(ListProperty property, Object arg) throws PropertyException {
Serializable value;
if (property.isContainer()) {
value = new ArrayList<Serializable>();
} else {
value = property.getValue();
}
if (property.getParent().isList()) {
((Collection<Serializable>) arg).add(value);
} else {
((Map<String, Serializable>) arg).put(getName(property), value);
}
return value;
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
@Override
public Object visit(MapProperty property, Object arg) throws PropertyException {
Serializable value;
if (property.isContainer()) {
value = new HashMap<String, Serializable>();
} else {
value = property.getValue();
}
if (BlobProperty.class.isAssignableFrom(property.getClass())) {
value = property.getValue();
if (property.getParent().isList()) {
((Collection<Serializable>) arg).add(value);
} else {
((Map<String, Serializable>) arg).put(getName(property), value);
}
return null;
} else if (property.getParent().isList()) {
((Collection<Serializable>) arg).add(value);
} else {
((Map<String, Serializable>) arg).put(getName(property), value);
}
return value;
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api
@Override
public Serializable remove() throws PropertyException {
Serializable value = getValue();
if (parent != null && parent.isList()) { // remove from list is
// handled separately
ListProperty list = (ListProperty) parent;
list.remove(this);
} else if (!isPhantom()) { // remove from map is easier -> mark the
// field as removed and remove the value
// do not remove the field if the previous value was null, except if its a property from a
// SimpleDocumentModel (forceDirty mode)
Serializable previous = internalGetValue();
init(null);
if (previous != null || isForceDirty()) {
setIsRemoved();
}
}
return value;
}
代码示例来源:origin: org.nuxeo.binary.metadata/nuxeo-binary-metadata
if (doc.getProperty(property).isList()) {
if (!metadataIsArray) {
metadataValue = Arrays.asList(metadataValue);
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-io
protected void writeProperty(JsonGenerator jg, Property prop) throws IOException {
if (prop.isScalar()) {
writeScalarProperty(jg, prop);
} else if (prop.isList()) {
writeListProperty(jg, prop);
} else if (prop instanceof BlobProperty) { // a blob
writeBlobProperty(jg, (BlobProperty) prop);
} else if (prop.isComplex()) {
writeComplexProperty(jg, prop);
} else if (prop.isPhantom()) {
jg.writeNull();
}
}
代码示例来源:origin: org.nuxeo.elasticsearch/nuxeo-elasticsearch-core
if (prop.isList()) {
ListType t = (ListType) prop.getType();
t.getField();
代码示例来源:origin: org.nuxeo.ecm.automation/nuxeo-automation-core
/**
* Removes a property from a document given the xpath. If the xpath points to a list property the list will be
* cleared. If the path points to a blob in a list the property is removed from the list. Otherwise the xpath should
* point to a non list property that will be removed.
*/
public static void removeProperty(DocumentModel doc, String xpath) {
Property p = doc.getProperty(xpath);
if (p instanceof ListProperty) {
((ListProperty) p).clear();
} else {
Property pp = p.getParent();
if (pp != null && pp.isList()) { // remove list entry
((ListProperty) pp).remove(p);
} else {
p.remove();
}
}
}
代码示例来源:origin: org.nuxeo.ecm.automation/nuxeo-automation-core
/**
* Converts the value of the given core property to JSON.
*
* @param fieldNameWriter the field name writer is used to write the field name depending on writer configuration,
* this parameter also allows us to handle different cases: field with prefix, field under complex
* property, or nothing for arrays and lists
*/
protected void writeProperty(JsonGenerator jg, Property prop, PropertyConsumer fieldNameWriter)
throws PropertyException, IOException {
if (prop.isScalar()) {
writeScalarProperty(jg, prop, fieldNameWriter);
} else if (prop.isList()) {
writeListProperty(jg, prop, fieldNameWriter);
} else {
if (prop.isPhantom()) {
if (writeNull) {
fieldNameWriter.accept(jg, prop);
jg.writeNull();
}
} else if (prop instanceof BlobProperty) { // a blob
writeBlobProperty(jg, prop, fieldNameWriter);
} else { // a complex property
writeMapProperty(jg, (ComplexProperty) prop, fieldNameWriter);
}
}
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-io
protected Property readProperty(Property parent, Field field, JsonNode jn) throws IOException {
Property property = PropertyFactory.createProperty(parent, field, 0);
if (jn.isNull()) {
property.setValue(null);
} else if (property.isScalar()) {
fillScalarProperty(property, jn);
} else if (property.isList()) {
fillListProperty(property, jn);
} else {
if (!(property instanceof BlobProperty)) {
fillComplexProperty(property, jn);
} else {
Blob blob = readEntity(Blob.class, Blob.class, jn);
property.setValue(blob);
}
}
return property;
}
代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-contentview-jsf
@Override
public Object visit(ScalarProperty property, Object arg) throws PropertyException {
if (property.getParent() instanceof BlobProperty) {
log.warn("Property '"
+ property.getName()
+ "' ignored during serialization. Blob and blob related properties are not written to json object.");
return null;
}
// convert values if needed
Serializable value = property.getValue();
if (value instanceof Calendar) {
value = dateFormat.format(((Calendar) value).getTime());
}
// build json
if (property.getParent().isList()) {
((JSONArray) arg).add(value);
} else {
try {
((JSONObject) arg).put(property.getField().getName().getPrefixedName(), value);
} catch (JSONException e) {
throw new PropertyException("Failed to put value", e);
}
}
return null;
}
代码示例来源:origin: org.nuxeo.ecm.automation/nuxeo-automation-core
/**
* Given a document property, updates its value with the given blob. The property can be a blob list or a blob. If a
* blob list the blob is appended to the list, if a blob then it will be set as the property value. Both blob list
* formats are supported: the file list (blob holder list) and simple blob list.
*/
public static void addBlob(Property p, Blob blob) throws PropertyException {
if (p.isList()) {
// detect if a list of simple blobs or a list of files (blob
// holder)
Type ft = ((ListProperty) p).getType().getFieldType();
if (ft.isComplexType() && ((ComplexType) ft).getFieldsCount() == 1) {
p.addValue(createBlobHolderMap(blob));
} else {
p.addValue(blob);
}
} else {
p.setValue(blob);
}
}
代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-contentview-jsf
@Override
public Object visit(MapProperty property, Object arg) throws PropertyException {
Object value;
if (property.isContainer()) {
value = new JSONObject();
} else {
value = property.getValue();
}
if (property instanceof BlobProperty) {
log.warn("Property '"
+ property.getName()
+ "' ignored during serialization. Blob and blob related properties are not written to json object.");
} else if (property.getParent() instanceof BlobProperty) {
log.warn("Property '"
+ property.getName()
+ "' ignored during serialization. Blob and blob related properties are not written to json object.");
} else if (property.getParent().isList()) {
((JSONArray) arg).add(value);
} else {
try {
((JSONObject) arg).put(property.getField().getName().getPrefixedName(), value);
} catch (JSONException e) {
throw new PropertyException("Failed to put value", e);
}
}
return value;
}
代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-contentview-jsf
@Override
public Object visit(ListProperty property, Object arg) throws PropertyException {
Object value;
if (property.isContainer()) {
value = new JSONArray();
} else {
value = property.getValue();
}
if (property.getParent() instanceof BlobProperty) {
log.warn("Property '"
+ property.getName()
+ "' ignored during serialization. Blob and blob related properties are not written to json object.");
} else if (property.getParent().isList()) {
((JSONArray) arg).add(value);
} else {
try {
((JSONObject) arg).put(property.getField().getName().getPrefixedName(), value);
} catch (JSONException e) {
throw new PropertyException("Failed to put value", e);
}
}
return value;
}
代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-rendering
if (p.isScalar()) {
return new PropertyWrapper(this).wrap(p);
} else if (p.isList()) {
if (obj instanceof ListProperty) {
return new ListPropertyTemplate(this, (ListProperty) obj);
内容来源于网络,如有侵权,请联系作者删除!