1 28 29 30 package com.caucho.widget; 31 32 import com.caucho.util.L10N; 33 34 import java.io.IOException ; 35 import java.util.Enumeration ; 36 import java.util.Locale ; 37 import java.util.Map ; 38 import java.util.logging.Logger ; 39 40 abstract public class WidgetConnection 41 { 42 private static L10N L = new L10N( WidgetConnection.class ); 43 44 static protected final Logger log = 45 Logger.getLogger( WidgetConnection.class.getName() ); 46 47 public <S extends WidgetState> S prepare( Widget<S> top ) 48 throws WidgetException 49 { 50 if ( top == null ) 51 throw new IllegalArgumentException ( 52 L.l( "`{0}' cannot be null", "top" ) ); 53 54 String attributeName = "com.caucho.widget." + System.identityHashCode(top); 55 56 S widgetState = null; 57 widgetState = (S) getAttribute( attributeName ); 58 59 if ( widgetState == null ) { 60 widgetState = top.decode( this ); 61 setAttribute( attributeName, widgetState ); 62 } 63 64 return widgetState; 65 } 66 67 public <S extends WidgetState> S render( Widget<S> top ) 68 throws WidgetException, IOException 69 { 70 S widgetState = prepare( top ); 71 72 top.render( this, widgetState ); 73 74 return widgetState; 75 } 76 77 abstract public <S extends WidgetState> WidgetURL createURL() 78 throws WidgetException; 79 80 abstract public String [] getPreferenceValues( String name, String [] defaults ); 81 82 abstract public Object getAttribute( String name ); 83 84 abstract public void setAttribute( String name, Object object ); 85 86 abstract public void removeAttribute( String name ); 87 88 abstract public Locale getLocale(); 89 90 abstract public String getContentType(); 91 92 abstract public Enumeration getAttributeNames(); 93 94 abstract public String getParameter(String name); 95 96 abstract public String [] getParameterValues(String name); 97 98 abstract public Map getParameterMap(); 99 100 abstract public Enumeration getParameterNames(); 101 102 abstract public String getRemoteUser(); 103 104 abstract public java.security.Principal getUserPrincipal(); 105 106 abstract public boolean isUserInRole(String role); 107 108 abstract public boolean isSecure(); 109 110 125 abstract public String resolveURL( String path ); 126 127 abstract public WidgetWriter getWriter() 128 throws IOException ; 129 130 133 abstract public void finish(); 134 } 135 136 | Popular Tags |