1 package org.kuali.ole.ingest.util;
2
3 import java.util.regex.Matcher;
4 import java.util.regex.Pattern;
5
6
7
8
9
10
11
12
13 public class OCLCUtil {
14
15 String normalizedOclc = null;
16
17
18
19
20
21
22 public String normalizedOclc(String oclc) {
23
24 StringBuffer buffer = new StringBuffer();
25 String regex = "(ocl77|ocm|ocn|on)";
26 Pattern pattern = Pattern.compile(regex);
27 Matcher matcher = pattern.matcher(oclc);
28 String modifiedString = matcher.replaceAll("");
29 String[] splitValues = modifiedString.split(" ");
30 if (splitValues.length > 1) {
31 for (String splitValue : splitValues) {
32 if(splitValue.contains("(") && splitValue.contains(")")) {
33 buffer.append(splitValue);
34 } else {
35 buffer.append((Integer.parseInt(splitValue)));
36 }
37 }
38 }else {
39 String ocolc = modifiedString.substring(modifiedString.indexOf("("), modifiedString.indexOf(")") + 1);
40 buffer.append(ocolc);
41 String content = modifiedString.substring(modifiedString.indexOf(")")+1,modifiedString.length());
42 buffer.append((Integer.parseInt(content)));
43 }
44 normalizedOclc = buffer.toString();
45 return normalizedOclc;
46 }
47
48 }