01: /*
02: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
03: *
04: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
05: *
06: * The contents of this file are subject to the terms of either the GNU
07: * General Public License Version 2 only ("GPL") or the Common
08: * Development and Distribution License("CDDL") (collectively, the
09: * "License"). You may not use this file except in compliance with the
10: * License. You can obtain a copy of the License at
11: * http://www.netbeans.org/cddl-gplv2.html
12: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13: * specific language governing permissions and limitations under the
14: * License. When distributing the software, include this License Header
15: * Notice in each file and include the License file at
16: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17: * particular file as subject to the "Classpath" exception as provided
18: * by Sun in the GPL Version 2 section of the License file that
19: * accompanied this code. If applicable, add the following below the
20: * License Header, with the fields enclosed by brackets [] replaced by
21: * your own identifying information:
22: * "Portions Copyrighted [year] [name of copyright owner]"
23: *
24: * Contributor(s):
25: *
26: * Portions Copyrighted 2007 Sun Microsystems, Inc.
27: */
28:
29: package org.netbeans.modules.web.jsf.impl.facesmodel;
30:
31: import java.util.ArrayList;
32: import java.util.List;
33: import org.netbeans.modules.web.jsf.api.facesmodel.JSFConfigVisitor;
34: import org.netbeans.modules.web.jsf.api.facesmodel.ResourceBundle;
35: import org.w3c.dom.Element;
36:
37: /**
38: * The resource-bundle element inside the application element
39: * references a java.util.ResourceBundle instance by name
40: * using the var element. ResourceBundles referenced in this
41: * manner may be returned by a call to
42: * Application.getResourceBundle() passing the current
43: * FacesContext for this request and the value of the var
44: * element below.
45: *
46: * @author Petr Pisl
47: */
48:
49: public class ResourceBundleImpl extends DescriptionGroupImpl implements
50: ResourceBundle {
51:
52: protected static final List<String> RESOURCE_BUNDLE_SORTED_ELEMENTS = new ArrayList<String>();
53: static {
54: RESOURCE_BUNDLE_SORTED_ELEMENTS
55: .addAll(DescriptionGroupImpl.DESCRIPTION_GROUP_SORTED_ELEMENTS);
56: RESOURCE_BUNDLE_SORTED_ELEMENTS.add(JSFConfigQNames.BASE_NAME
57: .getLocalName());
58: RESOURCE_BUNDLE_SORTED_ELEMENTS.add(JSFConfigQNames.VAR
59: .getLocalName());
60: }
61:
62: public ResourceBundleImpl(JSFConfigModelImpl model, Element element) {
63: super (model, element);
64: }
65:
66: public ResourceBundleImpl(JSFConfigModelImpl model) {
67: this (model, createElementNS(model,
68: JSFConfigQNames.RESOURCE_BUNDLE));
69: }
70:
71: public void accept(JSFConfigVisitor visitor) {
72: visitor.visit(this );
73: }
74:
75: public String getBaseName() {
76: return getChildElementText(JSFConfigQNames.BASE_NAME
77: .getQName(getNamespaceURI()));
78: }
79:
80: public void setBaseName(String baseName) {
81: setChildElementText(BASE_NAME, baseName,
82: JSFConfigQNames.BASE_NAME.getQName(getNamespaceURI()));
83: }
84:
85: public String getVar() {
86: return getChildElementText(JSFConfigQNames.VAR
87: .getQName(getNamespaceURI()));
88: }
89:
90: public void setVar(String var) {
91: setChildElementText(VAR, var, JSFConfigQNames.VAR
92: .getQName(getNamespaceURI()));
93: }
94:
95: @Override
96: protected List<String> getSortedListOfLocalNames() {
97: return RESOURCE_BUNDLE_SORTED_ELEMENTS;
98: }
99: }
|