1 22 23 package org.enhydra.kelp.common.map; 24 25 import java.util.ArrayList ; 27 import java.util.Arrays ; 28 29 public class MapEntry { 31 private String from = new String (); 32 private String to = new String (); 33 34 35 public MapEntry(String f, String t) { 36 from = f.trim(); 37 to = t.trim(); 38 } 39 40 public String getFrom() { 41 return from.trim(); 42 } 43 44 public String getTo() { 45 return to.trim(); 46 } 47 48 public boolean equals(Object o) { 49 boolean eq = false; 50 51 if (o instanceof MapEntry) { 52 MapEntry e = (MapEntry) o; 53 54 eq = e.from.equals(from) && e.to.equals(to); 55 } 56 return eq; 57 } 58 59 62 public boolean canReduce(MapEntry e) { 63 boolean reduce = false; 64 String fromRemains = new String (); 65 String toRemains = new String (); 66 67 if (from.length() >= e.from.length() 68 || to.length() >= e.to.length()) { 69 reduce = false; 70 } else if (e.from.startsWith(from) && e.to.startsWith(to)) { 71 fromRemains = e.from.substring(from.length()); 72 toRemains = e.to.substring(to.length()); 73 fromRemains = fromRemains.replace('/', '.'); 74 reduce = fromRemains.equals(toRemains); 75 } 76 return reduce; 77 } 78 79 } 80 | Popular Tags |