[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 there is a language on the element, strip if off
if (element.contains("[")) if (element.contains("["))
{ {
element = element.substring(0, element.indexOf("[")); element = element.substring(0, element.indexOf('['));
} }
String qualifier = null; String qualifier = null;
if (bits.length > 2) if (bits.length > 2)
@@ -357,7 +357,7 @@ public class MetadataImport
// If there is a language, strip if off // If there is a language, strip if off
if (qualifier.contains("[")) if (qualifier.contains("["))
{ {
qualifier = qualifier.substring(0, qualifier.indexOf("[")); qualifier = qualifier.substring(0, qualifier.indexOf('['));
} }
} }
DCValue[] current = item.getMetadata(schema, element, qualifier, language); 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 there is a language on the element, strip if off
if (element.contains("[")) if (element.contains("["))
{ {
element = element.substring(0, element.indexOf("[")); element = element.substring(0, element.indexOf('['));
} }
String qualifier = null; String qualifier = null;
if (bits.length > 2) if (bits.length > 2)
@@ -666,7 +666,7 @@ public class MetadataImport
// If there is a language, strip if off // If there is a language, strip if off
if (qualifier.contains("[")) 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 continue; // process next line in contents file
} }
int bitstreamEndIndex = line.indexOf("\t"); int bitstreamEndIndex = line.indexOf('\t');
if (bitstreamEndIndex == -1) if (bitstreamEndIndex == -1)
{ {
@@ -1480,17 +1480,17 @@ public class ItemImport
+ permissionsMarker.length(), pEndIndex); + permissionsMarker.length(), pEndIndex);
// get permission type ("read" or "write") // get permission type ("read" or "write")
int pTypeIndex = thisPermission.indexOf("-"); int pTypeIndex = thisPermission.indexOf('-');
// get permission group (should be in single quotes) // get permission group (should be in single quotes)
int groupIndex = thisPermission.indexOf("'", pTypeIndex); int groupIndex = thisPermission.indexOf('\'', pTypeIndex);
int groupEndIndex = thisPermission.indexOf("'", groupIndex + 1); int groupEndIndex = thisPermission.indexOf('\'', groupIndex + 1);
// if not in single quotes, assume everything after type flag is // if not in single quotes, assume everything after type flag is
// group name // group name
if (groupIndex == -1) if (groupIndex == -1)
{ {
groupIndex = thisPermission.indexOf(" ", pTypeIndex); groupIndex = thisPermission.indexOf(' ', pTypeIndex);
groupEndIndex = thisPermission.length(); groupEndIndex = thisPermission.length();
} }

View File

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

View File

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

View File

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

View File

