[Libreoffice-commits] core.git: 7 commits - scripting/java

Stephan Bergmann sbergman at redhat.com
Fri Mar 4 14:53:11 UTC 2016


 scripting/java/com/sun/star/script/framework/browse/ParcelBrowseNode.java    |    4 
 scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java    |    5 
 scripting/java/com/sun/star/script/framework/container/ParcelDescriptor.java |    2 
 scripting/java/com/sun/star/script/framework/container/ScriptEntry.java      |   71 ++--------
 scripting/java/com/sun/star/script/framework/container/ScriptMetaData.java   |    9 -
 5 files changed, 19 insertions(+), 72 deletions(-)

New commits:
commit 4225092a3586498f27dcb3cc54ae7f5b8ea53d4e
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Mar 4 15:51:04 2016 +0100

    cid#1326861,1326862: Eq: Problems with implementation of equals()
    
    Cloneable, odd additional equals overloads, odd hasCode implementation---all
    smells like clueless cargo cult.  And I see no place where it would get used.
    
    Change-Id: Icca89531ce9181fb47eacfb6fae704f4f45012a9

diff --git a/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java b/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java
index eb4eb44..92870c6 100644
--- a/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java
+++ b/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java
@@ -21,7 +21,7 @@ package com.sun.star.script.framework.container;
 import java.util.HashMap;
 import java.util.Map;
 
