Package org.exolab.castor.util

Examples of org.exolab.castor.util.MimeBase64Decoder


                if (str == null)
                    state.object = new byte[0];
                else {
                    //-- Base64 decoding
                    char[] chars = str.toCharArray();
                    MimeBase64Decoder decoder = new MimeBase64Decoder();
                    decoder.translate(chars, 0, chars.length);
                    state.object = decoder.getByteArray();
                }
            }
            else if (state.args != null) {
              state.object = createInstance(state.type, state.args);
            }
            else state.object = toPrimitiveObject(type,str,state.fieldDesc);
        }
        else if (ArrayHandler.class.isAssignableFrom(state.type)) {
            state.object = ((ArrayHandler)state.object).getObject();
            state.type = state.object.getClass();
           
        }

        //-- check for character content
        if ((state.buffer != null) &&
            (state.buffer.length() > 0) &&
            (state.classDesc != null)) {
            XMLFieldDescriptor cdesc = state.classDesc.getContentDescriptor();
            if (cdesc != null) {
                Object value = state.buffer.toString();
                if (isPrimitive(cdesc.getFieldType()))
                    value = toPrimitiveObject(cdesc.getFieldType(), (String)value, state.fieldDesc);
                else {
                    Class valueType = cdesc.getFieldType();
                    //-- handle base64
                    if (valueType.isArray() &&
                        (valueType.getComponentType() == Byte.TYPE))
                    {
                        char[] chars = ((String)value).toCharArray();
                        MimeBase64Decoder decoder = new MimeBase64Decoder();
                        decoder.translate(chars, 0, chars.length);
                        value = decoder.getByteArray();
                    }
                }


                try {
View Full Code Here


                if (str == null)
                    state.object = new byte[0];
                else {
                    //-- Base64 decoding
                    char[] chars = str.toCharArray();
                    MimeBase64Decoder decoder = new MimeBase64Decoder();
                    decoder.translate(chars, 0, chars.length);
                    state.object = decoder.getByteArray();
                }
            }
            else state.object = toPrimitiveObject(type,str);
        }
        else if (ArrayHandler.class.isAssignableFrom(state.type)) {
            state.object = ((ArrayHandler)state.object).getObject();
            state.type = state.object.getClass();
           
        }

        //-- check for character content
        if ((state.buffer != null) &&
            (state.buffer.length() > 0) &&
            (state.classDesc != null)) {
           XMLFieldDescriptor cdesc = state.classDesc.getContentDescriptor();
            if (cdesc != null) {
                Object value = state.buffer.toString();
                if (isPrimitive(cdesc.getFieldType()))
                    value = toPrimitiveObject(cdesc.getFieldType(), (String)value);
                else {
                    Class valueType = cdesc.getFieldType();
                    //-- handle base64
                    if (valueType.isArray() &&
                        (valueType.getComponentType() == Byte.TYPE))
                    {
                        char[] chars = ((String)value).toCharArray();
                        MimeBase64Decoder decoder = new MimeBase64Decoder();
                        decoder.translate(chars, 0, chars.length);
                        value = decoder.getByteArray();
                    }
                }


                try {
View Full Code Here

        tagName.equals( XML.Entries.Elements.OCValue ) ) {
      if ( _attrSet == null || _attr == null || _value != null )
    throw new SAXException( Messages.format( "dsml.openingTagNotRecognized", tagName ) );
      if ( XML.Entries.Attributes.Encodings.Base64.equals(
         attr.getValue( XML.Entries.Attributes.Encoding ) ) ) {
    _decoder = new MimeBase64Decoder();
      } else {
    _value = new StringBuffer();
      }
  } else {
      throw new SAXException( Messages.format( "dsml.openingTagNotRecognized", tagName ) );
View Full Code Here

        tagName.equals( XML.Entries.Elements.OCValue ) ) {
      if ( _attrSet == null || _attr == null || _value != null )
    throw new SAXException( Messages.format( "dsml.openingTagNotRecognized", tagName ) );
      if ( XML.Entries.Attributes.Encodings.Base64.equals(
         attr.getValue( XML.Entries.Attributes.Encoding ) ) ) {
    _decoder = new MimeBase64Decoder();
      } else {
    _value = new StringBuffer();
      }
  } else {
      throw new SAXException( Messages.format( "dsml.openingTagNotRecognized", tagName ) );
View Full Code Here

TOP

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

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.