*/\r
protected Object[] makeUrlsIf(boolean createFullUrl, Hashtable repstrings, boolean onlyIfMatches)\r
{\r
+ int pass = 0;\r
+ \r
// prepare string arrays in correct order to be assembled into URL input\r
String[][] idseq = new String[mtch.length][]; // indexed by pass\r
int mins = 0, maxs = 0; // allowed two values, 1 or n-sequences.\r
"Cannot have zero length vector of replacement strings - either 1 value or n values.");\r
}\r
}\r
- int pass = 0;\r
// iterate through input, collating segments to be inserted into url\r
StringBuffer matched[] = new StringBuffer[idseq.length];\r
// and precompile regexes\r
rgxs[pass] = null;\r
}\r
}\r
- // record which of the input sequences were actually used to generate the\r
+ // tot up the invariant lengths for this url\r
+ int urllength = url_prefix.length();\r
+ for (pass=0;pass<matched.length; pass++)\r
+ {\r
+ urllength+=url_suffix[pass].length();\r
+ }\r
+\r
+ // flags to record which of the input sequences were actually used to generate the\r
// url\r
boolean[] thismatched = new boolean[maxs];\r
int seqsmatched = 0;\r
{\r
// initialise flag for match\r
thismatched[sq] = false;\r
- String[] thematches = new String[rgxs.length];\r
+ StringBuffer[] thematches = new StringBuffer[rgxs.length];\r
for (pass = 0; pass < rgxs.length; pass++)\r
{\r
- thematches[pass] = ""; // initialise - in case there are no more\r
+ thematches[pass] = new StringBuffer(); // initialise - in case there are no more\r
// matches.\r
// if a regex is provided, then it must match for all sequences in all\r
// tokens for it to be considered.\r
{\r
rematchat = rg.matchedTo();\r
thismatched[sq] |= true;\r
+ urllength+=rg.charsMatched(); // count length\r
if (!createFullUrl)\r
{\r
continue; // don't bother making the URL replacement text.\r
int ns = rg.numSubs();\r
if (ns == 0)\r
{\r
- thematches[pass] += rg.stringMatched();// take whole regex\r
+ thematches[pass].append(rg.stringMatched());// take whole regex\r
}\r
/*\r
* else if (ns==1) { // take only subgroup match return new String[]\r
else\r
{\r
// debug\r
- for (int s = 0; s <= rg.numSubs(); s++)\r
+ /*for (int s = 0; s <= rg.numSubs(); s++)\r
{\r
System.err.println("Sub " + s + " : " + rg.matchedFrom(s)\r
+ " : " + rg.matchedTo(s) + " : '"\r
+ rg.stringMatched(s) + "'");\r
- }\r
+ }*/\r
// try to collate subgroup matches\r
StringBuffer subs = new StringBuffer();\r
// have to loop through submatches, collating them at top level\r
// s is top level submatch. search for submatches enclosed by\r
// this one\r
int r = s + 1;\r
- String rmtch = "";\r
+ StringBuffer rmtch = new StringBuffer();\r
while (r <= ns && rg.matchedTo(r) <= rg.matchedTo(s))\r
{\r
if (rg.matchedFrom(r) > -1)\r
{\r
- rmtch += rg.stringMatched(r);\r
+ rmtch.append(rg.stringMatched(r));\r
}\r
r++;\r
}\r
s++;\r
}\r
}\r
- thematches[pass] += subs.toString();\r
+ thematches[pass].append(subs);\r
}\r
}\r
}\r
if (!onlyIfMatches)\r
{\r
thismatched[sq] |= true;\r
+ urllength+=idseq[pass][sq].length(); // tot up length\r
if (createFullUrl)\r
{\r
- thematches[pass] = idseq[pass][sq]; // take whole string -\r
+ thematches[pass] = new StringBuffer(idseq[pass][sq]); // take whole string -\r
// regardless - probably not a\r
// good idea!\r
/*\r
// no matches - no url generated\r
return null;\r
}\r
+ // check if we are beyond the feasible command line string limit for this platform\r
+ if ((urllength+32)>Platform.getMaxCommandLineLength())\r
+ {\r
+ System.err.println("URL estimated to be too long "+urllength);\r
+ return null;\r
+ }\r
if (!createFullUrl)\r
{\r
// just return the essential info about what the URL would be generated from\r
{ seqsmatched }, thismatched};\r
}\r
// otherwise, create the URL completely.\r
+ \r
StringBuffer submiturl = new StringBuffer();\r
submiturl.append(url_prefix);\r
for (pass = 0; pass < matched.length; pass++)\r