-public class ScriptEntry implements Cloneable {
+public class ScriptEntry {
 
     private final String language;
     private final String languagename;
@@ -56,23 +56,6 @@ public class ScriptEntry implements Cloneable {
         this.description = description;
     }
 
-    @Override
-    public Object clone() throws CloneNotSupportedException {
-        return super.clone();
-    }
-
-    public boolean equals(ScriptEntry other) {
-        return language.equals(other.getLanguage()) &&
-               languagename.equals(other.getLanguageName()) &&
-               logicalname.equals(other.getLogicalName()) &&
-               languagedepprops.equals(other.getLanguageProperties());
-    }
-
-    @Override
-    public int hashCode() {
-        return 0;
-    }
-
     public Map<String, String> getLanguageProperties() {
         return languagedepprops;
     }
diff --git a/scripting/java/com/sun/star/script/framework/container/ScriptMetaData.java b/scripting/java/com/sun/star/script/framework/container/ScriptMetaData.java
index 75f0752..004fe2b 100644
--- a/scripting/java/com/sun/star/script/framework/container/ScriptMetaData.java
+++ b/scripting/java/com/sun/star/script/framework/container/ScriptMetaData.java
@@ -66,15 +66,6 @@ public class ScriptMetaData extends ScriptEntry {
         return (source != null && hasSource) ? source.getBytes() : null;
     }
 
-    public boolean equals(ScriptMetaData other) {
-        return super.equals(other) && hasSource == other.hasSource();
-    }
-
-    @Override
-    public int hashCode() {
-        return 0;
-    }
-
     public String getScriptFullURL() {
         String url = "vnd.sun.star.script:" + parent.getName() + "."
                      + getLanguageName() + "?" + "language=" + getLanguage()
commit 305453d2c79221d03452efd917eee122426fd32b
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Mar 4 15:37:15 2016 +0100

    This ScriptEntry ctor is always called with empty languagedepprops
    
    Change-Id: Ia8ddfecf2f809e9f0132ba59812446973532476c

diff --git a/scripting/java/com/sun/star/script/framework/browse/ParcelBrowseNode.java b/scripting/java/com/sun/star/script/framework/browse/ParcelBrowseNode.java
index f1e5d0e..6384f5b 100644
--- a/scripting/java/com/sun/star/script/framework/browse/ParcelBrowseNode.java
+++ b/scripting/java/com/sun/star/script/framework/browse/ParcelBrowseNode.java
@@ -47,7 +47,6 @@ import com.sun.star.uno.XComponentContext;
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashMap;
 
 import javax.swing.JOptionPane;
 
@@ -207,8 +206,7 @@ public class ParcelBrowseNode extends PropertySet implements
 
                     String language = container.getLanguage();
 
-                    ScriptEntry entry = new ScriptEntry(language, languageName,
-                                                        new HashMap<String, String>());
+                    ScriptEntry entry = new ScriptEntry(language, languageName);
 
                     Parcel parcel = (Parcel)container.getByName(getName());
                     ScriptMetaData data = new ScriptMetaData(parcel, entry, source);
diff --git a/scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java b/scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java
index 627b6ed..5f91b1a 100644
--- a/scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java
+++ b/scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java
@@ -48,8 +48,6 @@ import com.sun.star.uno.Type;
 import com.sun.star.uno.UnoRuntime;
 import com.sun.star.uno.XComponentContext;
 
-import java.util.HashMap;
-
 public class ScriptBrowseNode extends PropertySet implements
     XBrowseNode, XInvocation {
 
@@ -247,8 +245,7 @@ public class ScriptBrowseNode extends PropertySet implements
 
                 String language = provider.getName();
 
-                ScriptEntry entry = new ScriptEntry(language, languageName,
-                                                    new HashMap<String, String>());
+                ScriptEntry entry = new ScriptEntry(language, languageName);
 
                 ScriptMetaData data =
                     new ScriptMetaData(parent, entry, oldSource);
diff --git a/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java b/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java
index 24718a7..eb4eb44 100644
--- a/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java
+++ b/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java
@@ -38,9 +38,8 @@ public class ScriptEntry implements Cloneable {
         this.description = entry.description;
     }
 
-    public ScriptEntry(String language, String languagename,
-                       Map<String, String> languagedepprops) {
-        this(language, languagename, languagedepprops, "");
+    public ScriptEntry(String language, String languagename) {
+        this(language, languagename, new HashMap<String, String>(), "");
     }
 
     public ScriptEntry(String language, String languagename,
commit 8a4e256d67fae1751eda4f774cdee41ef632de04
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Mar 4 15:34:45 2016 +0100

    Scripting.location is unused
    
    Change-Id: Ia534b5aa579a678f8b0273e6c8c12a6ad335c67a

diff --git a/scripting/java/com/sun/star/script/framework/browse/ParcelBrowseNode.java b/scripting/java/com/sun/star/script/framework/browse/ParcelBrowseNode.java
index 8e9b3a0..f1e5d0e 100644
--- a/scripting/java/com/sun/star/script/framework/browse/ParcelBrowseNode.java
+++ b/scripting/java/com/sun/star/script/framework/browse/ParcelBrowseNode.java
@@ -207,7 +207,7 @@ public class ParcelBrowseNode extends PropertySet implements
 
                     String language = container.getLanguage();
 
-                    ScriptEntry entry = new ScriptEntry(language, languageName, "",
+                    ScriptEntry entry = new ScriptEntry(language, languageName,
                                                         new HashMap<String, String>());
 
                     Parcel parcel = (Parcel)container.getByName(getName());
diff --git a/scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java b/scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java
index 8c14918..627b6ed 100644
--- a/scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java
+++ b/scripting/java/com/sun/star/script/framework/browse/ScriptBrowseNode.java
@@ -247,7 +247,7 @@ public class ScriptBrowseNode extends PropertySet implements
 
                 String language = provider.getName();
 
-                ScriptEntry entry = new ScriptEntry(language, languageName, "",
+                ScriptEntry entry = new ScriptEntry(language, languageName,
                                                     new HashMap<String, String>());
 
                 ScriptMetaData data =
diff --git a/scripting/java/com/sun/star/script/framework/container/ParcelDescriptor.java b/scripting/java/com/sun/star/script/framework/container/ParcelDescriptor.java
index f58a9d8..a8b12e0 100644
--- a/scripting/java/com/sun/star/script/framework/container/ParcelDescriptor.java
+++ b/scripting/java/com/sun/star/script/framework/container/ParcelDescriptor.java
@@ -196,7 +196,7 @@ public class ParcelDescriptor {
             }
 
             ScriptEntry entry =
-                new ScriptEntry(language, languagename, "", langProps, description);
+                new ScriptEntry(language, languagename, langProps, description);
             scripts.add(entry);
         }
 
diff --git a/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java b/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java
index c49918f..24718a7 100644
--- a/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java
+++ b/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java
@@ -25,7 +25,6 @@ public class ScriptEntry implements Cloneable {
 
     private final String language;
     private final String languagename;
-    private final String location;
     private final String logicalname;
     private final String description;
 
@@ -35,18 +34,17 @@ public class ScriptEntry implements Cloneable {
         this.language = entry.language;
         this.languagename = entry.languagename;
         this.logicalname = entry.languagename;
-        this.location = entry.location;
         this.languagedepprops = entry.languagedepprops;
         this.description = entry.description;
     }
 
     public ScriptEntry(String language, String languagename,
-                       String location, Map<String, String> languagedepprops) {
-        this(language, languagename, location, languagedepprops, "");
+                       Map<String, String> languagedepprops) {
+        this(language, languagename, languagedepprops, "");
     }
 
     public ScriptEntry(String language, String languagename,
-                       String location, Map<String, String> languagedepprops,
+                       Map<String, String> languagedepprops,
                        String description) {
         this.language = language;
         this.languagename = languagename;
@@ -55,7 +53,6 @@ public class ScriptEntry implements Cloneable {
         // function name ( from xml ) will be used
         // as logical name also
         this.logicalname = languagename;
-        this.location = location;
         this.languagedepprops = languagedepprops;
         this.description = description;
     }
@@ -69,8 +66,7 @@ public class ScriptEntry implements Cloneable {
         return language.equals(other.getLanguage()) &&
                languagename.equals(other.getLanguageName()) &&
                logicalname.equals(other.getLogicalName()) &&
-               languagedepprops.equals(other.getLanguageProperties()) &&
-               location.equals(other.getLocation());
+               languagedepprops.equals(other.getLanguageProperties());
     }
 
     @Override
@@ -94,10 +90,6 @@ public class ScriptEntry implements Cloneable {
         return language;
     }
 
-    public  String getLocation() {
-        return location;
-    }
-
     public String getDescription() {
         return description;
     }
@@ -106,7 +98,6 @@ public class ScriptEntry implements Cloneable {
     public String toString() {
         return "\nLogicalName = " + logicalname +
                "\nLanguageName = " + languagename +
-               "\nLocation = " + location +
                "\nLanguaguageProperties = " + languagedepprops;
     }
 }
commit 90033c542bcbb613e1a7de078d597e5956215cae
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Mar 4 15:31:38 2016 +0100

    ScriptEntry fields can be final
    
    Change-Id: I7616641584b7ea8192cf3724d8b7d5b88af39da6

diff --git a/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java b/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java
index 377ca2d..c49918f 100644
--- a/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java
+++ b/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java
@@ -23,13 +23,13 @@ import java.util.Map;
 
 public class ScriptEntry implements Cloneable {
 
-    private String language;
-    private String languagename;
-    private String location;
-    private String logicalname;
-    private String description;
+    private final String language;
+    private final String languagename;
+    private final String location;
+    private final String logicalname;
+    private final String description;
 
-    private Map<String, String> languagedepprops;
+    private final Map<String, String> languagedepprops;
 
     protected ScriptEntry(ScriptEntry entry) {
         this.language = entry.language;
commit 8e4c33799f5a789b908b67714992c730978a5c20
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Mar 4 15:30:46 2016 +0100

    Turn forwarding among ScriptEntry ctors around, dropping one
    
    Change-Id: If3c86c7e5c4acaf4a3e48194e24c3c73e4e99499

diff --git a/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java b/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java
index 46c4562..377ca2d 100644
--- a/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java
+++ b/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java
@@ -26,25 +26,11 @@ public class ScriptEntry implements Cloneable {
     private String language;
     private String languagename;
     private String location;
-    private String logicalname = "";
-    private String description = "";
+    private String logicalname;
+    private String description;
 
     private Map<String, String> languagedepprops;
 
-    private ScriptEntry(String language, String languagename,
-                       String location) {
-
-        this.language = language;
-        this.languagename = languagename;
-        // logical name/ function name concept
-        // needs to be reworked, in meantime
-        // function name ( from xml ) will be used
-        // as logical name also
-        this.logicalname = languagename;
-        this.location = location;
-        this.languagedepprops =  new HashMap<String, String>();
-    }
-
     protected ScriptEntry(ScriptEntry entry) {
         this.language = entry.language;
         this.languagename = entry.languagename;
@@ -56,14 +42,20 @@ public class ScriptEntry implements Cloneable {
 
     public ScriptEntry(String language, String languagename,
                        String location, Map<String, String> languagedepprops) {
-        this(language, languagename, location);
-        this.languagedepprops = languagedepprops;
+        this(language, languagename, location, languagedepprops, "");
     }
 
     public ScriptEntry(String language, String languagename,
                        String location, Map<String, String> languagedepprops,
                        String description) {
-        this(language, languagename, location);
+        this.language = language;
+        this.languagename = languagename;
+        // logical name/ function name concept
+        // needs to be reworked, in meantime
+        // function name ( from xml ) will be used
+        // as logical name also
+        this.logicalname = languagename;
+        this.location = location;
         this.languagedepprops = languagedepprops;
         this.description = description;
     }
commit 9b70fdf5ed6d16eb8590ea940976402225d38ee8
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Mar 4 15:29:19 2016 +0100

    Remove unusd ScriptEntry ctor
    
    Change-Id: I7109877e789659b87cbc16e9c5da39dcc8249e09

diff --git a/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java b/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java
index 948e81f..46c4562 100644
--- a/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java
+++ b/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java
@@ -68,10 +68,6 @@ public class ScriptEntry implements Cloneable {
         this.description = description;
     }
 
-    public ScriptEntry(String languagename, String location) {
-        this("Java", languagename, location);
-    }
-
     @Override
     public Object clone() throws CloneNotSupportedException {
         return super.clone();
commit 05dba6868ec7a5f5fa89cfd44125996bc06bb06b
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Mar 4 15:26:03 2016 +0100

    Forwarding-only ctor, can be private
    
    Change-Id: I9ed2aa9c2bf2e17705dc711560154a9596c8264a

diff --git a/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java b/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java
index 2165acee..948e81f 100644
--- a/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java
+++ b/scripting/java/com/sun/star/script/framework/container/ScriptEntry.java
@@ -31,7 +31,7 @@ public class ScriptEntry implements Cloneable {
 
     private Map<String, String> languagedepprops;
 
-    public  ScriptEntry(String language, String languagename,
+    private ScriptEntry(String language, String languagename,
                        String location) {
 
         this.language = language;


More information about the Libreoffice-commits mailing list