1 16 19 20 package org.apache.pluto.util.impl; 21 22 import org.apache.pluto.om.common.ObjectID; 23 import org.apache.pluto.util.NamespaceMapper; 24 25 27 28 public class NamespaceMapperImpl implements NamespaceMapper 29 { 30 public NamespaceMapperImpl() 31 { 32 } 33 34 public String encode(ObjectID ns, String name) 36 { 37 StringBuffer buffer = new StringBuffer (50); 38 buffer.append("Pluto_"); 39 buffer.append(ns); 40 buffer.append('_'); 41 buffer.append(name); 42 return buffer.toString(); 43 } 44 45 public String encode(ObjectID ns1, ObjectID ns2, String name) 46 { 47 StringBuffer buffer = new StringBuffer (50); 48 buffer.append("Pluto_"); 49 buffer.append(ns1); 50 buffer.append('_'); 51 buffer.append(ns2); 52 buffer.append('_'); 53 buffer.append(name); 54 return buffer.toString(); 55 } 56 57 public String decode(ObjectID ns, String name) 58 { 59 if (!name.startsWith("Pluto_")) 60 { 61 return null; 62 } 63 StringBuffer buffer = new StringBuffer (50); 64 buffer.append("Pluto_"); 65 buffer.append(ns); 66 buffer.append('_'); 67 if (!name.startsWith(buffer.toString())) 68 { 69 return null; 70 } 71 return name.substring(buffer.length()); 72 } 73 } 75 | Popular Tags |