SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Studio
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-29-2009, 07:42 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Help with removeall in eclipse

I am having a issue where it doesn't seem to return anything for the string (TagRemoved) attached code
I have checked the true false portion and it is working as intended but for some reason the hangup seems to be at the Tagremoved.

TIA as I am new to learning eclipse but love it so far.

http://babgvant.com/downloads/PLUCKYHD/tagremoved.jpg
Reply With Quote
  #2  
Old 07-29-2009, 10:18 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Got this one fixed using replaceAll and changing it around a bit.
Reply With Quote
  #3  
Old 07-29-2009, 10:32 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
plucky, after looking at your code, there is a couple of issues... firstly, you've declared a method java_lang_string_replaceAll() that just returns null... so not matter what you pass in, it will always return null.

Also, your java code doesn't contain any null checking. that means, that you'll most likely run into java exceptions in the cases where no MediaTags are assigned to an item. Those exceptions,if they make it up to the STV, will result in a huge performance hit.

consider the following for your removeall method
Code:
public static String RemoveMediaTag(Object MediaFile, String tag) {
    String tags = MediaFileAPI.GetMediaFileMetadata(MediaFile, "MediaTags");
    String newTags = null;
    if (tags!=null) {
        newTags = tags.replaceAll(tag, "");
        newTags = newTags.replaceAll(";;",";");
        if (!tags.equals(newTags)) {
            MediaFileAPI.SetMediaFileMetadata(MediaFile, newTags);
        }
    }
    
    return newTags;
}
Reply With Quote
  #4  
Old 07-29-2009, 10:50 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Quote:
Originally Posted by stuckless View Post
plucky, after looking at your code, there is a couple of issues... firstly, you've declared a method java_lang_string_replaceAll() that just returns null... so not matter what you pass in, it will always return null.

Also, your java code doesn't contain any null checking. that means, that you'll most likely run into java exceptions in the cases where no MediaTags are assigned to an item. Those exceptions,if they make it up to the STV, will result in a huge performance hit.

consider the following for your removeall method
Code:
public static String RemoveMediaTag(Object MediaFile, String tag) {
    String tags = MediaFileAPI.GetMediaFileMetadata(MediaFile, "MediaTags");
    String newTags = null;
    if (tags!=null) {
        newTags = tags.replaceAll(tag, "");
        newTags = newTags.replaceAll(";;",";");
        if (!tags.equals(newTags)) {
            MediaFileAPI.SetMediaFileMetadata(MediaFile, newTags);
        }
    }
    
    return newTags;
}

Stuckless thanks I do check for nulls in others and you are correct I completely left it out on this one

Thanks for the tips I really appreciate it.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 06:05 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.