01: /*
02: * Copyright 2006-2007 Pentaho Corporation. All rights reserved.
03: * This software was developed by Pentaho Corporation and is provided under the terms
04: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
05: * this file except in compliance with the license. If you need a copy of the license,
06: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt.
07: *
08: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
09: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
10: * the license for the specific language governing your rights and limitations.
11: *
12: * Additional Contributor(s): Martin Schmid gridvision engineering GmbH
13: */
14: package org.pentaho.reportdesigner.crm.report.util;
15:
16: import org.jetbrains.annotations.NonNls;
17: import org.jetbrains.annotations.NotNull;
18: import org.jetbrains.annotations.Nullable;
19: import org.pentaho.reportdesigner.lib.common.xml.XMLContext;
20:
21: import java.io.File;
22:
23: /**
24: * User: Martin
25: * Date: 28.09.2007
26: * Time: 13:07:23
27: */
28: public class XMLContextKeys<T> {
29: @NotNull
30: public static final XMLContextKeys<File> CONTEXT_PATH = new XMLContextKeys<File>(
31: "ContextPath");
32:
33: @NotNull
34: private String key;
35:
36: private XMLContextKeys(@NotNull
37: @NonNls
38: String key) {
39: this .key = key;
40: }
41:
42: public void putObject(@NotNull
43: XMLContext xmlWriter, @Nullable
44: T object) {
45: xmlWriter.putContextObject(key, object);
46: }
47:
48: @Nullable
49: public T getObject(@Nullable
50: XMLContext xmlContext) {
51: if (xmlContext == null) {
52: return null;
53: }
54:
55: //noinspection unchecked
56: return (T) xmlContext.getContextObject(key);
57: }
58: }
|