KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > uitags > util > VelocityAdapter


1 /**
2 o * Mar 25, 2005
3  *
4  * Copyright 2004 uitags
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package net.sf.uitags.util;
19
20
21 /**
22  * An adapter class which makes possible things which Velocity can't usually do.
23  *
24  * @author hgani
25  * @version $Id$
26  */

27 public class VelocityAdapter {
28   /**
29    * Instantiates {@link UiString} class.
30    *
31    * @param arg1 the first argument
32    * @return the instance
33    */

34   public UiString createUiString(String JavaDoc arg1) {
35     // There is an overloaded UiString constructor that can receive a
36
// second argument for define a few options (via constants). However,
37
// Velocity templates cannot access class constants. Furthermore, it
38
// cannot perform bitwise operations, which is needed for combining
39
// several options). Due to this limitation, we don't need to expose
40
// the overloaded constructor that receives the second argument.
41
//
42
// Nevertheless, UiString options can still be set by invoking some of
43
// its option-related methods from the VM templates.
44
return new UiString(arg1);
45   }
46
47   /**
48    * Returns the length of the supplied array. If the supplied array is
49    * <code>null</code>, returns 0.
50    *
51    * @param arr the array whose length is to be returned
52    * @return the length of the given array
53    */

54   public int getArrayLength(Object JavaDoc[] arr) {
55     return (arr == null)? 0 : arr.length;
56   }
57 }
58
Popular Tags