001    /**
002     * Copyright (c) 2000-2013 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.portlet;
016    
017    import com.liferay.util.SerializableUtil;
018    
019    import java.io.Serializable;
020    
021    import javax.portlet.Event;
022    
023    import javax.xml.namespace.QName;
024    
025    /**
026     * @author Brian Wing Shun Chan
027     */
028    public class EventImpl implements Event {
029    
030            public EventImpl(String name, QName qName, Serializable value) {
031                    _name = name;
032                    _qName = qName;
033                    _value = value;
034            }
035    
036            @Override
037            public String getName() {
038                    return _name;
039            }
040    
041            @Override
042            public QName getQName() {
043                    return _qName;
044            }
045    
046            public byte[] getSerializedValue() {
047                    if (_serializedValue == null) {
048                            _serializedValue = SerializableUtil.serialize(_value);
049                    }
050    
051                    return _serializedValue;
052            }
053    
054            @Override
055            public Serializable getValue() {
056                    return _value;
057            }
058    
059            private String _name;
060            private QName _qName;
061            private byte[] _serializedValue;
062            private Serializable _value;
063    
064    }