Crates a deep copy of a {@link PUBLISH} object.
<p/>
Use this method if you want to reuse a publish received by a callback to prevent side effects.

@param original the original PUBLISH message
@return a deep copy of the original PUBLISH message
488205
public static PUBLISH copy(final PUBLISH original) {
        final PUBLISH publish = new PUBLISH();
        publish.setQoS(original.getQoS());
        publish.setRetain(original.isRetain());
        publish.setPayload(original.getPayload());
        publish.setTopic(original.getTopic());
        publish.setDuplicateDelivery(original.isDuplicateDelivery());
        publish.setMessageId(original.getMessageId());
        publish.setTTL(original.getTTL());
        return publish;
    }
796737
public SomeUnpublishedObject create(
            final String name) {
        final SomeUnpublishedObject obj = container.newTransientInstance(SomeUnpublishedObject.class);
        obj.setName(name);
        container.persistIfNotAlready(obj);
        return obj;
    }
389300
@Override
	public AbstractMessage copy()
    {
        ObjectMessageImpl clone = new ObjectMessageImpl();
        copyCommonFields(clone);
        clone.body = this.body;
        
        return clone;
    }
1017055
public static EditableDocument newDocument( Document original ) {
        BasicDocument newDoc = new BasicDocument();
        newDoc.putAll(original);
        return new DocumentEditor(newDoc, DEFAULT_FACTORY);
    }
1044098
public int originalFrame() {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) JmfTr.entry(this, tc, "originalFrame");

    int result;
    synchronized (getMessageLockArtefact()) {

      if ((contents == null) || reallocated) {
        result = -1;
      }
      else {
        result = length;
      }
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) JmfTr.exit(this, tc, "originalFrame", Integer.valueOf(result));
    return result;
  }
632356
void lazyCopy(JSMessageData original) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            JmfTr.entry(this, tc, "lazyCopy", new Object[] { original });

        synchronized (getMessageLockArtefact()) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                JmfTr.debug(this, tc, "lazyCopy locked dest ", new Object[] { getMessageLockArtefact() });

            // This is the only occasion that we reach out and lock another message instance
            // but we work on the assumption that lazy copying is happening as part of
            // instantiation of a new message instance, so the potential for deadlocking
            // is nil, since no other thread knows about this instance and can not therefore
            // be concurrently supplying 'this' as the 'original' argument in another thread.
            synchronized (original.getMessageLockArtefact()) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    JmfTr.debug(this, tc, "lazyCopy locked source ", new Object[] { original.getMessageLockArtefact() });

                // Copy common fields
                indirect = original.indirect;

                // If the message is assembled (i.e. we have a contents buffer) we share both the
                // buffer and the cache between original and copy.
                // If the message is unassembled (no contents buffer) we just share the cache.
                // In either case if a change later needs to be made to the shared portion we
                // will need to copy it before changing, so the shared flags is set to
                // indicate sharing exists between unrelated parts.
                if (original.contents == null) {
                    contents = null;
                    original.sharedCache = true;
                    sharedCache = true;
                    cache = original.cache;
                }
                else {
                    original.sharedContents = true;
                    sharedContents = true;
                    contents = original.contents;
                    original.sharedCache = true;
                    sharedCache = true;
                    cache = original.cache;
                }

                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    JmfTr.debug(this, tc, "lazyCopy unlocking source ", new Object[] { original.getMessageLockArtefact() });
            }

            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                JmfTr.debug(this, tc, "lazyCopy unlocking dest ", new Object[] { getMessageLockArtefact() });
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            JmfTr.exit(this, tc, "lazyCopy");
    }
1099416
public static final Object deepCopy(Object source, final KunderaMetadata kunderaMetadata)
    {
        Map<Object, Object> copiedObjectMap = new HashMap<Object, Object>();

        Object target = deepCopyUsingMetadata(source, copiedObjectMap, kunderaMetadata);

        copiedObjectMap.clear();
        copiedObjectMap = null;

        return target;
    }
655038
public static <T> T[] copyOf(final T[] original, final int newLength) {
        if (newLength == original.length) {
            return original.clone();
        }

        return (T[]) copyOf(original, newLength, original.getClass());
    }
