View Javadoc
1   /*
2    * (C) Copyright 2006-2014 Nuxeo SA (http://nuxeo.com/) and contributors.
3    *
4    * All rights reserved. This program and the accompanying materials
5    * are made available under the terms of the GNU Lesser General Public License
6    * (LGPL) version 2.1 which accompanies this distribution, and is available at
7    * http://www.gnu.org/licenses/lgpl-2.1.html
8    *
9    * This library is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12   * Lesser General Public License for more details.
13   *
14   * Contributors:
15   *     bstefanescu
16   */
17  package org.nuxeo.build.maven.filter;
18  
19  /**
20   * TODO NXBT-258
21   */
22  public class MiddleMatch extends SegmentMatch {
23  
24      public String suffix;
25  
26      public String prefix;
27  
28      private int len;
29  
30      public MiddleMatch(String suffix, String prefix) {
31          this.suffix = suffix;
32          this.prefix = prefix;
33          this.len = suffix.length() + prefix.length();
34      }
35  
36      @Override
37      public boolean match(String segment) {
38          return len <= segment.length() && segment.startsWith(prefix)
39                  && segment.endsWith(suffix);
40      }
41  
42      @Override
43      public String toString() {
44          return getClass().toString() + " (" + prefix + "," + suffix + ")";
45      }
46  
47  }