合并已经存在的Xml元素

@param src  The source xml element for merging
@param dest The dest xml element for merging
510756
protected void mergeExistedElement(XmlElement src, XmlElement dest) {

    // 合并属性
    List<Attribute> srcAttributes = src.getAttributes();
    List<Attribute> destAttributes = dest.getAttributes();
    for (Attribute srcAttr : srcAttributes) {
      Attribute matched = null;
      for (Attribute destAttr : destAttributes) {
        if (StringUtils.equals(srcAttr.getName(), destAttr.getName()) &&
            StringUtils.equals(srcAttr.getValue(), destAttr.getValue())) {
          matched = destAttr;
        }
      }
      // 不存在则添加到目标元素的属性列表中
      if (matched == null) {
        destAttributes.add(srcAttributes.indexOf(srcAttr), srcAttr);
      }
    }

    // 重组子节点
    // reformationTheElementChilds(src);
    // reformationTheElementChilds(dest);

    // 暂时不做处理 ---留待后续添加
  }
492403
function (src, dest) {
            // IE has a mergeAttributes method which does exactly that. Let's use it directly.
            // Note that copying attributes with a loop on attributes and setAttributes has strange results on IE7 (for
            // example, a TR can appear as disabled)
            if (Aria.$window.document.body.mergeAttributes) {
                this.copyAttributes = function (src, dest) {
                    dest.mergeAttributes(src, false);
                };
            } else {
                this.copyAttributes = function (src, dest) {
                    // on other browsers, let's copy the attributes manually:
                    var srcAttr = src.attributes;
                    for (var i = 0, l = srcAttr.length; i < l; i++) {
                        var attr = srcAttr[i];
                        dest.setAttribute(attr.name, attr.value);
                    }
                };
            }

            this.copyAttributes(src, dest);
        }
352712
public function copy( Table $src, Table $dest ) {

		$this->copy_structure( $src, $dest );
		$src_table  = $this->database->quote_identifier( $src->name() );
		$dest_table = $this->database->quote_identifier( $dest->name() );
		$query      = "INSERT INTO {$dest_table} SELECT * FROM {$src_table}";

		return (bool) $this->database->query( $query );
	}
1115349
public static ByteBuffer copy(ByteBuffer src, ByteBuffer dest, int length) {
		return copy(src, src.position(), dest, dest.position(), length);
	}
262839
public static function appendTo($src, $dest, $newline = false) {

        // Open the destination.
        $reader = @fopen($src, "r");
        if (false === $reader) {
            throw new FileNotFoundException($src);
        }

        // Open the destination.
        $writer = @fopen($dest, "a");
        if (false === $writer) {
            throw new IOException(sprintf("Failed to open \"%s\"", $dest));
        }

        // Append the source into destination.
        if (false === @file_put_contents($dest, $reader, FILE_APPEND)) {
            throw new IOException(sprintf("Failed to append \"%s\" into \"%s\"", $src, $dest));
        }

        // Append a new line.
        if (true === $newline && false === @file_put_contents($dest, "\n", FILE_APPEND)) {
            throw new IOException(sprintf("Failed to append \"%s\" into \"%s\"", $src, $dest));
        }

        // Close the files.
        if (false === @fclose($reader)) {
            throw new IOException(sprintf("Failed to close \"%s\"", $src));
        }
        if (false === @fclose($writer)) {
            throw new IOException(sprintf("Failed to close \"%s\"", $dest));
        }
    }
973450
public static void copyStream(final InputStream src, OutputStream dest) throws IOException {
        byte[] buffer = new byte[1024];
        int read;
        while ((read = src.read(buffer)) > -1) {
            dest.write(buffer, 0, read);
        }
        dest.flush();
    }
1198627
@Deprecated
  public boolean delete(String src) throws IOException {
    checkOpen();
    clearFileStatusCache();
     
    return namenode.delete(src, true);
  }
1343851
public static TextContainer copy(TextContainer src, TextContainer dest) {
        dest.setBackGround(src.getBackGround());

        dest.setBackgroundColor(src.getBackgroundColor());

        dest.setGravity(src.getGravity());

        dest.setRefreshFrequency(src.getRefreshFrequency());

        dest.setText(src.getText());

        dest.setTextSize(src.getTextSize());

        dest.setTextColor(src.getTextColor());

        dest.setTypeface(src.getTypeface());

        return dest;
    }
1186341
public static void copyFile(File src, File dest) throws IOException {

        if (src == null)
            throw new NullPointerException("Source must not be null");
        if (dest == null)
            throw new NullPointerException("Destination must not be null");
        if (!src.exists())
            throw new FileNotFoundException("Source '" + src + "' does not exist");
        if (!src.isFile())
            throw new IOException("Source '" + src + "' is not a file");
        if (dest.exists())
            throw new IOException("Destination '" + dest + "' is already exists");

        FileChannel in = null, out = null;
        try {
            in = new FileInputStream(src).getChannel();
            out = new FileOutputStream(dest).getChannel();

            in.transferTo(0, in.size(), out);
        } finally {
            try {
                in.close();
                out.close();
            } catch (IOException e) {
                // Ignore.
            }
        }

        if (src.length() != dest.length()) {
            throw new IOException("Failed to copy full contents from '" +
                src + "' to '" + dest + "'");
        }

        dest.setLastModified(src.lastModified());
    }
