Beispiel #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: static SingleByteConversion acquireSingleByteConversion(int ccsid) throws java.io.UnsupportedEncodingException
        internal static SingleByteConversion acquireSingleByteConversion(int ccsid)
        {
            // Attempt to find the shipped table using reflection
            SingleByteConversion singleByteConversion = null;
            Type conversionClass = null;

            try
            {
                conversionClass = Type.GetType("com.ibm.jtopenlite.ccsidConversion.CCSID" + ccsid);

                Type[] emptyParameterTypes          = new Type[0];
                System.Reflection.MethodInfo method = conversionClass.GetMethod("getInstance", emptyParameterTypes);
                object[] args = new object[0];
                singleByteConversion = (SingleByteConversion)method.invoke(null, args);
            }
            catch (ClassNotFoundException exceptionCause)
            {
                //
                // TODO:   Download tables from the server.
                //
                UnsupportedEncodingException ex = new UnsupportedEncodingException("CCSID=" + ccsid);
                ex.initCause(exceptionCause);
                throw ex;
            }
            catch (Exception exceptionCause)
            {
                UnsupportedEncodingException ex = new UnsupportedEncodingException("CCSID=" + ccsid);
                ex.initCause(exceptionCause);
                throw ex;
            }
            ccsidToSingleByteConversion[ccsid] = singleByteConversion;
            return(singleByteConversion);
        }
Beispiel #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static SingleByteConversion getSingleByteConversion(int ccsid) throws java.io.UnsupportedEncodingException
        public static SingleByteConversion getSingleByteConversion(int ccsid)
        {
            SingleByteConversion singleByteConversion;

            lock (@lock)
            {
                if (ccsid >= ccsidToSingleByteConversion.Length)
                {
                    SingleByteConversion[] newCcsidToSingleByteConversion = new SingleByteConversion[ccsid + 1];
                    for (int i = 0; i < ccsidToSingleByteConversion.Length; i++)
                    {
                        newCcsidToSingleByteConversion [i] = ccsidToSingleByteConversion [i];
                    }
                    ccsidToSingleByteConversion = newCcsidToSingleByteConversion;
                }
                singleByteConversion = ccsidToSingleByteConversion[ccsid];
                if (singleByteConversion == null)
                {
                    singleByteConversion = acquireSingleByteConversion(ccsid);
                }
            }
            return(singleByteConversion);
        }