Pricing dia - Erro ao aplicar pricing na venda
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@31704 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
541a4c12b8
commit
ae0ac95efe
|
@ -7,8 +7,7 @@
|
||||||
package com.rjconsultores.ventaboletos.utilerias.spring.security;
|
package com.rjconsultores.ventaboletos.utilerias.spring.security;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Static methods for translating Base64 encoded strings to byte arrays
|
* Static methods for translating Base64 encoded strings to byte arrays and vice-versa.
|
||||||
* and vice-versa.
|
|
||||||
*
|
*
|
||||||
* @author Josh Bloch
|
* @author Josh Bloch
|
||||||
* @version 1.3, 12/03/01
|
* @version 1.3, 12/03/01
|
||||||
|
@ -18,18 +17,14 @@ package com.rjconsultores.ventaboletos.utilerias.spring.security;
|
||||||
public class Base64 {
|
public class Base64 {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Translates the specified byte array into a Base64 string as per
|
* Translates the specified byte array into a Base64 string as per Preferences.put(byte[]).
|
||||||
* Preferences.put(byte[]).
|
|
||||||
*/
|
*/
|
||||||
public static String byteArrayToBase64(byte[] a) {
|
public static String byteArrayToBase64(byte[] a) {
|
||||||
return byteArrayToBase64(a, false);
|
return byteArrayToBase64(a, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Translates the specified byte array into an "aternate representation"
|
* Translates the specified byte array into an "aternate representation" Base64 string. This non-standard variant uses an alphabet that does not contain the uppercase alphabetic characters, which makes it suitable for use in situations where case-folding occurs.
|
||||||
* Base64 string. This non-standard variant uses an alphabet that does
|
|
||||||
* not contain the uppercase alphabetic characters, which makes it
|
|
||||||
* suitable for use in situations where case-folding occurs.
|
|
||||||
*/
|
*/
|
||||||
public static String byteArrayToAltBase64(byte[] a) {
|
public static String byteArrayToAltBase64(byte[] a) {
|
||||||
return byteArrayToBase64(a, true);
|
return byteArrayToBase64(a, true);
|
||||||
|
@ -74,10 +69,9 @@ public class Base64 {
|
||||||
// assert result.length() == resultLen;
|
// assert result.length() == resultLen;
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This array is a lookup table that translates 6-bit positive integer
|
* This array is a lookup table that translates 6-bit positive integer index values into their "Base64 Alphabet" equivalents as specified in Table 1 of RFC 2045.
|
||||||
* index values into their "Base64 Alphabet" equivalents as specified
|
|
||||||
* in Table 1 of RFC 2045.
|
|
||||||
*/
|
*/
|
||||||
private static final char intToBase64[] = {
|
private static final char intToBase64[] = {
|
||||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
|
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
|
||||||
|
@ -87,11 +81,7 @@ public class Base64 {
|
||||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'
|
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* This array is a lookup table that translates 6-bit positive integer
|
* This array is a lookup table that translates 6-bit positive integer index values into their "Alternate Base64 Alphabet" equivalents. This is NOT the real Base64 Alphabet as per in Table 1 of RFC 2045. This alternate alphabet does not use the capital letters. It is designed for use in environments where "case folding" occurs.
|
||||||
* index values into their "Alternate Base64 Alphabet" equivalents.
|
|
||||||
* This is NOT the real Base64 Alphabet as per in Table 1 of RFC 2045.
|
|
||||||
* This alternate alphabet does not use the capital letters. It is
|
|
||||||
* designed for use in environments where "case folding" occurs.
|
|
||||||
*/
|
*/
|
||||||
private static final char intToAltBase64[] = {
|
private static final char intToAltBase64[] = {
|
||||||
'!', '"', '#', '$', '%', '&', '\'', '(', ')', ',', '-', '.', ':',
|
'!', '"', '#', '$', '%', '&', '\'', '(', ')', ',', '-', '.', ':',
|
||||||
|
@ -102,23 +92,18 @@ public class Base64 {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Translates the specified Base64 string (as per Preferences.get(byte[]))
|
* Translates the specified Base64 string (as per Preferences.get(byte[])) into a byte array.
|
||||||
* into a byte array.
|
|
||||||
*
|
*
|
||||||
* @throw IllegalArgumentException if <tt>s</tt> is not a valid Base64
|
* @throw IllegalArgumentException if <tt>s</tt> is not a valid Base64 string.
|
||||||
* string.
|
|
||||||
*/
|
*/
|
||||||
public static byte[] base64ToByteArray(String s) {
|
public static byte[] base64ToByteArray(String s) {
|
||||||
return base64ToByteArray(s, false);
|
return base64ToByteArray(s, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Translates the specified "aternate representation" Base64 string
|
* Translates the specified "aternate representation" Base64 string into a byte array.
|
||||||
* into a byte array.
|
|
||||||
*
|
*
|
||||||
* @throw IllegalArgumentException or ArrayOutOfBoundsException
|
* @throw IllegalArgumentException or ArrayOutOfBoundsException if <tt>s</tt> is not a valid alternate representation Base64 string.
|
||||||
* if <tt>s</tt> is not a valid alternate representation
|
|
||||||
* Base64 string.
|
|
||||||
*/
|
*/
|
||||||
public static byte[] altBase64ToByteArray(String s) {
|
public static byte[] altBase64ToByteArray(String s) {
|
||||||
return base64ToByteArray(s, true);
|
return base64ToByteArray(s, true);
|
||||||
|
@ -168,17 +153,13 @@ public class Base64 {
|
||||||
result[outCursor++] = (byte) ((ch1 << 4) | (ch2 >> 2));
|
result[outCursor++] = (byte) ((ch1 << 4) | (ch2 >> 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// assert inCursor == s.length()-missingBytesInLastGroup;
|
|
||||||
// assert outCursor == result.length;
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Translates the specified character, which is assumed to be in the
|
* Translates the specified character, which is assumed to be in the "Base 64 Alphabet" into its equivalent 6-bit positive integer.
|
||||||
* "Base 64 Alphabet" into its equivalent 6-bit positive integer.
|
|
||||||
*
|
*
|
||||||
* @throw IllegalArgumentException or ArrayOutOfBoundsException if
|
* @throw IllegalArgumentException or ArrayOutOfBoundsException if c is not in the Base64 Alphabet.
|
||||||
* c is not in the Base64 Alphabet.
|
|
||||||
*/
|
*/
|
||||||
private static int base64toInt(char c, byte[] alphaToInt) {
|
private static int base64toInt(char c, byte[] alphaToInt) {
|
||||||
int result = alphaToInt[c];
|
int result = alphaToInt[c];
|
||||||
|
@ -187,12 +168,9 @@ public class Base64 {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This array is a lookup table that translates unicode characters
|
* This array is a lookup table that translates unicode characters drawn from the "Base64 Alphabet" (as specified in Table 1 of RFC 2045) into their 6-bit positive integer equivalents. Characters that are not in the Base64 alphabet but fall within the bounds of the array are translated to -1.
|
||||||
* drawn from the "Base64 Alphabet" (as specified in Table 1 of RFC 2045)
|
|
||||||
* into their 6-bit positive integer equivalents. Characters that
|
|
||||||
* are not in the Base64 alphabet but fall within the bounds of the
|
|
||||||
* array are translated to -1.
|
|
||||||
*/
|
*/
|
||||||
private static final byte base64ToInt[] = {
|
private static final byte base64ToInt[] = {
|
||||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||||
|
@ -204,8 +182,7 @@ public class Base64 {
|
||||||
35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51
|
35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* This array is the analogue of base64ToInt, but for the nonstandard
|
* This array is the analogue of base64ToInt, but for the nonstandard variant that avoids the use of uppercase alphabetic characters.
|
||||||
* variant that avoids the use of uppercase alphabetic characters.
|
|
||||||
*/
|
*/
|
||||||
private static final byte altBase64ToInt[] = {
|
private static final byte altBase64ToInt[] = {
|
||||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||||
|
@ -219,27 +196,6 @@ public class Base64 {
|
||||||
};
|
};
|
||||||
|
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
// int numRuns = Integer.parseInt(args[0]);
|
|
||||||
// int numBytes = Integer.parseInt(args[1]);
|
|
||||||
// java.util.Random rnd = new java.util.Random();
|
|
||||||
// for (int i=0; i<numRuns; i++) {
|
|
||||||
// for (int j=0; j<numBytes; j++) {
|
|
||||||
// byte[] arr = new byte[j];
|
|
||||||
// for (int k=0; k<j; k++)
|
|
||||||
// arr[k] = (byte)rnd.nextInt();
|
|
||||||
//
|
|
||||||
// String s = byteArrayToBase64(arr);
|
|
||||||
// byte [] b = base64ToByteArray(s);
|
|
||||||
// if (!java.util.Arrays.equals(arr, b))
|
|
||||||
// System.out.println("Dismal failure!");
|
|
||||||
//
|
|
||||||
// s = byteArrayToAltBase64(arr);
|
|
||||||
// b = altBase64ToByteArray(s);
|
|
||||||
// if (!java.util.Arrays.equals(arr, b))
|
|
||||||
// System.out.println("Alternate dismal failure!");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
Integer i = new Integer(-1);
|
Integer i = new Integer(-1);
|
||||||
Short s = i.shortValue();
|
Short s = i.shortValue();
|
||||||
System.out.println(s);
|
System.out.println(s);
|
||||||
|
|
Loading…
Reference in New Issue