1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 package com.sun.star.lib.uno.protocols.urp; 24 25 import java.io.IOException; 26 27 import java.util.Hashtable; 28 29 30 import com.sun.star.uno.IBridge; 31 import com.sun.star.uno.IEnvironment; 32 import com.sun.star.uno.Type; 33 34 35 class TestBridge implements IBridge { 36 static public final boolean DEBUG = false; 37 38 Hashtable _hashtable = new Hashtable(); 39 40 IEnvironment _source ;//= new com.sun.star.lib.uno.environments.java.java_environment(null); 41 42 43 class MyEnv implements IEnvironment { getContext()44 public Object getContext() { 45 return null; 46 } 47 getName()48 public String getName() { 49 return null; 50 } 51 registerInterface(Object object, String oId[], Type type)52 public Object registerInterface(Object object, String oId[], Type type) { 53 return null; 54 } 55 revokeInterface(String oId, Type type)56 public void revokeInterface(String oId, Type type) { 57 } 58 getRegisteredInterface(String oid, Type type)59 public Object getRegisteredInterface(String oid, Type type) { 60 Object object = _hashtable.get(oid); 61 62 if(DEBUG) System.err.println("##### " + getClass().getName() + ".getRegisteredInterface:" + oid + " " + object); 63 64 return object; 65 } 66 getRegisteredObjectIdentifier(Object object)67 public String getRegisteredObjectIdentifier(Object object) { 68 return null; 69 } 70 list()71 public void list() { 72 } 73 } 74 TestBridge()75 TestBridge() { 76 _source = new MyEnv(); 77 } 78 mapInterfaceTo(Object object, Type type)79 public Object mapInterfaceTo(Object object, Type type) { 80 if (object == null) { 81 return null; 82 } else { 83 String oid = ">" + object.toString() + type.toString() + "<"; 84 _hashtable.put(oid, object); 85 return oid; 86 } 87 } 88 mapInterfaceFrom(Object object, Type type)89 public Object mapInterfaceFrom(Object object, Type type) { 90 String oid = (String)object; 91 92 return _hashtable.get(oid); 93 } 94 getSourceEnvironment()95 public IEnvironment getSourceEnvironment() { 96 return _source; 97 } 98 getTargetEnvironment()99 public IEnvironment getTargetEnvironment() { 100 return null; 101 } 102 acquire()103 public void acquire() {} 104 release()105 public void release() {} 106 reset()107 public void reset() throws IOException {} 108 dispose()109 public void dispose() throws InterruptedException, IOException {} 110 } 111 112