001 package com.croftsoft.core.jnlp; 002 003 import java.io.*; 004 import java.net.*; 005 006 /********************************************************************* 007 * Static library methods for JNLP. 008 * 009 * @version 010 * 2002-12-22 011 * @since 012 * 2002-12-22 013 * @author 014 * <a href="https://www.croftsoft.com/">David Wallace Croft</a> 015 *********************************************************************/ 016 017 public final class JnlpLib 018 ////////////////////////////////////////////////////////////////////// 019 ////////////////////////////////////////////////////////////////////// 020 { 021 022 public static final JnlpServices JNLP_SERVICES 023 = createJnlpServices ( ); 024 025 ////////////////////////////////////////////////////////////////////// 026 ////////////////////////////////////////////////////////////////////// 027 028 public static URL createFileContentsURL ( String fileContentsSpec ) 029 throws MalformedURLException, UnsupportedOperationException 030 ////////////////////////////////////////////////////////////////////// 031 { 032 check ( ); 033 034 return JNLP_SERVICES.createFileContentsURL ( fileContentsSpec ); 035 } 036 037 public static URL getCodeBase ( ) 038 throws UnsupportedOperationException 039 ////////////////////////////////////////////////////////////////////// 040 { 041 check ( ); 042 043 return JNLP_SERVICES.getCodeBase ( ); 044 } 045 046 public static byte [ ] loadBytesUsingPersistenceService ( 047 String fileContentsSpec ) 048 throws IOException, UnsupportedOperationException 049 ////////////////////////////////////////////////////////////////////// 050 { 051 check ( ); 052 053 return JNLP_SERVICES.loadBytesUsingPersistenceService ( 054 fileContentsSpec ); 055 } 056 057 public static Serializable loadSerializableUsingPersistenceService ( 058 String fileContentsSpec ) 059 throws ClassNotFoundException, IOException, 060 UnsupportedOperationException 061 ////////////////////////////////////////////////////////////////////// 062 { 063 check ( ); 064 065 return JNLP_SERVICES.loadSerializableUsingPersistenceService ( 066 fileContentsSpec ); 067 } 068 069 public static void saveBytesUsingPersistenceService ( 070 String fileContentsSpec, 071 byte [ ] bytes ) 072 throws IOException, UnsupportedOperationException 073 ////////////////////////////////////////////////////////////////////// 074 { 075 check ( ); 076 077 JNLP_SERVICES.saveBytesUsingPersistenceService ( 078 fileContentsSpec, bytes ); 079 } 080 081 public static void saveSerializableUsingPersistenceService ( 082 String fileContentsSpec, 083 Serializable serializable ) 084 throws IOException, UnsupportedOperationException 085 ////////////////////////////////////////////////////////////////////// 086 { 087 check ( ); 088 089 JNLP_SERVICES.saveSerializableUsingPersistenceService ( 090 fileContentsSpec, serializable ); 091 } 092 093 public static boolean showDocument ( URL url ) 094 throws UnsupportedOperationException 095 ////////////////////////////////////////////////////////////////////// 096 { 097 check ( ); 098 099 return JNLP_SERVICES.showDocument ( url ); 100 } 101 102 ////////////////////////////////////////////////////////////////////// 103 ////////////////////////////////////////////////////////////////////// 104 105 private static void check ( ) 106 throws UnsupportedOperationException 107 ////////////////////////////////////////////////////////////////////// 108 { 109 if ( JNLP_SERVICES == null ) 110 { 111 throw new UnsupportedOperationException ( ); 112 } 113 } 114 115 private static JnlpServices createJnlpServices ( ) 116 ////////////////////////////////////////////////////////////////////// 117 { 118 try 119 { 120 return ( JnlpServices ) 121 Class.forName ( JnlpServices.IMPL_CLASS_NAME ).newInstance ( ); 122 } 123 catch ( Exception ex ) 124 { 125 return null; 126 } 127 catch ( NoClassDefFoundError er ) 128 { 129 return null; 130 } 131 } 132 133 private JnlpLib ( ) { } 134 135 ////////////////////////////////////////////////////////////////////// 136 ////////////////////////////////////////////////////////////////////// 137 }