963633
protected void mergeEntityProperty(EntityPropertyDesc dest, EntityPropertyInfo src) {
    dest.setEntityClassName(src.entityClass.getName());
    dest.setPropertyClassName(src.propertyField.getType().getName());
    Class<?> maybeNumberClass =
        ClassUtil.toBoxedPrimitiveTypeIfPossible(src.propertyField.getType());
    if (Number.class.isAssignableFrom(maybeNumberClass)) {
      dest.setNumber(true);
    }
    if (src.version != null) {
      dest.setVersion(true);
    }
    if (src.id != null) {
      dest.setId(true);
      if (src.generatedValue != null) {
        switch (src.generatedValue.strategy()) {
          case IDENTITY:
            dest.setGenerationType(GenerationType.IDENTITY);
            break;
          case SEQUENCE:
            dest.setGenerationType(GenerationType.SEQUENCE);
            if (src.sequenceGenerator != null) {
              dest.setInitialValue(src.sequenceGenerator.initialValue());
              dest.setAllocationSize(src.sequenceGenerator.allocationSize());
              dest.setAllocationSize(src.sequenceGenerator.allocationSize());
            }
            break;
          case TABLE:
            dest.setGenerationType(GenerationType.TABLE);
            if (src.tableGenerator != null) {
              dest.setInitialValue(src.tableGenerator.initialValue());
              dest.setAllocationSize(src.tableGenerator.allocationSize());
              dest.setAllocationSize(src.tableGenerator.allocationSize());
            }
            break;
          default:
            break;
        }
      }
    }
  }
422328
public static function copyFrom($src, StreamInterface $dest)
    {
        $srcStream = $src instanceof StreamInterface ? $src : new Stream($src, Stream::MODE_READ_ONLY_FROM_BEGIN);

        static::copy($srcStream, $dest);

        $srcStream->close();
    }
1286589
public function IsDerivedFrom( $src )
	{
		switch ( $src->TypeCode )
		{
			case XmlTypeCode::Node:
				if ( ! $this->IsNode )
					return false;
				break;

			case XmlTypeCode::AnyAtomicType:
			case XmlTypeCode::UntypedAtomic:
				if ( $this->IsNode )
					return false;
				break;

			case XmlTypeCode::Document:
				if ( $this->TypeCode != XmlTypeCode::Document || $this->SchemaElement != $src->SchemaElement)
					return false;
				break;

			case XmlTypeCode::Element:
				if ( $this->TypeCode != XmlTypeCode::Element || $this->SchemaElement != $src->SchemaElement)
					return false;
				break;

			case XmlTypeCode::Attribute:
				if ($this->TypeCode != XmlTypeCode::Attribute || $this->SchemaAttribute != $src->SchemaAttribute)
					return false;
				break;

			case XmlTypeCode::ProcessingInstruction:
				if ($this->TypeCode != XmlTypeCode::ProcessingInstruction)
					return false;
				break;

			case XmlTypeCode::Comment:
				if ( $this->TypeCode != XmlTypeCode::Comment )
					return false;
				break;

			case XmlTypeCode::Text:
				if ( $this->TypeCode != XmlTypeCode::Text )
					return false;
				break;
		}
		if ( ! is_null( $this->SchemaType ) || ! is_null( $src->SchemaType ) )
		{
			if ( ! is_null( $this->SchemaType ) && ! is_null( $src->SchemaType ) )
			{
				if ( ! DOMSchemaType::IsDerivedFrom( $this->SchemaType, $src->SchemaType, XmlSchemaDerivationMethod::Empty_ ) )
					return false;
			}
			else
				return false;
		}

		if ( $this->Cardinality != $src->Cardinality)
		{
			if ( ( $this->Cardinality == XmlTypeCardinality::ZeroOrOne || $this->Cardinality == XmlTypeCardinality::ZeroOrMore ) &&
				 ($src->Cardinality == XmlTypeCardinality::One || $src->Cardinality == XmlTypeCardinality::OneOrMore))
				return false;

			if ( $this->Cardinality == XmlTypeCardinality::One && $src->Cardinality == XmlTypeCardinality::OneOrMore)
				return false;
		}
		return true;
	}
23737
function (/*Object*/ dest) /*-> Object*/ {	// merge src properties into dest
		var sources = Array.prototype.slice.call(arguments, 1);
		for (var j = 0, len = sources.length, src; j < len; j++) {
			src = sources[j] || {};
			TL.Util.mergeData(dest, src);
		}
		return dest;
	}
115924
function(src, dest) {
    var i = 0;
    var len = Math.min(src.length, dest.length);
    while(i < len) {
      dest[i] = src[i];
      i++;
    }
    return dest;
  }
490830
public void serialize(Node src, net.oneandone.sushi.fs.Node dest, boolean format) throws IOException {
        // don't use Saver to allow transformer to decide about encoding */
        try (OutputStream out = dest.newOutputStream()) {
            serialize(new DOMSource(src), new StreamResult(out), dest.getWorld().getSettings().encoding, format);
        }
    }
1000584
public static JSONObject merge(JSONObject src, UnmodifiableJSONObject dest) {
        return merge(src, copy(dest));
    }
508589
public static void move(File src, File dest, boolean isOverride) throws IORuntimeException {
		// check
		if (false == src.exists()) {
			throw new IORuntimeException("File not found: " + src);
		}

		// 来源为文件夹，目标为文件
		if (src.isDirectory() && dest.isFile()) {
			throw new IORuntimeException(StrUtil.format("Can not move directory [{}] to file [{}]", src, dest));
		}

		if (isOverride && dest.isFile()) {// 只有目标为文件的情况下覆盖之
			dest.delete();
		}

		// 来源为文件，目标为文件夹
		if (src.isFile() && dest.isDirectory()) {
			dest = new File(dest, src.getName());
		}

		if (false == src.renameTo(dest)) {
			// 在文件系统不同的情况下，renameTo会失败，此时使用copy，然后删除原文件
			try {
				copy(src, dest, isOverride);
			} catch (Exception e) {
				throw new IORuntimeException(StrUtil.format("Move [{}] to [{}] failed!", src, dest), e);
			}
			// 复制后删除源
			del(src);
		}
	}