KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > trading > impl > OfferIteratorImpl


1
2 // Copyright (C) 1998-1999
3
// Object Oriented Concepts, Inc.
4

5 // **********************************************************************
6
//
7
// Copyright (c) 1997
8
// Mark Spruiell (mark@intellisoft.com)
9
//
10
// See the COPYING file for more information
11
//
12
// **********************************************************************
13

14 package org.jacorb.trading.impl;
15
16
17 import org.omg.CosTrading.*;
18 // GB: import jtport.ORBLayer;
19

20
21 /**
22  * Implementation of CosTrading::OfferIterator
23  */

24 public class OfferIteratorImpl extends OfferIteratorPOA
25 {
26   private Offer[] m_offers;
27   private int m_start;
28
29
30   private OfferIteratorImpl()
31   {
32   }
33
34
35   public OfferIteratorImpl(Offer[] offers, int start)
36   {
37     m_offers = offers;
38     m_start = start;
39   }
40
41
42   public int max_left() throws UnknownMaxLeft
43   {
44     return (m_offers.length - m_start);
45   }
46
47
48   public boolean next_n(int n, OfferSeqHolder offers)
49   {
50     boolean result;
51
52     int count;
53     if (n > (m_offers.length - m_start))
54       count = m_offers.length - m_start;
55     else
56       count = n;
57
58     offers.value = new Offer[count];
59     // for (int i = 0; i < count; i++)
60
// offers.value[i] = m_offers[m_start + i];
61
//NN: for efficiency improvement
62
java.lang.System.arraycopy(m_offers, m_start, offers.value, 0, count);
63
64     m_start += count;
65     result = (m_offers.length - m_start > 0); // any left?
66

67     return result;
68   }
69
70     //////////////////////////////////////////////////////////////// new!
71
/**
72      * Get all offers of this OfferIterator. Mainly for efficiency purposes
73      * *NOT* inherited from anywhere
74      * @return Offer[] All Offer-objects of this OfferIterator
75      */

76     public Offer[] getOffers(){
77     return m_offers;
78     }
79     //////////////////////////////////////////////////////////////// new!
80

81   public void destroy()
82   {
83       //GB: ORBLayer.instance().getORB().disconnect(this);
84
}
85 }
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
Popular Tags