Spec-Zone .ru
спецификации, руководства, описания, API
|
001/* 002 * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. 003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 004 * 005 * This code is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU General Public License version 2 only, as 007 * published by the Free Software Foundation. Oracle designates this 008 * particular file as subject to the "Classpath" exception as provided 009 * by Oracle in the LICENSE file that accompanied this code. 010 * 011 * This code is distributed in the hope that it will be useful, but WITHOUT 012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 014 * version 2 for more details (a copy is included in the LICENSE file that 015 * accompanied this code). 016 * 017 * You should have received a copy of the GNU General Public License version 018 * 2 along with this work; if not, write to the Free Software Foundation, 019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 020 * 021 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 022 * or visit www.oracle.com if you need additional information or have any 023 * questions. 024 */ 025 026package javafx.scene.media; 027 028import javafx.event.Event; 029import javafx.event.EventTarget; 030import javafx.event.EventType; 031 032/** 033 * An {@link Event} representing the occurrence of an error in handling media. 034 */ 035public class MediaErrorEvent extends Event { 036 037 private static final long serialVersionUID = 20121107L; 038 039 /** 040 * The only valid event type for the <code>MediaErrorEvent</code>. 041 */ 042 public static final EventType<MediaErrorEvent> MEDIA_ERROR = 043 new EventType<MediaErrorEvent>(Event.ANY, "Media Error Event"); 044 045 /** 046 * The {@link MediaException} which provoked this error event. 047 */ 048 private MediaException error; 049 050 /** 051 * Construct a new <code>MediaErrorEvent</code> with the specified event 052 * source, target and error. 053 * 054 * @param source the event source which sent the event 055 * @param target the event target to associate with the event 056 * @param error the error which provoked the event 057 * @throws <code>IllegalArgumentException</code> if <code>error</code> is 058 * <code>null</code>. 059 */ 060 MediaErrorEvent(Object source, EventTarget target, MediaException error) { 061 super(source, target, MEDIA_ERROR); 062 063 if(error == null) { 064 throw new IllegalArgumentException("error == null!"); 065 } 066 067 this.error = error; 068 } 069 070 /** 071 * Retrieve the error associated with this event. 072 * 073 * @return The <code>MediaException</code> 074 */ 075 public MediaException getMediaError() { 076 return error; 077 } 078 079 /** 080 * Retrieve a <code>String</code> representation of the event. 081 */ 082 @Override 083 public String toString() { 084 return super.toString() + ": source " + getSource() + 085 "; target " + getTarget() + "; error " + error; 086 } 087 088 @Override 089 public MediaErrorEvent copyFor(Object newSource, EventTarget newTarget) { 090 return (MediaErrorEvent) super.copyFor(newSource, newTarget); 091 } 092 093 @Override 094 public EventType<MediaErrorEvent> getEventType() { 095 return (EventType<MediaErrorEvent>) super.getEventType(); 096 } 097 098}