public void TestVariousLogTypes() { //NKB Testing only that logging classes use gives no exception // Since logging can be disabled, no checking of logging // output is done. POILogger log = POILogFactory.GetLogger("foo"); log.Log(POILogger.WARN, "Test = ", 1); }
public void TestVariousLogTypes() { //NKB Testing only that logging classes use gives no exception // Since logging can be disabled, no checking of logging // output is done. POILogger log = POILogFactory.GetLogger("foo"); log.Log(POILogger.WARN, "Test = ", 1); log.LogFormatted(POILogger.ERROR, "Test param 1 = %, param 2 = %", "2", 3); log.LogFormatted(POILogger.ERROR, "Test param 1 = %, param 2 = %", new int[] { 4, 5 }); log.LogFormatted(POILogger.ERROR, "Test param 1 = %1.1, param 2 = %0.1", new double[] { 4, 5.23 }); }
public void TestLog() { //NKB Testing only that logging classes use gives no exception // Since logging can be disabled, no checking of logging // output is done. POILogger l1 = POILogFactory.GetLogger("org.apache.poi.hssf.test"); POILogger l2 = POILogFactory.GetLogger("org.apache.poi.hdf.test"); l1.Log(POILogger.FATAL, "testing cat org.apache.poi.hssf.*:FATAL"); l1.Log(POILogger.ERROR, "testing cat org.apache.poi.hssf.*:ERROR"); l1.Log(POILogger.WARN, "testing cat org.apache.poi.hssf.*:WARN"); l1.Log(POILogger.INFO, "testing cat org.apache.poi.hssf.*:INFO"); l1.Log(POILogger.DEBUG, "testing cat org.apache.poi.hssf.*:DEBUG"); l2.Log(POILogger.FATAL, "testing cat org.apache.poi.hdf.*:FATAL"); l2.Log(POILogger.ERROR, "testing cat org.apache.poi.hdf.*:ERROR"); l2.Log(POILogger.WARN, "testing cat org.apache.poi.hdf.*:WARN"); l2.Log(POILogger.INFO, "testing cat org.apache.poi.hdf.*:INFO"); l2.Log(POILogger.DEBUG, "testing cat org.apache.poi.hdf.*:DEBUG"); }
/// <summary> /// Reads the dictionary. /// </summary> /// <param name="src">The byte array containing the bytes making out the dictionary.</param> /// <param name="offset">At this offset within src the dictionary starts.</param> /// <param name="Length">The dictionary Contains at most this many bytes.</param> /// <param name="codepage">The codepage of the string values.</param> /// <returns>The dictonary</returns> protected IDictionary ReadDictionary(byte[] src, long offset, int Length, int codepage) { /* Check whether "offset" points into the "src" array". */ if (offset < 0 || offset > src.Length) { throw new HPSFRuntimeException ("Illegal offset " + offset + " while HPSF stream Contains " + Length + " bytes."); } int o = (int)offset; /* * Read the number of dictionary entries. */ long nrEntries = LittleEndian.GetUInt(src, o); o += LittleEndianConsts.INT_SIZE; Hashtable m = new Hashtable((int)nrEntries, (float)1.0); try { for (int i = 0; i < nrEntries; i++) { /* The key. */ long id = LittleEndian.GetUInt(src, o); o += LittleEndianConsts.INT_SIZE; /* The value (a string). The Length is the either the * number of (two-byte) characters if the character Set is Unicode * or the number of bytes if the character Set is not Unicode. * The Length includes terminating 0x00 bytes which we have To strip * off To Create a Java string. */ long sLength = LittleEndian.GetUInt(src, o); o += LittleEndianConsts.INT_SIZE; /* Read the string. */ StringBuilder b = new StringBuilder(); switch (codepage) { case -1: { /* Without a codepage the Length is equal To the number of * bytes. */ b.Append(Encoding.UTF8.GetString(src, o, (int)sLength)); break; } case (int)Constants.CP_UNICODE: { /* The Length is the number of characters, i.e. the number * of bytes is twice the number of the characters. */ int nrBytes = (int)(sLength * 2); byte[] h = new byte[nrBytes]; for (int i2 = 0; i2 < nrBytes; i2 += 2) { h[i2] = src[o + i2 + 1]; h[i2 + 1] = src[o + i2]; } b.Append(Encoding.GetEncoding(codepage).GetString(h, 0, nrBytes)); break; } default: { /* For encodings other than Unicode the Length is the number * of bytes. */ b.Append(Encoding.GetEncoding(codepage).GetString(src, o, (int)sLength)); break; } } /* Strip 0x00 characters from the end of the string: */ while (b.Length > 0 && b[b.Length - 1] == 0x00) { b.Length = b.Length - 1; } if (codepage == (int)Constants.CP_UNICODE) { if (sLength % 2 == 1) { sLength++; } o += (int)(sLength + sLength); } else { o += (int)sLength; } m[id] = b.ToString(); } } catch (Exception ex) { POILogger l = POILogFactory.GetLogger(typeof(Property)); l.Log(POILogger.WARN, "The property Set's dictionary Contains bogus data. " + "All dictionary entries starting with the one with ID " + id + " will be ignored.", ex); } return(m); }