001/**
002 *
003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
004 *
005 * This library is free software; you can redistribute it and/or
006 * modify it under the terms of the GNU Lesser General Public
007 * License as published by the Free Software Foundation; either 
008 * version 2.1 of the License, or (at your option) any later version.
009 * 
010 * This library is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013 * Lesser General Public License for more details.
014 * 
015 * You should have received a copy of the GNU Lesser General Public 
016 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
017 * 
018 **/
019package lucee.runtime.extension;
020
021import java.net.MalformedURLException;
022import java.net.URL;
023
024public class ExtensionProviderImpl implements ExtensionProvider {
025
026
027        //private String name;
028        private URL url;
029        private String strUrl;
030        private boolean readOnly;
031        
032        public ExtensionProviderImpl(URL url, boolean readOnly) {
033                //this.name = name;
034                this.url = url;
035                this.readOnly=readOnly;
036        }
037        
038        public ExtensionProviderImpl(String strUrl, boolean readOnly) {
039                //this.name = name;
040                this.strUrl=strUrl;
041                this.readOnly=readOnly;
042        }
043
044        /**
045         * @return the url
046         * @throws MalformedURLException 
047         */
048        public URL getUrl() throws MalformedURLException {
049                if(url==null)url=new URL(strUrl);
050                return url;
051        }
052
053        public String getUrlAsString() {
054                if(strUrl!=null) return strUrl;
055                return url.toExternalForm();
056        }
057
058        public boolean isReadOnly() {
059                return readOnly;
060        }
061
062        @Override
063        public String toString() {
064                return "url:"+getUrlAsString()+";";
065        }
066
067        public int hashCode() {
068                return toString().hashCode();
069        }
070
071        public boolean equals(Object obj) {
072                //if(!(obj instanceof ExtensionProvider))return false;
073                
074                return toString().equals(obj.toString());
075        }
076
077}