Revision: 27537
          http://sourceforge.net/p/bibdesk/svn/27537
Author:   hofman
Date:     2022-06-03 16:00:48 +0000 (Fri, 03 Jun 2022)
Log Message:
-----------
Explicitly pass isNew argument only to designated initializer, all other 
initializers call the designated one with YES

Modified Paths:
--------------
    trunk/bibdesk/BDSKAsynchronousWebParser.m
    trunk/bibdesk/BDSKBibTeXParser.m
    trunk/bibdesk/BDSKDublinCoreXMLParser.m
    trunk/bibdesk/BDSKHCiteParser.m
    trunk/bibdesk/BDSKInspireParser.m
    trunk/bibdesk/BDSKJSTORParser.m
    trunk/bibdesk/BDSKMARCParser.m
    trunk/bibdesk/BDSKPRISMParser.m
    trunk/bibdesk/BDSKPubMedParser.m
    trunk/bibdesk/BDSKPubMedXMLParser.m
    trunk/bibdesk/BDSKRISParser.m
    trunk/bibdesk/BDSKReferParser.m
    trunk/bibdesk/BDSKSciFinderParser.m
    trunk/bibdesk/BDSKWebOfScienceParser.m
    trunk/bibdesk/BDSKZoomGroupServer.m
    trunk/bibdesk/BibItem.h
    trunk/bibdesk/BibItem.m
    trunk/bibdesk/UnitTests/TestBibItem.m

Modified: trunk/bibdesk/BDSKAsynchronousWebParser.m
===================================================================
--- trunk/bibdesk/BDSKAsynchronousWebParser.m   2022-06-03 15:49:11 UTC (rev 
27536)
+++ trunk/bibdesk/BDSKAsynchronousWebParser.m   2022-06-03 16:00:48 UTC (rev 
27537)
@@ -124,7 +124,7 @@
         [pubFields setValue:[[download URL] absoluteString] 
forKey:BDSKUrlString];
         [pubFields setValue:[error localizedRecoverySuggestion] 
forKey:BDSKAbstractString];
         [pubFields setValue:[download string] forKey:BDSKAnnoteString];
-        BibItem *errorItem = [[BibItem alloc] initWithType:BDSKMiscString 
citeKey:nil pubFields:pubFields isNew:YES];
+        BibItem *errorItem = [[BibItem alloc] initWithType:BDSKMiscString 
citeKey:nil pubFields:pubFields];
         items = [NSArray arrayWithObjects:errorItem, nil];
         [errorItem release];
     }

Modified: trunk/bibdesk/BDSKBibTeXParser.m
===================================================================
--- trunk/bibdesk/BDSKBibTeXParser.m    2022-06-03 15:49:11 UTC (rev 27536)
+++ trunk/bibdesk/BDSKBibTeXParser.m    2022-06-03 16:00:48 UTC (rev 27537)
@@ -1139,6 +1139,7 @@
             BibItem *newBI = [[BibItem alloc] initWithType:entryType
                                                    citeKey:citeKey
                                                  pubFields:dictionary
+                                                     files:nil
                                                      isNew:filePath == 
BDSKParserPasteDragString];
             // we set the macroResolver so we know the fields were parsed with 
this macroResolver, mostly to prevent scripting to add the item to the wrong 
document
             [newBI setMacroResolver:macroResolver];

Modified: trunk/bibdesk/BDSKDublinCoreXMLParser.m
===================================================================
--- trunk/bibdesk/BDSKDublinCoreXMLParser.m     2022-06-03 15:49:11 UTC (rev 
27536)
+++ trunk/bibdesk/BDSKDublinCoreXMLParser.m     2022-06-03 16:00:48 UTC (rev 
27537)
@@ -158,8 +158,7 @@
         // @article is most common for ADS
         BibItem *pub = [[BibItem alloc] initWithType:BDSKArticleString
                                              citeKey:nil 
-                                           pubFields:pubDict 
-                                               isNew:YES];
+                                           pubFields:pubDict];
         [pubDict release];
         [arrayOfPubs addObject:pub];
         [pub release];

