1 7 8 package com.sun.corba.se.impl.ior; 9 10 import java.util.Iterator ; 11 12 import org.omg.CORBA.INTERNAL ; 13 14 import org.omg.CORBA_2_3.portable.OutputStream ; 15 import org.omg.CORBA_2_3.portable.InputStream ; 16 17 import org.omg.IOP.TAG_INTERNET_IOP ; 18 19 import com.sun.corba.se.spi.ior.IdentifiableContainerBase ; 20 import com.sun.corba.se.spi.ior.IdentifiableFactoryFinder ; 21 import com.sun.corba.se.spi.ior.IORTemplate ; 22 import com.sun.corba.se.spi.ior.ObjectKeyTemplate ; 23 import com.sun.corba.se.spi.ior.TaggedProfileTemplate ; 24 import com.sun.corba.se.spi.ior.ObjectId ; 25 import com.sun.corba.se.spi.ior.IOR ; 26 import com.sun.corba.se.spi.ior.IORFactory ; 27 28 import com.sun.corba.se.spi.orb.ORB ; 29 30 34 public class IORTemplateImpl extends IdentifiableContainerBase implements IORTemplate 35 { 36 private ObjectKeyTemplate oktemp ; 37 38 public boolean equals( Object obj ) 39 { 40 if (obj == null) 41 return false ; 42 43 if (!(obj instanceof IORTemplateImpl)) 44 return false ; 45 46 IORTemplateImpl other = (IORTemplateImpl)obj ; 47 48 return super.equals( obj ) && oktemp.equals( other.getObjectKeyTemplate() ) ; 49 } 50 51 public int hashCode() 52 { 53 return super.hashCode() ^ oktemp.hashCode() ; 54 } 55 56 public ObjectKeyTemplate getObjectKeyTemplate() 57 { 58 return oktemp ; 59 } 60 61 public IORTemplateImpl( ObjectKeyTemplate oktemp ) 62 { 63 this.oktemp = oktemp ; 64 } 65 66 public IOR makeIOR( ORB orb, String typeid, ObjectId oid ) 67 { 68 return new IORImpl( orb, typeid, this, oid ) ; 69 } 70 71 public boolean isEquivalent( IORFactory other ) 72 { 73 if (!(other instanceof IORTemplate)) 74 return false ; 75 76 IORTemplate list = (IORTemplate)other ; 77 78 Iterator thisIterator = iterator() ; 79 Iterator listIterator = list.iterator() ; 80 while (thisIterator.hasNext() && listIterator.hasNext()) { 81 TaggedProfileTemplate thisTemplate = 82 (TaggedProfileTemplate)thisIterator.next() ; 83 TaggedProfileTemplate listTemplate = 84 (TaggedProfileTemplate)listIterator.next() ; 85 if (!thisTemplate.isEquivalent( listTemplate )) 86 return false ; 87 } 88 89 return (thisIterator.hasNext() == listIterator.hasNext()) && 90 getObjectKeyTemplate().equals( list.getObjectKeyTemplate() ) ; 91 } 92 93 97 public void makeImmutable() 98 { 99 makeElementsImmutable() ; 100 super.makeImmutable() ; 101 } 102 103 public void write( OutputStream os ) 104 { 105 oktemp.write( os ) ; 106 EncapsulationUtility.writeIdentifiableSequence( this, os ) ; 107 } 108 109 public IORTemplateImpl( InputStream is ) 110 { 111 ORB orb = (ORB)(is.orb()) ; 112 IdentifiableFactoryFinder finder = 113 orb.getTaggedProfileTemplateFactoryFinder() ; 114 115 oktemp = orb.getObjectKeyFactory().createTemplate( is ) ; 116 EncapsulationUtility.readIdentifiableSequence( this, finder, is ) ; 117 118 makeImmutable() ; 119 } 120 } 121 | Popular Tags |