📄 partimpl.java
字号:
// $Id: PartImpl.java,v 1.1 2001/12/17 17:45:08 per_nyfelt Exp $import java.io.*;import java.util.*;import org.ozoneDB.*;public final class PartImpl extends OzoneObject implements Part, Externalizable { protected String type = "part-type9999"; protected int x; protected int y; protected Date build; protected Vector to; protected Vector from; public PartImpl() { build = new Date(); to = new Vector(); from = new Vector(); } public void connect( int index, Part part ) throws Exception { to.addElement( new Connection( part ) ); part.backConnect( this ); } public void backConnect( Part part ) { if (!(part instanceof OzoneProxy)) { throw new RuntimeException( "backConnect(): parameter is not converted." ); } from.addElement( part ); // from.add (part); } public void deconnect() throws Exception { for (Enumeration e = to.elements(); e.hasMoreElements();) { Connection connection = (Connection)e.nextElement(); connection.p.deBackConnect( this ); } to.clear(); // DxIterator it = to.iterator(); // Connection connection; // while ((connection=(Connection)it.next()) != null) // connection.p.deBackConnect (this); } public void deBackConnect( Part part ) { if (!from.removeElement( part )) { throw new RuntimeException( "deBackConnect(): cannot remove part." ); } // DxIterator it = from.iterator(); // while (it.next() != null) { // if (((OzoneProxy)part).isSame ((OzoneProxy)it.object())) { // it.removeObject(); // break; // } // } // throw new RuntimeException ("deBackConnect(): part not found."); } public void set( String _type, int _x, int _y ) { type = _type.toString(); x = _x; y = _y; //throw new NullPointerException(); } public void get() { } public void traversal( int _x, int _y, int depth ) throws Exception { x = _x; y = _y; // do some db independent crunching // String[] dummies = new String[1000]; // for (int i=0; i<1000; i++) // dummies[i] = String.valueOf (i); if (depth > 1) { for (Enumeration e = to.elements(); e.hasMoreElements();) { Connection connection = (Connection)e.nextElement(); connection.p.traversal( _x, _y, depth - 1 ); } } } public void writeExternal( ObjectOutput out ) throws IOException { out.writeLong( build.getTime() ); out.writeObject( type ); out.writeInt( x ); out.writeInt( y ); out.writeObject( to ); out.writeObject( from ); } public synchronized void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException { build = new Date( in.readLong() ); type = (String)in.readObject(); x = in.readInt(); y = in.readInt(); to = (Vector)in.readObject(); from = (Vector)in.readObject(); } public void done() throws Exception { } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -