SupportClass.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. //
  2. // In order to convert some functionality to Visual C#, the Java Language Conversion Assistant
  3. // creates "support classes" that duplicate the original functionality.
  4. //
  5. // Support classes replicate the functionality of the original code, but in some cases they are
  6. // substantially different architecturally. Although every effort is made to preserve the
  7. // original architecture of the application in the converted project, the user should be aware that
  8. // the primary goal of these support classes is to replicate functionality, and that at times
  9. // the architecture of the resulting solution may differ somewhat.
  10. //
  11. using System;
  12. namespace FastReport.Barcode.QRCode
  13. {
  14. /*/// <summary>
  15. /// Contains conversion support elements such as classes, interfaces and static methods.
  16. /// </summary>*/
  17. internal class SupportClass
  18. {
  19. /*******************************/
  20. /*/// <summary>
  21. /// Performs an unsigned bitwise right shift with the specified number
  22. /// </summary>
  23. /// <param name="number">Number to operate on</param>
  24. /// <param name="bits">Ammount of bits to shift</param>
  25. /// <returns>The resulting number from the shift operation</returns>*/
  26. public static int URShift(int number, int bits)
  27. {
  28. if (number >= 0)
  29. return number >> bits;
  30. else
  31. return (number >> bits) + (2 << ~bits);
  32. }
  33. /*/// <summary>
  34. /// Performs an unsigned bitwise right shift with the specified number
  35. /// </summary>
  36. /// <param name="number">Number to operate on</param>
  37. /// <param name="bits">Ammount of bits to shift</param>
  38. /// <returns>The resulting number from the shift operation</returns>*/
  39. public static int URShift(int number, long bits)
  40. {
  41. return URShift(number, (int)bits);
  42. }
  43. /*/// <summary>
  44. /// Performs an unsigned bitwise right shift with the specified number
  45. /// </summary>
  46. /// <param name="number">Number to operate on</param>
  47. /// <param name="bits">Ammount of bits to shift</param>
  48. /// <returns>The resulting number from the shift operation</returns>*/
  49. public static long URShift(long number, int bits)
  50. {
  51. if (number >= 0)
  52. return number >> bits;
  53. else
  54. return (number >> bits) + (2L << ~bits);
  55. }
  56. /*/// <summary>
  57. /// Performs an unsigned bitwise right shift with the specified number
  58. /// </summary>
  59. /// <param name="number">Number to operate on</param>
  60. /// <param name="bits">Ammount of bits to shift</param>
  61. /// <returns>The resulting number from the shift operation</returns>*/
  62. public static long URShift(long number, long bits)
  63. {
  64. return URShift(number, (int)bits);
  65. }
  66. /*******************************/
  67. /*/// <summary>
  68. /// This method returns the literal value received
  69. /// </summary>
  70. /// <param name="literal">The literal to return</param>
  71. /// <returns>The received value</returns>*/
  72. public static long Identity(long literal)
  73. {
  74. return literal;
  75. }
  76. /*/// <summary>
  77. /// This method returns the literal value received
  78. /// </summary>
  79. /// <param name="literal">The literal to return</param>
  80. /// <returns>The received value</returns>*/
  81. public static ulong Identity(ulong literal)
  82. {
  83. return literal;
  84. }
  85. /*/// <summary>
  86. /// This method returns the literal value received
  87. /// </summary>
  88. /// <param name="literal">The literal to return</param>
  89. /// <returns>The received value</returns>*/
  90. public static float Identity(float literal)
  91. {
  92. return literal;
  93. }
  94. /*/// <summary>
  95. /// This method returns the literal value received
  96. /// </summary>
  97. /// <param name="literal">The literal to return</param>
  98. /// <returns>The received value</returns>*/
  99. public static double Identity(double literal)
  100. {
  101. return literal;
  102. }
  103. /*******************************/
  104. /*/// <summary>
  105. /// Receives a byte array and returns it transformed in an sbyte array
  106. /// </summary>
  107. /// <param name="byteArray">Byte array to process</param>
  108. /// <returns>The transformed array</returns>*/
  109. public static sbyte[] ToSByteArray(byte[] byteArray)
  110. {
  111. sbyte[] sbyteArray = null;
  112. if (byteArray != null)
  113. {
  114. sbyteArray = new sbyte[byteArray.Length];
  115. for (int index = 0; index < byteArray.Length; index++)
  116. sbyteArray[index] = (sbyte)byteArray[index];
  117. }
  118. return sbyteArray;
  119. }
  120. }
  121. }