home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 139 / dpcs0999.iso / Web / CFserver / data1.cab / Java / allaire / util / template / CustomElement.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-04-12  |  2.5 KB  |  50 lines

  1. package allaire.util.template;
  2.  
  3. import java.io.ByteArrayOutputStream;
  4. import netscape.util.Enumeration;
  5.  
  6. class CustomElement extends TemplateTagElement {
  7.    private static final String CLASS = "CLASS";
  8.  
  9.    public void process(TemplateOutput var1) throws TemplateException {
  10.       TagAttributes var2 = ((TemplateTagElement)this).getAttributes();
  11.       Object var3 = null;
  12.       Class var4 = ((TemplateElement)this).getParser().getCustomTagClass(((TemplateTagElement)this).getTagName());
  13.       if (var4 != null) {
  14.          try {
  15.             var3 = var4.newInstance();
  16.          } catch (Exception var11) {
  17.             throw new TemplateException(1005, "Error attempting to create a custom tag object for tag " + "named '" + ((TemplateTagElement)this).getTagName() + "'. The class registered " + "for the tag is '" + var4.getName() + "'.");
  18.          }
  19.       } else {
  20.          String var5 = var2.getRequired("CLASS");
  21.          var5 = ((TemplateElement)this).resolveExpressionsInText(var5);
  22.  
  23.          try {
  24.             var3 = Class.forName(var5).newInstance();
  25.          } catch (Exception var10) {
  26.             throw new TemplateException(1005, "Error attempting to create a custom tag object for the " + ((TemplateTagElement)this).getTagName() + " tag (The CLASS attribute " + "for the tag is '" + var5 + "'.");
  27.          }
  28.  
  29.          if (!(var3 instanceof TemplateCustomTag)) {
  30.             throw new TemplateException(1000, "The CLASS attribute of the " + ((TemplateTagElement)this).getTagName() + " tag specifies " + "a class (" + var5 + ") which does not implement " + "the TemplateCodeGenerator interface.");
  31.          }
  32.       }
  33.  
  34.       TemplateCustomTag var14 = (TemplateCustomTag)var3;
  35.       ByteArrayOutputStream var6 = new ByteArrayOutputStream();
  36.       TemplateOutput var7 = new TemplateOutput(var6);
  37.       if (((TemplateTagElement)this).hasSubElements()) {
  38.          Enumeration var8 = ((TemplateTagElement)this).getSubElements().elements();
  39.  
  40.          while(var8.hasMoreElements()) {
  41.             TemplateElement var9 = (TemplateElement)var8.nextElement();
  42.             var9.process(var7);
  43.          }
  44.       }
  45.  
  46.       TemplateParser var15 = ((TemplateElement)this).getParser();
  47.       var14.generate(var15.getRuntimeContext(), var2, var6.toString(), var1);
  48.    }
  49. }
  50.