int len = removeWhiteSpace(base64Data); if (!isData( (d1 = base64Data[dataIndex++]) )|| !isData( (d2 = base64Data[dataIndex++]) )|| !isData( (d3 = base64Data[dataIndex++]) )|| !isData( (d4 = base64Data[dataIndex++]) )) return null;//if found "no data" just return null if (!isData( (d1 = base64Data[dataIndex++]) ) || !isData( (d2 = base64Data[dataIndex++]) )) { return null;//if found "no data" just return null if (!isData( (d3 ) ) || !isData( (d4 ) )) {//Check if they are PAD characters if (isPad( d3 ) && isPad( d4)) { //Two PAD e.g. 3c[Pad][Pad] if ((b2 & 0xf) != 0)//last 4 bits should be zero return null; tmp[encodedIndex] = (byte)( b1 <<2 | b2>>4 ) ; return tmp; } else if (!isPad( d3) && isPad(d4)) { //One PAD e.g. 3cQ[Pad] b3 = base64Alphabet[ d3 ]; if ((b3 & 0x3 ) != 0)//last 2 bits should be zero
int len = removeWhiteSpace(base64Data); if (!isData( (d1 = base64Data[dataIndex++]) )|| !isData( (d2 = base64Data[dataIndex++]) )|| !isData( (d3 = base64Data[dataIndex++]) )|| !isData( (d4 = base64Data[dataIndex++]) )) return null;//if found "no data" just return null if (!isData( (d1 = base64Data[dataIndex++]) ) || !isData( (d2 = base64Data[dataIndex++]) )) { return null;//if found "no data" just return null if (!isData( (d3 ) ) || !isData( (d4 ) )) {//Check if they are PAD characters if (isPad( d3 ) && isPad( d4)) { //Two PAD e.g. 3c[Pad][Pad] if ((b2 & 0xf) != 0)//last 4 bits should be zero return null; tmp[encodedIndex] = (byte)( b1 <<2 | b2>>4 ) ; return tmp; } else if (!isPad( d3) && isPad(d4)) { //One PAD e.g. 3cQ[Pad] b3 = base64Alphabet[ d3 ]; if ((b3 & 0x3 ) != 0)//last 2 bits should be zero
/** * remove WhiteSpace from MIME containing encoded Base64 data. * * @param data the byte array of base64 data (with WS) * @return the new length */ protected static int removeWhiteSpace(char[] data) { if (data == null) return 0; // count characters that's not whitespace int newSize = 0; int len = data.length; for (int i = 0; i < len; i++) { if (!isWhiteSpace(data[i])) data[newSize++] = data[i]; } return newSize; } }
/** * remove WhiteSpace from MIME containing encoded Base64 data. * * @param data the byte array of base64 data (with WS) * @return the new length */ protected static int removeWhiteSpace(char[] data) { if (data == null) return 0; // count characters that's not whitespace int newSize = 0; int len = data.length; for (int i = 0; i < len; i++) { if (!isWhiteSpace(data[i])) data[newSize++] = data[i]; } return newSize; } }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT */ public byte[] createBase64Binary(String literal) { if (literal == null) return null; byte[] value = Base64.decode(collapseWhiteSpace(literal)); if (value == null) { throw new InvalidDatatypeValueException("Invalid base64Binary value: '" + literal + "'"); } return value; }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT */ public byte[] createBase64Binary(String literal) { if (literal == null) return null; byte[] value = Base64.decode(collapseWhiteSpace(literal)); if (value == null) { throw new InvalidDatatypeValueException("Invalid base64Binary value: '" + literal + "'"); } return value; }
@Override public Object getValue(String literal) { byte[] bytes = Base64.decode(literal); return (bytes != null) ? new ByteSequence(this, bytes) : null; } }
@Override public String toString() { if (canonical == null) { canonical = Base64.encode(bytes); } return canonical; } }
protected static boolean isBase64(char octect) { return (isWhiteSpace(octect) || isPad(octect) || isData(octect)); }
protected static boolean isBase64(char octect) { return (isWhiteSpace(octect) || isPad(octect) || isData(octect)); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT */ public String convertBase64Binary(byte[] instanceValue) { return instanceValue == null ? null : Base64.encode(instanceValue); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT */ public String convertBase64Binary(byte[] instanceValue) { return instanceValue == null ? null : Base64.encode(instanceValue); }
@Override public String toString() { if (canonical == null) { canonical = Base64.encode(bytes); } return canonical; } }
@Override public Object getValue(String literal) { byte[] bytes = Base64.decode(literal); return (bytes != null) ? new ByteSequence(this, bytes) : null; } }