aboutsummaryrefslogtreecommitdiff
path: root/id.server/src/at/gv/egovernment/moa
diff options
context:
space:
mode:
authorharald.bratko <harald.bratko@d688527b-c9ab-4aba-bd8d-4036d912da1d>2007-01-10 15:34:50 +0000
committerharald.bratko <harald.bratko@d688527b-c9ab-4aba-bd8d-4036d912da1d>2007-01-10 15:34:50 +0000
commit006abfa4f5064a905b14618708768e3aa295f264 (patch)
tree1021f36a9538178abf01bc679bda4c61ed7ab422 /id.server/src/at/gv/egovernment/moa
parentd1a11db05caa68dde526c38248dc5d2f01b89368 (diff)
downloadmoa-id-spss-006abfa4f5064a905b14618708768e3aa295f264.tar.gz
moa-id-spss-006abfa4f5064a905b14618708768e3aa295f264.tar.bz2
moa-id-spss-006abfa4f5064a905b14618708768e3aa295f264.zip
Changed method replaceTag throw exception only if a tag is not present, but isexpected to be present.
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@768 d688527b-c9ab-4aba-bd8d-4036d912da1d
Diffstat (limited to 'id.server/src/at/gv/egovernment/moa')
-rw-r--r--id.server/src/at/gv/egovernment/moa/id/auth/builder/Builder.java14
1 files changed, 13 insertions, 1 deletions
diff --git a/id.server/src/at/gv/egovernment/moa/id/auth/builder/Builder.java b/id.server/src/at/gv/egovernment/moa/id/auth/builder/Builder.java
index a5d87ef83..a5614655b 100644
--- a/id.server/src/at/gv/egovernment/moa/id/auth/builder/Builder.java
+++ b/id.server/src/at/gv/egovernment/moa/id/auth/builder/Builder.java
@@ -16,18 +16,30 @@ public class Builder {
* @param htmlTemplate template
* @param tag special tag
* @param value value replacing the tag
+ * @param expected specifies if the tag is expected to present; if <code>true</code> and the tag
+ * is not present, an exception is thrown; if <code>false</code> and the tag is
+ * not present, the original string is returned
* @param maxreplacements: -1 to replace each occurence of tag, or limit replacements by a given positive number
* @return XML or HTML code, the tag replaced
* @throws BuildException when template does not contain the tag
*/
- protected String replaceTag(String template, String tag, String value, int maxreplacements) throws BuildException {
+ protected String replaceTag(
+ String template,
+ String tag,
+ String value,
+ boolean expected,
+ int maxreplacements)
+ throws BuildException
+ {
String result = template;
int index = result.indexOf(tag);
if (index < 0) {
+ if (expected) {
// Substring not found but should
throw new BuildException(
"builder.01",
new Object[] {"&lt;" + tag.substring(1, tag.length() - 1) + "&gt;"});
+ }
} else {
// replace each occurence
if (maxreplacements == -1) {