/* */ package quicktime.app;
/* */
/* */ import java.io.File;
/* */ import java.io.FileInputStream;
/* */ import java.io.FileNotFoundException;
/* */ import java.io.IOException;
/* */ import java.io.InputStream;
/* */ import java.util.Enumeration;
/* */ import java.util.Vector;
/* */ import quicktime.QTException;
/* */ import quicktime.QTRuntimeException;
/* */ import quicktime.QTSession;
/* */ import quicktime.app.display.QTDrawable;
/* */ import quicktime.io.OpenMovieFile;
/* */ import quicktime.io.QTFile;
/* */ import quicktime.std.StdQTException;
/* */ import quicktime.std.image.GraphicsImporter;
/* */ import quicktime.std.movies.Movie;
/* */ import quicktime.std.movies.Track;
/* */ import quicktime.std.movies.media.DataRef;
/* */ import quicktime.std.movies.media.Media;
/* */ import quicktime.std.qtcomponents.MovieImporter;
/* */ import quicktime.util.QTHandle;
/* */ import quicktime.util.QTUtils;
/* */
/* */ /** @deprecated */
/* */ public final class QTFactory
/* */ {
/* 52 */ private static boolean apriori = QTSession.apriori();
/* */ private static Vector classPaths;
/* */ private static final boolean debug = false;
/* */
/* */ private static void buildClassPathsVector()
/* */ throws IOException
/* */ {
/* 64 */ classPaths = new Vector(8);
/* */
/* 66 */ String str1 = System.getProperty("java.class.path");
/* 67 */ while (str1 != null) {
/* 68 */ int i = str1.indexOf(File.pathSeparatorChar);
/* 69 */ String str3 = null;
/* 70 */ if (i == -1) {
/* 71 */ str3 = str1;
/* 72 */ str1 = null;
/* */ }
/* */ else {
/* 75 */ str3 = str1.substring(0, i);
/* 76 */ str1 = str1.substring(i + 1);
/* */ }
/* */
/* 80 */ str3 = returnExistingFile(str3);
/* 81 */ if (str3 != null) {
/* 82 */ str3 = str3.substring(0, str3.lastIndexOf(File.separatorChar) + 1);
/* 83 */ if ((!classPaths.contains(str3)) && (str3.length() > 0))
/* */ {
/* 85 */ classPaths.addElement(str3);
/* */ }
/* */ }
/* */ }
/* 88 */ String str2 = System.getProperty("user.dir");
/* 89 */ str2 = returnExistingFile(str2);
/* */
/* 91 */ if (str2 != null)
/* 92 */ classPaths.addElement(str2);
/* */ }
/* */
/* */ private static String returnExistingFile(String paramString) throws IOException {
/* 96 */ File localFile = new File(paramString);
/* 97 */ if (!localFile.exists()) return null;
/* 98 */ if ((localFile.isDirectory()) &&
/* 99 */ (paramString.charAt(paramString.length() - 1) != File.separatorChar)) {
/* 100 */ return paramString + File.separatorChar;
/* */ }
/* 102 */ return localFile.getCanonicalPath();
/* */ }
/* */
/* */ /** @deprecated */
/* */ public static File findInSystemPaths(String paramString)
/* */ throws IOException
/* */ {
/* 117 */ if (classPaths == null) buildClassPathsVector();
/* 118 */ return _doFISP(paramString, false);
/* */ }
/* */
/* */ private static File _doFISP(String paramString, boolean paramBoolean) throws IOException {
/* 122 */ String str1 = paramString;
/* 123 */ int i = str1.length();
/* 124 */ while (i > 0)
/* */ {
/* 127 */ i = str1.substring(0, i).lastIndexOf('/');
/* 128 */ String str2 = (i == -1) || (i == 0) ? str1 : str1.substring(i + 1);
/* */
/* 132 */ for (int j = classPaths.size() - 1; j >= 0; j--) {
/* 133 */ String str3 = (String)classPaths.elementAt(j);
/* */
/* 135 */ String str4 = returnExistingFile(str3 + str2);
/* 136 */ if (str4 != null) return new File(str4);
/* */ }
/* */ }
/* */
/* 140 */ throw new FileNotFoundException(paramString);
/* */ }
/* */
/* */ /** @deprecated */
/* */ public static void addDirectory(File paramFile)
/* */ throws IOException
/* */ {
/* 152 */ if (!paramFile.exists()) throw new IOException(paramFile + ",does not exist");
/* 153 */ if (!paramFile.isDirectory()) throw new IOException(paramFile + ",must be a directory");
/* */
/* 155 */ if (classPaths == null) buildClassPathsVector();
/* */
/* 157 */ String str = paramFile.getCanonicalPath();
/* 158 */ str = str.replace('/', File.separatorChar);
/* 159 */ if (str.charAt(str.length() - 1) != '/') str = str + "/";
/* */
/* 161 */ if (classPaths.contains(str)) return;
/* */
/* 163 */ classPaths.addElement(str);
/* */ }
/* */
/* */ /** @deprecated */
/* */ public static void removeDirectory(File paramFile)
/* */ throws IOException
/* */ {
/* 173 */ if (!paramFile.exists()) return;
/* 174 */ if (!paramFile.isDirectory()) return;
/* */
/* 176 */ if (classPaths == null) return;
/* */
/* 178 */ String str = paramFile.getCanonicalPath();
/* 179 */ str = str.replace('/', File.separatorChar);
/* 180 */ if (str.charAt(str.length() - 1) != '/') str = str + "/";
/* */
/* 182 */ classPaths.removeElement(str);
/* */ }
/* */
/* */ /** @deprecated */
/* */ public static File findAbsolutePath(String paramString)
/* */ throws IOException
/* */ {
/* 200 */ paramString = paramString.replace('/', File.separatorChar);
/* 201 */ if (classPaths == null) buildClassPathsVector();
/* */
/* 203 */ Enumeration localEnumeration = classPaths.elements();
/* 204 */ while (localEnumeration.hasMoreElements()) {
/* 205 */ String str1 = (String)localEnumeration.nextElement();
/* */
/* 207 */ String str2 = returnExistingFile(str1 + paramString);
/* 208 */ if (str2 != null)
/* */ {
/* 210 */ return new File(str2);
/* */ }
/* */ }
/* 213 */ throw new FileNotFoundException(paramString);
/* */ }
/* */
/* */ /** @deprecated */
/* */ public static QTDrawable makeDrawable(QTFile paramQTFile)
/* */ throws IOException, QTException
/* */ {
/* 231 */ return makeDrawable(paramQTFile, new QTDrawableMaker());
/* */ }
/* */
/* */ /** @deprecated */
/* */ public static QTDrawable makeDrawable(QTFile paramQTFile, QTDrawableMaker paramQTDrawableMaker)
/* */ throws IOException, QTException
/* */ {
/* 251 */ if (!paramQTFile.exists()) throw new FileNotFoundException(paramQTFile.getName());
/* 252 */ String str = getFileExtension(paramQTFile.getAbsolutePath());
/* */
/* 254 */ if (("mid".equalsIgnoreCase(str)) || ("smf".equalsIgnoreCase(str)) || ("midi".equalsIgnoreCase(str)) || ("kar".equalsIgnoreCase(str)))
/* */ {
/* 258 */ localObject = readBytesIntoHandle(new FileInputStream(paramQTFile));
/* 259 */ localMovie = importMovie((QTHandle)localObject, QTUtils.toOSType("Midi"));
/* 260 */ if (localMovie != null) return paramQTDrawableMaker.fromMovie(localMovie);
/* */
/* */ }
/* */
/* 264 */ Object localObject = openAsImage(paramQTFile);
/* 265 */ Movie localMovie = null;
/* 266 */ if (localObject != null) {
/* 267 */ localMovie = checkIfMovie(paramQTFile);
/* 268 */ if (localMovie == null) {
/* 269 */ return paramQTDrawableMaker.fromGraphicsImporter((GraphicsImporter)localObject);
/* */ }
/* 271 */ return paramQTDrawableMaker.fromMovie(localMovie);
/* */ }
/* */
/* 274 */ localMovie = openAsMovie(paramQTFile);
/* 275 */ if (localMovie != null) return paramQTDrawableMaker.fromMovie(localMovie);
/* */
/* 280 */ throw new QTException(-2003);
/* */ }
/* */
/* */ /** @deprecated */
/* */ public static QTDrawable makeDrawable(InputStream paramInputStream, int paramInt, String paramString)
/* */ throws IOException, QTException
/* */ {
/* 312 */ return makeDrawable(paramInputStream, paramInt, paramString, new QTDrawableMaker());
/* */ }
/* */
/* */ /** @deprecated */
/* */ public static QTDrawable makeDrawable(InputStream paramInputStream, int paramInt, String paramString, QTDrawableMaker paramQTDrawableMaker)
/* */ throws IOException, QTException
/* */ {
/* 345 */ QTHandle localQTHandle = readBytesIntoHandle(paramInputStream);
/* 346 */ DataRef localDataRef = new DataRef(localQTHandle, paramInt, paramString);
/* */
/* 348 */ if ((paramString != null) && (
/* 349 */ ("mid".equalsIgnoreCase(paramString)) || ("smf".equalsIgnoreCase(paramString)) || ("midi".equalsIgnoreCase(paramString)) || ("kar".equalsIgnoreCase(paramString))))
/* */ {
/* 353 */ localObject = importMovie(localQTHandle, QTUtils.toOSType("Midi"));
/* 354 */ if (localObject != null) return paramQTDrawableMaker.fromMovie((Movie)localObject);
/* */
/* */ }
/* */
/* 358 */ Object localObject = importImage(localDataRef);
/* 359 */ Movie localMovie = null;
/* 360 */ if (localObject != null) {
/* 361 */ localMovie = checkIfMovie(localDataRef);
/* 362 */ if (localMovie == null) {
/* 363 */ return paramQTDrawableMaker.fromGraphicsImporter((GraphicsImporter)localObject);
/* */ }
/* 365 */ return paramQTDrawableMaker.fromMovie(localMovie);
/* */ }
/* */
/* 368 */ localMovie = openAsMovie(localDataRef);
/* 369 */ if (localMovie != null) return paramQTDrawableMaker.fromMovie(localMovie);
/* */
/* 374 */ throw new QTException(-2003);
/* */ }
/* */
/* */ /** @deprecated */
/* */ public static QTDrawable makeDrawable(String paramString)
/* */ throws QTException
/* */ {
/* 389 */ return makeDrawable(paramString, new QTDrawableMaker());
/* */ }
/* */
/* */ /** @deprecated */
/* */ public static QTDrawable makeDrawable(String paramString, QTDrawableMaker paramQTDrawableMaker)
/* */ throws QTException
/* */ {
/* 409 */ if (paramString.startsWith("file:"))
/* */ {
/* 412 */ paramString = paramString.substring(5);
/* 413 */ while ((paramString.charAt(0) == '/') &&
/* 414 */ (paramString.charAt(1) == '/'))
/* */ {
/* 416 */ paramString = paramString.substring(1);
/* */ }
/* */ try {
/* 419 */ return makeDrawable(new QTFile(paramString), paramQTDrawableMaker);
/* */ } catch (IOException localIOException) {
/* 421 */ throw new QTException(-43);
/* */ }
/* */ }
/* */
/* 425 */ DataRef localDataRef = new DataRef(paramString);
/* */
/* 427 */ GraphicsImporter localGraphicsImporter = importImage(localDataRef);
/* 428 */ Movie localMovie = null;
/* 429 */ if (localGraphicsImporter != null) {
/* 430 */ localMovie = checkIfMovie(localDataRef);
/* 431 */ if (localMovie == null) {
/* 432 */ return paramQTDrawableMaker.fromGraphicsImporter(localGraphicsImporter);
/* */ }
/* 434 */ return paramQTDrawableMaker.fromMovie(localMovie);
/* */ }
/* */
/* 437 */ localMovie = openAsMovie(localDataRef);
/* 438 */ if (localMovie != null) return paramQTDrawableMaker.fromMovie(localMovie);
/* */
/* 443 */ throw new QTException(-2003);
/* */ }
/* */
/* */ private static String getFileExtension(String paramString) {
/* 447 */ int i = paramString.lastIndexOf('.');
/* 448 */ return i == -1 ? "" : paramString.substring(i + 1);
/* */ }
/* */
/* */ private static QTHandle readBytesIntoHandle(InputStream paramInputStream) throws IOException, QTException {
/* 452 */ byte[] arrayOfByte = new byte[paramInputStream.available()];
/* 453 */ int i = paramInputStream.read(arrayOfByte);
/* 454 */ if ((i < 0) || (i != arrayOfByte.length)) throw new IOException("Problem in reading bytes from InputStream");
/* 455 */ return new QTHandle(arrayOfByte);
/* */ }
/* */
/* */ private static GraphicsImporter openAsImage(QTFile paramQTFile) throws QTException {
/* */ try {
/* 460 */ return new GraphicsImporter(paramQTFile); } catch (StdQTException localStdQTException) {
/* */ }
/* 462 */ return null;
/* */ }
/* */
/* */ private static GraphicsImporter openAsImage(DataRef paramDataRef) throws QTException {
/* */ try {
/* 467 */ return new GraphicsImporter(paramDataRef); } catch (StdQTException localStdQTException) {
/* */ }
/* 469 */ return null;
/* */ }
/* */
/* */ private static GraphicsImporter importImage(DataRef paramDataRef) throws QTException {
/* */ try {
/* 474 */ return new GraphicsImporter(paramDataRef);
/* */ } catch (QTException localQTException) {
/* */ }
/* 477 */ return null;
/* */ }
/* */
/* */ private static Movie checkIfMovie(QTFile paramQTFile) throws QTException {
/* 481 */ return checkMovie(Movie.fromFile(OpenMovieFile.asRead(paramQTFile), 0, null));
/* */ }
/* */
/* */ private static Movie checkIfMovie(DataRef paramDataRef) throws QTException {
/* */ try {
/* 486 */ return checkMovie(Movie.fromDataRef(paramDataRef, 0));
/* */ } catch (QTException localQTException) {
/* */ }
/* 489 */ return null;
/* */ }
/* */
/* */ private static Movie checkMovie(Movie paramMovie) throws QTException {
/* */ try {
/* 494 */ if (paramMovie.getTrackCount() > 1) return paramMovie;
/* 495 */ Track localTrack = paramMovie.getIndTrack(1);
/* 496 */ Media localMedia = Media.getTrackMedia(localTrack);
/* 497 */ if (localMedia.getSampleCount() > 1) {
/* 498 */ paramMovie.setActive(true);
/* 499 */ return paramMovie;
/* */ }
/* */
/* 502 */ localMedia.disposeQTObject();
/* 503 */ localTrack.disposeQTObject();
/* 504 */ paramMovie.disposeQTObject(); } catch (QTException localQTException) {
/* */ }
/* 506 */ return null;
/* */ }
/* */
/* */ private static Movie openAsMovie(QTFile paramQTFile) throws QTException {
/* 510 */ OpenMovieFile localOpenMovieFile = OpenMovieFile.asRead(paramQTFile);
/* */ try {
/* 512 */ return Movie.fromFile(localOpenMovieFile); } catch (StdQTException localStdQTException) {
/* */ }
/* 514 */ return null;
/* */ }
/* */
/* */ private static Movie openAsMovie(DataRef paramDataRef) throws QTException {
/* */ try {
/* 519 */ return Movie.fromDataRef(paramDataRef, 1); } catch (QTException localQTException) {
/* */ }
/* 521 */ return null;
/* */ }
/* */
/* */ private static Movie importMovie(QTHandle paramQTHandle, int paramInt) throws QTException {
/* 525 */ if (paramInt == 0) throw new QTException(-2003); try
/* */ {
/* 527 */ MovieImporter localMovieImporter = new MovieImporter(paramInt);
/* 528 */ Movie localMovie = new Movie(1);
/* 529 */ localMovie.setDefaultDataRef(new DataRef(new QTHandle()));
/* 530 */ localMovieImporter.fromHandle(paramQTHandle, localMovie, null, 0, 1);
/* 531 */ return localMovie; } catch (QTException localQTException) {
/* */ }
/* 533 */ return null;
/* */ }
/* */
/* */ static
/* */ {
/* 55 */ if ((QTSession.isCurrentOS(4)) && (QTSession.getJavaVersion() >= 65540))
/* 56 */ throw new QTRuntimeException("Unsupported on Mac OS X and Java 1.4 and higher.");
/* */ }
/* */ }
/* Location: Z:\System\Library\Java\Extensions\QTJava.zip
* Qualified Name: quicktime.app.QTFactory
* JD-Core Version: 0.6.2
*/