Clover coverage report - brownies library - 1.0-beta-1 Coverage timestamp: 月 8 16 2004 17:14:42 GMT+09:00 FRAMES NO FRAMES |
file stats: | LOC: | 127 |  | Methods: | 5
| NCLOC: | 59 |  | Classes: | 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
Source file | Conditionals | Statements | Methods | TOTAL
BaseDesktopComponent.java | 0% | 0% | 0% | 0% |

1 |  |
     /*
2 |  |
      * Joey and its relative products are published under the terms
3 |  |
      * of the Apache Software License.
4 |  |
      */
5 |  |
     /*
6 |  |
      * Created on 2004/01/08
7 |  |
      */
8 |  |
     package org.asyrinx.brownie.tapestry.components.layer;
9 |  |
10 |  |
     import org.apache.commons.logging.Log;
11 |  |
     import org.apache.commons.logging.LogFactory;
12 |  |
     import org.apache.tapestry.IMarkupWriter;
13 |  |
     import org.apache.tapestry.IRender;
14 |  |
     import org.apache.tapestry.IRequestCycle;
15 |  |
     import org.apache.tapestry.engine.IPageLoader;
16 |  |
     import org.apache.tapestry.engine.IPageSource;
17 |  |
     import org.apache.tapestry.engine.ITemplateSource;
18 |  |
     import org.apache.tapestry.parse.ComponentTemplate;
19 |  |
     import org.apache.tapestry.spec.IComponentSpecification;
20 |  |
21 |  |
     /**
22 |  |
      * @author akima
23 |  |
      */
24 |  |
     public abstract class BaseDesktopComponent extends AbstractDesktopComponent {
25 |  |
26 |  |
         /**
27 |  |
          * @param scriptName
28 |  |
          */
29 | 0 |
         protected BaseDesktopComponent(String scriptName) {
30 | 0 |
             super(scriptName);
31 |  |
         }
32 |  |
33 |  |
         private static final Log LOG = LogFactory
34 |  |
                 .getLog(BaseDesktopComponent.class);
35 |  |
36 |  |
         private static final int OUTER_INIT_SIZE = 5;
37 |  |
38 |  |
         private IRender[] _outer;
39 |  |
40 |  |
         private int _outerCount = 0;
41 |  |
42 |  |
         /**
43 |  |
          * Adds an element as an outer element for the receiver. Outer elements are
44 |  |
          * elements that should be directly rendered by the receiver's
45 |  |
          * <code>render()</code> method. That is, they are top-level elements on
46 |  |
          * the HTML template.
47 |  |
          *
48 |  |
          *
49 |  |
          */
50 |  |
51 | 0 |
         protected void addOuter(IRender element) {
52 | 0 |
             if (_outer == null) {
53 | 0 |
                 _outer = new IRender[OUTER_INIT_SIZE];
54 | 0 |
                 _outer[0] = element;
55 | 0 |
                 _outerCount = 1;
56 | 0 |
                 return;
57 |  |
             }
58 |  |
             // No more room? Make the array bigger.
59 | 0 |
             if (_outerCount == _outer.length) {
60 | 0 |
                 IRender[] newOuter;
61 | 0 |
                 newOuter = new IRender[_outer.length * 2];
62 | 0 |
                 System.arraycopy(_outer, 0, newOuter, 0, _outerCount);
63 | 0 |
                 _outer = newOuter;
64 |  |
             }
65 | 0 |
             _outer[_outerCount++] = element;
66 |  |
         }
67 |  |
68 |  |
         /**
69 |  |
          *
70 |  |
          * Reads the receiver's template and figures out which elements wrap which
71 |  |
          * other elements.
72 |  |
          *
73 |  |
          * <P>
74 |  |
          * This is coded as a single, big, ugly method for efficiency.
75 |  |
          *
76 |  |
          */
77 | 0 |
         private void readTemplate(IRequestCycle cycle, IPageLoader loader) {
78 | 0 |
             IPageSource pageSource = loader.getEngine().getPageSource();
79 |  |
80 | 0 |
             if (LOG.isDebugEnabled())
81 | 0 |
                 LOG.debug(this + " reading template");
82 |  |
83 | 0 |
             ITemplateSource source = loader.getTemplateSource();
84 | 0 |
             ComponentTemplate componentTemplate = source.getTemplate(cycle, this);
85 |  |
86 |  |
             // Most of the work is done inside the loader class.
87 |  |
             // We instantiate it just to invoke process() on it.
88 |  |
89 | 0 |
             new BaseDesktopComponentTemplateLoader(cycle, loader, this,
90 |  |
                     componentTemplate, pageSource).process();
91 |  |
92 | 0 |
             if (LOG.isDebugEnabled())
93 | 0 |
                 LOG.debug(this + " finished reading template");
94 |  |
         }
95 |  |
96 |  |
         /**
97 |  |
          * Renders the top level components contained by the receiver.
98 |  |
          *
99 |  |
          * @since 2.0.3
100 |  |
          */
101 | 0 |
         protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) {
102 | 0 |
             if (LOG.isDebugEnabled())
103 | 0 |
                 LOG.debug("Begin render " + getExtendedId());
104 |  |
105 | 0 |
             for (int i = 0; i < _outerCount; i++)
106 | 0 |
                 _outer[i].render(writer, cycle);
107 |  |
108 | 0 |
             if (LOG.isDebugEnabled())
109 | 0 |
                 LOG.debug("End render " + getExtendedId());
110 |  |
         }
111 |  |
112 |  |
         /**
113 |  |
          * Loads the template for the component, then invokes
114 |  |
          * {@link AbstractComponent#finishLoad(IRequestCycle, IPageLoader, IComponentSpecification))}.
115 |  |
          * Subclasses must invoke this method first, before adding any additional
116 |  |
          * behavior, though its usually simpler to override {@link #finishLoad()}
117 |  |
          * instead.
118 |  |
          *
119 |  |
          */
120 |  |
121 | 0 |
         public void finishLoad(IRequestCycle cycle, IPageLoader loader,
122 |  |
                 IComponentSpecification specification) {
123 | 0 |
             readTemplate(cycle, loader);
124 | 0 |
             super.finishLoad(cycle, loader, specification);
125 |  |
         }
126 |  |
127 |  |
     }