01: /* UploadEvent.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Fri May 11 17:10:32 2007, Created by tomyeh
10: }}IS_NOTE
11:
12: Copyright (C) 2007 Potix Corporation. All Rights Reserved.
13:
14: {{IS_RIGHT
15: This program is distributed under GPL Version 2.0 in the hope that
16: it will be useful, but WITHOUT ANY WARRANTY.
17: }}IS_RIGHT
18: */
19: package org.zkoss.zk.ui.event;
20:
21: import org.zkoss.util.media.Media;
22:
23: import org.zkoss.zk.ui.Component;
24:
25: /**
26: * Represents that user has uploaded one or several files from
27: * the client to the server.
28: *
29: * @author tomyeh
30: */
31: public class UploadEvent extends Event {
32: private final Media[] _meds;
33:
34: /** Constructs the upload event.
35: * @param meds the media being uploaded, or null if no file is
36: * uploaded. If a zero-length array is passed, null is assumed.
37: */
38: public UploadEvent(String name, Component target, Media[] meds) {
39: super (name, target);
40: _meds = meds != null && meds.length > 0 ? meds : null;
41: }
42:
43: /** Returns the first media being uploaded, or null if no file
44: * is uploaded.
45: */
46: public final Media getMedia() {
47: return _meds != null ? _meds[0] : null;
48: }
49:
50: /** Returns the array of media being uploaded, or null
51: * if the user uploaded no file at all.
52: * If non-null is returned, the array length must be at least one.
53: */
54: public final Media[] getMedias() {
55: return _meds;
56: }
57: }
|