/** * {@inheritDoc} * * @see com.xpn.xwiki.objects.BaseElement#clone() */ @Override public Object clone() { BaseProperty property = (BaseProperty) super.clone(); property.setObject(getObject()); return property; }
/** * {@inheritDoc} * * @see com.xpn.xwiki.objects.ObjectInterface#safeput(java.lang.String, com.xpn.xwiki.objects.PropertyInterface) */ public void safeput(String name, PropertyInterface property) { addField(name, property); if (property instanceof BaseProperty) { ((BaseProperty) property).setObject(this); ((BaseProperty) property).setName(name); } }
public void fromXML(Element pcel) throws XWikiException { List list = pcel.elements(); BaseClass bclass = getxWikiClass(); for (int i = 0; i < list.size(); i++) { Element ppcel = (Element) list.get(i); String name = ppcel.getName(); if (bclass == null) { Object[] args = {getClass().getName()}; throw new XWikiException(XWikiException.MODULE_XWIKI_CLASSES, XWikiException.ERROR_XWIKI_CLASSES_PROPERTY_CLASS_IN_METACLASS, "Cannot find property class {0} in MetaClass object", null, args); } PropertyClass pclass = (PropertyClass) bclass.safeget(name); if (pclass != null) { BaseProperty bprop = pclass.newPropertyfromXML(ppcel); bprop.setObject(this); safeput(name, bprop); } } }
BaseProperty property = pclass.newPropertyfromXML(pcel); property.setName(name); property.setObject(this); safeput(name, property);
public BaseCollection fromValueMap(Map<String, ? > map, BaseCollection object) { for (PropertyClass property : (Collection<PropertyClass>) getFieldList()) { String name = property.getName(); Object formvalue = map.get(name); if (formvalue != null) { BaseProperty objprop; objprop = property.fromValue(formvalue); if (objprop != null) { objprop.setObject(object); object.safeput(name, objprop); } } } return object; }
/** * Initialize statistics object from XML schema. * * @param oel the XML root node containing statistics datas. * @throws XWikiException error when parsing XML schema. */ public void fromXML(Element oel) throws XWikiException { Element cel = oel.element("class"); BaseClass bclass = new BaseClass(); if (cel != null) { bclass.fromXML(cel); setClassName(bclass.getName()); } setName(oel.element(XMLNODE_NAME).getText()); List< ? > list = oel.elements(XMLNODE_PROPERTY); for (int i = 0; i < list.size(); i++) { Element pcel = (Element) ((Element) list.get(i)).elements().get(0); String name = pcel.getName(); PropertyClass pclass = (PropertyClass) bclass.get(name); if (pclass != null) { BaseProperty property = pclass.newPropertyfromXML(pcel); property.setName(name); property.setObject(this); safeput(name, property); } } } }
public BaseCollection fromMap(Map<String, ? > map, BaseCollection object) { for (PropertyClass property : (Collection<PropertyClass>) getFieldList()) { String name = property.getName(); Object formvalues = map.get(name); if (formvalues != null) { BaseProperty objprop; if (formvalues instanceof String[]) { objprop = property.fromStringArray(((String[]) formvalues)); } else { objprop = property.fromString(formvalues.toString()); } if (objprop != null) { objprop.setObject(object); object.safeput(name, objprop); } } } return object; }
/** * Create and add the main tag property to the provided tag object. The new property corresponds to the definition * in the tag class, but in case of an error, the default type is a relational-stored list. * * @param tagObject the target tag object * @param context the current request context * @return the created property * @see #TAG_PROPERTY */ private BaseProperty createTagProperty(BaseObject tagObject, XWikiContext context) { BaseProperty tagProperty; try { BaseClass tagClass = context.getWiki().getClass(TAG_CLASS, context); PropertyClass tagPropertyDefinition = (PropertyClass) tagClass.getField(TAG_PROPERTY); tagProperty = tagPropertyDefinition.newProperty(); } catch (XWikiException ex) { LOGGER.warn("Failed to properly create tag property for the tag object, creating a default one"); tagProperty = new DBStringListProperty(); } tagProperty.setName(TAG_PROPERTY); tagProperty.setObject(tagObject); tagObject.safeput(TAG_PROPERTY, tagProperty); return tagProperty; }
property.setObject(object); property.setName(name); loadXWikiProperty(property, context, false);