// --- BEGIN COPYRIGHT BLOCK --- // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; version 2 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // (C) 2007 Red Hat, Inc. // All rights reserved. // --- END COPYRIGHT BLOCK --- package com.netscape.certsrv.pattern; import java.util.Enumeration; import com.netscape.certsrv.base.EBaseException; import com.netscape.certsrv.base.IAttrSet; /** * This is a generic pattern subtitution engine. The * pattern format should be: *
* $[attribute set key].[attribute name]$ *
* For example, *
* $request.requestor_email$ $ctx.user_id$ *
*
* @version $Revision$, $Date$
*/
public class Pattern {
private String mS = null;
/**
* Constructs a pattern object with the given string.
*
* @param s string with pattern (i.e. $request.requestor_email$)
*/
public Pattern(String s) {
mS = s;
}
/**
* Subtitutes this pattern with the given attribute set.
*
* @param key key name of the given attribute set
* @param attrSet attribute set
* @return substituted string
*/
public String substitute(String key, IAttrSet attrSet) {
return substitute2(key, attrSet);
}
/**
* Subtitutes this pattern with the given attribute set.
*
* @param attrSetCollection attribute set collection
* @return substituted string
*/
public String substitute(AttrSetCollection attrSetCollection) {
String temp = mS;
Enumeration