/* */ package NET.worlds.scape; /* */ /* */ import NET.worlds.network.URL; /* */ import java.io.File; /* */ import java.util.Hashtable; /* */ import java.util.StringTokenizer; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public abstract class TextureDecoder /* */ { /* 36 */ protected static Hashtable handlers = new Hashtable(); /* */ /* */ /* */ /* */ /* */ private static TextureDecoder defaultDecoder; /* */ /* */ /* */ /* */ private static String allExts; /* */ /* */ /* */ /* */ /* */ static /* */ { /* 52 */ addHandler(defaultDecoder = new FileTextureDecoder()); /* 53 */ addHandler(new StandardTextureDecoder()); /* 54 */ addHandler(new ScapePicTextureDecoder()); /* */ } /* */ /* */ /* */ /* */ /* */ protected abstract String getExts(); /* */ /* */ /* */ /* */ /* */ protected abstract Texture read(String paramString1, String paramString2); /* */ /* */ /* */ /* */ /* */ private static void addHandler(TextureDecoder decoder) /* */ { /* 72 */ StringTokenizer e = new StringTokenizer(decoder.getExts(), ";"); /* 73 */ while (e.hasMoreTokens()) { /* 74 */ String ext = e.nextToken().toLowerCase(); /* 75 */ handlers.put(ext, decoder); /* 76 */ if (allExts == null) { /* 77 */ allExts = ext; /* */ } else { /* 79 */ allExts = allExts + File.pathSeparator + ext; /* */ } /* */ } /* */ } /* */ /* */ public static String getAllExts() { /* 85 */ return allExts; /* */ } /* */ /* */ public static String getJavaExts() /* */ { /* 90 */ return new StandardTextureDecoder().getExts(); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public static Texture decode(URL url, String filename) /* */ { /* 99 */ return decode(url, url.getAbsolute(), filename); /* */ } /* */ /* */ /* */ public static Texture decode(URL url, String lookupName, String filename) /* */ { /* 105 */ Texture tex = FileTexture.dictLookup(lookupName); /* 106 */ if (tex != null) { /* 107 */ return tex; /* */ } /* 109 */ String urlName = url.getInternal(); /* */ /* */ /* 112 */ int delim = urlName.lastIndexOf('.'); /* 113 */ int lastPath = urlName.lastIndexOf('/'); /* 114 */ lastPath = Math.max(lastPath, urlName.lastIndexOf('\\')); /* 115 */ lastPath = Math.max(lastPath, urlName.lastIndexOf(':')); /* 116 */ if (delim > lastPath) { /* 117 */ String ext = urlName.substring(delim + 1).toLowerCase(); /* 118 */ TextureDecoder decoder = (TextureDecoder)handlers.get(ext); /* 119 */ if (decoder != null) { /* 120 */ Texture t = decoder.read(lookupName, filename); /* 121 */ if (t.textureID != 0) /* 122 */ return t; /* */ } /* */ } /* 125 */ return null; /* */ } /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\TextureDecoder.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */