Back to index

im-sdk  12.3.91
Public Member Functions | Package Functions | Private Member Functions | Private Attributes
sun.awt.im.iiimp.ODClassLoader Class Reference
Collaboration diagram for sun.awt.im.iiimp.ODClassLoader:
Collaboration graph
[legend]

List of all members.

Public Member Functions

Class findClass (String name)
 findClass from class byte array strage made from JarInputStream.
ImageIcon getImageIcon (String name)
String getString (String name)
URL getURL (String name)
Class findClass (String name)
 findClass from class byte array strage made from JarInputStream.
ImageIcon getImageIcon (String name)
String getString (String name)
URL getURL (String name)

Package Functions

 ODClassLoader ()
void addJar (JarInputStream jis)
 ODClassLoader ()
void addJar (JarInputStream jis)

Private Member Functions

Object[] getWriteList (String dirname)
void debug (String str)
Object[] getWriteList (String dirname)
void debug (String str)

Private Attributes

HashMap byteTable = new HashMap()

Detailed Description

Definition at line 55 of file ODClassLoader.java.


Constructor & Destructor Documentation

Definition at line 60 of file ODClassLoader.java.

                    {
       super(ClassLoader.getSystemClassLoader());
    }

Definition at line 60 of file ODClassLoader.java.

                    {
       super(ClassLoader.getSystemClassLoader());
    }

Member Function Documentation

void sun.awt.im.iiimp.ODClassLoader.addJar ( JarInputStream  jis) [inline, package]

Definition at line 64 of file ODClassLoader.java.

                                    {
       JarEntry je;
       boolean defc;
       
       for (;;) {
           try {
              je = jis.getNextJarEntry();
           } catch(Exception e) {
              continue;
           }
           
           if (je == null) {
              break;
           }

           String name = je.getName();
           //
           // should use ByteArrayOutputStream and getByteArray()!!!
           //
           byte[] buf = new byte[1024];
           int bufLen = 2048;
           byte[] buffer = new byte[bufLen];
           int total = 0, len;
           try {
              for (;(len = jis.read(buf, 0, buf.length)) != -1;) {
                  if (bufLen < total + len) {
                     byte[] tmp = new byte[bufLen * 2];
                     System.arraycopy(buffer, 0, tmp, 0, total);
                     buffer = tmp;
                     bufLen *= 2;
                  }
                  System.arraycopy(buf, 0, buffer, total, len);
                  total += len;
              }
           } catch(Exception e) {
              if (Manager.DEBUG) {
                  e.printStackTrace();
              }
              continue;
           }
           //
           // store byte array for findClass() of ODClassLoader
           //
           byte[] realBuf = new byte[total];
           System.arraycopy(buffer, 0, realBuf, 0, total);
           byteTable.put(name, realBuf);
       }
    }

Here is the caller graph for this function:

void sun.awt.im.iiimp.ODClassLoader.addJar ( JarInputStream  jis) [inline, package]

Definition at line 64 of file ODClassLoader.java.

                                    {
       JarEntry je;
       boolean defc;
       
       for (;;) {
           try {
              je = jis.getNextJarEntry();
           } catch(Exception e) {
              continue;
           }
           
           if (je == null) {
              break;
           }

           String name = je.getName();
           //
           // should use ByteArrayOutputStream and getByteArray()!!!
           //
           byte[] buf = new byte[1024];
           int bufLen = 2048;
           byte[] buffer = new byte[bufLen];
           int total = 0, len;
           try {
              for (;(len = jis.read(buf, 0, buf.length)) != -1;) {
                  if (bufLen < total + len) {
                     byte[] tmp = new byte[bufLen * 2];
                     System.arraycopy(buffer, 0, tmp, 0, total);
                     buffer = tmp;
                     bufLen *= 2;
                  }
                  System.arraycopy(buf, 0, buffer, total, len);
                  total += len;
              }
           } catch(Exception e) {
              if (Manager.DEBUG) {
                  e.printStackTrace();
              }
              continue;
           }
           //
           // store byte array for findClass() of ODClassLoader
           //
           byte[] realBuf = new byte[total];
           System.arraycopy(buffer, 0, realBuf, 0, total);
           byteTable.put(name, realBuf);
       }
    }
void sun.awt.im.iiimp.ODClassLoader.debug ( String  str) [inline, private]

Definition at line 238 of file ODClassLoader.java.

                                   {
       if (Manager.DEBUG) {
           System.err.println(str);
       }
    }

Here is the caller graph for this function:

void sun.awt.im.iiimp.ODClassLoader.debug ( String  str) [inline, private]

Definition at line 238 of file ODClassLoader.java.

                                   {
       if (Manager.DEBUG) {
           System.err.println(str);
       }
    }
Class sun.awt.im.iiimp.ODClassLoader.findClass ( String  name) [inline]

findClass from class byte array strage made from JarInputStream.

Definition at line 116 of file ODClassLoader.java.

                                        {
       
       byte[] ba = (byte[])byteTable.get(name.replace('.', '/') + ".class");

       if (ba == null) {
           debug(" ODClassLoader: Unknown class " + name);
           return null;
       }
       Class cls = null;
       try {
           // CodeSource object will be added later.
           //
           cls = defineClass(name, ba, 0, ba.length, (CodeSource)null);
       } catch(Throwable e) {
           debug(" E = " + e);
           return null;
       }

       return cls;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Class sun.awt.im.iiimp.ODClassLoader.findClass ( String  name) [inline]

findClass from class byte array strage made from JarInputStream.

Definition at line 116 of file ODClassLoader.java.

                                        {
       
       byte[] ba = (byte[])byteTable.get(name.replace('.', '/') + ".class");

       if (ba == null) {
           debug(" ODClassLoader: Unknown class " + name);
           return null;
       }
       Class cls = null;
       try {
           // CodeSource object will be added later.
           //
           cls = defineClass(name, ba, 0, ba.length, (CodeSource)null);
       } catch(Throwable e) {
           debug(" E = " + e);
           return null;
       }

       return cls;
    }

Here is the call graph for this function:

ImageIcon sun.awt.im.iiimp.ODClassLoader.getImageIcon ( String  name) [inline]

Definition at line 137 of file ODClassLoader.java.

                                               {

       byte[] ba = (byte[])byteTable.get(name);
       if (ba == null) {
           debug(" ODClassLoader: " + name + " not found.");
           return null;
       }

       return new ImageIcon(ba);
    }

Here is the call graph for this function:

ImageIcon sun.awt.im.iiimp.ODClassLoader.getImageIcon ( String  name) [inline]

Definition at line 137 of file ODClassLoader.java.

                                               {

       byte[] ba = (byte[])byteTable.get(name);
       if (ba == null) {
           debug(" ODClassLoader: " + name + " not found.");
           return null;
       }

       return new ImageIcon(ba);
    }

Here is the call graph for this function:

String sun.awt.im.iiimp.ODClassLoader.getString ( String  name) [inline]

Definition at line 148 of file ODClassLoader.java.

                                         {

       byte[] ba = (byte[])byteTable.get(name);
       if (ba == null) {
           debug(" ODClassLoader: " + name + " not found.");
           return null;
       }
       String ret = null;
       try {
           ret = new String(ba, "UTF-8");
       } catch(Exception e) {
           if (Manager.DEBUG) {
              e.printStackTrace();
           }
       }

       return ret;
    }

Here is the call graph for this function:

String sun.awt.im.iiimp.ODClassLoader.getString ( String  name) [inline]

Definition at line 148 of file ODClassLoader.java.

                                         {

       byte[] ba = (byte[])byteTable.get(name);
       if (ba == null) {
           debug(" ODClassLoader: " + name + " not found.");
           return null;
       }
       String ret = null;
       try {
           ret = new String(ba, "UTF-8");
       } catch(Exception e) {
           if (Manager.DEBUG) {
              e.printStackTrace();
           }
       }

       return ret;
    }

Here is the call graph for this function:

URL sun.awt.im.iiimp.ODClassLoader.getURL ( String  name) [inline]

Definition at line 169 of file ODClassLoader.java.

                                   {

       byte[] ba = (byte[])byteTable.get(name);

       if (ba == null) {
           debug(" ODClassLoader: " + name + " not found.");
       }
       URL url = null;
       String anchor = null;
       try {
           File f = File.createTempFile("iiim", "iiim");
           String tempName = f.getAbsolutePath();
           f.delete();
           f = new File(tempName);
           f.mkdir();

           int anchorID = name.indexOf('#');
           if (anchorID > 0) {
              anchor = name.substring(anchorID);
              name = name.substring(0, anchorID);
           }

           int fileid = name.lastIndexOf("/");
           String dirname = name.substring(0, fileid);
           Object[] writeList = getWriteList(dirname);

           for (int i = 0; i < writeList.length; i++) { 
              String filename = ((String)writeList[i]).substring
                  (fileid, ((String)writeList[i]).length());
              if (filename.equals("") || filename.equals("/")) {
                  continue;
              }
              File f2 = new File(f, filename);
              byte[] ba2 = (byte[])byteTable.get((String)writeList[i]);
              if (ba2 == null) {
                  continue;
              }
              FileOutputStream fos = new FileOutputStream(f2);
              BufferedOutputStream bos = new BufferedOutputStream(fos);
              bos.write(ba2);
              bos.close();
              if (name.equals((String)writeList[i])) {
                  url = f2.toURL();
                  if (anchor != null) {
                     String s = url.toExternalForm();
                     url = new URL(s + anchor);
                  }
              }
           }
       } catch(Exception e) {
           debug(" getURL faied");
       }

       return url;
    }

Here is the call graph for this function:

URL sun.awt.im.iiimp.ODClassLoader.getURL ( String  name) [inline]

Definition at line 169 of file ODClassLoader.java.

                                   {

       byte[] ba = (byte[])byteTable.get(name);

       if (ba == null) {
           debug(" ODClassLoader: " + name + " not found.");
       }
       URL url = null;
       String anchor = null;
       try {
           File f = File.createTempFile("iiim", "iiim");
           String tempName = f.getAbsolutePath();
           f.delete();
           f = new File(tempName);
           f.mkdir();

           int anchorID = name.indexOf('#');
           if (anchorID > 0) {
              anchor = name.substring(anchorID);
              name = name.substring(0, anchorID);
           }

           int fileid = name.lastIndexOf("/");
           String dirname = name.substring(0, fileid);
           Object[] writeList = getWriteList(dirname);

           for (int i = 0; i < writeList.length; i++) { 
              String filename = ((String)writeList[i]).substring
                  (fileid, ((String)writeList[i]).length());
              if (filename.equals("") || filename.equals("/")) {
                  continue;
              }
              File f2 = new File(f, filename);
              byte[] ba2 = (byte[])byteTable.get((String)writeList[i]);
              if (ba2 == null) {
                  continue;
              }
              FileOutputStream fos = new FileOutputStream(f2);
              BufferedOutputStream bos = new BufferedOutputStream(fos);
              bos.write(ba2);
              bos.close();
              if (name.equals((String)writeList[i])) {
                  url = f2.toURL();
                  if (anchor != null) {
                     String s = url.toExternalForm();
                     url = new URL(s + anchor);
                  }
              }
           }
       } catch(Exception e) {
           debug(" getURL faied");
       }

       return url;
    }

Here is the call graph for this function:

Object [] sun.awt.im.iiimp.ODClassLoader.getWriteList ( String  dirname) [inline, private]

Definition at line 225 of file ODClassLoader.java.

                                                  {
       HashSet strSet = new HashSet();
       Iterator iterator = byteTable.keySet().iterator();
       for (; iterator.hasNext();) {
           String key = (String)iterator.next();
           if (key.startsWith(dirname)) {
              strSet.add(key);
           }
       }

       return strSet.toArray();
    }

Here is the caller graph for this function:

Object [] sun.awt.im.iiimp.ODClassLoader.getWriteList ( String  dirname) [inline, private]

Definition at line 225 of file ODClassLoader.java.

                                                  {
       HashSet strSet = new HashSet();
       Iterator iterator = byteTable.keySet().iterator();
       for (; iterator.hasNext();) {
           String key = (String)iterator.next();
           if (key.startsWith(dirname)) {
              strSet.add(key);
           }
       }

       return strSet.toArray();
    }

Member Data Documentation

HashMap sun.awt.im.iiimp.ODClassLoader.byteTable = new HashMap() [private]

Definition at line 58 of file ODClassLoader.java.


The documentation for this class was generated from the following files: