001/* 002 * Copyright 2012 Atteo. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.atteo.xmlcombiner; 017 018/** 019 * Controls the behavior of merging child elements. 020 */ 021public enum CombineChildren { 022 /** 023 * Merge subelements from both elements. 024 * 025 * <p> 026 * This is the default. 027 * Those subelements which can be uniquely paired between two documents using the key (tag+selected attributes) 028 * will be merged, those that cannot be paired will be appended.<br/> 029 * Example:<br/> 030 * First: 031 * <pre> 032 * {@code 033 * <config> 034 * <service id="1"> 035 * <parameter>parameter</parameter> 036 * </service> 037 * </config> 038 * } 039 * </pre> 040 * Second: 041 * <pre> 042 * {@code 043 * <config> 044 * <service id="1"/> 045 * <parameter>other value</parameter> 046 * </service> 047 * </config> 048 * } 049 * </pre> 050 * Result: 051 * <pre> 052 * {@code 053 * <config> 054 * <service id="1"/> 055 * <parameter>other value</parameter> 056 * </service> 057 * </config> 058 * } 059 * </pre> 060 * </p> 061 */ 062 MERGE, 063 064 /** 065 * Always append child elements from both recessive and dominant elements. 066 * 067 * <p> 068 * Example:<br/> 069 * First: 070 * <pre> 071 * {@code 072 * <config> 073 * <service id="1" combine.children="append"> 074 * <parameter>parameter</parameter> 075 * </service> 076 * </config> 077 * } 078 * </pre> 079 * Second: 080 * <pre> 081 * {@code 082 * <config> 083 * <service id="1"> 084 * <parameter>parameter</parameter> 085 * </service> 086 * </config> 087 * } 088 * </pre> 089 * Result: 090 * <pre> 091 * {@code 092 * <config> 093 * <service id="1" combine.children="append"> 094 * <parameter>parameter</parameter> 095 * <parameter>parameter</parameter> 096 * </service> 097 * </config> 098 * } 099 * </pre> 100 * </p> 101 */ 102 APPEND; 103 104 public static final String ATTRIBUTE_NAME = "combine.children"; 105}