01: /*
02: * Enhydra Java Application Server Project
03: *
04: * The contents of this file are subject to the Enhydra Public License
05: * Version 1.1 (the "License"); you may not use this file except in
06: * compliance with the License. You may obtain a copy of the License on
07: * the Enhydra web site ( http://www.enhydra.org/ ).
08: *
09: * Software distributed under the License is distributed on an "AS IS"
10: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11: * the License for the specific terms governing rights and limitations
12: * under the License.
13: *
14: * The Initial Developer of the Enhydra Application Server is Lutris
15: * Technologies, Inc. The Enhydra Application Server and portions created
16: * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17: * All Rights Reserved.
18: *
19: * Contributor(s):
20: *
21: */
22:
23: package org.enhydra.kelp.common.map;
24:
25: // Standard imports
26: import java.util.ArrayList;
27: import java.util.Arrays;
28:
29: //
30: public class MapEntry {
31: private String from = new String();
32: private String to = new String();
33:
34: public MapEntry(String f, String t) {
35: from = f.trim();
36: to = t.trim();
37: }
38:
39: public String getFrom() {
40: return from.trim();
41: }
42:
43: public String getTo() {
44: return to.trim();
45: }
46:
47: public boolean equals(Object o) {
48: boolean eq = false;
49:
50: if (o instanceof MapEntry) {
51: MapEntry e = (MapEntry) o;
52:
53: eq = e.from.equals(from) && e.to.equals(to);
54: }
55: return eq;
56: }
57:
58: /**
59: *
60: */
61: public boolean canReduce(MapEntry e) {
62: boolean reduce = false;
63: String fromRemains = new String();
64: String toRemains = new String();
65:
66: if (from.length() >= e.from.length()
67: || to.length() >= e.to.length()) {
68: reduce = false;
69: } else if (e.from.startsWith(from) && e.to.startsWith(to)) {
70: fromRemains = e.from.substring(from.length());
71: toRemains = e.to.substring(to.length());
72: fromRemains = fromRemains.replace('/', '.');
73: reduce = fromRemains.equals(toRemains);
74: }
75: return reduce;
76: }
77:
78: }
|