Modified: trunk/bibdesk/BDSKHCiteParser.m
===================================================================
--- trunk/bibdesk/BDSKHCiteParser.m     2022-06-03 15:49:11 UTC (rev 27536)
+++ trunk/bibdesk/BDSKHCiteParser.m     2022-06-03 16:00:48 UTC (rev 27537)
@@ -94,7 +94,7 @@
         type = [rd objectForKey:BDSKTypeString];
         [rd removeObjectForKey:BDSKTypeString];
         
-        BibItem *item = [[BibItem alloc] initWithType:type citeKey:nil 
pubFields:rd isNew:YES];
+        BibItem *item = [[BibItem alloc] initWithType:type citeKey:nil 
pubFields:rd];
         [items addObject:item];
         [item release];
     }

Modified: trunk/bibdesk/BDSKInspireParser.m
===================================================================
--- trunk/bibdesk/BDSKInspireParser.m   2022-06-03 15:49:11 UTC (rev 27536)
+++ trunk/bibdesk/BDSKInspireParser.m   2022-06-03 16:00:48 UTC (rev 27537)
@@ -109,7 +109,7 @@
            if (outError)
                *outError = [NSError localErrorWithCode:kBDSKWebParserFailed 
localizedDescription:NSLocalizedString(@"You need to Reload to get the items.", 
@"Error description")];
            NSMutableDictionary *pubFields = [NSMutableDictionary 
dictionaryWithObjectsAndKeys:NSLocalizedString(@"You need to Reload to get the 
items.", @"Error description"), BDSKTitleString, [[self URL] absoluteString], 
BDSKUrlString, nil];
-           BibItem *errorItem = [[BibItem alloc] initWithType:BDSKMiscString 
citeKey:nil pubFields:pubFields isNew:YES];
+           BibItem *errorItem = [[BibItem alloc] initWithType:BDSKMiscString 
citeKey:nil pubFields:pubFields];
            NSArray *items = [NSArray arrayWithObjects:errorItem, nil];
            [errorItem release];
            return items;

Modified: trunk/bibdesk/BDSKJSTORParser.m
===================================================================
--- trunk/bibdesk/BDSKJSTORParser.m     2022-06-03 15:49:11 UTC (rev 27536)
+++ trunk/bibdesk/BDSKJSTORParser.m     2022-06-03 16:00:48 UTC (rev 27537)
@@ -166,8 +166,7 @@
                        
                        newBI = [[BibItem alloc] initWithType:BDSKArticleString
                                                                                
  citeKey:nil
-                                                                               
pubFields:pubDict
-                                            isNew:YES];
+                                                                               
pubFields:pubDict];
                        [returnArray addObject:newBI];
                        [newBI release];
                        
@@ -185,8 +184,7 @@
                                        
                                        newBI = [[BibItem alloc] 
initWithType:BDSKArticleString
                                                                                
                  citeKey:nil
-                                                                               
                pubFields:pubDict
-                                                    isNew:YES];
+                                                                               
                pubFields:pubDict];
                                        [returnArray addObject:newBI];
                                        [newBI release];
                                }
@@ -235,8 +233,7 @@
                
                newBI = [[BibItem alloc] initWithType:BDSKArticleString
                                                                          
citeKey:nil
-                                                                       
pubFields:pubDict
-                                        isNew:YES];
+                                                                       
pubFields:pubDict];
                [returnArray addObject:newBI];
                [newBI release];
        }

Modified: trunk/bibdesk/BDSKMARCParser.m
===================================================================
--- trunk/bibdesk/BDSKMARCParser.m      2022-06-03 15:49:11 UTC (rev 27536)
+++ trunk/bibdesk/BDSKMARCParser.m      2022-06-03 16:00:48 UTC (rev 27537)
@@ -123,8 +123,7 @@
                 
                 newBI = [[BibItem alloc] initWithType:BDSKBookString
                                               citeKey:nil
-                                            pubFields:pubDict
-                                                isNew:YES];
+                                            pubFields:pubDict];
                 [returnArray addObject:newBI];
                 [newBI release];
             }
@@ -158,8 +157,7 @@
                
                newBI = [[BibItem alloc] initWithType:BDSKBookString
                                                                          
citeKey:nil
-                                                                       
pubFields:pubDict
-                                        isNew:YES];
+                                                                       
pubFields:pubDict];
                [returnArray addObject:newBI];
                [newBI release];
        }
