Clones the given element bean with a different set of settings.<p>

@param source the element to clone
@param settings the new settings

@return the element bean
194416
public static CmsContainerElementBean cloneWithSettings(
        CmsContainerElementBean source,
        Map<String, String> settings) {

        boolean createNew = source.m_createNew;
        if (settings.containsKey(CmsContainerElement.CREATE_AS_NEW)) {
            createNew = Boolean.valueOf(settings.get(CmsContainerElement.CREATE_AS_NEW)).booleanValue();
            settings = new HashMap<String, String>(settings);
            settings.remove(CmsContainerElement.CREATE_AS_NEW);
        }
        CmsContainerElementBean result = new CmsContainerElementBean(
            source.m_elementId,
            source.m_formatterId,
            settings,
            createNew);
        result.m_resource = source.m_resource;
        result.m_sitePath = source.m_sitePath;
        result.m_inMemoryOnly = source.m_inMemoryOnly;
        result.m_inheritanceInfo = source.m_inheritanceInfo;
        if (result.m_inMemoryOnly) {
            String editorHash = source.m_editorHash;
            if (editorHash.contains(CmsADEManager.CLIENT_ID_SEPERATOR)) {
                editorHash = editorHash.substring(0, editorHash.indexOf(CmsADEManager.CLIENT_ID_SEPERATOR));
            }
            editorHash += result.getSettingsHash();
            result.m_editorHash = editorHash;
        }
        return result;
    }
475297
public static <T, U> U convert(T source, Class<U> targetClass) {
        return BeanConvertStrategy.convertBean(source, targetClass);
    }
794371
public <T> T getOnce(final Class<T> clazz, final String name)
	{
		return new JAXBNamedResourceFactory<T>(this.config, this.factory, name, clazz).get();
	}
965517
public static void copyProperties(Object source, Object target, CopyOptions copyOptions) {
		if (null == copyOptions) {
			copyOptions = new CopyOptions();
		}
		BeanCopier.create(source, target, copyOptions).copy();
	}
362740
private static Node cloneNode(final Node dom) {
        final Transformer transformer;
        try {
            transformer = TransformerFactory.newInstance().newTransformer();
        } catch (final TransformerConfigurationException ex) {
            throw new IllegalStateException(
                "Could not create new Transformer to clone Node",
                ex
            );
        }
        final DOMSource source = new DOMSource(dom);
        try {
            final DOMResult result = new DOMResult();
            transformer.transform(source, result);
            return result.getNode();
        } catch (final TransformerException ex) {
            throw new IllegalArgumentException(
                String.format(
                    "Could not clone Node %s with Transformer %s",
                    source,
                    transformer
                ),
                ex
            );
        }
    }
569627
public static void copyAttributes(Element source, Map<String, String> dest) {
        NamedNodeMap attributes = source.getAttributes();

        if (attributes != null) {
            for (int i = 0; i < attributes.getLength(); i++) {
                Node attribute = attributes.item(i);
                dest.put(attribute.getNodeName(), attribute.getNodeValue());
            }
        }
    }
288265
public static <T> T fillBeanWithMap(Map<?, ?> map, T bean, CopyOptions copyOptions) {
		return fillBeanWithMap(map, bean, false, copyOptions);
	}
186217
public JRecordExtractor<T, Example>
  extractWithSettingsExample(String settings) {
    return new JRecordExtractor<>(JavaOps.extractWithSettingsExample(self, settings));
  }
408597
public static Field getField(Object source, String fieldName) {
        if (source == null) {
            return null;
        }
        return getField(source.getClass(), fieldName);
    }
292476
protected JSONObject elementToJson(CmsContainerElementBean element, Set<String> excludeSettings) {

        JSONObject data = null;
        try {
            data = new JSONObject();
            data.put(FavListProp.ELEMENT.name().toLowerCase(), element.getId().toString());
            if (element.getFormatterId() != null) {
                data.put(FavListProp.FORMATTER.name().toLowerCase(), element.getFormatterId().toString());
            }
            JSONObject properties = new JSONObject();
            for (Map.Entry<String, String> entry : element.getIndividualSettings().entrySet()) {
                String settingKey = entry.getKey();
                if (!excludeSettings.contains(settingKey)) {
                    properties.put(entry.getKey(), entry.getValue());
                }
            }
            data.put(FavListProp.PROPERTIES.name().toLowerCase(), properties);
        } catch (JSONException e) {
            // should never happen
            if (!LOG.isDebugEnabled()) {
                LOG.warn(e.getLocalizedMessage());
            }
            LOG.debug(e.getLocalizedMessage(), e);
            return null;
        }
        return data;
    }
