• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2007 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.tonicsystems.jarjar;
18 
19 import java.util.*;
20 
21 abstract public class PatternElement
22 {
23     private String pattern;
24 
setPattern(String pattern)25     public void setPattern(String pattern) {
26         this.pattern = pattern;
27     }
28 
getPattern()29     public String getPattern() {
30         return pattern;
31     }
32 
createWildcards(List<? extends PatternElement> patterns)33     static List<Wildcard> createWildcards(List<? extends PatternElement> patterns) {
34         List<Wildcard> wildcards = new ArrayList<Wildcard>();
35         for (PatternElement pattern : patterns) {
36             String result = (pattern instanceof Rule) ? ((Rule)pattern).getResult() : "";
37             String expr = pattern.getPattern();
38             if (expr.indexOf('/') >= 0)
39                 throw new IllegalArgumentException("Patterns cannot contain slashes");
40             wildcards.add(new Wildcard(expr.replace('.', '/'), result));
41         }
42         return wildcards;
43     }
44 }
45