@@ -236,8 +234,7 @@
             
             newBI = [[BibItem alloc] initWithType:BDSKBookString
                                           citeKey:nil
-                                        pubFields:pubDict
-                                            isNew:YES];
+                                        pubFields:pubDict];
             [returnArray addObject:newBI];
             [newBI release];
         }
@@ -430,8 +427,7 @@
     
     BibItem *newBI = [[BibItem alloc] initWithType:BDSKBookString
                                            citeKey:nil
-                                         pubFields:pubDict
-                                             isNew:YES];
+                                         pubFields:pubDict];
     [pubDict release];
     
     return newBI;

Modified: trunk/bibdesk/BDSKPRISMParser.m
===================================================================
--- trunk/bibdesk/BDSKPRISMParser.m     2022-06-03 15:49:11 UTC (rev 27536)
+++ trunk/bibdesk/BDSKPRISMParser.m     2022-06-03 16:00:48 UTC (rev 27537)
@@ -184,8 +184,7 @@
         
         BibItem *pub = [[BibItem alloc] initWithType:BDSKArticleString
                                              citeKey:nil
-                                           pubFields:pubDict
-                                               isNew:YES];
+                                           pubFields:pubDict];
         [pubDict release];
         [pubs addObject:pub];
         [pub release];

Modified: trunk/bibdesk/BDSKPubMedParser.m
===================================================================
--- trunk/bibdesk/BDSKPubMedParser.m    2022-06-03 15:49:11 UTC (rev 27536)
+++ trunk/bibdesk/BDSKPubMedParser.m    2022-06-03 16:00:48 UTC (rev 27537)
@@ -112,8 +112,7 @@
                     [self fixPublicationDictionary:pubDict];
                     newBI = [[BibItem alloc] initWithType:[self 
pubTypeFromDictionary:pubDict]
                                                   citeKey:nil
-                                                pubFields:pubDict
-                                                    isNew:YES];
+                                                pubFields:pubDict];
                                        [returnArray addObject:newBI];
                                        [newBI release];
                                }
@@ -145,8 +144,7 @@
         [self fixPublicationDictionary:pubDict];
         newBI = [[BibItem alloc] initWithType:[self 
pubTypeFromDictionary:pubDict]
                                       citeKey:nil
-                                    pubFields:pubDict
-                                        isNew:YES];
+                                    pubFields:pubDict];
         [returnArray addObject:newBI];
         [newBI release];
     }

Modified: trunk/bibdesk/BDSKPubMedXMLParser.m
===================================================================
--- trunk/bibdesk/BDSKPubMedXMLParser.m 2022-06-03 15:49:11 UTC (rev 27536)
+++ trunk/bibdesk/BDSKPubMedXMLParser.m 2022-06-03 16:00:48 UTC (rev 27537)
@@ -359,8 +359,7 @@
         
         BibItem *pub = [[BibItem allocWithZone:[self zone]] 
initWithType:BDSKArticleString
                                                                  citeKey:nil
-                                                               
pubFields:pubFields
-                                                                   isNew:YES];
+                                                               
pubFields:pubFields];
         [pubs addObject:pub];
         [pub release];
         [pubFields release];

Modified: trunk/bibdesk/BDSKRISParser.m
===================================================================
--- trunk/bibdesk/BDSKRISParser.m       2022-06-03 15:49:11 UTC (rev 27536)
+++ trunk/bibdesk/BDSKRISParser.m       2022-06-03 16:00:48 UTC (rev 27537)
@@ -108,8 +108,7 @@
                     [self fixPublicationDictionary:pubDict];
                     newBI = [[BibItem alloc] initWithType:pubType
                                                   citeKey:nil
-                                                pubFields:pubDict
-                                                    isNew:YES];
+                                                pubFields:pubDict];
                                        [returnArray addObject:newBI];
                                        [newBI release];
                                }

Modified: trunk/bibdesk/BDSKReferParser.m
===================================================================
--- trunk/bibdesk/BDSKReferParser.m     2022-06-03 15:49:11 UTC (rev 27536)
+++ trunk/bibdesk/BDSKReferParser.m     2022-06-03 16:00:48 UTC (rev 27537)
@@ -250,7 +250,7 @@
                 
                 fixDateInDictionary(pubDict);
                 
