cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rica...@locus.apache.org
Subject cvs commit: xml-cocoon/src/org/apache/cocoon/processor/xsp/library XSPSessionLibrary.java
Date Sun, 09 Jan 2000 02:46:52 GMT
ricardo     00/01/08 18:46:52

  Modified:    src/org/apache/cocoon/processor/xsp/library
                        XSPSessionLibrary.java
  Log:
  Provided support for deprecated methods. Made all methods static. Removed Java2 dependency
  
  Revision  Changes    Path
  1.3       +34 -31    xml-cocoon/src/org/apache/cocoon/processor/xsp/library/XSPSessionLibrary.java
  
  Index: XSPSessionLibrary.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/processor/xsp/library/XSPSessionLibrary.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XSPSessionLibrary.java	2000/01/05 19:38:08	1.2
  +++ XSPSessionLibrary.java	2000/01/09 02:46:52	1.3
  @@ -67,28 +67,44 @@
   
   public class XSPSessionLibrary {
     // HttpSession
  -  // JSDK 2.1 version: deprecated "name"
  -  public static Object getAttribute(HttpSession session, String name) {
  -    if (name == null || name.length() == 0) {
  -      return null;
  +
  +  /* Begin Deprecated Methods */
  +  public static Element getValue(HttpSession session, String name, Document document) {
  +    Object value = session.getValue(name);
  +    Element element = document.createElement("session:value");
  +    element.setAttribute("name", name);
  +
  +    if (value == null) {
  +      return element;
  +    }
  +
  +    if (value instanceof XObject) {
  +      DocumentFragment fragment = document.createDocumentFragment();
  +      ((XObject) value).toDOM(fragment);
  +      element.appendChild(fragment);
  +    } else {
  +      element.appendChild(document.createTextNode(value.toString()));
       }
   
  -    return session.getValue(name);
  +    return element;
     }
   
  -  // JSDK 2.2 version: "attribute" instead of 'name"
  -  /*
  -  public static Object getAttribute(HttpSession session, String name) {
  -    if (name == null || name.length() == 0) {
  -      return null;
  +  public static Element getValueNames(HttpSession session, Document document) {
  +    String[] attributeNames = session.getValueNames();
  +    Element element = document.createElement("session:value-names");
  +
  +    for (int i = 0; i < attributeNames.length; i++) {
  +      Element nameElement = document.createElement("session:value-name");
  +      nameElement.appendChild(document.createTextNode(attributeNames[i]));
  +      element.appendChild(nameElement);
       }
   
  -    return session.getAttribute(name);
  +    return element;
     }
  -  */
  +  /* End Deprecated Methods */
   
     public static Element getAttribute(HttpSession session, String name, Document document)
{
  -    Object value = getAttribute(session, name);
  +    Object value = session.getAttribute(name);
   
       if (value == null) {
         return null;
  @@ -109,17 +125,7 @@
       return element;
     }
   
  -  // JSDK 2.1 version: deprecated "name"
     public static String[] getAttributeNames(HttpSession session) {
  -    String[] attributeNames = session.getValueNames();
  -    Arrays.sort(attributeNames); // Since Java2
  -
  -    return attributeNames;
  -  }
  -
  -  // JSDK 2.2 version: "attribute" instead of "name"
  -  /*
  -  public static String[] getAttributeNames(HttpSession session) {
       Vector v = new Vector();
       Enumeration e = session.getAttributeNames();
   
  @@ -129,12 +135,9 @@
   
       String[] attributeNames = new String[v.size()];
       v.copyInto(attributeNames);
  -    Arrays.sort(attributeNames); // Since Java2
   
       return attributeNames;
     }
  -  */
  -
   
     public static Element getAttributeNames(HttpSession session, Document document) {
       String[] attributeNames = getAttributeNames(session);
  @@ -149,31 +152,31 @@
       return element;
     }
   
  -  public Element getCreationTime(HttpSession session, Document document) {
  +  public static Element getCreationTime(HttpSession session, Document document) {
       Element element = document.createElement("session:creation-time");
       element.appendChild(document.createTextNode(String.valueOf(session.getCreationTime())));
       return element;
     }
   
  -  public Element getId(HttpSession session, Document document) {
  +  public static Element getId(HttpSession session, Document document) {
       Element element = document.createElement("session:id");
       element.appendChild(document.createTextNode(session.getId()));
       return element;
     }
   
  -  public Element getLastAccessedTime(HttpSession session, Document document) {
  +  public static Element getLastAccessedTime(HttpSession session, Document document) {
       Element element = document.createElement("session:last-accessed-time");
       element.appendChild(document.createTextNode(String.valueOf(session.getLastAccessedTime())));
       return element;
     }
   
  -  public Element getMaxInactiveInterval(HttpSession session, Document document) {
  +  public static Element getMaxInactiveInterval(HttpSession session, Document document)
{
       Element element = document.createElement("session:max-inactive-interval");
       element.appendChild(document.createTextNode(String.valueOf(session.getMaxInactiveInterval())));
       return element;
     }
   
  -  public Element isNew(HttpSession session, Document document) {
  +  public static Element isNew(HttpSession session, Document document) {
       Element element = document.createElement("session:is-new");
       element.appendChild(document.createTextNode(String.valueOf(session.isNew())));
       return element;
  
  
  

Mime
View raw message