@@ -134,13 +134,17 @@ public class XSLTDisseminationCrosswalk
// right format for value of "schemaLocation" attribute. // right format for value of "schemaLocation" attribute.
schemaLocation = ConfigurationManager.getProperty(prefix+"schemaLocation"); schemaLocation = ConfigurationManager.getProperty(prefix+"schemaLocation");
if (schemaLocation == null) if (schemaLocation == null)
{
log.warn("No schemaLocation for crosswalk="+myAlias+", key="+prefix+"schemaLocation"); log.warn("No schemaLocation for crosswalk="+myAlias+", key="+prefix+"schemaLocation");
}
// sanity check: schemaLocation should have space. // 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="+ log.warn("Possible INVALID schemaLocation (no space found) for crosswalk="+
myAlias+", key="+prefix+"schemaLocation"+ myAlias+", key="+prefix+"schemaLocation"+
"\n\tCorrect format is \"{namespace} {schema-URL}\""); "\n\tCorrect format is \"{namespace} {schema-URL}\"");
}
// grovel for namespaces of the form: // grovel for namespaces of the form:
// crosswalk.diss.{PLUGIN_NAME}.namespace.{PREFIX} = {URI} // 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 //Pull apart default group name into its three main parts
// Format: <DSpace-Obj-Type>_<DSpace-Obj-ID>_<Group-Type> // Format: <DSpace-Obj-Type>_<DSpace-Obj-ID>_<Group-Type>
// (e.g. COLLECTION_123_ADMIN) // (e.g. COLLECTION_123_ADMIN)
String objType = groupName.substring(0, groupName.indexOf("_")); String objType = groupName.substring(0, groupName.indexOf('_'));
String tmpEndString = groupName.substring(groupName.indexOf("_")+1); String tmpEndString = groupName.substring(groupName.indexOf('_')+1);
String objID = tmpEndString.substring(0, tmpEndString.indexOf("_")); String objID = tmpEndString.substring(0, tmpEndString.indexOf('_'));
String groupType = tmpEndString.substring(tmpEndString.indexOf("_")+1); String groupType = tmpEndString.substring(tmpEndString.indexOf('_')+1);
try try
{ {
@@ -868,10 +868,10 @@ public class PackageUtils
//Pull apart default group name into its three main parts //Pull apart default group name into its three main parts
// Format: <DSpace-Obj-Type>_<DSpace-Obj-ID>_<Group-Type> // Format: <DSpace-Obj-Type>_<DSpace-Obj-ID>_<Group-Type>
// (e.g. COLLECTION_123_ADMIN) // (e.g. COLLECTION_123_ADMIN)
String objType = groupName.substring(0, groupName.indexOf("_")); String objType = groupName.substring(0, groupName.indexOf('_'));
String tmpEndString = groupName.substring(groupName.indexOf("_")+1); String tmpEndString = groupName.substring(groupName.indexOf('_')+1);
String objID = tmpEndString.substring(0, tmpEndString.indexOf("_")); String objID = tmpEndString.substring(0, tmpEndString.indexOf('_'));
String groupType = tmpEndString.substring(tmpEndString.indexOf("_")+1); String groupType = tmpEndString.substring(tmpEndString.indexOf('_')+1);
try try
{ {

View File

@@ -808,7 +808,7 @@ public class ConfigurationManager
int start = value.indexOf("${", from); int start = value.indexOf("${", from);
if (start >= 0) if (start >= 0)
{ {
int end = value.indexOf("}", start); int end = value.indexOf('}', start);
if (end < 0) if (end < 0)
break; break;
String var = value.substring(start+2, end); 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) public String makeSortString(String value, String language)
{ {
int padding = 0; int padding = 0;
int endYearIdx = value.indexOf("-"); int endYearIdx = value.indexOf('-');
if (endYearIdx >= 0 && endYearIdx < 4) if (endYearIdx >= 0 && endYearIdx < 4)
{ {

View File

@@ -1043,7 +1043,7 @@ public class DatabaseManager
int count = 0; int count = 0;
int inputlen = input.length(); int inputlen = input.length();
while ((index = input.indexOf("'", count)) != -1) while ((index = input.indexOf('\'', count)) != -1)
{ {
// Flip the value of inquote // Flip the value of inquote
inquote = !inquote; inquote = !inquote;
@@ -1066,7 +1066,7 @@ public class DatabaseManager
continue; continue;
} }
int endMarker = input.indexOf(";", index); int endMarker = input.indexOf(';', index);
if (endMarker == -1) if (endMarker == -1)
{ {
@@ -1530,7 +1530,7 @@ public class DatabaseManager
String schema = ConfigurationManager.getProperty("db.schema"); String schema = ConfigurationManager.getProperty("db.schema");
String catalog = null; String catalog = null;
int dotIndex = table.indexOf("."); int dotIndex = table.indexOf('.');
if (dotIndex > 0) if (dotIndex > 0)
{ {
catalog = table.substring(0, dotIndex); 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 // 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(); List linkParts = new ArrayList();
// each link has a mime-type, title, and format (used in href URL) // each link has a mime-type, title, and format (used in href URL)
for (int i = 0; i < formats.length; i++) 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 '/' // substring(1) is to remove initial '/'
path = path.substring(1); path = path.substring(1);
int split = path.indexOf("/"); int split = path.indexOf('/');
if (split != -1) if (split != -1)
{ {
feedType = path.substring(0,split); 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 // 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" // 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(".")); basicHost = host.substring(host.substring(0, lastDot).lastIndexOf("."));
} }

View File

@@ -92,12 +92,14 @@ public class SuggestServlet extends DSpaceServlet
String basicHost = ""; String basicHost = "";
if (host.equals("localhost") || host.equals("127.0.0.1") if (host.equals("localhost") || host.equals("127.0.0.1")
|| host.equals(InetAddress.getLocalHost().getHostAddress())) || host.equals(InetAddress.getLocalHost().getHostAddress()))
{
basicHost = host; basicHost = host;
}
else else
{ {
// cut off all but the hostname, to cover cases where more than one URL // 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" // 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(".")); basicHost = host.substring(host.substring(0, lastDot).lastIndexOf("."));
} }

View File

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

View File

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

View File

@@ -185,7 +185,7 @@ class DAVLookup extends DAVResource
String handle = null; String handle = null;
// if "prefix" contains a slash, then it's the whole handle: // if "prefix" contains a slash, then it's the whole handle:
if (prefix.indexOf("/") >= 0) if (prefix.indexOf('/') >= 0)
{ {
handle = prefix; handle = prefix;
log.debug("Lookup: resolving escaped handle \"" + handle + "\""); 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 srcPath = (new URI(this.request.getRequestURI())).getPath();
String destPath = (new URI(destination)).getPath(); String destPath = (new URI(destination)).getPath();
int slash = srcPath.lastIndexOf("/"); int slash = srcPath.lastIndexOf('/');
if (slash > -1) if (slash > -1)
{ {
String lastElt = srcPath.substring(slash); String lastElt = srcPath.substring(slash);

View File

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

View File

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

View File

@@ -87,10 +87,14 @@ public class StatisticsSolrDateFilter implements StatisticsFilter {
Calendar endCal = (Calendar) startCal.clone(); Calendar endCal = (Calendar) startCal.clone();
if(startStr.startsWith("+")) if(startStr.startsWith("+"))
startStr = startStr.substring(startStr.indexOf("+") + 1); {
startStr = startStr.substring(startStr.indexOf('+') + 1);
}
if(endStr.startsWith("+")) if(endStr.startsWith("+"))
endStr = endStr.substring(endStr.indexOf("+") + 1); {
endStr = endStr.substring(endStr.indexOf('+') + 1);
}
startCal.add(dateType, Integer.parseInt(startStr)); startCal.add(dateType, Integer.parseInt(startStr));
endCal.add(dateType, Integer.parseInt(endStr)); 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 //Currently only check if robot.txt is present in our line
if (logLine.contains("robots.txt")) { if (logLine.contains("robots.txt")) {
//We got a robots.txt so we got a bot //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 //Only add single IP addresses once we got it in it is enough
logSpiders.add(ip); logSpiders.add(ip);
} }

View File

@@ -88,7 +88,7 @@ public class QualityValue {
// Check there are no more than three digits after the decimal point // Check there are no more than three digits after the decimal point
String qStr = "" + q; String qStr = "" + q;
int pos = qStr.indexOf("."); int pos = qStr.indexOf('.');
if (qStr.substring(pos + 1).length() > 3) if (qStr.substring(pos + 1).length() > 3)
{ {
throw new NumberFormatException("Invalid value - no more than three digits after the decimal point: " + qStr); 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? // Are there any authentication details?
String usernamePassword = getUsernamePassword(request); String usernamePassword = getUsernamePassword(request);
if ((usernamePassword != null) && (!usernamePassword.equals(""))) { if ((usernamePassword != null) && (!usernamePassword.equals(""))) {
int p = usernamePassword.indexOf(":"); int p = usernamePassword.indexOf(':');
if (p != -1) { if (p != -1) {
adr.setUsername(usernamePassword.substring(0, p)); adr.setUsername(usernamePassword.substring(0, p));
adr.setPassword(usernamePassword.substring(p + 1)); adr.setPassword(usernamePassword.substring(p + 1));

View File

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

View File

@@ -133,7 +133,7 @@ public class ServiceDocumentServlet extends HttpServlet {
// Are there any authentication details? // Are there any authentication details?
String usernamePassword = getUsernamePassword(request); String usernamePassword = getUsernamePassword(request);
if ((usernamePassword != null) && (!usernamePassword.equals(""))) { if ((usernamePassword != null) && (!usernamePassword.equals(""))) {
int p = usernamePassword.indexOf(":"); int p = usernamePassword.indexOf(':');
if (p != -1) { if (p != -1) {
sdr.setUsername(usernamePassword.substring(0, p)); sdr.setUsername(usernamePassword.substring(0, p));
sdr.setPassword(usernamePassword.substring(p + 1)); 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 // 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" // 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(".")); basicHost = host.substring(host.substring(0, lastDot).lastIndexOf('.'));
} }
if ((fromPage == null) || ((fromPage.indexOf(basicHost) == -1) && (validReferral == false))) if ((fromPage == null) || ((fromPage.indexOf(basicHost) == -1) && (validReferral == false)))

View File

@@ -287,7 +287,7 @@ abstract public class AbstractStep extends AbstractDSpaceTransformer
//key: entry # (i.e. step & page), //key: entry # (i.e. step & page),
//value: entry name key (i.e. display name) //value: entry name key (i.e. display name)
Map progBarInfo = this.submissionInfo.getProgressBarInfo(); Map progBarInfo = this.submissionInfo.getProgressBarInfo();
Iterator i = progBarInfo.keySet().iterator(); Iterator i = progBarInfo.keySet().iterator();
//add each entry to progress bar //add each entry to progress bar
@@ -483,7 +483,7 @@ abstract public class AbstractStep extends AbstractDSpaceTransformer
if (errors!=null && errors.length() > 0) if (errors!=null && errors.length() > 0)
{ {
if(errors.indexOf(",") > 0) if(errors.indexOf(',') > 0)
fields = Arrays.asList(errors.split(",")); fields = Arrays.asList(errors.split(","));
else//only one error field else//only one error field
fields.add(errors); fields.add(errors);

View File

@@ -355,7 +355,7 @@ public class BitstreamReader extends AbstractReader implements Recyclable
// Trim any path information from the bitstream // Trim any path information from the bitstream
if (bitstreamName != null && bitstreamName.length() >0 ) if (bitstreamName != null && bitstreamName.length() >0 )
{ {
int finalSlashIndex = bitstreamName.lastIndexOf("/"); int finalSlashIndex = bitstreamName.lastIndexOf('/');
if (finalSlashIndex > 0) if (finalSlashIndex > 0)
{ {
bitstreamName = bitstreamName.substring(finalSlashIndex+1); 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 // setup list of sources, get relevant parts of path
this.inputSources = new ArrayList<Source>(); this.inputSources = new ArrayList<Source>();
String path = src.substring(0, src.lastIndexOf("/")); String path = src.substring(0, src.lastIndexOf('/'));
String file = src.substring(src.lastIndexOf("/")+1); String file = src.substring(src.lastIndexOf('/')+1);
// now build own list of inputsources // now build own list of inputsources
String[] files = file.split(","); String[] files = file.split(",");

View File

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