-                newBI = [[BibItem alloc] initWithType:type citeKey:nil 
pubFields:pubDict isNew:YES];
+                newBI = [[BibItem alloc] initWithType:type citeKey:nil 
pubFields:pubDict];
                 [returnArray addObject:newBI];
                 [newBI release];
             }

Modified: trunk/bibdesk/BDSKSciFinderParser.m
===================================================================
--- trunk/bibdesk/BDSKSciFinderParser.m 2022-06-03 15:49:11 UTC (rev 27536)
+++ trunk/bibdesk/BDSKSciFinderParser.m 2022-06-03 16:00:48 UTC (rev 27537)
@@ -252,7 +252,7 @@
                 type = BDSKArticleString;
             }
             
-            BibItem *pub = [[BibItem alloc] initWithType:type citeKey:nil 
pubFields:pubFields isNew:YES];
+            BibItem *pub = [[BibItem alloc] initWithType:type citeKey:nil 
pubFields:pubFields];
             [toReturn addObject:pub];
             [pub release];
             [pubFields removeAllObjects];

Modified: trunk/bibdesk/BDSKWebOfScienceParser.m
===================================================================
--- trunk/bibdesk/BDSKWebOfScienceParser.m      2022-06-03 15:49:11 UTC (rev 
27536)
+++ trunk/bibdesk/BDSKWebOfScienceParser.m      2022-06-03 16:00:48 UTC (rev 
27537)
@@ -223,7 +223,7 @@
                         if (nil == type) type = BDSKMiscString;
                     }
                     
-                    newBI = [[BibItem alloc] initWithType:type citeKey:nil 
pubFields:pubDict isNew:YES];
+                    newBI = [[BibItem alloc] initWithType:type citeKey:nil 
pubFields:pubDict];
                                        [returnArray addObject:newBI];
                                        [newBI release];
                                }

Modified: trunk/bibdesk/BDSKZoomGroupServer.m
===================================================================
--- trunk/bibdesk/BDSKZoomGroupServer.m 2022-06-03 15:49:11 UTC (rev 27536)
+++ trunk/bibdesk/BDSKZoomGroupServer.m 2022-06-03 16:00:48 UTC (rev 27537)
@@ -245,8 +245,7 @@
                 record = [result objectForKey:@"renderedString"];
                 anItem = [[BibItem alloc] initWithType:BDSKBookString
                                                citeKey:nil
-                                             pubFields:[NSDictionary 
dictionaryWithObjectsAndKeys:record, BDSKAnnoteString, nil]
-                                                 isNew:YES];
+                                             pubFields:[NSDictionary 
dictionaryWithObjectsAndKeys:record, BDSKAnnoteString, nil]];
                 [anItem autorelease];
             }
             [pubs addObject:anItem];

Modified: trunk/bibdesk/BibItem.h
===================================================================
--- trunk/bibdesk/BibItem.h     2022-06-03 15:49:11 UTC (rev 27536)
+++ trunk/bibdesk/BibItem.h     2022-06-03 16:00:48 UTC (rev 27537)
@@ -172,19 +172,19 @@
 - (id)init;
 
 /*!
-     @method initWithType:citeKey:pubFields:filesArray:createdDate:
+     @method initWithType:citeKey:pubFields:filesA:isNew:
      @abstract Initializes an alloc'd BibItem to a type and allows to set the 
authors. This is the designated intializer.
      @discussion This lets you set the type and the Authors array at 
initialization time. Call it with an empty array for authArray if you don't 
want to do that -<em>Don't use nil</em> The authors array is kept up but isn't 
used much right now. This will change. The createdDate should be nil when the 
BibItem is not newly added, such as in a parser. 
      @param key The cite key. Pass nil to generate the cite key.
      @param type A string representing the type of entry this item is - used 
to make the BibItem have the right entries in its dictionary.
      @param fieldsDict The dictionary of fields to initialize the item with.
-     @param filesArray The array of linked files and URLs to initialize the 
item with.
+     @param files The array of linked files and URLs to initialize the item 
with.
      @param isNew Boolean determines if the item is new for the BibTeX 
document. Determines if the date-added should be set. Should be YES unless when 
reading the BibTeX source file.
      @result The receiver, initialized to type and containing authors 
authArray.
 */
 - (id)initWithType:(NSString *)type citeKey:(NSString *)key 
