You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by tn...@apache.org on 2013/06/10 23:46:20 UTC
svn commit: r1491615 [2/2] - in /commons/proper/collections/trunk/src:
main/java/org/apache/commons/collections4/trie/
main/java/org/apache/commons/collections4/trie/analyzer/
test/java/org/apache/commons/collections4/trie/
test/java/org/apache/commons...
Copied: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/trie/analyzer/StringKeyAnalyzer.java (from r1491240, commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/trie/StringKeyAnalyzer.java)
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/trie/analyzer/StringKeyAnalyzer.java?p2=commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/trie/analyzer/StringKeyAnalyzer.java&p1=commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/trie/StringKeyAnalyzer.java&r1=1491240&r2=1491615&rev=1491615&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/trie/StringKeyAnalyzer.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/trie/analyzer/StringKeyAnalyzer.java Mon Jun 10 21:46:19 2013
@@ -14,7 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.commons.collections4.trie;
+package org.apache.commons.collections4.trie.analyzer;
+
+import org.apache.commons.collections4.trie.KeyAnalyzer;
/**
* An {@link KeyAnalyzer} for {@link String}s.
@@ -22,60 +24,42 @@ package org.apache.commons.collections4.
* @since 4.0
* @version $Id$
*/
-public class StringKeyAnalyzer extends AbstractKeyAnalyzer<String> {
+public class StringKeyAnalyzer extends KeyAnalyzer<String> {
private static final long serialVersionUID = -7032449491269434877L;
- /**
- * A singleton instance of {@link StringKeyAnalyzer}
- */
+ /** A singleton instance of {@link StringKeyAnalyzer}. */
public static final StringKeyAnalyzer INSTANCE = new StringKeyAnalyzer();
- /**
- * The number of bits per {@link Character}
- */
+ /** The number of bits per {@link Character}. */
public static final int LENGTH = Character.SIZE;
- /**
- * A bit mask where the first bit is 1 and the others are zero
- */
+ /** A bit mask where the first bit is 1 and the others are zero. */
private static final int MSB = 0x8000;
- /**
- * Returns a bit mask where the given bit is set
- */
+ /** Returns a bit mask where the given bit is set. */
private static int mask(final int bit) {
return MSB >>> bit;
}
- /**
- * {@inheritDoc}
- */
public int bitsPerElement() {
return LENGTH;
}
- /**
- * {@inheritDoc}
- */
public int lengthInBits(final String key) {
return key != null ? key.length() * LENGTH : 0;
}
- /**
- * {@inheritDoc}
- */
public int bitIndex(final String key, final int offsetInBits, final int lengthInBits,
- final String other, final int otherOffsetInBits, final int otherLengthInBits) {
+ final String other, final int otherOffsetInBits, final int otherLengthInBits) {
+
boolean allNull = true;
if (offsetInBits % LENGTH != 0 || otherOffsetInBits % LENGTH != 0
|| lengthInBits % LENGTH != 0 || otherLengthInBits % LENGTH != 0) {
- throw new IllegalArgumentException(
- "The offsets and lengths must be at Character boundaries");
+ throw new IllegalArgumentException("The offsets and lengths must be at Character boundaries");
}
-
final int beginIndex1 = offsetInBits / LENGTH;
final int beginIndex2 = otherOffsetInBits / LENGTH;
@@ -123,9 +107,6 @@ public class StringKeyAnalyzer extends A
return KeyAnalyzer.EQUAL_BIT_KEY;
}
- /**
- * {@inheritDoc}
- */
public boolean isBitSet(final String key, final int bitIndex, final int lengthInBits) {
if (key == null || bitIndex >= lengthInBits) {
return false;
@@ -137,11 +118,8 @@ public class StringKeyAnalyzer extends A
return (key.charAt(index) & mask(bit)) != 0;
}
- /**
- * {@inheritDoc}
- */
public boolean isPrefix(final String prefix, final int offsetInBits,
- final int lengthInBits, final String key) {
+ final int lengthInBits, final String key) {
if (offsetInBits % LENGTH != 0 || lengthInBits % LENGTH != 0) {
throw new IllegalArgumentException(
"Cannot determine prefix outside of Character boundaries");
Added: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/trie/analyzer/package-info.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/trie/analyzer/package-info.java?rev=1491615&view=auto
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/trie/analyzer/package-info.java (added)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/trie/analyzer/package-info.java Mon Jun 10 21:46:19 2013
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * This package contains various {@link org.apache.commons.collections4.trie.KeyAnalyzer} implementations.
+ *
+ * @version $Id$
+ */
+package org.apache.commons.collections4.trie.analyzer;
Propchange: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/trie/analyzer/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/trie/analyzer/package-info.java
------------------------------------------------------------------------------
svn:keywords = Id Revision HeadURL
Propchange: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/trie/analyzer/package-info.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/trie/PatriciaTrieTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/trie/PatriciaTrieTest.java?rev=1491615&r1=1491614&r2=1491615&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/trie/PatriciaTrieTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/trie/PatriciaTrieTest.java Mon Jun 10 21:46:19 2013
@@ -34,6 +34,9 @@ import java.util.TreeMap;
import java.util.Map.Entry;
import org.apache.commons.collections4.Trie.Cursor;
+import org.apache.commons.collections4.trie.analyzer.CharacterKeyAnalyzer;
+import org.apache.commons.collections4.trie.analyzer.IntegerKeyAnalyzer;
+import org.apache.commons.collections4.trie.analyzer.StringKeyAnalyzer;
import org.junit.Assert;
import org.junit.Test;
@@ -1079,6 +1082,7 @@ public class PatriciaTrieTest {
}
}
+ @SuppressWarnings("unused")
void selectFor(final Object object) {
selectFor = object;
}
Copied: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/trie/analyzer/ByteArrayKeyAnalyzerTest.java (from r1491240, commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/trie/ByteArrayKeyAnalyzerTest.java)
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/trie/analyzer/ByteArrayKeyAnalyzerTest.java?p2=commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/trie/analyzer/ByteArrayKeyAnalyzerTest.java&p1=commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/trie/ByteArrayKeyAnalyzerTest.java&r1=1491240&r2=1491615&rev=1491615&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/trie/ByteArrayKeyAnalyzerTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/trie/analyzer/ByteArrayKeyAnalyzerTest.java Mon Jun 10 21:46:19 2013
@@ -14,12 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.commons.collections4.trie;
+package org.apache.commons.collections4.trie.analyzer;
import java.math.BigInteger;
import java.util.Map;
import java.util.TreeMap;
+import org.apache.commons.collections4.trie.PatriciaTrie;
+import org.apache.commons.collections4.trie.analyzer.ByteArrayKeyAnalyzer;
import org.junit.Assert;
import org.junit.Test;