326385
public static GatewayBean unmarshallGateway(Map<String, Object> source) {
        if (source == null) {
            return null;
        }
        GatewayBean bean = new GatewayBean();
        bean.setId(asString(source.get("id")));
        bean.setName(asString(source.get("name")));
        bean.setDescription(asString(source.get("description")));
        bean.setType(asEnum(source.get("type"), GatewayType.class));
        bean.setConfiguration(asString(source.get("configuration")));
        bean.setCreatedBy(asString(source.get("createdBy")));
        bean.setCreatedOn(asDate(source.get("createdOn")));
        bean.setModifiedBy(asString(source.get("modifiedBy")));
        bean.setModifiedOn(asDate(source.get("modifiedOn")));
        postMarshall(bean);
        return bean;
    }
744948
public static void copyAttributes(Map<String, String> source, Element dest) {
        for (Entry<String, String> entry : source.entrySet()) {
            dest.setAttribute(entry.getKey(), entry.getValue());
        }
    }
220801
public void setSource(final String sourceText) {
		String formattedSource;

		if (sourceText == null) {
			formattedSource = "";
		} else {
			formattedSource = WebUtilities.encode(sourceText); // XML escape content
		}

		source.setText(formattedSource);
	}
985915
protected void copyProperties(Object dest, Object source) {
        try {
            BeanUtils.copyProperties(dest, source);
        } catch (Exception e) {
            String errorMessage = MessageFormat.format("M:{0};;E:{1}",
                    e.getCause().getMessage(), e.toString());
            throw new WebApplicationException(errorMessage, Status.BAD_REQUEST);
        }
    }
1075882
public static Configuration copyConfiguration(final Configuration original) {
		Configuration copy = new MapConfiguration(new HashMap<String, Object>());

		for (Iterator<?> i = original.getKeys(); i.hasNext();) {
			String key = (String) i.next();
			Object value = original.getProperty(key);

			if (value instanceof List) {
				value = new ArrayList((List) value);
			}

			copy.setProperty(key, value);
		}

		return copy;
	}
1106825
public static <T> T cloneBean(final Object bean) {
		try {
			return (T) BeanUtils.cloneBean(bean);
		} catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) {
			throw new RuntimeException(e);
		}
	}
1201300
protected CmsContainerElementBean transformContainerElement(
        CmsObject cms,
        CmsTemplateMapperConfiguration config,
        CmsContainerElementBean element) {

        if (m_forSave) {
            try {
                element.initResource(cms);
            } catch (Exception e) {
                LOG.error(e.getLocalizedMessage(), e);
                return null;
            }
        }
        Map<String, String> settings = element.getIndividualSettings();
        if (settings == null) {
            settings = new HashMap<>();
        }
        Map<String, String> newSettings = new HashMap<>();
        for (Map.Entry<String, String> entry : settings.entrySet()) {
            String key = entry.getKey();
            if (CmsTemplateContextInfo.SETTING.equals(key)) {
                continue;
            }
            String value = entry.getValue();
            if (value == null) {
                continue;
            }
            String newValue = value;
            if (key.startsWith(CmsFormatterConfig.FORMATTER_SETTINGS_KEY)) {
                if (CmsUUID.isValidUUID(value)) {
                    String newId = config.getMappedFormatterConfiguration(value);
                    if (newId != null) {
                        newValue = newId;
                    }
                } else if (value.startsWith(CmsFormatterConfig.SCHEMA_FORMATTER_ID)) {
                    String schemaFormatterIdStr = value.substring(CmsFormatterConfig.SCHEMA_FORMATTER_ID.length());
                    if (CmsUUID.isValidUUID(schemaFormatterIdStr)) {
                        CmsUUID schemaFormatterId = new CmsUUID(schemaFormatterIdStr);
                        CmsUUID mappedFormatterId = config.getMappedFormatterJspId(schemaFormatterId);
                        if (mappedFormatterId != null) {
                            newValue = CmsFormatterConfig.SCHEMA_FORMATTER_ID + mappedFormatterId;
                        }
                    }
                }
            }
            newSettings.put(key, newValue);
        }
        CmsContainerElementBean newElement = element.clone();
        newElement.updateIndividualSettings(newSettings);
        CmsUUID formatterId = element.getFormatterId();
        if ((formatterId == null) && m_forSave) {
            try {
                if (element.isGroupContainer(cms)) {
                    // ID for group-container.jsp
                    formatterId = new CmsUUID("e7029fa2-761e-11e0-bd7f-9ffeadaf4d46");
                    newElement.setFormatterId(formatterId);
                } else if (OpenCms.getResourceManager().matchResourceType(
                    "function",
                    element.getResource().getTypeId())) {
                    formatterId = new CmsUUID("087ba7c9-e7fc-4336-acb8-d3416a4eb1fd");
                    newElement.setFormatterId(formatterId);
                }
            } catch (CmsException e) {
                LOG.warn(e.getLocalizedMessage(), e);
            }
        }
        CmsUUID mappedFormatterJspId = config.getMappedFormatterJspId(formatterId);
        if (mappedFormatterJspId != null) {
            newElement.setFormatterId(mappedFormatterJspId);
        }
        return newElement;
    }