tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Tools and Libs > Open Symphony Core > Decode Object

Decode Object 

OSCore (Open Symphony Core) is a java library with lot of utilities and reusable components. This requires the libraries oscore-2.2.6.jar, mail.jar to be in classpath. The following example shows using TextUtils.decodeObject() API. It decodes the Object encoded using TextUtils.encodeObject() API.

File Name  :  
com/bethecoder/tutorials/oscore/DecodeObjectTest.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
package com.bethecoder.tutorials.oscore;

import java.io.IOException;
import java.util.List;

import com.opensymphony.util.TextUtils;

public class DecodeObjectTest {

  /**
   @param args
   @throws IOException 
   @throws ClassNotFoundException 
   */
  public static void main(String[] argsthrows IOException, ClassNotFoundException {

    String str = (StringTextUtils.decodeObject("rO0ABXQAB0FCQ0RFRkc=");
    System.out.println(str);
    
    String encDoubleStr = 
      "rO0ABXNyABBqYXZhLmxhbmcuRG91YmxlgLPCSilr+wQCAAFEAAV2YWx1ZXhyABBqYXZhLmxhbmcu" 
      "TnVtYmVyhqyVHQuU4IsCAAB4cD/zwMoqWx1d";
    Double num = (DoubleTextUtils.decodeObject(encDoubleStr);
    System.out.println(num);
    
    String encStrListStr = 
      "rO0ABXNyABpqYXZhLnV0aWwuQXJyYXlzJEFycmF5TGlzdNmkPL7NiAbSAgABWwABYXQAE1tMamF2" 
      "YS9sYW5nL09iamVjdDt4cHVyABNbTGphdmEubGFuZy5TdHJpbmc7rdJW5+kde0cCAAB4cAAAAAJ0" 
      "AANPTkV0AANUV08=";
    
    List<String> strList = (List<String>TextUtils.decodeObject(encStrListStr);
    System.out.println(strList);
  }

}
   

It gives the following output,
ABCDEFG
1.2345678
[ONE, TWO]



 
  


  
bl  br