1 /*
2 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
355 if (match != null) {
356 rewriteMatch = match;
357 longestRewriteMatch = ((RewriteUri) entry).getURIStartString().length();
358 }
359 break;
360 case URISUFFIX:
361 match = ((UriSuffix) entry).match(uri, longestSuffixMatch);
362 if (match != null) {
363 suffixMatch = match;
364 longestSuffixMatch = ((UriSuffix) entry).getURISuffix().length();
365 }
366 break;
367 case GROUP:
368 GroupEntry grpEntry = (GroupEntry) entry;
369 match = grpEntry.matchURI(uri);
370 if (grpEntry.isInstantMatch) {
371 //use it if there is a match of the uri type
372 return match;
373 } else if (grpEntry.longestRewriteMatch > longestRewriteMatch) {
374 rewriteMatch = match;
375 } else if (grpEntry.longestSuffixMatch > longestSuffixMatch) {
376 suffixMatch = match;
377 }
378 break;
379 }
380 }
381
382 if (longestRewriteMatch > 0) {
383 return rewriteMatch;
384 } else if (longestSuffixMatch > 0) {
385 return suffixMatch;
386 }
387
388 //if no single match is found, try delegates
389 return matchDelegate(CatalogEntryType.DELEGATEURI, uri);
390 }
391
392 /**
393 * Matches delegatePublic or delegateSystem against the specified id
394 *
395 * @param type the type of the Catalog entry
396 * @param id the system or public id to be matched
|
1 /*
2 * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
355 if (match != null) {
356 rewriteMatch = match;
357 longestRewriteMatch = ((RewriteUri) entry).getURIStartString().length();
358 }
359 break;
360 case URISUFFIX:
361 match = ((UriSuffix) entry).match(uri, longestSuffixMatch);
362 if (match != null) {
363 suffixMatch = match;
364 longestSuffixMatch = ((UriSuffix) entry).getURISuffix().length();
365 }
366 break;
367 case GROUP:
368 GroupEntry grpEntry = (GroupEntry) entry;
369 match = grpEntry.matchURI(uri);
370 if (grpEntry.isInstantMatch) {
371 //use it if there is a match of the uri type
372 return match;
373 } else if (grpEntry.longestRewriteMatch > longestRewriteMatch) {
374 rewriteMatch = match;
375 longestRewriteMatch = grpEntry.longestRewriteMatch;
376 } else if (grpEntry.longestSuffixMatch > longestSuffixMatch) {
377 suffixMatch = match;
378 longestSuffixMatch = grpEntry.longestSuffixMatch;
379 }
380 break;
381 }
382 }
383
384 if (longestRewriteMatch > 0) {
385 return rewriteMatch;
386 } else if (longestSuffixMatch > 0) {
387 return suffixMatch;
388 }
389
390 //if no single match is found, try delegates
391 return matchDelegate(CatalogEntryType.DELEGATEURI, uri);
392 }
393
394 /**
395 * Matches delegatePublic or delegateSystem against the specified id
396 *
397 * @param type the type of the Catalog entry
398 * @param id the system or public id to be matched
|