Package org.exolab.castor.util

Examples of org.exolab.castor.util.MimeBase64Encoder


                    //-- handle base64 content
                    Class objType = obj.getClass();
                    if (objType.isArray() &&
                       (objType.getComponentType() == Byte.TYPE))
                    {
                        MimeBase64Encoder encoder = new MimeBase64Encoder();
                        encoder.translate((byte[])obj);
                        chars = encoder.getCharArray();
                    }
                    //-- all other types
                    else {
                        String str = obj.toString();
                        if ((str != null) && (str.length() > 0)) {
                            chars = str.toCharArray();
                        }
                    }
                    if ((chars != null) && (chars.length > 0)) {
                        try {
                            handler.characters(chars, 0, chars.length);
                        }
                        catch(org.xml.sax.SAXException sx) {
                            throw new MarshalException(sx);
                        }
                    }
                }
            }
            //-- element references
            else if (descriptor.isReference()) {
                Object id = getObjectID(object);
                if (id != null) {
                    char[] chars = id.toString().toCharArray();
                    try {
                        handler.characters(chars, 0, chars.length);
                    }
                    catch(org.xml.sax.SAXException sx) {
                        throw new MarshalException(sx);
                    }
                }
            }
            // special case for byte[]
            else if (byteArray) {
                //-- Base64Encoding
                MimeBase64Encoder encoder = new MimeBase64Encoder();
                encoder.translate((byte[])object);
                char[] chars = encoder.getCharArray();
                try {
                    handler.characters(chars, 0, chars.length);
                }
                catch(org.xml.sax.SAXException sx) {
                    throw new MarshalException(sx);
View Full Code Here


                        }
                    }

                    if (bytes != null)
                    {
                        MimeBase64Encoder encoder = new MimeBase64Encoder();
                        encoder.translate( bytes );
                        chars = encoder.getCharArray();
                        attrList.addAttribute( XML.Entries.Attributes.Encoding, "NMTOKEN",
                                               XML.Entries.Attributes.Encodings.Base64 );
                    }
                    _docHandler.startElement( prefix( XML.Entries.Elements.Value ), attrList );
                    _docHandler.characters( chars, 0, chars.length );
View Full Code Here

      if ( i == value.length ) {
          chars = new char[ value.length ];
          for ( i = 0 ; i < value.length ; ++i )
        chars[ i ] = (char) value[ i ];
      } else {
          MimeBase64Encoder encoder;
         
          encoder = new MimeBase64Encoder();
          encoder.translate( value );
          chars = encoder.getCharArray();
          attrList.addAttribute( XML.Entries.Attributes.Encoding, "NMTOKEN",
               XML.Entries.Attributes.Encodings.Base64 );
      }
        }
View Full Code Here

TOP

Related Classes of org.exolab.castor.util.MimeBase64Encoder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.