oMtrs = oMatcher.getMatch();
if (oMtrs!=null) sMatch = oMtrs.toString();
}
} // fi
if (sMatch.length()==0)
throw new ParserException("Match could not be retrieved for pattern " + sPattern);
int iDquote = sMatch.indexOf('"');
int iSquote = sMatch.indexOf("'");
char cQuote = (char) 0;
if (iDquote>0 && iSquote>0)
cQuote = iDquote<iSquote ? (char)34 : (char)39;
else if (iDquote>0)
cQuote = (char)34;
else if (iSquote>0)
cQuote = (char)39;
if (cQuote==(char)0)
oSrcSubs.setSubstitution(sMatch.substring(0,sAttributeName.length())+"="+sNewValue);
else
oSrcSubs.setSubstitution(sMatch.substring(0,sAttributeName.length())+"="+cQuote+sNewValue+cQuote);
if (DebugFile.trace) DebugFile.writeln("Util.substitute("+sPattern+","+sMatch.substring(0,sAttributeName.length())+"="+cQuote+sNewValue+cQuote+")");
return Util.substitute(oMatcher, oPattern, oSrcSubs, sBase);
} else {
return sBase;
} // fi (oMatcher.contains())
} catch (MalformedPatternException mpe) {
if (DebugFile.trace) {
DebugFile.writeln("MalformedPatternException " + mpe.getMessage());
try { DebugFile.writeln(StackTraceUtil.getStackTrace(mpe)); } catch (Exception ignore) { }
}
throw new ParserException("MalformedPatternException " + mpe.getMessage()+ " pattern " + sPattern + " substitution " + sNewValue, mpe);
}
catch (ArrayIndexOutOfBoundsException aiob) {
String sStack = "";
try { sStack = StackTraceUtil.getStackTrace(aiob); } catch (Exception ignore) { }
if (DebugFile.trace) {
DebugFile.writeln("ArrayIndexOutOfBoundsException " + aiob.getMessage());
DebugFile.writeln(sStack);
}
int iAt = sStack.indexOf("at ");
if (iAt>0) {
int iLf = sStack.indexOf("\n",iAt);
if (iLf>iAt)
throw new ParserException("ArrayIndexOutOfBoundsException " + sStack.substring(iAt,iLf) + " " + aiob.getMessage()+ " attribute " + sAttributeName + " pattern " + sPattern + " match " + sMatch + " former value " + sFormerValue + " substitution " + sNewValue, aiob);
else
throw new ParserException("ArrayIndexOutOfBoundsException " + sStack.substring(iAt) + " " + aiob.getMessage()+ " attribute " + sAttributeName + " pattern " + sPattern + " match " + sMatch + " former value " + sFormerValue + " substitution " + sNewValue, aiob);
} else {
throw new ParserException("ArrayIndexOutOfBoundsException " + aiob.getMessage()+ " attribute " + sAttributeName + " pattern " + sPattern + " match " + sMatch + " former value " + sFormerValue + " substitution " + sNewValue, aiob);
}
}
} // doSubstitution