1309755
protected byte[] copyOf(byte[] original, int newLength) {

        byte[] copy = new byte[newLength];

        System.arraycopy(original, 0, copy, 0,
                         Math.min(original.length, newLength));

        return copy;
    }
412372
public static Object duplicate(Object object, boolean deepCopy) {
	if (object == null) return null;
	if (object instanceof Number) return object;
	if (object instanceof String) return object;
	if (object instanceof Date) return ((Date) object).clone();
	if (object instanceof Boolean) return object;

	RefBoolean before = new RefBooleanImpl();
	try {
	    Object copy = ThreadLocalDuplication.get(object, before);
	    if (copy != null) {
		return copy;
	    }

	    if (object instanceof Collection) return ((Collection) object).duplicate(deepCopy);
	    if (object instanceof Duplicable) return ((Duplicable) object).duplicate(deepCopy);
	    if (object instanceof UDF) return ((UDF) object).duplicate();
	    if (object instanceof List) return duplicateList((List) object, deepCopy);
	    if (object instanceof Map) return duplicateMap((Map) object, deepCopy);
	    if (object instanceof Serializable) {
		try {
		    String ser = JavaConverter.serialize((Serializable) object);
		    return JavaConverter.deserialize(ser);

		}
		catch (Throwable t) {
		    ExceptionUtil.rethrowIfNecessary(t);
		}
	    }
	}
	finally {
	    if (!before.toBooleanValue()) ThreadLocalDuplication.reset();
	}

	return object;
    }
284106
public BaseMessage getOriginalMessage(BaseMessage messageResponseIn)
    {
        BaseMessage messageOrig = null;
        TrxMessageHeader trxMessageHeader = (TrxMessageHeader)messageResponseIn.getMessageHeader();
        String strOrigTrxID = (String)trxMessageHeader.get(TrxMessageHeader.ORIG_LOG_TRX_ID);
        MessageLogModel recMessageLog = this.getMessageLog(strOrigTrxID);
        if ((recMessageLog != null)
            && ((recMessageLog.getEditMode() == DBConstants.EDIT_CURRENT)
                || (recMessageLog.getEditMode() == DBConstants.EDIT_IN_PROGRESS)))
        {
            messageOrig = (BaseMessage)recMessageLog.createMessage(strOrigTrxID);
        }
        return messageOrig;
    }
352405
public void publishTo(final K key, final Publisher<V> publisher) {
        registered.get(key).fromStream(Spouts.from(publisher));
    }
900753
public @Nonnull ContentMapping getMappingOrCreate(@Nonnull String original, @Nonnull Function<String, ContentMapping> generator) {
        boolean isNew = !mappings.containsKey(original);
        ContentMapping mapping = mappings.computeIfAbsent(original, generator);
        try {
            if (isNew) {
                save();
            }
        } catch (IOException e) {
            LOGGER.log(Level.WARNING, "Could not save mappings file", e);
        }
        return mapping;
    }
1273441
public static Version copy(Version version) {
        if (version == null) {
            return null;
        }
        Version result = new Version();
        result.labels = new LinkedList<String>(version.labels);
        result.numbers = new LinkedList<Integer>(version.numbers);
        result.snapshot = version.snapshot;
        return result;
    }
1018641
public static CmsParameterConfiguration unmodifiableVersion(CmsParameterConfiguration original) {

        return new CmsParameterConfiguration(
            Collections.unmodifiableMap(original.m_configurationStrings),
            original.m_configurationObjects);
    }
938909
private static void logOriginal(Status original) {
		String text = original.getText();
		String message = String.format(MESSAGE_ORIGINAL, text);
		System.out.println(message);
	}
1016787
private List<List<Double>> deepCopy(final List<List<Double>> original) {
    final List<List<Double>> result = new ArrayList<>(original.size());
    for (final List<Double> originalRow : original) {
      final List<Double> row = new ArrayList<>(originalRow.size());
      for (final double element : originalRow) {
        row.add(element);
      }
      result.add(row);
    }
    return result;
  }