1 /*
2 * Apache License
3 * Version 2.0, January 2004
4 * http://www.apache.org/licenses/
5 *
6 * Copyright 2008 by chenillekit.org
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 */
14
15 package org.chenillekit.access.internal;
16
17 import org.apache.tapestry5.EventContext;
18 import org.apache.tapestry5.internal.URLEventContext;
19 import org.apache.tapestry5.services.ContextValueEncoder;
20
21 /**
22 * This is class is actually a copy of the {@link URLEventContext} Tapestry5 internal
23 * class which exists just cause the orginal one is in the <em>.internal</em> package.
24 * <pre>
25 * Original author note: When the orignal one will be elevated to public
26 * (if that will be the case) i will delete this one.
27 * </pre>
28 *
29 * @version $Id$
30 */
31 public class CKUrlEventContext implements EventContext
32 {
33 private final ContextValueEncoder valueEncoder;
34 private final String[] elements;
35
36 public CKUrlEventContext(ContextValueEncoder valueEncoder, String[] elements)
37 {
38 this.valueEncoder = valueEncoder;
39 this.elements = elements;
40 }
41
42 /* (non-Javadoc)
43 * @see org.apache.tapestry5.EventContext#get(java.lang.Class, int)
44 */
45 public <T> T get(Class<T> desiredType, int index)
46 {
47 return valueEncoder.toValue(desiredType, elements[index]);
48 }
49
50 /* (non-Javadoc)
51 * @see org.apache.tapestry5.EventContext#getCount()
52 */
53 public int getCount()
54 {
55 return elements == null ? 0 : elements.length;
56 }
57
58 }