Results 1 to 1 of 1
- 02-16-2012, 12:01 AM #1
Member
- Join Date
- Jul 2008
- Posts
- 4
- Rep Power
- 0
Creating objects at runtime if needed, otherwise using old object
I am new to this.... here is my problem...
I am trying to create a JSON response, in which I have to add different URLs...based on there extension(like .flv or .mp4)...
currently, I have hardcoded my method to accept only flv and mp4 files, but I want to generalize the method...
here is the hardcoded way..
Java Code:BitrateUrls burls = new BitrateUrls(); Encoding enocflv = new Encoding(); Encoding enocmp4 = new Encoding(); else if (nName.startsWith("original_") && nName.endsWith(".flv")) { BitrateUrl flvurl = populateBitRateUrls(n.getPath(), nName); enocflv.setType(MediaCmsConstants.MEDIA_ENOC_FLV); enocflv.getBitrateUrl().add(flvurl); } else if(nName.startsWith("original_") && nName.endsWith(".mp4")){ BitrateUrl mp4url = populateBitRateUrls(n.getPath(), nName); enocmp4.setType(MediaCmsConstants.MEDIA_ENOC_MP4); enocmp4.getBitrateUrl().add(mp4url); } if(!enoc.getBitrateUrl().isEmpty()){ burls.getEncoding().add(enoc); } if(!enocmp4.getBitrateUrl().isEmpty()){ burls.getEncoding().add(enocmp4); }
here is the way I am trying to generalize it....
the problem now it lists all the mp4 renditions under 1 file extension.... and if I initilaize the enoc variable inside elseif block, then it changes the JSON response.... by specifying file extension seperately...in JSON response..... instead of grouping them...like it shows in hardcoded way.....Java Code:Encoding enoc = new Encoding(); else if (nName.startsWith("original_")){ BitrateUrl url = populateBitRateUrls(n.getPath(), nName); String extension = nName.substring(nName.lastIndexOf(".")+1, nName.length()).toLowerCase(); enoc.setType(extension); enoc.getBitrateUrl().add(url); burls.getEncoding().add(enoc); }
So, How can I create objects at runtime and use the appropriate one for particular file extension..dynamically....
Please let me know if you need more explanation...
Similar Threads
-
Creating and implementing class for creating a calendar object
By kumalh in forum New To JavaReplies: 9Last Post: 07-29-2011, 02:18 PM -
create Objects for XML Mapping from XSD on runtime
By eagle1985 in forum XMLReplies: 0Last Post: 03-03-2010, 10:07 AM -
how to create an object at runtime
By sireesha in forum New To JavaReplies: 8Last Post: 10-01-2008, 12:52 PM -
Creating and using java objects at runtime...
By baran_khan in forum Advanced JavaReplies: 5Last Post: 08-28-2008, 05:36 PM -
creating array at runtime
By javaplus in forum New To JavaReplies: 4Last Post: 11-08-2007, 10:06 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks