You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-dev@xml.apache.org by vg...@apache.org on 2004/07/20 22:31:37 UTC
cvs commit: xml-xindice/java/src/org/apache/xindice/tools/command AddDocument.java AddIndexer.java AddMultipleDocuments.java AddResource.java ImportTree.java RetrieveDocument.java XPathQuery.java XUpdate.java
vgritsenko 2004/07/20 13:31:37
Modified: java/src/org/apache/xindice/core/request URIMapper.java
java/src/org/apache/xindice/core/indexer
MemValueIndexer.java
java/src/org/apache/xindice/tools/command AddDocument.java
AddIndexer.java AddMultipleDocuments.java
AddResource.java ImportTree.java
RetrieveDocument.java XPathQuery.java XUpdate.java
Log:
Code cleanup (unnecessary new String(), String == usage, etc)
Submitted by: Dave Brosius" <db...@qis.net>
Revision Changes Path
1.20 +3 -3 xml-xindice/java/src/org/apache/xindice/core/request/URIMapper.java
Index: URIMapper.java
===================================================================
RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/request/URIMapper.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- URIMapper.java 8 Feb 2004 02:50:54 -0000 1.19
+++ URIMapper.java 20 Jul 2004 20:31:37 -0000 1.20
@@ -174,7 +174,7 @@
*/
public String getContentType() {
// Return the docuement's content type, for now this can only be "text/xml"
- return new String("text/xml");
+ return "text/xml";
}
/**
1.9 +4 -4 xml-xindice/java/src/org/apache/xindice/core/indexer/MemValueIndexer.java
Index: MemValueIndexer.java
===================================================================
RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/indexer/MemValueIndexer.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- MemValueIndexer.java 8 Feb 2004 02:50:21 -0000 1.8
+++ MemValueIndexer.java 20 Jul 2004 20:31:37 -0000 1.9
@@ -982,7 +982,7 @@
log.debug("Exception while converting value \"" + theValue + "\" from String to " + itsValueTypeName, anException);
}
}
- return new String();
+ return "";
}
/**
@@ -1007,7 +1007,7 @@
*/
private final Object getNextValueOf(Object theValue, int theType) {
if (theValue instanceof EmptyValue) {
- return new String("\0");
+ return "\0";
}
Object aReturn = null;
1.14 +3 -3 xml-xindice/java/src/org/apache/xindice/tools/command/AddDocument.java
Index: AddDocument.java
===================================================================
RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/tools/command/AddDocument.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- AddDocument.java 8 Feb 2004 02:57:35 -0000 1.13
+++ AddDocument.java 20 Jul 2004 20:31:37 -0000 1.14
@@ -52,7 +52,7 @@
return false;
}
- if (table.get(XMLTools.FILE_PATH) == "") {
+ if ("".equals(table.get(XMLTools.FILE_PATH))) {
System.out.println("ERROR : File path required");
return false;
}
1.11 +3 -3 xml-xindice/java/src/org/apache/xindice/tools/command/AddIndexer.java
Index: AddIndexer.java
===================================================================
RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/tools/command/AddIndexer.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- AddIndexer.java 8 Feb 2004 02:57:35 -0000 1.10
+++ AddIndexer.java 20 Jul 2004 20:31:37 -0000 1.11
@@ -90,7 +90,7 @@
doc.appendChild(idxEle);
// If in verbose mode, show....
- if (table.get(XMLTools.VERBOSE) == "true") {
+ if ("true".equals(table.get(XMLTools.VERBOSE))) {
String indexstr = TextWriter.toString(doc);
System.out.println("Index node element = ");
System.out.println("\t" + indexstr + "\n");
1.12 +3 -3 xml-xindice/java/src/org/apache/xindice/tools/command/AddMultipleDocuments.java
Index: AddMultipleDocuments.java
===================================================================
RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/tools/command/AddMultipleDocuments.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- AddMultipleDocuments.java 25 May 2004 15:58:46 -0000 1.11
+++ AddMultipleDocuments.java 20 Jul 2004 20:31:37 -0000 1.12
@@ -50,7 +50,7 @@
return false;
}
- if (table.get(XMLTools.FILE_PATH) == "") {
+ if ("".equals(table.get(XMLTools.FILE_PATH))) {
System.out.println("ERROR : Directory name and switch required");
return false;
}
1.3 +76 -76 xml-xindice/java/src/org/apache/xindice/tools/command/AddResource.java
Index: AddResource.java
===================================================================
RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/tools/command/AddResource.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AddResource.java 8 Feb 2004 02:57:35 -0000 1.2
+++ AddResource.java 20 Jul 2004 20:31:37 -0000 1.3
@@ -15,78 +15,78 @@
*
* CVS $Id$
*/
-
-package org.apache.xindice.tools.command;
-
-import org.apache.xindice.tools.XMLTools;
-
-import org.xmldb.api.DatabaseManager;
-import org.xmldb.api.base.Collection;
-import org.xmldb.api.base.Resource;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.util.Hashtable;
-
-/**
- * AddResource is designed to let the user add single binary resource
- * and/or multiple binary resources to any existing collection
- * within the current database.
- *
- * @version CVS $Revision$, $Date$
- */
-public class AddResource extends Command {
-
- /**
- * Adds a resource to the collection
- */
- public boolean execute(Hashtable table) throws Exception {
-
- Collection col = null;
- if (table.get(XMLTools.COLLECTION) == null) {
- System.out.println("ERROR : Collection and switch required");
- return false;
- }
-
- if (table.get(XMLTools.FILE_PATH) == "") {
- System.out.println("ERROR : File path required");
- return false;
- }
-
- try {
- // Create a collection instance
- String colstring = normalizeCollectionURI((String) table.get(XMLTools.COLLECTION),
- (String) table.get(XMLTools.LOCAL));
- col = DatabaseManager.getCollection(colstring);
- if (col == null) {
- System.out.println("ERROR : Collection not found!");
- return false;
- }
-
- // Read data
- File file = new File((String) table.get(XMLTools.FILE_PATH));
- InputStream fis = new FileInputStream(file);
- byte[] data = new byte[fis.available()];
- fis.read(data);
- fis.close();
-
- // Create the BinaryResource and store the resource
- Resource resource = col.createResource((String) table.get(XMLTools.NAME_OF),
- "BinaryResource");
- resource.setContent(data);
- col.storeResource(resource);
-
- System.out.println("Added resource " + table.get(XMLTools.COLLECTION) + "/" +
- resource.getId());
- resource = null;
- } finally {
- if (col != null) {
- col.close();
- }
- col = null;
- }
-
- return true;
- }
-}
+
+package org.apache.xindice.tools.command;
+
+import org.apache.xindice.tools.XMLTools;
+
+import org.xmldb.api.DatabaseManager;
+import org.xmldb.api.base.Collection;
+import org.xmldb.api.base.Resource;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Hashtable;
+
+/**
+ * AddResource is designed to let the user add single binary resource
+ * and/or multiple binary resources to any existing collection
+ * within the current database.
+ *
+ * @version CVS $Revision$, $Date$
+ */
+public class AddResource extends Command {
+
+ /**
+ * Adds a resource to the collection
+ */
+ public boolean execute(Hashtable table) throws Exception {
+
+ Collection col = null;
+ if (table.get(XMLTools.COLLECTION) == null) {
+ System.out.println("ERROR : Collection and switch required");
+ return false;
+ }
+
+ if ("".equals(table.get(XMLTools.FILE_PATH))) {
+ System.out.println("ERROR : File path required");
+ return false;
+ }
+
+ try {
+ // Create a collection instance
+ String colstring = normalizeCollectionURI((String) table.get(XMLTools.COLLECTION),
+ (String) table.get(XMLTools.LOCAL));
+ col = DatabaseManager.getCollection(colstring);
+ if (col == null) {
+ System.out.println("ERROR : Collection not found!");
+ return false;
+ }
+
+ // Read data
+ File file = new File((String) table.get(XMLTools.FILE_PATH));
+ InputStream fis = new FileInputStream(file);
+ byte[] data = new byte[fis.available()];
+ fis.read(data);
+ fis.close();
+
+ // Create the BinaryResource and store the resource
+ Resource resource = col.createResource((String) table.get(XMLTools.NAME_OF),
+ "BinaryResource");
+ resource.setContent(data);
+ col.storeResource(resource);
+
+ System.out.println("Added resource " + table.get(XMLTools.COLLECTION) + "/" +
+ resource.getId());
+ resource = null;
+ } finally {
+ if (col != null) {
+ col.close();
+ }
+ col = null;
+ }
+
+ return true;
+ }
+}
1.13 +3 -3 xml-xindice/java/src/org/apache/xindice/tools/command/ImportTree.java
Index: ImportTree.java
===================================================================
RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/tools/command/ImportTree.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- ImportTree.java 8 Feb 2004 02:57:35 -0000 1.12
+++ ImportTree.java 20 Jul 2004 20:31:37 -0000 1.13
@@ -181,7 +181,7 @@
* should be included
*/
public boolean accept(File pathname) {
- if (this.extension != "") {
+ if (this.extension.length() > 0) {
return pathname.getName().endsWith("." + this.extension) || pathname.isDirectory();
} else {
return true;
1.11 +3 -3 xml-xindice/java/src/org/apache/xindice/tools/command/RetrieveDocument.java
Index: RetrieveDocument.java
===================================================================
RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/tools/command/RetrieveDocument.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- RetrieveDocument.java 8 Feb 2004 02:57:35 -0000 1.10
+++ RetrieveDocument.java 20 Jul 2004 20:31:37 -0000 1.11
@@ -66,7 +66,7 @@
String documentstr = (String) resource.getContent();
- if ((documentstr != null) && (table.get(XMLTools.FILE_PATH) != "")) {
+ if (documentstr != null && !"".equals(table.get(XMLTools.FILE_PATH))) {
try {
File file = new File((String) table.get(XMLTools.FILE_PATH));
// Create the directory structure if necessary
1.14 +4 -4 xml-xindice/java/src/org/apache/xindice/tools/command/XPathQuery.java
Index: XPathQuery.java
===================================================================
RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/tools/command/XPathQuery.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- XPathQuery.java 20 May 2004 12:21:46 -0000 1.13
+++ XPathQuery.java 20 Jul 2004 20:31:37 -0000 1.14
@@ -52,7 +52,7 @@
return false;
}
- if (table.get(XMLTools.QUERY) == "") {
+ if ("".equals(table.get(XMLTools.QUERY))) {
System.out.println("ERROR : Query and switch required");
return false;
}
@@ -100,7 +100,7 @@
}
private void addNamespaces(XPathQueryService service, String namespacesString) throws XMLDBException {
- if ((namespacesString != "") && (namespacesString != null)) {
+ if (namespacesString != null && namespacesString.length() > 0) {
StringTokenizer st = new StringTokenizer(namespacesString, "=;");
if (st.countTokens() % 2 != 0) {
throw new XMLDBException(0, "mismatched namespace prefixes and uris in '" + namespacesString + "'");
1.6 +3 -3 xml-xindice/java/src/org/apache/xindice/tools/command/XUpdate.java
Index: XUpdate.java
===================================================================
RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/tools/command/XUpdate.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XUpdate.java 8 Feb 2004 02:57:35 -0000 1.5
+++ XUpdate.java 20 Jul 2004 20:31:37 -0000 1.6
@@ -53,7 +53,7 @@
return false;
}
- if ((String) table.get(XMLTools.FILE_PATH) == "") {
+ if ("".equals(table.get(XMLTools.FILE_PATH))) {
System.out.println("ERROR : Path to file containing XUpdate to execute required");
return false;
}