pubFields:(NSDictionary *)fieldsDict files:(NSArray *)filesArray 
isNew:(BOOL)isNew;
 
-- (id)initWithType:(NSString *)type citeKey:(NSString *)key 
pubFields:(NSDictionary *)fieldsDict isNew:(BOOL)isNew;
+- (id)initWithType:(NSString *)type citeKey:(NSString *)key 
pubFields:(NSDictionary *)fieldsDict;
 
 - (id)initWithType:(NSString *)type citeKey:(NSString *)key 
pubFields:(NSMutableDictionary *)fieldsDict URLStrings:(NSArray *)urlsArray;
 

Modified: trunk/bibdesk/BibItem.m
===================================================================
--- trunk/bibdesk/BibItem.m     2022-06-03 15:49:11 UTC (rev 27536)
+++ trunk/bibdesk/BibItem.m     2022-06-03 16:00:48 UTC (rev 27537)
@@ -242,12 +242,29 @@
        return self;
 }
 
-// this is the designated initializer.
-- (id)initWithType:(NSString *)type citeKey:(NSString *)key 
pubFields:(NSDictionary *)fieldsDict isNew:(BOOL)isNew{ 
-    return [self initWithType:type citeKey:key pubFields:fieldsDict files:nil 
isNew:isNew];
+- (id)initWithType:(NSString *)type citeKey:(NSString *)key 
pubFields:(NSDictionary *)fieldsDict{
+    return [self initWithType:type citeKey:key pubFields:fieldsDict files:nil 
isNew:YES];
 }
 
-- (id)initWithType:(NSString *)type citeKey:(NSString *)key 
pubFields:(NSDictionary *)fieldsDict files:(NSArray *)filesArray 
isNew:(BOOL)isNew{ 
+- (id)initWithType:(NSString *)type citeKey:(NSString *)key 
pubFields:(NSMutableDictionary *)fieldsDict URLStrings:(NSArray *)urlsArray{
+    NSMutableArray *filesArray = nil;
+    if ([urlsArray count]) {
+        NSUserDefaults *sud = [NSUserDefaults standardUserDefaults];
+        BOOL addLinkedFiles = NO == [sud boolForKey:BDSKUseLocalUrlAndUrlKey];
+        if (addLinkedFiles)
+            filesArray = [NSMutableArray array];
+        for (NSString *url in urlsArray) {
+            if (addLinkedFiles)
+                [filesArray addObject:[BDSKLinkedFile 
linkedFileWithURLString:url]];
+            if ([fieldsDict objectForKey:BDSKUrlString] == nil && 
(addLinkedFiles == NO || [sud boolForKey:BDSKAutomaticallyConvertURLFieldsKey] 
== NO || [sud boolForKey:BDSKRemoveConvertedRemoteURLFieldsKey] == NO))
+                [(NSMutableDictionary *)fieldsDict setObject:url 
forKey:BDSKUrlString];
+        }
+    }
+    return [self initWithType:type citeKey:citeKey pubFields:fieldsDict 
files:filesArray isNew:YES];
+}
+
+// this is the designated initializer.
+- (id)initWithType:(NSString *)type citeKey:(NSString *)key 
pubFields:(NSDictionary *)fieldsDict files:(NSArray *)filesArray 
isNew:(BOOL)isNew{
     self = [super init];
     if (self){
                pubFields = [[NSMutableDictionary alloc] 
initWithDictionary:fieldsDict];
@@ -298,23 +315,6 @@
     return self;
 }
 
-- (id)initWithType:(NSString *)type citeKey:(NSString *)key 
pubFields:(NSMutableDictionary *)fieldsDict URLStrings:(NSArray *)urlsArray{
-    NSMutableArray *filesArray = nil;
-    if ([urlsArray count]) {
-        NSUserDefaults *sud = [NSUserDefaults standardUserDefaults];
-        BOOL addLinkedFiles = NO == [sud boolForKey:BDSKUseLocalUrlAndUrlKey];
-        if (addLinkedFiles)
-            filesArray = [NSMutableArray array];
-        for (NSString *url in urlsArray) {
-            if (addLinkedFiles)
-                [filesArray addObject:[BDSKLinkedFile 
linkedFileWithURLString:url]];
-            if ([fieldsDict objectForKey:BDSKUrlString] == nil && 
(addLinkedFiles == NO || [sud boolForKey:BDSKAutomaticallyConvertURLFieldsKey] 
== NO || [sud boolForKey:BDSKRemoveConvertedRemoteURLFieldsKey] == NO))
-                [(NSMutableDictionary *)fieldsDict setObject:url 
forKey:BDSKUrlString];
-        }
-    }
-    return [self initWithType:type citeKey:citeKey pubFields:fieldsDict 
files:filesArray isNew:YES];
-}
-
 + (NSString *)defaultCiteKey {
     return defaultCiteKey;
 }

Modified: trunk/bibdesk/UnitTests/TestBibItem.m
===================================================================
--- trunk/bibdesk/UnitTests/TestBibItem.m       2022-06-03 15:49:11 UTC (rev 
27536)
+++ trunk/bibdesk/UnitTests/TestBibItem.m       2022-06-03 16:00:48 UTC (rev 
27537)
@@ -64,7 +64,7 @@
        // This was Mike's original test, but I'm not sure what Less, von More 
is supposed to mean anyway
        NSDictionary *pubFields = [NSDictionary 
dictionaryWithObjectsAndKeys:@"Hello", BDSKTitleString,
                                                           @"Less, von More, 
Jr.", BDSKAuthorString, nil];
-       BibItem *b = [[[BibItem alloc] initWithType:BDSKArticleString 
citeKey:nil pubFields:pubFields isNew:YES] autorelease];
+       BibItem *b = [[[BibItem alloc] initWithType:BDSKArticleString 
citeKey:nil pubFields:pubFields] autorelease];
        
     STAssertTrue(1==[b numberOfAuthors],@"Check that Less, von More, Jr. 
parses to single author");
 }
@@ -76,8 +76,8 @@
                                                                @"First von 
Last", BDSKAuthorString, nil];
        NSDictionary *pubFields2 = [NSDictionary 
dictionaryWithObjectsAndKeys:@"Hello", BDSKTitleString,
                                                                @"von Last, 
First", BDSKAuthorString, nil];
-       BibItem *b1 = [[[BibItem alloc] initWithType:BDSKArticleString 
citeKey:nil pubFields:pubFields1 isNew:YES] autorelease];
-       BibItem *b2 = [[[BibItem alloc] initWithType:BDSKArticleString 
citeKey:nil pubFields:pubFields2 isNew:YES] autorelease];
+       BibItem *b1 = [[[BibItem alloc] initWithType:BDSKArticleString 
citeKey:nil pubFields:pubFields1] autorelease];
+       BibItem *b2 = [[[BibItem alloc] initWithType:BDSKArticleString 
citeKey:nil pubFields:pubFields2] autorelease];
 
        STAssertEqualObjects([[b1 firstAuthor] firstName], @"First", @"first 
name of First von Last");
        STAssertEqualObjects([[b1 firstAuthor] lastName], @"Last", @"last name 
of First von Last");
@@ -97,8 +97,8 @@
                                                                @"First von 
Last, Jr.", BDSKAuthorString, nil];
        NSDictionary *pubFields2 = [NSDictionary 
dictionaryWithObjectsAndKeys:@"Hello", BDSKTitleString,
                                                                @"von Last, 
Jr., First", BDSKAuthorString, nil];
-       BibItem *b1 = [[[BibItem alloc] initWithType:BDSKArticleString 
citeKey:nil pubFields:pubFields1 isNew:YES] autorelease];
-       BibItem *b2 = [[[BibItem alloc] initWithType:BDSKArticleString 
citeKey:nil pubFields:pubFields2 isNew:YES] autorelease];
+       BibItem *b1 = [[[BibItem alloc] initWithType:BDSKArticleString 
citeKey:nil pubFields:pubFields1] autorelease];
+       BibItem *b2 = [[[BibItem alloc] initWithType:BDSKArticleString 
citeKey:nil pubFields:pubFields2] autorelease];
        
        // GJ: my understanding was that "First von Last, Jr." was an 
acceptable BibTex form,
        // but a note before BibAuthor's setupNames method suggests otherwise

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to