diff options
Diffstat (limited to 'id.server/src/at/gv/egovernment/moa/id/auth/builder/Builder.java')
-rw-r--r-- | id.server/src/at/gv/egovernment/moa/id/auth/builder/Builder.java | 30 |
1 files changed, 30 insertions, 0 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 new file mode 100644 index 000000000..e5bbaa585 --- /dev/null +++ b/id.server/src/at/gv/egovernment/moa/id/auth/builder/Builder.java @@ -0,0 +1,30 @@ +package at.gv.egovernment.moa.id.auth.builder; + +import at.gv.egovernment.moa.id.BuildException; + +/** + * Base class for HTML/XML builders providing commonly useful functions. + * + * @author Paul Ivancsics + * @version $Id$ + */ +public class Builder { + + /** + * Replaces a special tag in an XML or HTML template by a value. + * @param htmlTemplate template + * @param tag special tag + * @param value value replacing the tag + * @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) throws BuildException { + int index = template.indexOf(tag); + if (index < 0) + throw new BuildException( + "builder.01", + new Object[] {"<" + tag.substring(1, tag.length() - 1) + ">"}); + return template.substring(0, index) + value + template.substring(index + tag.length()); + } + +} |