001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.wicket.request.resource;
018
019import java.util.Locale;
020
021/**
022 * Static resource reference for javascript resources. The resources are filtered (stripped comments
023 * and whitespace) if there is a registered compressor.
024 * 
025 * @see org.apache.wicket.settings.ResourceSettings#getJavaScriptCompressor()
026 * @author Matej
027 */
028public class JavaScriptResourceReference extends PackageResourceReference
029{
030        private static final long serialVersionUID = 1L;
031
032        /**
033         * Construct.
034         * 
035         * @param scope
036         *            mandatory parameter
037         * @param name
038         *            mandatory parameter
039         * @param locale
040         *            resource locale
041         * @param style
042         *            resource style
043         * @param variation
044         *            resource variation
045         */
046        public JavaScriptResourceReference(Class<?> scope, String name, Locale locale, String style,
047                String variation)
048        {
049                super(scope, name, locale, style, variation);
050        }
051
052        /**
053         * Construct.
054         *
055         * @param scope
056         *            mandatory parameter
057         * @param name
058         *            mandatory parameter
059         */
060        public JavaScriptResourceReference(Class<?> scope, String name)
061        {
062                super(scope, name);
063        }
064
065        /**
066         * Construct.
067         *
068         * @param key
069         *            mandatory parameter
070         */
071        public JavaScriptResourceReference(Key key)
072        {
073                super(key);
074        }
075
076        @Override
077        public JavaScriptPackageResource getResource()
078        {
079                final JavaScriptPackageResource resource = new JavaScriptPackageResource(getScope(), getName(), getLocale(), getStyle(),
080                                getVariation());
081                removeCompressFlagIfUnnecessary(resource);
082                return resource;
083        }
084}