[DS-707] Use character instead of string

git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@5530 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Graham Triggs
2010-10-21 16:46:54 +00:00
parent 53084f0384
commit 1ea64c3b31
31 changed files with 80 additions and 70 deletions

View File

@@ -347,7 +347,7 @@ public class MetadataImport
// If there is a language on the element, strip if off
if (element.contains("["))
{
element = element.substring(0, element.indexOf("["));
element = element.substring(0, element.indexOf('['));
}
String qualifier = null;
if (bits.length > 2)
@@ -357,7 +357,7 @@ public class MetadataImport
// If there is a language, strip if off
if (qualifier.contains("["))
{
qualifier = qualifier.substring(0, qualifier.indexOf("["));
qualifier = qualifier.substring(0, qualifier.indexOf('['));
}
}
DCValue[] current = item.getMetadata(schema, element, qualifier, language);
@@ -656,7 +656,7 @@ public class MetadataImport
// If there is a language on the element, strip if off
if (element.contains("["))
{
element = element.substring(0, element.indexOf("["));
element = element.substring(0, element.indexOf('['));
}
String qualifier = null;
if (bits.length > 2)
@@ -666,7 +666,7 @@ public class MetadataImport
// If there is a language, strip if off
if (qualifier.contains("["))
{
qualifier = qualifier.substring(0, qualifier.indexOf("["));
qualifier = qualifier.substring(0, qualifier.indexOf('['));
}
}

View File

@@ -1149,7 +1149,7 @@ public class ItemImport
continue; // process next line in contents file
}
int bitstreamEndIndex = line.indexOf("\t");
int bitstreamEndIndex = line.indexOf('\t');
if (bitstreamEndIndex == -1)
{
@@ -1480,17 +1480,17 @@ public class ItemImport
+ permissionsMarker.length(), pEndIndex);
// get permission type ("read" or "write")
int pTypeIndex = thisPermission.indexOf("-");
int pTypeIndex = thisPermission.indexOf('-');
// get permission group (should be in single quotes)
int groupIndex = thisPermission.indexOf("'", pTypeIndex);
int groupEndIndex = thisPermission.indexOf("'", groupIndex + 1);
int groupIndex = thisPermission.indexOf('\'', pTypeIndex);
int groupEndIndex = thisPermission.indexOf('\'', groupIndex + 1);
// if not in single quotes, assume everything after type flag is
// group name
if (groupIndex == -1)
{
groupIndex = thisPermission.indexOf(" ", pTypeIndex);
groupIndex = thisPermission.indexOf(' ', pTypeIndex);
groupEndIndex = thisPermission.length();
}

View File

@@ -267,7 +267,7 @@ public class ShibAuthentication implements AuthenticationMethod
// strip scope if present and roleHeader_ignoreScope
if (roleHeader_ignoreScope)
{
int index = affiliation.indexOf("@");
int index = affiliation.indexOf('@');
if (index != -1) affiliation = affiliation.substring(0,index);
}

View File

