Author: vgritsenko
Date: Thu Dec 15 14:11:59 2005
New Revision: 357079
URL: http://svn.apache.org/viewcvs?rev=357079&view=rev
Log:
<action dev="VG" type="fix" fixes-bug="37383" due-to="Terry Rosenbaum">
Fix ClassCastException in MemValueIndexer.
</action>
Modified:
xml/xindice/trunk/java/src/org/apache/xindice/core/indexer/MemValueIndexer.java
xml/xindice/trunk/status.xml
Modified: xml/xindice/trunk/java/src/org/apache/xindice/core/indexer/MemValueIndexer.java
URL: http://svn.apache.org/viewcvs/xml/xindice/trunk/java/src/org/apache/xindice/core/indexer/MemValueIndexer.java?rev=357079&r1=357078&r2=357079&view=diff
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/core/indexer/MemValueIndexer.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/core/indexer/MemValueIndexer.java Thu Dec 15 14:11:59 2005
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * CVS $Id$
+ * $Id$
*/
package org.apache.xindice.core.indexer;
@@ -46,7 +46,7 @@
* useful for temporary indexing of persistent Collections.
*
* @author Terry Rosenbaum ([email protected])
- * @version CVS $Revision$, $Date$
+ * @version $Revision$, $Date$
*/
public class MemValueIndexer implements Indexer {
@@ -87,6 +87,8 @@
private static final String CHAR_VAL = "char";
private static final String BOOLEAN_VAL = "boolean";
+ private static final IndexMatch[] EMPTY_INDEX_MATCH_ARRAY = new IndexMatch[0];
+
//
// Instance variables
//
@@ -194,7 +196,8 @@
* @param theElementID The Element ID of the value
* @param theAttributeID The Attribute ID of the value (if any, else -1)
*/
- public synchronized void remove(String theValue, Key theKey, int thePosition, int theLength, short theElementID, short theAttributeID) throws DBException {
+ public synchronized void remove(String theValue, Key theKey, int thePosition, int theLength,
+ short theElementID, short theAttributeID) throws DBException {
Object aValue;
if (itsValueType != STRING) {
@@ -234,7 +237,8 @@
* @param theElementID The Element ID of the value
* @param theAttributeID The Attribute ID of the value (if any, else -1)
*/
- public synchronized void add(String theValue, Key theKey, int thePosition, int theLength, short theElementID, short theAttributeID) throws DBException {
+ public synchronized void add(String theValue, Key theKey, int thePosition, int theLength,
+ short theElementID, short theAttributeID) throws DBException {
Object aValue;
if (itsValueType != STRING) {
@@ -296,7 +300,7 @@
}
}
- TreeSet aLocatorSet = null;
+ TreeSet aLocatorSet;
Object aLowEndpoint = aMatchValueArray[0];
Object aHighEndpoint = aMatchValueArray[aMatchValueArray.length - 1];
@@ -321,7 +325,7 @@
// see whether or not we even have the value to be excluded
TreeSet anExcludedLocatorSet = (TreeSet) itsValues.get(aLowEndpoint);
- aValueIterator = itsValues.values().iterator();
+ aValueIterator = itsValues.entrySet().iterator();
int aResultIndex = 0;
if (anExcludedLocatorSet == null) {
// allocate return array to include all locators since none are excluded
@@ -334,7 +338,8 @@
Iterator aLocatorIterator = ((TreeSet) ((Map.Entry) aValueIterator.next()).getValue()).iterator();
for (; aLocatorIterator.hasNext(); ++aResultIndex) {
ValueLocator aLocator = (ValueLocator) aLocatorIterator.next();
- aResult[aResultIndex] = new IndexMatch(new Key(aLocator.getKey()), aLocator.getPosition(), aLocator.getLength(), aLocator.getElementID(), aLocator.getAttributeID());
+ aResult[aResultIndex] = new IndexMatch(
+ new Key(aLocator.getKey()), aLocator.getPosition(), aLocator.getLength(), aLocator.getElementID(), aLocator.getAttributeID());
}
}
} else {
@@ -352,7 +357,8 @@
Iterator aLocatorIterator = ((TreeSet) ((Map.Entry) aValueIterator.next()).getValue()).iterator();
for (; aLocatorIterator.hasNext(); ++aResultIndex) {
ValueLocator aLocator = (ValueLocator) aLocatorIterator.next();
- aResult[aResultIndex] = new IndexMatch(new Key(aLocator.getKey()), aLocator.getPosition(), aLocator.getLength(), aLocator.getElementID(), aLocator.getAttributeID());
+ aResult[aResultIndex] = new IndexMatch(
+ new Key(aLocator.getKey()), aLocator.getPosition(), aLocator.getLength(), aLocator.getElementID(), aLocator.getAttributeID());
}
}
}
@@ -485,7 +491,7 @@
break;
}
- return aResult;
+ return aResult == null ? EMPTY_INDEX_MATCH_ARRAY : aResult;
}
/**
@@ -599,8 +605,8 @@
* @param theMap Map containing Sets of ValueLocator objects as values
* @return a new array of IndexMatch objects
*/
- private final IndexMatch[] getIndexMatchArray(Map theMap) {
- IndexMatch[] aResult = null;
+ private IndexMatch[] getIndexMatchArray(Map theMap) {
+ IndexMatch[] aResult;
// count results to size result array
if (theMap != null) {
@@ -624,7 +630,7 @@
* @param theSecondMap Map containing Sets of ValueLocator objects as values
* @return a new array of IndexMatch objects
*/
- private final IndexMatch[] getIndexMatchArray(Map theFirstMap, Map theSecondMap) {
+ private IndexMatch[] getIndexMatchArray(Map theFirstMap, Map theSecondMap) {
int aLocatorCount = 0;
// count results to size result array
@@ -653,7 +659,7 @@
* @param theExcludeFlag filtering is exclude if true, include if false
* @return a new array of IndexMatch objects
*/
- private final IndexMatch[] getIndexMatchArray(Map theMap, Object[] theFilterList, boolean theExcludeFlag) {
+ private IndexMatch[] getIndexMatchArray(Map theMap, Object[] theFilterList, boolean theExcludeFlag) {
if (theMap == null) {
return new IndexMatch[0];
}
@@ -662,7 +668,7 @@
Iterator aValueIterator;
int aLocatorCount = 0;
- aValueIterator = theMap.values().iterator();
+ aValueIterator = theMap.entrySet().iterator();
// iterate over the values adding locators for each matched to result
while (aValueIterator.hasNext()) {
@@ -708,7 +714,8 @@
* @param theExcludeFlag filtering is exclude if true, include if false
* @return a new array of IndexMatch objects
*/
- private final IndexMatch[] getIndexMatchArray(Map theFirstMap, Map theFilterThisMap, Map theThirdMap, Object[] theFilterList, boolean theExcludeFlag) {
+ private IndexMatch[] getIndexMatchArray(Map theFirstMap, Map theFilterThisMap, Map theThirdMap,
+ Object[] theFilterList, boolean theExcludeFlag) {
if (theFilterThisMap == null) {
return getIndexMatchArray(theFirstMap, theThirdMap);
}
@@ -723,7 +730,7 @@
// qualify the results for filter operation
// adding those qualifying to aResultCollection and counting filtered results
- aValueIterator = theFirstMap.values().iterator();
+ aValueIterator = theFirstMap.entrySet().iterator();
// iterate over the values adding locators for each matched to result
while (aValueIterator.hasNext()) {
@@ -930,7 +937,7 @@
* @param theValue String from which to derive the value
* @return an Object representing the value extracted from theValue
*/
- private final Object getTypedValue(String theValue) {
+ private Object getTypedValue(String theValue) {
if (itsValueType != STRING && itsValueType != TRIMMED) {
theValue = theValue.trim();
} else {
@@ -992,7 +999,7 @@
* @param theValue Object to return next value of
* @return an Object representing the next value above specified value or null if theValue is already at maximum for type
*/
- private final Object getNextValueOf(Object theValue) {
+ private Object getNextValueOf(Object theValue) {
return getNextValueOf(theValue, itsValueType);
}
@@ -1005,7 +1012,7 @@
* @param theType type of Object to return
* @return an Object representing the next value above specified value or null if theValue is already at maximum for type
*/
- private final Object getNextValueOf(Object theValue, int theType) {
+ private Object getNextValueOf(Object theValue, int theType) {
if (theValue instanceof EmptyValue) {
return "\0";
}
@@ -1095,7 +1102,7 @@
int aCount = 0;
if (theMap != null) {
- Iterator aValueIterator = theMap.values().iterator();
+ Iterator aValueIterator = theMap.entrySet().iterator();
// iterate over the values adding locators for each to result
// no need to filter while iterating
while (aValueIterator.hasNext()) {
@@ -1120,7 +1127,7 @@
return theStartIndex;
}
- Iterator aValueIterator = theMap.values().iterator();
+ Iterator aValueIterator = theMap.entrySet().iterator();
// iterate over the values adding locators for each to result
// no need to filter while iterating
while (aValueIterator.hasNext()) {
@@ -1128,7 +1135,8 @@
Iterator aLocatorIterator = ((TreeSet) ((Map.Entry) aValueIterator.next()).getValue()).iterator();
for (; aLocatorIterator.hasNext(); ++theStartIndex) {
ValueLocator aLocator = (ValueLocator) aLocatorIterator.next();
- theArray[theStartIndex] = new IndexMatch(new Key(aLocator.getKey()), aLocator.getPosition(), aLocator.getLength(), aLocator.getElementID(), aLocator.getAttributeID());
+ theArray[theStartIndex] = new IndexMatch(
+ new Key(aLocator.getKey()), aLocator.getPosition(), aLocator.getLength(), aLocator.getElementID(), aLocator.getAttributeID());
}
}
@@ -1152,7 +1160,8 @@
Iterator aLocatorIterator = theSet.iterator();
for (; aLocatorIterator.hasNext(); ++theStartIndex) {
ValueLocator aLocator = (ValueLocator) aLocatorIterator.next();
- theArray[theStartIndex] = new IndexMatch(new Key(aLocator.getKey()), aLocator.getPosition(), aLocator.getLength(), aLocator.getElementID(), aLocator.getAttributeID());
+ theArray[theStartIndex] = new IndexMatch(
+ new Key(aLocator.getKey()), aLocator.getPosition(), aLocator.getLength(), aLocator.getElementID(), aLocator.getAttributeID());
}
return theStartIndex;
}
@@ -1164,7 +1173,7 @@
* and compare as String values. Any EmptyValue converted
* to String is an empty String.
*/
- private static class EmptyValue extends Object implements Comparable {
+ private static class EmptyValue implements Comparable {
/**
* Creates a new object.
Modified: xml/xindice/trunk/status.xml
URL: http://svn.apache.org/viewcvs/xml/xindice/trunk/status.xml?rev=357079&r1=357078&r2=357079&view=diff
==============================================================================
--- xml/xindice/trunk/status.xml (original)
+++ xml/xindice/trunk/status.xml Thu Dec 15 14:11:59 2005
@@ -74,6 +74,9 @@
<changes>
<release version="1.1b5-dev" date="Dec 15 2005">
+ <action dev="VG" type="fix" fixes-bug="37383" due-to="Terry Rosenbaum">
+ Fix ClassCastException in MemValueIndexer.
+ </action>
<action dev="VG" type="update">
Make an attempt to lock a database before opening it up.
Prevents opening up same database by different processes,
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.