001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.lar.xstream;
016    
017    import com.liferay.portal.kernel.lar.xstream.XStreamConverter;
018    import com.liferay.portal.kernel.lar.xstream.XStreamMarshallingContext;
019    
020    import com.thoughtworks.xstream.converters.MarshallingContext;
021    
022    import java.util.Iterator;
023    
024    /**
025     * @author Daniel Kocsis
026     */
027    public class XStreamMarshallingContextAdapter
028            implements XStreamMarshallingContext {
029    
030            public XStreamMarshallingContextAdapter(
031                    MarshallingContext marshallingContext) {
032    
033                    _marshallingContext = marshallingContext;
034            }
035    
036            @Override
037            public void convertAnother(Object object) {
038                    _marshallingContext.convertAnother(object);
039            }
040    
041            @Override
042            public void convertAnother(
043                    Object object, XStreamConverter xStreamConverter) {
044    
045                    _marshallingContext.convertAnother(
046                            object, new ConverterAdapter(xStreamConverter));
047            }
048    
049            @Override
050            public Object get(Object key) {
051                    return _marshallingContext.get(key);
052            }
053    
054            @Override
055            public Iterator<String> keys() {
056                    return _marshallingContext.keys();
057            }
058    
059            @Override
060            public void put(Object key, Object value) {
061                    _marshallingContext.put(key, value);
062            }
063    
064            private final MarshallingContext _marshallingContext;
065    
066    }