KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > simya > ldap > taglib > ModifyAttribute


1 package net.simya.ldap.taglib;
2
3 import javax.servlet.jsp.tagext.*;
4 import javax.servlet.jsp.*;
5 import javax.naming.NamingException JavaDoc;
6 import javax.naming.directory.DirContext JavaDoc;
7 import javax.naming.directory.Attribute JavaDoc;
8 import net.simya.ldap.beans.*;
9 import net.simya.ldap.servlet.*;
10
11 public class ModifyAttribute
12        extends TagSupport
13 {
14     private static final String JavaDoc DEFAULT_DELIMITER = ", ";
15     private static final String JavaDoc DEFAULT_MIMETYPE = "text/plain";
16     private static final String JavaDoc DEFAULT_MIMETEXT = "text";
17     private static final int DEFAULT_INDEX = -1;
18     private static final String JavaDoc DEFAULT_VALUE = "";
19     
20     private String JavaDoc name = null;
21     private String JavaDoc value = null;
22     private String JavaDoc modType= null;
23     private String JavaDoc mimeType = DEFAULT_MIMETYPE;
24     
25     public int doStartTag()
26     throws JspException
27     {
28         Modify modifyTag = (Modify) getParent();
29   
30         if ( modifyTag == null )
31             throw new JspTagException( "<modify attribute> tag should be child node of <modify> tag." );
32         
33         if (modType.equalsIgnoreCase("add"))
34             modifyTag.setAttribute(name,value, DirContext.ADD_ATTRIBUTE);
35         if (modType.equalsIgnoreCase("replace"))
36             modifyTag.setAttribute(name,value, DirContext.REPLACE_ATTRIBUTE);
37         if (modType.equalsIgnoreCase("remove"))
38             modifyTag.setAttribute(name,value, DirContext.REMOVE_ATTRIBUTE);
39         
40         return EVAL_BODY_INCLUDE;
41     }
42     
43     public void release()
44     {
45         name = null;
46         value = null;
47         modType = null;
48         mimeType = DEFAULT_MIMETYPE;
49     }
50    
51     public String JavaDoc getName() { return this.name; }
52     public void setName(String JavaDoc name) { this.name = name; }
53
54     public String JavaDoc getValue() { return this.value; }
55     public void setValue(String JavaDoc value) { this.value = value; }
56
57     public String JavaDoc getType() { return this.modType; }
58     public void setType(String JavaDoc modType) { this.modType = modType; }
59
60     public String JavaDoc getMimeType() { return this.mimeType; }
61     public void setMimeType(String JavaDoc mimeType) { this.mimeType = mimeType; }
62 }
Popular Tags