Package org.jboss.shrinkwrap.descriptor.api.webcommon31

Examples of org.jboss.shrinkwrap.descriptor.api.webcommon31.LocaleEncodingMappingListType


*/
public class LocaleEncodingMappingListMergeHandler implements WebFragmentMergeHandler<WebFragmentType, WebAppType> {

    @Override
    public void merge(WebFragmentType webFragment, WebAppType webApp, MergeContext mergeContext) throws DeploymentException {
        LocaleEncodingMappingListType targetLocaleEncodingMappingList = null;
        for (LocaleEncodingMappingListType localeEncodingMappingList : webFragment.getLocaleEncodingMappingListArray()) {
            for (LocaleEncodingMappingType localeEncodingMapping : localeEncodingMappingList.getLocaleEncodingMappingArray()) {
                String localeEncodingMappingKey = createLocaleEncodingMappingKey(localeEncodingMapping.getLocale());
                MergeItem mergeItem = (MergeItem) mergeContext.getAttribute(localeEncodingMappingKey);
                if (mergeItem != null && mergeItem.isFromWebFragment() && !mergeItem.getValue().equals(localeEncodingMapping.getEncoding())) {
                    throw new DeploymentException(WebDeploymentMessageUtils.createDuplicateKeyValueMessage("locale-encoding-mapping", "locale", localeEncodingMapping.getLocale(), "encoding",
                            (String) mergeItem.getValue(), mergeItem.getBelongedURL(), localeEncodingMapping.getLocale(), mergeContext.getCurrentJarUrl()));
                }
                if (targetLocaleEncodingMappingList == null) {
                    targetLocaleEncodingMappingList = webApp.getLocaleEncodingMappingListArray().length > 0 ? webApp.getLocaleEncodingMappingListArray(0) : webApp.addNewLocaleEncodingMappingList();
                }
                targetLocaleEncodingMappingList.addNewLocaleEncodingMapping().set(localeEncodingMapping);
                mergeContext.setAttribute(localeEncodingMappingKey, new MergeItem(localeEncodingMapping.getEncoding(), mergeContext.getCurrentJarUrl(), ElementSource.WEB_FRAGMENT));
            }
        }
    }
View Full Code Here


        if (localeEncodingMappingLists.length == 0) {
            return;
        }
        //Spec 14.2 While multiple locale-encoding-mapping lists are found, we need to concatenate the items
        if (localeEncodingMappingLists.length > 1) {
            LocaleEncodingMappingListType targetLocaleEncodingMappingList = localeEncodingMappingLists[0];
            for (int i = 1; i < localeEncodingMappingLists.length; i++) {
                LocaleEncodingMappingListType localeEncodingMappingList = localeEncodingMappingLists[i];
                for (LocaleEncodingMappingType localeEncodingMapping : localeEncodingMappingList.getLocaleEncodingMappingArray()) {
                    targetLocaleEncodingMappingList.addNewLocaleEncodingMapping().set(localeEncodingMapping);
                }
            }
            for (int i = 1, iLength = localeEncodingMappingLists.length; i < iLength; i++) {
                webApp.removeLocaleEncodingMappingList(1);
View Full Code Here

TOP

Related Classes of org.jboss.shrinkwrap.descriptor.api.webcommon31.LocaleEncodingMappingListType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.