@@ -162,13 +162,13 @@ public class ChoiceAuthorityManager
private String config2fkey(String field)
{
// field is expected to be "schema.element.qualifier"
int dot = field.indexOf(".");
int dot = field.indexOf('.');
if (dot < 0)
return null;
String schema = field.substring(0, dot);
String element = field.substring(dot+1);
String qualifier = null;
dot = element.indexOf(".");
dot = element.indexOf('.');
if (dot >= 0)
{
qualifier = element.substring(dot+1);

View File

@@ -114,7 +114,7 @@ public class MetadataAuthorityManager
{
// field is expected to be "schema.element.qualifier"
String field = key.substring(authPrefix.length());
int dot = field.indexOf(".");
int dot = field.indexOf('.');
if (dot < 0)
{
log.warn("Skipping invalid MetadataAuthority configuration property: "+key+": does not have schema.element.qualifier");
@@ -123,7 +123,7 @@ public class MetadataAuthorityManager
String schema = field.substring(0, dot);
String element = field.substring(dot+1);
String qualifier = null;
dot = element.indexOf(".");
dot = element.indexOf('.');
if (dot >= 0)
{
qualifier = element.substring(dot+1);

View File

@@ -134,13 +134,17 @@ public class XSLTDisseminationCrosswalk
// right format for value of "schemaLocation" attribute.
schemaLocation = ConfigurationManager.getProperty(prefix+"schemaLocation");
if (schemaLocation == null)
{
log.warn("No schemaLocation for crosswalk="+myAlias+", key="+prefix+"schemaLocation");
}
// sanity check: schemaLocation should have space.
else if (schemaLocation.length() > 0 && schemaLocation.indexOf(" ") < 0)
else if (schemaLocation.length() > 0 && schemaLocation.indexOf(' ') < 0)
{
log.warn("Possible INVALID schemaLocation (no space found) for crosswalk="+
myAlias+", key="+prefix+"schemaLocation"+
"\n\tCorrect format is \"{namespace} {schema-URL}\"");
}
// grovel for namespaces of the form:
// crosswalk.diss.{PLUGIN_NAME}.namespace.{PREFIX} = {URI}

View File

@@ -799,10 +799,10 @@ public class PackageUtils
//Pull apart default group name into its three main parts
// Format: <DSpace-Obj-Type>_<DSpace-Obj-ID>_<Group-Type>
// (e.g. COLLECTION_123_ADMIN)
String objType = groupName.substring(0, groupName.indexOf("_"));
String tmpEndString = groupName.substring(groupName.indexOf("_")+1);
String objID = tmpEndString.substring(0, tmpEndString.indexOf("_"));
String groupType = tmpEndString.substring(tmpEndString.indexOf("_")+1);
String objType = groupName.substring(0, groupName.indexOf('_'));
String tmpEndString = groupName.substring(groupName.indexOf('_')+1);
String objID = tmpEndString.substring(0, tmpEndString.indexOf('_'));
String groupType = tmpEndString.substring(tmpEndString.indexOf('_')+1);
try
{
@@ -868,10 +868,10 @@ public class PackageUtils
//Pull apart default group name into its three main parts
// Format: <DSpace-Obj-Type>_<DSpace-Obj-ID>_<Group-Type>
// (e.g. COLLECTION_123_ADMIN)
String objType = groupName.substring(0, groupName.indexOf("_"));
String tmpEndString = groupName.substring(groupName.indexOf("_")+1);
String objID = tmpEndString.substring(0, tmpEndString.indexOf("_"));
String groupType = tmpEndString.substring(tmpEndString.indexOf("_")+1);
String objType = groupName.substring(0, groupName.indexOf('_'));
String tmpEndString = groupName.substring(groupName.indexOf('_')+1);
String objID = tmpEndString.substring(0, tmpEndString.indexOf('_'));
String groupType = tmpEndString.substring(tmpEndString.indexOf('_')+1);
try
{

View File

@@ -808,7 +808,7 @@ public class ConfigurationManager
int start = value.indexOf("${", from);
if (start >= 0)
{
int end = value.indexOf("}", start);
int end = value.indexOf('}', start);
if (end < 0)
break;
String var = value.substring(start+2, end);

View File

@@ -51,7 +51,7 @@ public class OrderFormatDate implements OrderFormatDelegate
public String makeSortString(String value, String language)
{
int padding = 0;
int endYearIdx = value.indexOf("-");
int endYearIdx = value.indexOf('-');
if (endYearIdx >= 0 && endYearIdx < 4)
{

View File

@@ -1043,7 +1043,7 @@ public class DatabaseManager
int count = 0;
int inputlen = input.length();
while ((index = input.indexOf("'", count)) != -1)
while ((index = input.indexOf('\'', count)) != -1)
{
// Flip the value of inquote
inquote = !inquote;
@@ -1066,7 +1066,7 @@ public class DatabaseManager
continue;
}
int endMarker = input.indexOf(";", index);
int endMarker = input.indexOf(';', index);
if (endMarker == -1)
{
@@ -1530,7 +1530,7 @@ public class DatabaseManager
String schema = ConfigurationManager.getProperty("db.schema");
String catalog = null;
int dotIndex = table.indexOf(".");
int dotIndex = table.indexOf('.');
if (dotIndex > 0)
{
catalog = table.substring(0, dotIndex);

View File

@@ -319,7 +319,7 @@ public class LayoutTag extends TagSupport
}
// build a list of link attributes for each link format
String[] formats = feedData.substring(feedData.indexOf(":")+1).split(",");
String[] formats = feedData.substring(feedData.indexOf(':')+1).split(",");
List linkParts = new ArrayList();
// each link has a mime-type, title, and format (used in href URL)
for (int i = 0; i < formats.length; i++)

View File

@@ -187,7 +187,7 @@ public class FeedServlet extends DSpaceServlet
{
// substring(1) is to remove initial '/'
path = path.substring(1);
int split = path.indexOf("/");
int split = path.indexOf('/');
if (split != -1)
{
feedType = path.substring(0,split);

View File

@@ -91,7 +91,7 @@ public class FeedbackServlet extends DSpaceServlet
{
// cut off all but the hostname, to cover cases where more than one URL
// arrives at the installation; e.g. presence or absence of "www"
int lastDot = host.lastIndexOf(".");
int lastDot = host.lastIndexOf('.');
basicHost = host.substring(host.substring(0, lastDot).lastIndexOf("."));
}

View File

@@ -92,12 +92,14 @@ public class SuggestServlet extends DSpaceServlet
String basicHost = "";
if (host.equals("localhost") || host.equals("127.0.0.1")
|| host.equals(InetAddress.getLocalHost().getHostAddress()))
{
basicHost = host;
}
else
{
// cut off all but the hostname, to cover cases where more than one URL
// arrives at the installation; e.g. presence or absence of "www"
int lastDot = host.lastIndexOf(".");
int lastDot = host.lastIndexOf('.');
basicHost = host.substring(host.substring(0, lastDot).lastIndexOf("."));
}

View File

@@ -358,7 +358,7 @@ public class LNISmokeTest
}
// hack: parse "handle bitstream" syntax of handle.
if (handle.indexOf(" ") >= 0 && bitstream == null)
if (handle.indexOf(' ') >= 0 && bitstream == null)
{
String h[] = handle.split("\\s+");
handle = h[0];
@@ -433,7 +433,7 @@ public class LNISmokeTest
{
value = outputPretty.outputString(kids);
}
if (value.indexOf("\n") >= 0)
if (value.indexOf('\n') >= 0)
{
value = "\n" + value;
}

View File

@@ -95,7 +95,7 @@ public class LNIClientUtils
throws MalformedURLException
{
/* chop off last path element */
int s = endpoint.lastIndexOf("/");
int s = endpoint.lastIndexOf('/');
if (s < 0)
{
throw new MalformedURLException(

View File

@@ -185,7 +185,7 @@ class DAVLookup extends DAVResource
String handle = null;
// if "prefix" contains a slash, then it's the whole handle:
if (prefix.indexOf("/") >= 0)
if (prefix.indexOf('/') >= 0)
{
handle = prefix;
log.debug("Lookup: resolving escaped handle \"" + handle + "\"");

View File

@@ -1161,7 +1161,7 @@ abstract class DAVResource
{
String srcPath = (new URI(this.request.getRequestURI())).getPath();
String destPath = (new URI(destination)).getPath();
int slash = srcPath.lastIndexOf("/");
int slash = srcPath.lastIndexOf('/');
if (slash > -1)
{
String lastElt = srcPath.substring(slash);

View File

@@ -346,7 +346,7 @@ public class DAVServlet extends HttpServlet
{
String crud = ct.nextToken();
String dcrud = new String(Base64.decodeBase64(crud.getBytes()));
int colon = dcrud.indexOf(":");
int colon = dcrud.indexOf(':');
if (colon > 0)
{
username = URLDecode(dcrud.substring(0, colon));

View File

@@ -464,7 +464,7 @@ public class StatisticsDataVisits extends StatisticsData
name = vals[0].value;
if(dsoLength != -1 && name.length() > dsoLength){
//Cut it off at the first space
int firstSpace = name.indexOf(" ", dsoLength);
int firstSpace = name.indexOf(' ', dsoLength);
if(firstSpace != -1){
name = name.substring(0, firstSpace) + " ...";
}
@@ -478,7 +478,7 @@ public class StatisticsDataVisits extends StatisticsData
if(dsoLength != -1 && name.length() > dsoLength){
//Cut it off at the first space
int firstSpace = name.indexOf(" ", dsoLength);
int firstSpace = name.indexOf(' ', dsoLength);
if(firstSpace != -1){
name = name.substring(0, firstSpace) + " ...";
}
@@ -491,7 +491,7 @@ public class StatisticsDataVisits extends StatisticsData
if(dsoLength != -1 && name.length() > dsoLength){
//Cut it off at the first space
int firstSpace = name.indexOf(" ", dsoLength);
int firstSpace = name.indexOf(' ', dsoLength);
if(firstSpace != -1){
name = name.substring(0, firstSpace) + " ...";
}

View File

@@ -87,10 +87,14 @@ public class StatisticsSolrDateFilter implements StatisticsFilter {
Calendar endCal = (Calendar) startCal.clone();
if(startStr.startsWith("+"))
startStr = startStr.substring(startStr.indexOf("+") + 1);
{
startStr = startStr.substring(startStr.indexOf('+') + 1);
}
if(endStr.startsWith("+"))
endStr = endStr.substring(endStr.indexOf("+") + 1);
{
endStr = endStr.substring(endStr.indexOf('+') + 1);
}
startCal.add(dateType, Integer.parseInt(startStr));
endCal.add(dateType, Integer.parseInt(endStr));

View File

@@ -83,7 +83,7 @@ public class ApacheLogRobotsProcessor {
//Currently only check if robot.txt is present in our line
if (logLine.contains("robots.txt")) {
//We got a robots.txt so we got a bot
String ip = logLine.substring(0, logLine.indexOf("-")).trim();
String ip = logLine.substring(0, logLine.indexOf('-')).trim();
//Only add single IP addresses once we got it in it is enough
logSpiders.add(ip);
}

View File

@@ -88,7 +88,7 @@ public class QualityValue {
// Check there are no more than three digits after the decimal point
String qStr = "" + q;
int pos = qStr.indexOf(".");
int pos = qStr.indexOf('.');
if (qStr.substring(pos + 1).length() > 3)
{
throw new NumberFormatException("Invalid value - no more than three digits after the decimal point: " + qStr);

View File

@@ -83,7 +83,7 @@ public class AtomDocumentServlet extends DepositServlet {
// Are there any authentication details?
String usernamePassword = getUsernamePassword(request);
if ((usernamePassword != null) && (!usernamePassword.equals(""))) {
int p = usernamePassword.indexOf(":");
int p = usernamePassword.indexOf(':');
if (p != -1) {
adr.setUsername(usernamePassword.substring(0, p));
adr.setPassword(usernamePassword.substring(p + 1));

View File

@@ -196,7 +196,7 @@ public class DepositServlet extends HttpServlet {
// Are there any authentication details?
String usernamePassword = getUsernamePassword(request);
if ((usernamePassword != null) && (!usernamePassword.equals(""))) {
int p = usernamePassword.indexOf(":");
int p = usernamePassword.indexOf(':');
if (p != -1) {
d.setUsername(usernamePassword.substring(0, p));
d.setPassword(usernamePassword.substring(p + 1));

View File

@@ -133,7 +133,7 @@ public class ServiceDocumentServlet extends HttpServlet {
// Are there any authentication details?
String usernamePassword = getUsernamePassword(request);
if ((usernamePassword != null) && (!usernamePassword.equals(""))) {
int p = usernamePassword.indexOf(":");
int p = usernamePassword.indexOf(':');
if (p != -1) {
sdr.setUsername(usernamePassword.substring(0, p));
sdr.setPassword(usernamePassword.substring(p + 1));

View File

@@ -110,8 +110,8 @@ public class SendFeedbackAction extends AbstractAction
{
// cut off all but the hostname, to cover cases where more than one URL
// arrives at the installation; e.g. presence or absence of "www"
int lastDot = host.lastIndexOf(".");
basicHost = host.substring(host.substring(0, lastDot).lastIndexOf("."));
int lastDot = host.lastIndexOf('.');
basicHost = host.substring(host.substring(0, lastDot).lastIndexOf('.'));
}
if ((fromPage == null) || ((fromPage.indexOf(basicHost) == -1) && (validReferral == false)))

View File

@@ -483,7 +483,7 @@ abstract public class AbstractStep extends AbstractDSpaceTransformer
if (errors!=null && errors.length() > 0)
{
if(errors.indexOf(",") > 0)
if(errors.indexOf(',') > 0)
fields = Arrays.asList(errors.split(","));
else//only one error field
fields.add(errors);

View File

@@ -355,7 +355,7 @@ public class BitstreamReader extends AbstractReader implements Recyclable
// Trim any path information from the bitstream
if (bitstreamName != null && bitstreamName.length() >0 )
{
int finalSlashIndex = bitstreamName.lastIndexOf("/");
int finalSlashIndex = bitstreamName.lastIndexOf('/');
if (finalSlashIndex > 0)
{
bitstreamName = bitstreamName.substring(finalSlashIndex+1);

View File

@@ -101,8 +101,8 @@ public class ConcatenationReader extends ResourceReader {
// setup list of sources, get relevant parts of path
this.inputSources = new ArrayList<Source>();
String path = src.substring(0, src.lastIndexOf("/"));
String file = src.substring(src.lastIndexOf("/")+1);
String path = src.substring(0, src.lastIndexOf('/'));
String file = src.substring(src.lastIndexOf('/')+1);
// now build own list of inputsources
String[] files = file.split(",");

View File

@@ -221,8 +221,8 @@ public class IncludePageMeta extends AbstractWingTransformer implements Cacheabl
{
// only try to concatenate css and js
String curfile = metadata.getValue();
if (curfile.lastIndexOf("?") != -1) {
curfile = curfile.substring(0, curfile.lastIndexOf("?"));
if (curfile.lastIndexOf('?') != -1) {
curfile = curfile.substring(0, curfile.lastIndexOf('?'));
}
if (curfile.endsWith(".css") || curfile.endsWith(".js") || curfile.endsWith(".json")) {
String curval = metadata.getValue();
@@ -231,29 +231,29 @@ public class IncludePageMeta extends AbstractWingTransformer implements Cacheabl
// merge
String lastval = last.getValue();
curval = metadata.getValue();
String newval = lastval.substring(0,lastval.lastIndexOf(".")) + ",";
newval += curval.substring(curval.lastIndexOf("/")+1,curval.lastIndexOf("."));
newval += lastval.substring(lastval.lastIndexOf("."));
String newval = lastval.substring(0,lastval.lastIndexOf('.')) + ",";
newval += curval.substring(curval.lastIndexOf('/')+1,curval.lastIndexOf('.'));
newval += lastval.substring(lastval.lastIndexOf('.'));
last.value = newval;
} else {
// no merge, so add to list
newMetadataList.add(metadata);
// handle query string cases
if(curval.lastIndexOf("?") != -1) {
if(curval.substring(curval.lastIndexOf("?")).equals("?nominify")) {
if(curval.lastIndexOf('?') != -1) {
if(curval.substring(curval.lastIndexOf('?')).equals("?nominify")) {
// concat should still be possible, so set last
last = metadata;
} else if(curval.substring(curval.lastIndexOf("?")).equals("?noconcat")) {
} else if(curval.substring(curval.lastIndexOf('?')).equals("?noconcat")) {
// no concat should be possible so set last to null
last = null;
// query string can be removed
curval = curval.substring(0, curval.lastIndexOf("?"));
curval = curval.substring(0, curval.lastIndexOf('?'));
metadata.value = curval;
} else {
// no concat should be possible so set last to null
last = null;
// query string should be set to "nominify"
curval = curval.substring(0, curval.lastIndexOf("?")) + "?nominify";
curval = curval.substring(0, curval.lastIndexOf('?')) + "?nominify";
metadata.value = curval;
}
} else {
@@ -302,17 +302,17 @@ public class IncludePageMeta extends AbstractWingTransformer implements Cacheabl
String curval = current.getValue();
String lastval = last.getValue();
// check if extensions and query strings are equal
if(!lastval.substring(lastval.lastIndexOf(".")).equals(curval.substring(curval.lastIndexOf(".")))) {
if(!lastval.substring(lastval.lastIndexOf('.')).equals(curval.substring(curval.lastIndexOf('.')))) {
return false;
}
// check if paths are equal
if(!lastval.substring(0,lastval.lastIndexOf("/")+1).equals(curval.substring(0,curval.lastIndexOf("/")+1))) {
if(!lastval.substring(0,lastval.lastIndexOf('/')+1).equals(curval.substring(0,curval.lastIndexOf('/')+1))) {
return false;
}
// only valid nonempty query string is "nominify"
if(curval.lastIndexOf("?") != -1
&& !"?nominify".equals(curval.substring(curval.lastIndexOf("?")))) {
if(curval.lastIndexOf('?') != -1
&& !"?nominify".equals(curval.substring(curval.lastIndexOf('?')))) {
return false;
}