Revision: 1777
Author:
olso...@gmail.com
Date: Mon Feb 16 18:24:17 2015 UTC
Log: cutter part of shelf key now case insensitive
https://code.google.com/p/solrmarc/source/detail?r=1777
Modified:
/trunk/lib/solrmarc/src/org/solrmarc/callnum/LCCallNumber.java
/trunk/test/src/org/solrmarc/callnum/LCCallNumberUnitTests.java
=======================================
--- /trunk/lib/solrmarc/src/org/solrmarc/callnum/LCCallNumber.java Fri Jan
23 19:54:42 2015 UTC
+++ /trunk/lib/solrmarc/src/org/solrmarc/callnum/LCCallNumber.java Mon Feb
16 18:24:17 2015 UTC
@@ -142,8 +142,10 @@
* regular expression string for the cutter, without preceding
characters
* (such as the "required" period, which is sometimes missing, or
spaces).
* A Cutter is a single letter followed by digits.
+ *
+ * Must match uppper and lower case, catalog patrons expect to type in
either case.
*/
- public static final String CUTTER_REGEX = "[A-Z]\\d+";
+ public static final String CUTTER_REGEX = "[A-Za-z]\\d+";
/**
* Separates the class from the rest of a call number.
@@ -173,7 +175,7 @@
* and we just need to separate the cutter from any suffix.
* Matching group 1 contains the cutter.
*/
- protected static Pattern cutterAfterSuffixPat =
Pattern.compile("(\\.?[A-Z]\\d+|^\\.[A-Z]| \\.[A-Z])");
+ protected static Pattern cutterAfterSuffixPat =
Pattern.compile("(\\.?[A-Za-z]\\d+|^\\.[A-Za-z]| \\.[A-Za-z])");
/* Constructors */
/**
@@ -354,7 +356,7 @@
Utils.appendNumericallySortable(key,
classSuffix.toUpperCase());
}
if (cutter != null) {
- appendCutterShelfKey(key, cutter);
+ appendCutterShelfKey(key, cutter.toUpperCase());
}
// TODO: better way to deal with trailing . or space in call num,
as in "BF199.",
// causes meaningless class suffix resulting in trailing
space on shelf key
=======================================
--- /trunk/test/src/org/solrmarc/callnum/LCCallNumberUnitTests.java Fri Jan
23 19:54:42 2015 UTC
+++ /trunk/test/src/org/solrmarc/callnum/LCCallNumberUnitTests.java Mon Feb
16 18:24:17 2015 UTC
@@ -1071,7 +1071,7 @@
* unit test for getShelfKey: classification but no cutter
*/
@Test
- public void testGetShelfKey2()
+ public void testGetShelfKey_classNoCutter()
{
String callnum = "BF199";
assertEquals("BF 3199", new LCCallNumber(callnum).getShelfKey());
@@ -1097,7 +1097,7 @@
}
/**
- * unit test for getShelfKey: check that lower case input is
+ * unit test for getShelfKey: check that lower case user input is
handled sensibly
*/
@Test
public void testGetShelfKey_lowerCase()
@@ -1106,6 +1106,13 @@
assertEquals("BQ 41270", new LCCallNumber(callnum).getShelfKey());
callnum = "l666 15th A8"; // suffix with letters
assertEquals("L 3666 215TH A8", new
LCCallNumber(callnum).getShelfKey());
+
+ // Check that upper case and lower case input normalizer the same
+ String callnumUpper = "M857 .K93 H2 OP.79";
+ String callnumLower = "m857 .k93 h2 op.79";
+ String callnumKey = "M 3857 K93 H2 OP 279";
+ assertEquals(callnumKey, new
LCCallNumber(callnumUpper).getShelfKey());
+ assertEquals(callnumKey, new
LCCallNumber(callnumLower).getShelfKey());
}
/**