Richard S. Hall | 85bafab | 2009-07-13 13:25:46 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | |
| 20 | package org.cauldron.bld.core.internal.license; |
| 21 | |
| 22 | import java.util.Collections; |
| 23 | import java.util.HashMap; |
| 24 | import java.util.Set; |
| 25 | import java.util.regex.Pattern; |
| 26 | |
| 27 | import org.cauldron.bld.core.licence.ILicenseManager; |
| 28 | import org.cauldron.bld.core.licence.ILicensePolicy; |
| 29 | //import org.cauldron.sigil.model.project.ISigilProjectModel; |
| 30 | |
| 31 | public class LicenseManager implements ILicenseManager { |
| 32 | |
| 33 | private HashMap<String, Pattern> licenses = new HashMap<String, Pattern>(); |
| 34 | private HashMap<String, LicensePolicy> policies = new HashMap<String, LicensePolicy>(); |
| 35 | private LicensePolicy defaultPolicy = new LicensePolicy(this); |
| 36 | |
| 37 | public void addLicense(String name, Pattern pattern) { |
| 38 | licenses.put( name, pattern ); |
| 39 | } |
| 40 | |
| 41 | public void removeLicense(String name) { |
| 42 | licenses.remove(name); |
| 43 | } |
| 44 | |
| 45 | public Set<String> getLicenseNames() { |
| 46 | return Collections.unmodifiableSet(licenses.keySet()); |
| 47 | } |
| 48 | |
| 49 | public Pattern getLicensePattern(String name) { |
| 50 | return licenses.get( name ); |
| 51 | } |
| 52 | |
| 53 | public ILicensePolicy getDefaultPolicy() { |
| 54 | return defaultPolicy; |
| 55 | } |
| 56 | |
| 57 | //public ILicensePolicy getPolicy(ISigilProjectModel project) { |
| 58 | // synchronized( policies ) { |
| 59 | // LicensePolicy p = policies.get(project.getName()); |
| 60 | // |
| 61 | // if ( p == null ) { |
| 62 | // p = new LicensePolicy(this, project); |
| 63 | // policies.put( project.getName(), p ); |
| 64 | // } |
| 65 | // |
| 66 | // return p; |
| 67 | // } |
| 68 | //} |
| 69 | |
| 70 | } |